module mc10153_test;

/*  verilog test of primitive definition for MC10153 latch  */  

	wire d_out;
	reg d_in,gate_bar,enable_bar,com_clock;
	parameter d = 20 ;     // waveform time step

/*  create instance of latch  */
	mc10153 lat1(d_out,d_in,gate_bar,enable_bar,com_clock);

/*  describe external stimulus of inputs  */
	initial
		begin
			#d gate_bar=1;
			#d ;
			#d d_in=0;
			#d d_in=1;
			#d d_in=0;
			#d ;
			#d ;
			#d gate_bar=0; enable_bar=0; com_clock=0;
			#d ;
			#d d_in=1;
			#d d_in=0;
			#d ;
			#d d_in=1;
			#d com_clock=1;
			#d ;
			#d d_in=0;
			#d ;
			#d ;
			#d d_in=1;
			#d d_in=0;
			#d ;
			#d ;
			#d com_clock=0;
			#d ;
			#d ;
			#d d_in=0;
			#d d_in=1;
			#d d_in=0;
			#d ;
			#d ;
			#d ;
			#d enable_bar=1;
			#d ;
			#d ;
			#d d_in=0;
			#d d_in=1;
			#d d_in=0;
			#d ;
			#d ;
			#d enable_bar=0;
			#d;
			#d d_in=0;
			#d d_in=1;
			#d d_in=0;
			#d ;
			#d d_in=1;
			#d ;
			#d enable_bar=1;
			#d ;
			#d d_in=0;
			#d ;
			#d ;
			#d enable_bar=0;
			#d ;
			#d d_in=0;
			#d d_in=1;
			#d ;
			#d ;
			#d gate_bar=1;
			#d ;
			#d ;
			#d gate_bar=0;
			#d ;
			#d ;
			#d gate_bar=1;
			#d ;
			#d gate_bar=0;
			#d ;
			#d gate_bar=1;
			#d ;


			$stop;
			
		end

/*  monitor system  */
	initial
		$gr_waves("dat in",d_in,"/G",gate_bar,"/CE",enable_bar,
				"c clock",com_clock,"dat out",d_out);

endmodule

	primitive mc10153(q_out,d_in,gate_bar,enable_bar,com_clock);

/*   ---  Primitive definition of ECL MC10153 latch  (p3-86)        */

	output q_out;
	reg q_out;
	input d_in,gate_bar,enable_bar,com_clock;

	table

//	D	/G	/CE	CC		state		output
	?	1	?	?	:	?	:	0;
	0	0	0	0	:	?	:	0;
	1	0	0	0	:	?	:	1;
	?	0	0	1	:	?	:	-;
	?	0	1	0	:	?	:	-;
	?	0	1	1	:	?	:	-;
	?	x	?	?	:	?	:	x;

	endtable

	endprimitive
