/************************************************************************/
/* Parity checker pal. This pal takes the latched parity errors from	*/
/* each byte as well as the latched byte enables and bank.		*/
/* Parity errors detected during /CASP are clocked on the next bclk 	*/
/* edge and can then be read along with the offending bank. An /NMI is 	*/
/* generated when a parity error occurs. No further parity errors a	*/
/* checked for until the software (optionally) reads the error latch	*/
/* and then issues a /paritycl to clear the parity error latch and	*/
/* deassert the /NMI.							*/
/************************************************************************/
/*  Allowable Target Device Types:	GAL20V8A-15			*/
/************************************************************************/

#define DESIGNER George Scolaro	(C) 1989,90
#define REVISION 02	891201
#define PARTNUM U20

parity(	in	bclk,		/* 32532 system clock */
		!casp,		/* cas parity (from DRAMC) */
		!rsto,		/* system reset */
		!banks,		/* bank select signal */
		!parityrd,	/* read data */
		!paritycl,	/* clear parity error latch */
		!belp0..3,	/* 4 clocked byte enables */
		!pdip0..3;	/* 4 bytes worth of parity information */
	reg
		!bankc,		/* clocked bank select signal */
		!cparity,	/* parity check enable signal */
		!bankl,		/* latch bank select if parity error */
		!perr0..3;	/* parity error occurred on this byte */
	io
		!nmi;		/* the actual parity error signal  */
)
{
group perr[perr0..3];

perr[].oe	= parityrd;
bankc.oe	= parityrd;
bankl.oe	= parityrd;
cparity.oe	= parityrd;
nmi.oe		= 1;

perr[].ck	= bclk;
bankc.ck	= bclk;
bankl.ck	= bclk;
cparity.ck	= bclk;


cparity.d = casp;
bankc.d	= banks;

nmi	= perr0				/* async output */
	| perr1
	| perr2
	| perr3
	| rsto
	| nmi & !paritycl;

perr0.d	= pdip0 & belp0 & cparity & !nmi
	| perr0 & !(rsto | paritycl);

perr1.d	= pdip1 & belp1 & cparity & !nmi
	| perr1 & !(rsto | paritycl);

perr2.d	= pdip2 & belp2 & cparity & !nmi
	| perr2 & !(rsto | paritycl);

perr3.d	= pdip3 & belp3 & cparity & !nmi
	| perr3 & !(rsto | paritycl);

bankl.d	= bankc & pdip0 & belp0 & cparity & !nmi
	| bankc & pdip1 & belp1 & cparity & !nmi
	| bankc & pdip2 & belp2 & cparity & !nmi
	| bankc & pdip3 & belp3 & cparity & !nmi
	| bankl & !(rsto | paritycl);

putpart("g20v8", "parity",
	bclk, casp, rsto, banks, belp0, paritycl, pdip3, pdip1, pdip0,
	belp3, belp1, GND,
	parityrd, belp2, bankc, cparity, nmi, bankl, perr2, perr0,
	perr1 ,perr3, pdip2, VCC);
}
