Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Question for controller of test fixture

Status
Not open for further replies.

pig8190

Newbie level 4
Joined
Feb 23, 2012
Messages
7
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,336
Hello, everyone .....if we want to write the test fixture for traffic controller, and then I put one Po(Power outage) mode to control light and the two RED light will blink. However, If I want two of sequence of stimulus into the test fixture: S0 => S1 => S2 => S0
S0 => S1 => S2 => S3 (10 clock cycles) => S4 => S2 => S0

How to I start with that????
thanks so much!!!!!!!!!!!!
This my code for traffic controller:(This may helpful to let u guys know what I asking for)

Code:
module Traffic_ctrl(clk, rst, enable, sens, PO, lights);
	input clk;
	input rst;
	input enable;
	input [2:0] sens;
	input PO;
	output[5:0] lights;
	
	parameter BLANK		= 	3'b000;
	parameter GREEN  		= 	3'b001; 
	parameter YELLOW		= 	3'b010;
	parameter RED		   = 	3'b100;
	parameter S0			=  3'b000;
	parameter S1			=  3'b001;
	parameter S2 			=  3'b011;
	parameter S3			=  3'b010;
	parameter S4   		=  3'b110;
	parameter S5			=  3'b101;
	
	reg [2:0] ps, ns; 
	reg [5:0] lights;

	//Sequential Logic
always @(posedge clk, posedge rst)
	if (rst) 
		ps <= S0; 
	else if(enable) 
		ps <= ns;

// Nest-state logic 
	always @(ps, sens, PO)
		case (ps)
			S0: if (PO) 
					ns = S5; 
				 else 
					begin
						if (sens[2])
							ns = S1;
						else 
							ns = S0;
					end 
					
			S1: 	if (PO)
						ns = S5;
					else 
						ns = S2;
			
			S2: if (PO == 0)
					begin
						if (sens[0]==1'b0) 
							ns = S0;
						else 
							ns = S3; 
					end 
				 else 
					ns = S5; 
					
			S3: if (PO) 
					ns = S5;
				 else 
					begin
						if (sens[1]) 
							ns = S4;
						else 
							ns = S3; 
					end 
					
			S4: 	if (PO)
						ns = S5;
					else 
						ns = S2;
			
			S5: 	ns = S2;
					
			default:    ns = S0;
		endcase

		
// Output Logic
	always @(ps)
		case(ps)
			S0: 	lights = {GREEN, RED};
			S1: 	lights = {YELLOW, RED};
			S2: 	lights = {RED, RED};
			S3: 	lights = {RED, GREEN};
			S4: 	lights = {RED, YELLOW};
			S5:	lights = {BLANK, BLANK};
						
			default: 	lights = {RED, RED};
		endcase

endmodule
 
Last edited by a moderator:

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top