Continue to Site

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.

Testbench giving unknown (x) on output

Status
Not open for further replies.

ipunished

Junior Member level 3
Joined
Mar 15, 2011
Messages
31
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,286
Location
United Kingdom
Activity points
1,504
Hi,

so i want to make a simple code to make an LED blink.

here is the code I have

Code:
module led_glow(
    input clock,
	 output led
    );

reg [5:0]count;

always @ (posedge clock)
	begin
		count <= count+1;
	end
	
wire [3:0]PWM_in;

assign PWM_in = count[5]?count[4:1] : ~count[4:1];

reg [4:0]PWM;

always @ (posedge clock)
	begin
		PWM <= PWM[3:0] + PWM_in;
	end
	
wire out;

assign led = PWM[4];
//assign led = out;

endmodule

here is the testbench.

Code:
module led_glow_test;

	// Inputs
	reg clock;
	reg [5:0]count = 0;
	//reg [3:0]PWM_in;
	//reg [4:0]PWM;
	
	// Outputs
	wire led;
	localparam T = 100;
	// Instantiate the Unit Under Test (UUT)
	led_glow uut (
		.clock(clock), 
		.led(led)
	);
initial begin
	clock = 0;
	forever
		#T clock = ~clock;
end
	initial begin
		// Initialize Inputs
		//count = 6'b0;
		//PWM_in = 4'b0;
		//PWM = 5'b0;

		// Wait 100 ns for global reset to finish
		#100;
        
		// Add stimulus here

	end
      
endmodule

the problem is I keep getting unknown (x) on led output.. and the register count just keeps on zero..

any ideas whats wrong?

Thanks
 

Two regs(count and pwm) are not initialized, you should use a reset signal to give the two regs initial values.
In real design, your code may be work, but in simulation, you will get x on the output.

- - - Updated - - -

Two regs(count and pwm) are not initialized, you should use a reset signal to give the two regs initial values.
In real design, your code may be work, but in simulation, you will get x on the output.
 
Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top