Altera_Forum
Honored Contributor
12 years agohow to write a counter? verilog~~~
Hi,
Anybody can teach me about counter? Here is my code~ always @(posedge clk) begin if (reset==1) begin readdata <=16'd0;//output x<=8'd0;//output selA<=3'd0;//output ld<=1'd0;//output end else if(chipselect) begin c<=c+1; //c is a reg case (c) (0|2|4|6|8) : begin x <= writedata[7:0]; selA <= writedata[10:8]; ld <= writedata[11]; end (1|3|5|7|9) : readdata[15:0] <= Q; endcase end end