blob: f1f13bbe74aeb6e39b3d506d9dd63412965b98ae (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
module MyCounter (clock, preset, updown, presetdata, counter);
input clock, preset, updown;
input [1: 0] presetdata;
output reg [1:0] counter;
always @(posedge clock)
if(preset)
counter <= presetdata;
else
if(updown)
counter <= counter + 1;
else
counter <= counter - 1;
endmodule
|