0

I am trying to make an led on the DE0 FPGA turn on every 8 button presses. I have written the code for a counter, but the led is turning on every other button press, not every 8.

Here is what I have:

module tima(output led, input reset,  input clock);
reg [7:0]count;
initial count = 0;

always @ (posedge clock, posedge reset) begin
    if(reset)
    count <= 0;
    else
   count <= count + 1'd1;
end

assign led = count;

endmodule
josed2212
  • 31
  • 3
  • If you want to do something "every 8", you need only 3 bits for that, not 8. And assigning `count` to `led` discards all bits but the LSB which toggles every clock cycle. – mkrieger1 Oct 28 '21 at 20:48
  • your counter works of clocks. Where is the button push? 'led' is one-bit wide. The lowest bit of the *counter* changes every clock cycle, it is '1' every second clock cycle. This bit get's assigned to led. I guess, you need `assign led = clock[3];` – Serge Oct 28 '21 at 23:25

0 Answers0