I want to design a counter in Verilog HDL which would have a press button when pressed the counter show start counting incrementally. However, the counter does not start counting. This is the major issue. What could possibly be wrong?
I have provide a code snippet below.
module pressbutton_counter(rst,clk,p_b,count);
input rst,clk;
input [1:0]p_b;
output reg [4:0]count;
always @(posedge clk)
begin
if (rst)
count <= 0;
else if(p_b==2'b01)
count<=count+1;
else if(p_b==2'b10)
count<=count+2;
else if(p_b==2'b11)
count<=count+3;
else
count<=count+1;
end
endmodule
New contributor
Obaid Ullah is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2