6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Fri Jun 07, 2024 12:08 am

All times are UTC




Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Need diode help
PostPosted: Tue Jul 26, 2022 8:13 pm 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
If I've got this right, the selection of whether RAM or ROM would be selected for the lower 4 banks would depend on additional inputs to the CPLD (which I guess could be the jumpers). Is that right? That would certainly work.

What I don't know at the moment is how to enable the 'optional' open collector mode for the I/O pins. I'm digging through what documentation I have but it's annoyingly vague in many places.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Tue Jul 26, 2022 8:18 pm 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
By the way, if anyone is interested, here's the CUPL code for my original plan, which might help further explain what I was thinking.

Code:
Name     EXTMEMDECODE ;
PartNo   00 ;
Date     03/07/2022 ;
Revision 01 ;
Designer SMD ;
Company  Machina Speculatrix ;
Assembly ;
Location ;
Device   f1502plcc44 ;

/*

This provides decoding for extended memory on the Zolatron 64.

The memory sits at address $8000. The decoding allows us to select one of 16
8K banks at this address.

The bank is selected by writing the value 0-15 to the address $BFE0. This
CPLD provides the decoding for that address as well as a register (BSEL) of four
D-type latches that hold the selected value.

This register connects to address lines A13-A16 of the RAM, thus
selecting the effective address of the bank.

The BSEL register is also used to select among five chip enable signals -
four for the RAM chips and one for the RAM. If the BSEL value is 0-3
then the appropriate CHIP_EN line 0-3 is selected. If BSEL is 4-15 then
CHIP_EN4 is selected.

On the board itself, four jumpers individually select whether CHIP_EN lines
0-3 go to their respective ROMs or to the RAM.

*/

/* --------------- INPUTS --------------------------------------------------- */
PIN 29  = CLK ;                            /* PHI2 clock                      */
PIN [24,21..16,14,12,11,9] = [A15..5];     /* Address bus                     */
PIN [8,6,5,4] = [D3..0] ;                  /* Data bus to select mem bank     */

/* --------------- OUTPUTS -------------------------------------------------- */
PIN [33,34,36,37] = [BSEL3..0] ;           /* Bank select register            */
PIN [39,27,28,40,31] = ![CHIP_EN4..0];     /* Chip enable reg - active low    */

NODE [CHIP_SEL4..0];                       /* Internal chip select register   */
NODE BSEL_EN;                              /* Enable latching for bank select */

/* BSEL_EN is selected when the address set is $BFE0. This is the case when
we're writing a value to select the memory bank. */

BSEL_EN = A15 & !A14 & [A13..5]:& ;      /* Decodes for 32-bit block at $BFE0 */

/* The four D-latches in the BSEL register have their clocks enabled (allowing
the flip-flop to be set to the appropriate value) only when the main clock is
high *and* BSEL_EN is active.

Essentially if you write to $BFE0, BSEL_EN gets enabled when the clock goes
high. The four latches will set according to the inputs on D0-D3.
When the clock goes low, these values are latched. When we no longer have $BFE0
as the address, the values will remain latched.

These four latches are connected to A13-A16 on the RAM chip. They're
not attached to the address bus - so they don't interfere with anything else.
*/
BSEL3.d = D3 ;                              /* Latch input                    */
BSEL3.ck = CLK & BSEL_EN ;                  /* Address-qualified clock        */
BSEL2.d = D2 ;                              /* Latch input                    */
BSEL2.ck = CLK & BSEL_EN ;                  /* Address-qualified clock        */
BSEL1.d = D1 ;                              /* Latch input                    */
BSEL1.ck = CLK & BSEL_EN ;                  /* Address-qualified clock        */
BSEL0.d = D0 ;                              /* Latch input                    */
BSEL0.ck = CLK & BSEL_EN ;                  /* Address-qualified clock        */

/* Match the CHIP_SEL internal register settings to the current value of the
BSEL register. */
FIELD BANK = [BSEL3..0];
FIELD CHIPSL = [CHIP_SEL4..0];                     /* 4 = RAM, 3..0 = ROM/RAM */
TABLE BANK => CHIPSL {
    'b'0000 => 'b'00001 ;
    'b'0001 => 'b'00010 ;
    'b'0010 => 'b'00100 ;
    'b'0011 => 'b'01000 ;
    'b'01XX => 'b'10000 ;
    'b'1XXX => 'b'10000 ;
}

/* Set the appropriate chip enable signal when address $8000 is selected.     */
CHIP_EN0 = A15 & !A14 & !A13 & CHIP_SEL0;          /* ROM/RAM Bank 0          */
CHIP_EN1 = A15 & !A14 & !A13 & CHIP_SEL1;          /* ROM/RAM Bank 1          */
CHIP_EN2 = A15 & !A14 & !A13 & CHIP_SEL2;          /* ROM/RAM Bank 2          */
CHIP_EN3 = A15 & !A14 & !A13 & CHIP_SEL3;          /* ROM/RAM Bank 3          */
CHIP_EN4 = A15 & !A14 & !A13 & CHIP_SEL4;          /* RAM Banks 4-15          */


I'm open to criticism on this, too, as I'm still getting to grips with CPLDs.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Tue Jul 26, 2022 11:11 pm 
Offline

Joined: Fri Dec 21, 2018 1:05 am
Posts: 1080
Location: Albuquerque NM USA
I'm curios and want to learn how you can map 16 blocks of 8K RAM with just 4 flip flops. I'm not familiar with CUPL so I redraw you design in Quartus schematic. I think you can map the 16 blocks of 8K RAM only in the memory region $8000-$9FFF; and with external jumpers you can also map four 8K ROM only in memory region of $8000-$9FFF.

BTW, I'm not familiar with CUPL, but I believe signal.d and signal.ck will instantiate a D-flipflop. You may need to use signal.l and signal.le to instantiate a latch. But like I said, I'm not familiar with CUPL...

Bill


Attachments:
extMemDecode.pdf [12.74 KiB]
Downloaded 31 times
Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Wed Jul 27, 2022 4:19 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8199
Location: Midwestern USA
Read up on .OE for defining an output as open collector. Latches are defined with .L and .LE. Using .D and .CK, as Plasmo noted, defines a flip-flop, a C-D one, in this case.

Lastly, Atmel technical support recommends the use of PINNODE for buried logic, not NODE.

Attachment:
File comment: CUPL Programming Reference
cupl_reference.pdf [814.53 KiB]
Downloaded 25 times

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Wed Jul 27, 2022 6:55 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
Thanks for all the input. I have some reading to do. And yes, the 16 blocks are in the space starting at $8000, the four latches controlling the top four address pins of the RAM (13-16).

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Wed Jul 27, 2022 7:16 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
By the way, I obviously misspoke when writing ‘latch’ rather than ‘flip-flop’. But the logic as I have it seems to work (tested on my ATF15XX-DK3). Any reason I shouldn’t use the flip-flops?

I’ve read both the WinCUPL Reference and the CUPL reference regarding .oe - no mention of open collector specifically. What it says is: “The .OE extension is used to specify a product term driven output enable signal”.

Oh, okay. But I’m still unclear how to use the .oe extension in the code.

EDIT: Would it be something like:

Code:
PIN [39,27,28,40,31] = ![CHIP_EN4..0].oe ; 

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Wed Jul 27, 2022 9:38 pm 
Offline
User avatar

Joined: Fri Dec 12, 2008 10:40 pm
Posts: 1003
Location: Canada
I'm not sure on this. The code I gave was for VHDL. I have used CUPL, but ever for that and only for simple quick things.

Another solution would be to use a 74HC07. Drive it with you /CSx outputs then use it to or-tie them. It is a hex non-inverting buffer with open drain.

Those diodes might just work fine. Like I said before, the 2V is likely the few uA of leakage current being fed into a single CMOS input.

_________________
Bill


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Wed Jul 27, 2022 10:07 pm 
Offline

Joined: Wed Jun 23, 2021 8:02 am
Posts: 165
There are two ways to get an open collector output using CUPL. One is to use a separate 3 state buffer output. So, for example if we take your output

CHIP_EN0 = A15 & !A14 & !A13 & CHIP_SEL0; /* ROM/RAM Bank 0 */

you would change this to:

CHIP_EN0a = A15 & !A14 & !A13 & CHIP_SEL0; /* ROM/RAM Bank 0 */
CHIP_EN0 = 'b'0; /* CHIP_EN0 always low when it is enabled */
CHIP_EN0.oe = !CHIP_EN0a; /* CHIP_EN0 enabled, i.e. low, when CHIP_EN0a is low. Otherwise CHIP_EN0 is tristated. */

The disadvantage of this method is that it can require an extra macrocell. Depending on the precise logic expression used to calculate the output, you may need a macrocell to calculate the OE signal (CHIP_EN0.oe in the example) and another to generate the actual output.

The second way to do it is more economical. It is possible to explicitly set outputs on the ATF1502 to open collector, so another macrocell isn't required. I thought it should be possible to declare this in the CUPL file, but it doesn't work. The only way I found to do it is to build the CUPL using a batch script like this:

cupl -j -a -l -e -x -f -b -m4 f1502plcc44 %~dpnx1
find1502 -i %~dpn1.tt2 -CUPL -dev P1502C44 -str JTAG ON -str logic_doubling off -str open_collector = CHIP_EN0 CHIP_EN1 CHIP_EN2 CHIP_EN3

To run this script you need the following in your path: <CUPL PATH>\WinCupl;<CUPL PATH>\WinCupl\Fitters;<CUPL PATH>\Shared
where <CUPL PATH> is the path where you installed WINCUPL - usually C:\Wincupl
You also need to set an environment variable:
set LIBCUPL=<CUPL PATH>\Shared\cupl.dl


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Wed Jul 27, 2022 10:16 pm 
Offline

Joined: Wed Jun 23, 2021 8:02 am
Posts: 165
Also, it's best to avoid gating clocks if possible and use the 'clock enable' on the flip flops. Additionally, you need to include !RnW as another condition for your bank latch to be updated. The way you have it now, read cycles will also cause the latch to be updated; even worse, 'dummy' cycles with invalid addresses could also cause the latch to be updated, which would cause your system to malfunction.
Finally, you are sampling the data on the wrong clock edge. Write data should be latched on the falling edge of the clock.
So the following:

BSEL0.d = D0 ; /* Latch input */
BSEL0.ck = CLK & BSEL_EN ; /* Address-qualified clock */

should change to this:

BSEL0.d = D0 ; /* Latch input */
BSEL0.ck = !CLK; /* Clock flip flop on falling edge of PHI2 */
BSEL0.ce = BSEL_EN & !RnW ; /* Clock is enabled when a write cycle occurs with address targeting the bank selector */


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Thu Jul 28, 2022 7:16 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
Thanks all for the input. Time to take another look at the code.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Thu Jul 28, 2022 8:56 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
Okay, this is my updated code based on input.

Code:
Name     EXTMEMEXP ;
PartNo   00 ;
Date     03/07/2022 ;
Revision 01 ;
Designer SMD ;
Company  Machina Speculatrix ;
Assembly ;
Location ;
Device   f1502ispplcc44 ;

/* --------------- INPUTS --------------------------------------------------- */
PIN 43  = CLK ;                                /* PHI2 clock                      */
PIN [24,21..16,14,12,11,9] = [A15..5];     /* Address bus                    */
PIN [8,6,5,4] = [D3..0] ;                  /* Data bus to select mem bank     */
PIN 41 = RWB;                              /* Read!Write signal  */

/* --------------- OUTPUTS -------------------------------------------------- */
PIN [33,34,36,37] = [BSEL3..0];            /* Bank select register            */
PIN [39,27,28,40,31] = ![CHIP_EN4..0];     /* Chip enable reg - active low    */

NODE [CE_BUF4..0];                         /* Tristate buffer                 */
NODE [CHIP_SEL4..0];                       /* Internal chip select register   */
NODE BSEL_EN;                              /* Enable latching for bank select */

BSEL_EN = A15 & !A14 & [A13..5]:& ;      /* Decodes for 32-bit block at $BFE0 */

BSEL3.d = D3 ;                             /* Latch input                     */
BSEL3.ck = !CLK;                           /* On falling edge of clock        */
BSEL3.ce = !RWB & BSEL_EN;                 /* Enable only for writes          */
BSEL2.d = D2 ;
BSEL2.ck = !CLK;
BSEL2.ce = !RWB & BSEL_EN;
BSEL1.d = D1 ;
BSEL1.ck = !CLK;
BSEL1.ce = !RWB & BSEL_EN;
BSEL0.d = D0 ;
BSEL0.ck = !CLK;
BSEL0.ce = !RWB & BSEL_EN;

/* Match the CHIP_SEL internal register settings to the current value of the
BSEL register. */
FIELD BANK = [BSEL3..0];
FIELD CHIPSL = [CHIP_SEL4..0];                     /* 4 = RAM, 3..0 = ROM/RAM */
TABLE BANK => CHIPSL {
    'b'0000 => 'b'00001 ;
    'b'0001 => 'b'00010 ;
    'b'0010 => 'b'00100 ;
    'b'0011 => 'b'01000 ;
    'b'01XX => 'b'10000 ;
    'b'1XXX => 'b'10000 ;
}

/* Set buffer */
CE_BUF0 = A15 & !A14 & !A13 & CHIP_SEL0;
CE_BUF1 = A15 & !A14 & !A13 & CHIP_SEL1;
CE_BUF2 = A15 & !A14 & !A13 & CHIP_SEL2;
CE_BUF3 = A15 & !A14 & !A13 & CHIP_SEL3;
CE_BUF4 = A15 & !A14 & !A13 & CHIP_SEL4;

/* Set the appropriate chip enable signal when address $8000 is selected.     */
CHIP_EN0 = 'b'0;                    /* Goes low when enabled                  */
CHIP_EN0.oe = !CE_BUF0;             /* If buffer not enabled, goes tri-stated */
CHIP_EN1 = 'b'0;
CHIP_EN1.oe = !CE_BUF1;
CHIP_EN2 = 'b'0;
CHIP_EN2.oe = !CE_BUF2;
CHIP_EN3 = 'b'0;
CHIP_EN3.oe = !CE_BUF3;
CHIP_EN4 = 'b'0;
CHIP_EN4.oe = !CE_BUF4;


And yes, I know I'm still using NODE instead of PINNODE ... baby steps.

I confess I'm still struggling to get my head around:

Code:
CHIP_EN4 = 'b'0;
CHIP_EN4.oe = !CE_BUF4;


I'm reading that as saying all the chip enable pins are low (ie, enabled) by default, but then the next line overwrites that for each pin that isn't actually selected.

Also, I still have then CHIP_EN pins be active low - is this still necessary?

Code:
PIN [39,27,28,40,31] = ![CHIP_EN4..0];


I'm learning more from this thread than I have in hours of perusing the documentation!

EDIT: This code does compile and fits fine. Now to test it on the ATF15XX-DK3.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Thu Jul 28, 2022 9:32 am 
Offline
User avatar

Joined: Thu May 28, 2009 9:46 pm
Posts: 8199
Location: Midwestern USA
speculatrix wrote:
EDIT: This code does compile and fits fine. Now to test it on the ATF15XX-DK3.

Yes, but does it simulate in WinSim?

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


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Thu Jul 28, 2022 12:54 pm 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
I haven't had much luck getting the simulator to work, although I admit I haven't put a lot of effort into it yet.

I'm currently having a battle with my test rig. I have a row of DIP switches that I use to supply input signals to the ATF15XX-DK3. These are providing the right 5V inputs but, for whatever reason, when I connect to the test board, some of these signals (not all) seem to be getting pulled down. Which is weird.

I recently add the PLCC44 adapter board (before, I was using the TQFP44 adapter without trouble). I removed the adapter board to check I hadn't missed/bent any legs when something caught my eye. Wedged hard into the pins of one header was an SMD diode! It's a model I don't own, so this must have been done at the factory! Alas, removing it didn't solve the problem and some of the signals that are being pulled low go to a different header anyway.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
 Post subject: Re: Need diode help
PostPosted: Sat Jul 30, 2022 9:52 am 
Offline
User avatar

Joined: Tue Apr 03, 2018 2:10 pm
Posts: 125
kernelthread wrote:
find1502 -i %~dpn1.tt2 -CUPL -dev P1502C44 -str JTAG ON -str logic_doubling off -str open_collector = CHIP_EN0 CHIP_EN1 CHIP_EN2 CHIP_EN3


I used this method in the end. I use a script (probably derived from yours, I think) for building anyway, so the open_collector bit was easy to add. It shows every sign of working, at least on my test rig.

I'm not about to order PCBs. I'm ordering the ones with surface mount diodes and pullups on the basis that if the open collector thing works I can just bridge the diode pads and leave the pullups unpopulated.


FYI, here's the currently working code:

Code:
Name     EXTMEMDECODE ;
PartNo   00 ;
Date     03/07/2022 ;
Revision 01 ;
Designer SMD ;
Company  Machina Speculatrix ;
Assembly ;
Location ;
Device   f1502ispplcc44 ;

/*

This provides decoding for extended memory on the Zolatron 64.

The memory sits at address $8000. The decoding allows us to select one of 16
8K banks at this address.

The bank is selected by writing the value 0-15 to the address $BFE0. This
CPLD provides the decoding for that address as well as a register (BSEL) of four
D flip-flops that hold the selected value.

This register connects to address lines A13-A16 of the RAM, thus
selecting the effective address of the bank.

The BSEL register is also used to select among five chip enable signals -
four for the RAM chips and one for the RAM. If the BSEL value is 0-3
then the appropriate CHIP_EN line 0-3 is selected. If BSEL is 4-15 then
CHIP_EN4 is selected.

On the board itself, four jumpers individually select whether CHIP_EN lines
0-3 go to their respective ROMs or to the RAM.

*/

/* --------------- INPUTS --------------------------------------------------- */
PIN 43 = CLK;                              /* PHI2 clock                      */
PIN 41 = RWB;                              /* Read!Write signal from CPU      */
PIN [8,6,5,4] = [D3..0] ;                  /* Data bus to select mem bank     */
PIN [24,21..16,14,12,11,9] = [A15..5];     /* Address bus                     */

/* --------------- OUTPUTS -------------------------------------------------- */
PIN [33,34,36,37] = [BSEL3..0] ;           /* Bank select register            */
PIN [39,27,28,40,31] = ![CHIP_EN4..0];     /* Chip enable reg - active low    */

NODE [CHIP_SEL4..0];                       /* Internal chip select register   */
NODE BSEL_EN;                              /* Enable latching for bank select */


/* --------------- BANK SELECTION ------------------------------------------- */
/* BSEL_EN is selected when the address set is $BFE0. This is the case when
we're writing a value to select the memory bank. */

BSEL_EN = A15 & !A14 & [A13..5]:& ;      /* Decodes for 32-bit block at $BFE0 */

/* The four D-latches in the BSEL register have their clocks enabled (allowing
the flip-flop to be set to the appropriate value) only when the main clock is
high *and* BSEL_EN is active.

Essentially if you write to $BFE0, BSEL_EN gets enabled when the clock goes
high. The four flip-flops will set according to the inputs on D0-D3.
When the clock goes low, these values are latched. When we no longer have $BFE0
as the address, the values will remain latched.

These four flip-flops are connected to A13-A16 on the RAM chip. They're
not attached to the address bus - so they don't interfere with anything else.
*/
BSEL3.d = D3;                     /* Value from data bus                      */
BSEL3.ck = !CLK;                  /* Act on falling edge of clock             */
BSEL3.ce = !RWB & BSEL_EN;        /* Only during writes & with $BFE0 selected */
BSEL2.d = D2;
BSEL2.ck = !CLK;
BSEL2.ce = !RWB & BSEL_EN;
BSEL1.d = D1;
BSEL1.ck = !CLK;
BSEL1.ce = !RWB & BSEL_EN;
BSEL0.d = D0;
BSEL0.ck = !CLK;
BSEL0.ce = !RWB & BSEL_EN;


/* --------------- CHIP ENABLE ---------------------------------------------- */

/* Match the CHIP_SEL internal register settings to the current value of the
BSEL register. */
FIELD BANK = [BSEL3..0];
FIELD CHIPSL = [CHIP_SEL4..0];                   /* 4 = RAM, 3..0 = ROM/RAM   */
TABLE BANK => CHIPSL {
    'b'0000 => 'b'00001 ;                        /* CHIP_EN0 - BANK 0 RAM/ROM */
    'b'0001 => 'b'00010 ;                        /* CHIP_EN1 - BANK 1 RAM/ROM */
    'b'0010 => 'b'00100 ;                        /* CHIP_EN2 - BANK 2 RAM/ROM*/
    'b'0011 => 'b'01000 ;                        /* CHIP_EN3 - BANK 3 RAM/ROM */
    'b'01XX => 'b'10000 ;                        /* CHIP_EN4 - BANKS 4-15 RAM */
    'b'1XXX => 'b'10000 ;                        /*    "         "     "   "  */
}

/* Set the appropriate chip enable signal when address $8000 is selected.     */
CHIP_EN0 = A15 & !A14 & !A13 & CHIP_SEL0;          /* ROM/RAM Bank 0          */
CHIP_EN1 = A15 & !A14 & !A13 & CHIP_SEL1;          /* ROM/RAM Bank 1          */
CHIP_EN2 = A15 & !A14 & !A13 & CHIP_SEL2;          /* ROM/RAM Bank 2          */
CHIP_EN3 = A15 & !A14 & !A13 & CHIP_SEL3;          /* ROM/RAM Bank 3          */
CHIP_EN4 = A15 & !A14 & !A13 & CHIP_SEL4;          /* RAM Banks 4-15          */


Many thanks for your help.

_________________
I like it when things smoke.
BlogZolatron 64 project


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 29 posts ]  Go to page Previous  1, 2

All times are UTC


Who is online

Users browsing this forum: GARTHWILSON and 26 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: