style: ✨ counter
This commit is contained in:
parent
13b2826b20
commit
c6bdc199f3
3 changed files with 33 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
*.bin
|
14
01-counter/counter.v
Normal file
14
01-counter/counter.v
Normal file
|
@ -0,0 +1,14 @@
|
|||
module counter(out, clk, reset);
|
||||
parameter WIDTH = 8;
|
||||
output [WIDTH-1:0] out;
|
||||
input clk, reset;
|
||||
reg [WIDTH-1: 0] out;
|
||||
wire clk, reset;
|
||||
|
||||
always @(posedge clk or posedge reset) begin
|
||||
if (reset)
|
||||
out <= 0;
|
||||
else
|
||||
out <= out + 1;
|
||||
end
|
||||
endmodule
|
18
01-counter/counter_tb.v
Normal file
18
01-counter/counter_tb.v
Normal file
|
@ -0,0 +1,18 @@
|
|||
module counter_test;
|
||||
reg reset = 0;
|
||||
initial begin
|
||||
#17 reset = 1;
|
||||
#11 reset = 0;
|
||||
#17 reset = 1;
|
||||
#11 reset = 0;
|
||||
#17 $stop;
|
||||
end
|
||||
|
||||
reg clk = 0;
|
||||
always #5 clk = !clk;
|
||||
|
||||
wire [7:0] value;
|
||||
counter c1(value, clk, reset);
|
||||
initial
|
||||
$monitor("Time = %t, Value = %h (%0d)", $time, value, value);
|
||||
endmodule
|
Loading…
Add table
Add a link
Reference in a new issue