I'm trying to learn verilog having done C++ before. As a learning exercise I'm trying to flash turn an LED on after seeing 10 button presses. I also have an additional reset button that starts the 10 count again. What ever I try I can't get it to compile. Can anyone point me in the right direction?
My code is:
module led_counter (button, nreset, led);
input button, nreset;
output led;
reg counter[4:0]; // to hold the current count
always @ (negedge nreset) begin
counter <= 0; // Just reset counter
end
always @ (negedge button) begin
if (counter == 10) begin // see if the button has been pressed 10 times
led_state <= 1; // turn the led on
end
else begin
led_state <= 0; // the led is off
counter <= counter + 1;
end
end
assign led = led_state;
endmodule