6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 3:56 am

All times are UTC




Post new topic Reply to topic  [ 13 posts ] 
Author Message
PostPosted: Wed Feb 09, 2022 7:38 am 
Offline

Joined: Tue Feb 08, 2022 7:08 pm
Posts: 7
Hi all, newcomer here.
It seems to be CPLD experience on this forum, and I could need some help. I am working on the refining an old 8-bit system using a ATF1504, WinCupl, ATMISP and ATDH1150USB for JTAG programming. The CPLD works fine for chip select and other logic. 4MHz clock speed.

I plan to substitute a 74HC540 used as a keypad interface. One of the keypad switches/data lines should be like this in the CUPL code:

Code:
PIN  = KEY1;     /* Keypad switch input 74HC540 pin 2 */
PIN  = GATE1;   /* 540 pin 1*/
PIN  = GATE2;   /* 540 pin 19*/
PIN  = AD0;      /* LSB in bus line, 540 pin 18 */
/* Eq */
AD0 = !KEY1;                       /* inverted like in 540 */
AD0.OE = !GATE1 & !GATE2; 


Resulting fit file contents looks fine:
Code:
AD0 = !KEY1;
AD0.OE = (!GATE1 & !GATE2);


However, it does not work, the uP does not get any key input as it does with the 540 in place.
Have I misunderstood anything obvious here? Maybe timing issues? Any tips are welcome.


Thanks in advance and all the best,
Tore B
Oslo, Norway

74HC540 internals:
Code:
Broken external image link
https://www.technobotsonline.com/images/detailed/5/Ext-2201-540.jpg


Last edited by ToreB on Wed Feb 09, 2022 9:09 am, edited 1 time in total.

Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 09, 2022 8:10 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Welcome! I don't see any obvious mistake - but it's easy to miss the obvious...

Perhaps double-check your pin assignments - perhaps even check the logical behaviour with 0V and 5V inputs.

But if it's not a logical error, then a timing error seems possible.

Or maybe there are other ways, preferred ways, to describe three-state outputs and negative logic inputs?


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 09, 2022 8:27 am 
Offline

Joined: Tue Feb 08, 2022 7:08 pm
Posts: 7
BigEd, thank you for your prompt and welcoming answer.
Using CPLD's has indeed had a steep learning curve. I have struggled with this for several days now, pins are OK. I let the compiler choose pins, and have triple-checked the connections.
I have tried using a different variant of CUPL code like this:
PINNODE = KEYLATCH_1;
KEYLATCH_1 = !KEY1;
AD0 = KEYLATCH_1;
KEYLATCH_1.OE = !GATE1 & !GATE2;

However, this does not work either, the resulting fit file output is the same as above, so the complier obviously simplifies the equation.
I have seen some WinCupl bugs regarding capital/lower case letters using flip-flops/latches, but using .oe instead of .OE does not change things.

I am still working on this, I will try to smoothe the gating signals with 68 ohm series resistors.

Cheers,
Tore


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 09, 2022 11:32 am 
Offline

Joined: Tue Feb 08, 2022 7:08 pm
Posts: 7
SOLVED!
A ringing filter with a 68ohm serial resistor on smoothed the high-frequency gating signal (OE signal) did the trick.
I am a beginner with CPLD's, and after reading other threads on this forum I ended up with the speed- and visibility optimized code below.
All the best,
Tore

Code:
/*  Input pins */
PIN = [KEY7..0];
PIN 43 = GATE1;  /*GCLK1    26*/
PIN 2 =  GATE2;  /* GCLOCK2 4 */
/*  Output pins */
PIN = [AD7..0];
/* Buried logic */
pinnode   =   [latches7..0];
[latches7..0]   = ![KEY7..0];
[latches7..0].oe   = !GATE1 & !GATE2;
/*  Logic Equations */
[AD7..0] = [latches7..0];


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 09, 2022 11:50 am 
Offline
User avatar

Joined: Thu Dec 11, 2008 1:28 pm
Posts: 10986
Location: England
Excellent!


Top
 Profile  
Reply with quote  
PostPosted: Wed Feb 09, 2022 6:18 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
ToreB wrote:
SOLVED!
A ringing filter with a 68ohm serial resistor on smoothed the high-frequency gating signal (OE signal) did the trick.

Try adding this statement near the top of your PLD file and see what happens:

Code:
property atmel {output_fast = off};

What that will do is reduce the slew rate of the 1504's outputs and cut down on ringing and other assorted noise.

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 10, 2022 10:13 am 
Offline

Joined: Tue Feb 08, 2022 7:08 pm
Posts: 7
Thank for all input. I have added the output_fast = off after input in other threads in this forum.

Now, my next challenge is that I want to substitute a second 540 IC.
Could the above construction be expanded so I can have a second set of buried latches, connecting to the same address bus lines, but with different output enable triggering signals? My first code attempt returns errors that all AD lines already are assigned when defining the second buried latch output connection.
Code:
/* *************** INPUT PINS *********************/
PIN = [KEY7..0];
PIN = [I_O_INPUT7..0];
PIN 43 = GATE1;  /*GCLK1    26*/
PIN 2 =  GATE2;  /* GCLOCK2 4 */
PIN = GATE3;

/* *************** OUTPUT PINS *********************/
PIN = [AD7..0];

/* Buried logic */
pinnode   =   [keypadlatch7..0];
pinnode   =   [inputlatch7..0];

/*  Logic Equations */

/* 74HC540 Keypad inputs */
[keypadlatch7..0]   = ![KEY7..0];
[keypadlatch7..0].oe   = !GATE1 & !GATE2;
[AD7..0] = [keypadlatch7..0];

/* 74HC540 I/O inputs */
[inputlatch7..0]   = ![I_O_INPUT7..0];
[inputlatch7..0].oe   = !GATE1 & !GATE3;
[AD7..0] = [inputlatch7..0];

One solution could be to define some sort of CPLD-internal address bus that several latches can connect to.
Or maybe I could use only one latch, and define logic to select the latch input sources?
Any tips?
Thanks in advance,
Tore


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 10, 2022 4:25 pm 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8507
Location: Midwestern USA
Code:
/* 74HC540 I/O inputs */
[inputlatch7..0]   = ![I_O_INPUT7..0];
[inputlatch7..0].oe   = !GATE1 & !GATE3;  <—— ???
[AD7..0] = [inputlatch7..0];

The .OE extension is used to enable physical pins as outputs in cases where said pins are bi-directional. What are you trying to accomplish here? You've got inputlatch defined as a set of buried nodes. Nodes are not like physical pins.

Also, as written, your “latches” are not behaving as latches. Defining a pinnode as a latch implies use of some sort of flip-flop, which means specific extensions are needed to tell the compiler to not treat your latches as ordinary two-state pinnodes. As an example, here's an excerpt from a CUPL file that implements a 65C816 extended addressing latch:

Code:
   pinnode   = extram; /* extended address latch */

   extram.LE = PHI1;   /* open bank latch */
   extram.L  = D0;     /* capture A16 */

The .L extension defines the pinnode extram as a latch. The .LE extension opens the latch when the Ø2 clock is low (PHI1 is the inversion of PHI2).

_________________
x86?  We ain't got no x86.  We don't NEED no stinking x86!


Top
 Profile  
Reply with quote  
PostPosted: Thu Feb 10, 2022 5:38 pm 
Offline

Joined: Tue Feb 08, 2022 7:08 pm
Posts: 7
Thank you for taking the time to answer me.
I am sorry for my confusion in this, my eyes are sore from trying to understand the CUPL example files and PDF documentation.

The 74HC540 is a tri-state buffer, (indeed not a latch) and my original 8-bit computer design has two of these connected to the address/data bus. They have individual enable logic, and the CPU is reading their 8-bit values in turn, as keypad and general input ports. The 540 remain in high impedance state until both gate inputs are low.

My goal is to implement this in a ATF1504, routing the two input ports to the ATF, as well as the address bus as birectional port.
The internal 540-implementation should feed the AD bus with the port inputs, and I would also like to use the AD bus internally for some other CE logic as well.
I thought this could be achieved by using the .OE function, but I am truly a beginner in the use of CPLD's.

Thanks in advance,
Tore


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 14, 2022 3:38 pm 
Offline

Joined: Tue Feb 08, 2022 7:08 pm
Posts: 7
I'll deal with the dual-540 setup later.
I now have to find out how to use bi-directional pins in the CPLD. There's a hint in the CUPL manual, but it refers to a application manual that is not available to me.
I have already routed the AD bus to the CPLD and successfully implemented a '573 external address latch, producing the A0-7 part of the address bus.
However, I also need to interface this bus with the above mentioned keypad signals, and thus need to program this in a bi-directional fashion. I have read somewhere that bi-directional pins needs to be read using the .IO extension, and any output must be done by the use of the .oe extension.
Code:
/*  Input pins */
PIN = [KEY7..0];
PIN = GATE1;
PIN 43 = AS;  /*GCLK1*/
PIN 2 =  GATE2;  /* GCLK2 */
/*  Output pins */
PIN = [A7..0];
/* Bi-directional pins */
PIN = [AD7..0];

/* '573 latch implementation */
[A7..0].l = [AD7..AD0].io;
[A7..0].le = AS; 

/* Keypad input interface */
[AD7..AD0]= ![KEY7..0];
[AD7..AD0].oe = !GATE1 & !GATE2;

Would the above be the correct definition of the bi-directional AD bus here? (.io used in latch input and .oe use din the key value output?
I need to use this bus as input to other logic functions as well in the CPLD. I guess I can do this, but also need to use the .io extension in these statements?

Thanks in advance and cheers from,
Tore


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 14, 2022 5:44 pm 
Offline

Joined: Sat Jan 02, 2016 10:22 am
Posts: 197
Have you had a look at the Atmel example file ATF8255. I had a quick glance, there's a lot of code in there but it may have the answer you need.


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 14, 2022 6:39 pm 
Offline

Joined: Tue Feb 08, 2022 7:08 pm
Posts: 7
Martin, thanks.
I have indeed been trying to understand this file, but it has a very high complexity, at least to me. I am having problems to extract the bidirectional pin read/write technique from the rest of rather complex logic.
I am in the process of trying the above code, it compiles OK, and it looks like it works. Nothing would be better...
Cheers,
Tore


Top
 Profile  
Reply with quote  
PostPosted: Mon Feb 14, 2022 8:47 pm 
Offline

Joined: Fri Dec 21, 2018 1:05 am
Posts: 1120
Location: Albuquerque NM USA
Daryl’s 65SPI is written in CUPL. It is fairly complex with internal registers and multiplexed output data bus. I’m not proficient in CUPL, but know enough to convert it to Altera schematic. As an example code, you may want to take a look at Daryl’s CUPL design file and my equivalent schematic.

viewtopic.php?f=4&t=1265&hilit=65spi&start=75#p81413

https://sbc.rictor.org/65spi2.html
Bill


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 18 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: