summaryrefslogtreecommitdiff
path: root/part_3/mylib/counter_16.v
diff options
context:
space:
mode:
Diffstat (limited to 'part_3/mylib/counter_16.v')
-rw-r--r--part_3/mylib/counter_16.v24
1 files changed, 24 insertions, 0 deletions
diff --git a/part_3/mylib/counter_16.v b/part_3/mylib/counter_16.v
new file mode 100644
index 0000000..a52dc38
--- /dev/null
+++ b/part_3/mylib/counter_16.v
@@ -0,0 +1,24 @@
+`timescale 1ns / 100ps
+
+module counter_16 (
+ clock,
+ enable,
+ count,
+ reset
+ );
+
+ parameter BIT_SZ = 16;
+ input clock;
+ input enable;
+ input reset;
+ output reg [BIT_SZ-1:0] count;
+
+
+ initial count = 0;
+
+ always @ (posedge clock)
+ if (reset == 1'b0)
+ count <= 0;
+ else if (enable == 1'b0)
+ count <= count + 1'b1;
+endmodule