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.
Blog –
Zolatron 64 project