add counter

This commit is contained in:
Jose Luis Montañes Ojados
2026-03-01 01:42:33 +01:00
parent 1525373c61
commit 53925538d6
3 changed files with 63 additions and 1 deletions

18
counter/counter.v Normal file
View File

@@ -0,0 +1,18 @@
/*
Contador
*/
module counter #(parameter N = 8) (
input clk,
input rst,
input write,
input [N-1:0] write_value,
output reg [N-1:0] count
);
always @(posedge clk or posedge rst) begin
if (rst) count <= 0;
else if (write) count <= write_value;
else count <= count + 1;
end
endmodule