Trafficlight

MODULE Ampel
 
TITLE 'Ampel'
 
declarations
 
	T pin 16 istype 'buffer,com'//Taster ist pin 16
 
	FF0 node istype 'buffer,reg';
	FF1 node istype 'buffer,reg';
	FF2 node istype 'buffer,reg';
 
 
 
	Ar,Age,Fr,Fgr pin 3,4,9,10  ISTYPE 'BUFFER,COM';//Ar = Auto rot ,Age = Auto gelb, Fr = Fußgänger rot, Fgr = Fußgänger grün 
 
	run node;
 
	takt pin 11;//takt
 
equations
 
	FF2.clk   = takt; //Takt wird zugewiesen
	FF1.clk  = takt;  // "
	FF0.clk = takt;   // "
 
truth_table
 
	([T, FF2, FF1, FF0] :> [FF2, FF1, FF0])
	[0,0,0,0]:>[0,0,0]; 
	[0,0,0,1]:>[0,1,0]; 
	[0,0,1,0]:>[0,1,1]; 
	[0,0,1,1]:>[1,0,0]; 
	[0,1,0,0]:>[1,0,1]; 
	[0,1,0,1]:>[0,0,0];
	[0,1,1,0]:>[.x.,.x.,.x.]; 
	[0,1,1,1]:>[.x.,.x.,.x.]; 
	[1,0,0,0]:>[0,0,1]; 
	[1,0,0,1]:>[0,1,0]; 
	[1,0,1,0]:>[0,1,1]; 
	[1,0,1,1]:>[1,0,0]; 
	[1,1,0,0]:>[1,0,1]; 
	[1,1,0,1]:>[0,0,0]; 
	[1,1,1,0]:>[.x.,.x.,.x.]; 
	[1,1,1,1]:>[.x.,.x.,.x.]; 
 
 
 
 
Truth_Table
 
 
    ([T,FF2.q,FF1.q,FF0.q]->[Ar,Age,Fr,Fgr])
 
	     [0, 0, 0, 0] -> [0, 0, 1, 0];	
	     [0, 0, 0, 1] -> [0, 1, 1, 0];	
	     [0, 0, 1, 0] -> [1, 0, 1, 0];	
	     [0, 0, 1, 1] -> [1, 0, 0, 1];
             [0, 1, 0, 0] -> [1, 0, 1, 0];	
 	     [0, 1, 0, 1] -> [1, 1, 1, 0];	
	[.x.,.x.,.x.,.x.] -> [.x.,.x.,.x.,.x.];	
	[.x.,.x.,.x.,.x.] -> [.x.,.x.,.x.,.x.];	
     	     [1, 0, 0, 0] -> [0, 0, 1, 0];	
	     [1, 0, 0, 1] -> [0, 1, 1, 0];	
	     [1, 0, 1, 0] -> [1, 0, 1, 0];	
	     [1, 0, 1, 1] -> [1, 0, 0, 1];
	     [1, 1, 0, 0] -> [1, 0, 1, 0];	
	     [1, 1, 0, 1] -> [1, 1, 1, 0];	
	[.x.,.x.,.x.,.x.] -> [.x.,.x.,.x.,.x.];	
	[.x.,.x.,.x.,.x.] -> [.x.,.x.,.x.,.x.];	
 
 
 
 
END