Initial commit

This commit is contained in:
Nikolay Puzanov
2021-02-28 18:59:56 +03:00
parent ff795d2b6e
commit 2fbacc0544
61 changed files with 6063 additions and 0 deletions

33
source/tick_generator.sv Normal file
View File

@@ -0,0 +1,33 @@
`timescale 1ns/100ps
`default_nettype none
`include "assert.vh"
module tick_generator #(parameter PERIOD = 1000)
(input wire clock,
input wire reset,
output reg tick_o);
initial begin
`assert(PERIOD > 1);
end
localparam TICK_CW = $clog2(PERIOD);
logic [TICK_CW-1:0] cntr;
always_ff @(posedge clock, posedge reset)
if (reset) begin
cntr <= '0;
tick_o <= 1'b0;
end
else begin
if (cntr == (PERIOD-1)) begin
cntr <= '0;
tick_o <= 1'b1;
end
else begin
cntr <= cntr + 1'b1;
tick_o <= 1'b0;
end
end
endmodule // tick_generator