|
1234567891011121314151617181920212223 |
- //////////////////////////////////////////////////////////////
- // 20-bit loadable up-down counter //////
- //////////////////////////////////////////////////////////////
-
- module counter(clk, rst, data, updown, load, data_out);
-
- input clk, rst, load;
- input updown;
- input [19:0] data;
-
- output reg [19:0] data_out;
-
- always @(posedge clk)
- begin
- if(rst)
- data_out <= 20'b0;
- else if(load)
- data_out <= data;
- else
- data_out <= ((updown)?(data_out + 1'b1):(data_out -1'b1));
- end
-
- endmodule
|