style: counter

This commit is contained in:
Ahmet Kaan GÜMÜŞ 2024-10-25 15:20:56 +03:00
parent 13b2826b20
commit c6bdc199f3
3 changed files with 33 additions and 0 deletions

1
.gitignore vendored Normal file
View file

@ -0,0 +1 @@
*.bin

14
01-counter/counter.v Normal file
View 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
View 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