I can't understand why my program returns nothing. I'm trying to make a simple 6-bit up-counter that counts on a button press.
module top (CLK, BTN_RST, LED, BTN_C);
input CLK, BTN_RST, BTN_C;
output [5:0]LED;
reg [5:0]LED;
always @(posedge CLK or posedge BTN_RST) begin
if (BTN_RST) begin
LED <= 6'b000000;
end
else begin: COUNT
while (BTN_C) begin
LED <= LED + 1'b1;
disable COUNT;
end
end
end
endmodule
The testbench is:
module top_test;
reg CLK;
reg BTN_RST;
reg BTN_C;
reg [5:0]LED;
initial begin
CLK = 0;
BTN_RST = 0;
BTN_C = 0;
#1 BTN_RST = 1;
#5 BTN_RST = 0;
#10 BTN_C = 1;
#50;
end
always
begin
#5 CLK=~CLK;
end
endmodule
This code compiles and runs (as I can see on iSim), but the LED
output gives me XXXXXX. I think I'm not only got some mistakes here, but I also can't understand how the testbench works and how to make right assignments on input and output. Can anyone please help me?