6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu Nov 21, 2024 10:52 pm

All times are UTC




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Jun 27, 2022 9:49 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
So I'm trying to teach myself CPLD programming and just ran out of talent. I've got some decoding logic working fine and decided the next step would be to implement a counter on an ATF1502S.

I figured I'd start on the nursery slopes with a simple decade counter. When I try to compile this, however, I get an error. The compilation, with cupl.exe, works fine. But when I run find1502.exe, I get the error:

Code:
Atmel ATF1502AS Fitter Version 1.8.7.8 (02-05-03)
Copyright 1999,2000 Atmel Corporation
Error - Node Q3 is registered and there is no .CLK in .olb
Reading input file failed ...


Here is my code:

Code:
Name      COUNT10;
Partno    00;
Date      27/06/2022;
Revision  01;
Designer  SMD;
Company   ;
Assembly  ;
Location  ;
Device    f1502tqfp44;

/***************************************************************/
/* Decade Counter                                              */
/***************************************************************/

/**  Inputs  **/
PIN 15        = pulse;           /* Counter clock              */
PIN 44        = clr;             /* Counter clear input        */

/**  Outputs  **/
PIN [28,25,22,19] = [Q3..0];     /* Counter outputs on LEDs    */

FIELD count = [Q3..0];          /* Counter output bit field    */
$repeat i = [0..9]
$define S{i} 'b'{i}             /* Creates S0-S9 with vals 0-9 */
$repend

/** State machine **/
SEQUENCE count {
$repeat i = [0..9]
  present S{i}
     if pulse next S{(i+1)%10};
    if clr next S0;
     default next S{i};
$repend
}


I'm compiling with:

Code:
C:\Wincupl\Shared\cupl.exe -j -a -l -e -x -f -b -m4 f1502tqfp44 COUNT10


And running find1502 with:

Code:
find1502 -i E:\NasSync\DEV\Dev-PLD\CUPL_Projects\COUNT10\COUNT10.tt2 -CUPL -dev P1502T44 -str JTAG ON -str logic_doubling off


I rechecked my previous projects and they're still working fine, so I haven't borked my dev setup.

What am I doing wrong?

[EDIT] Just realised that Atmel docs actually have this precise thing as an example. I'll be back once I've read that.
[EDIT 2] Turns out the Atmel example was the code on which I'd based mine anyway. And the Atmel code produces the same error, even when I remove all specific pin assignments and let the fitter decide on pins.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 27, 2022 4:04 pm 
Offline
User avatar

Joined: Sun Nov 07, 2021 4:11 pm
Posts: 101
Location: Toronto, Canada
Howdy! I think the problem is that the way you're using the PULSE signal leads to behaviour that's not what you expect. In your state machine, PULSE is used as a combinational input—basically, you're asking the PLD to only count forward if PULSE is active.

This doesn't actually make the PLD use that signal as a clock; instead, I think you have to explicitly define the clock used by the FSM's flip-flops by using the .CK extension. Try something like this—this compiles fine for me, but I don't have any ATF-15 devices to test with, so I'm not sure if it's right:

Code:
Name      COUNT10;
Partno    00;
Date      27/06/2022;
Revision  01;
Designer  SMD;
Company   ;
Assembly  ;
Location  ;
Device    f1502tqfp44;

/***************************************************************/
/* Decade Counter                                              */
/***************************************************************/

/**  Inputs  **/
PIN 15        = pulse;           /* Counter clock              */
PIN 44        = clr;             /* Counter clear input        */

/**  Outputs  **/
PIN [28,25,22,19] = [Q3..0];     /* Counter outputs on LEDs    */

FIELD count = [Q3..0];          /* Counter output bit field    */
$repeat i = [0..9]
$define S{i} 'b'{i}             /* Creates S0-S9 with vals 0-9 */
$repend

/** Define clock source for flip-flops **/
Q0.CK = pulse;
Q1.CK = pulse;
Q2.CK = pulse;
Q3.CK = pulse;

/** State machine **/
SEQUENCE count {
$repeat i = [0..9]
  present S{i}
    if clr next S0;
    default next S{(i+1)%10};
$repend
}


I think that the examples in the book are meant for devices (like the 22V10) that have a single clock line, and so which clock signal to use is implicit; I believe that, on the ATF15, you can use any input as a clock, and so it looks like you have to explicitly set it.

I hope this helps!



—Marco


Top
 Profile  
Reply with quote  
PostPosted: Mon Jun 27, 2022 7:57 pm 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
I'll give that a whirl. Many thanks.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 28, 2022 9:21 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
Yep, that did the trick!

The clr button has no effect, but hey - one problem at a time!

EDIT: This sorted the clr button:

Code:
Q0.ar = clr;
Q1.ar = clr;
Q2.ar = clr;
Q3.ar = clr;

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
PostPosted: Tue Jun 28, 2022 12:01 pm 
Offline
User avatar

Joined: Sun Nov 07, 2021 4:11 pm
Posts: 101
Location: Toronto, Canada
Glad that worked! I didn't even think about the asynchronous reset… I guess it makes sense that you'd have to specify it as well (at least as far as anything ever makes sense with WinCUPL…). Cheers!


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: