sameem_shabbir
Advanced Member level 4
I am using Spartan 3 starter kit board.
I made a counter in verilog
The counter output is not true i.e. it counts its own counting not 1 2 3 4 ...
I connected the output to leds and the input clock to the slider button. I t was not working properly.
Is there any problem in my code. Plz help
CODE
module counter(load, p, clk, q);
parameter n = 2;
input load;
input [n-1:0] p;
input clk;
output [n-1:0] q;
reg [n-1:0] q;
always @(posedge clk)
if (load)
q = p;
else
q = q + 1;
endmodule
Plz help
I made a counter in verilog
The counter output is not true i.e. it counts its own counting not 1 2 3 4 ...
I connected the output to leds and the input clock to the slider button. I t was not working properly.
Is there any problem in my code. Plz help
CODE
module counter(load, p, clk, q);
parameter n = 2;
input load;
input [n-1:0] p;
input clk;
output [n-1:0] q;
reg [n-1:0] q;
always @(posedge clk)
if (load)
q = p;
else
q = q + 1;
endmodule
Plz help