pwm-controller/pwm_block/sim/clk_enable_pulser_tb.v
Madeline Busig 31730fba46 Add clock enable pulser with testbench
Clock divider implemented in RTL does not get implemented properly when
used inside IP block. Instead, this module will pulse an enable pin at
the same intervals, which will be used by other modules instead of a
separate clock.
2025-12-02 23:56:01 -08:00

59 lines
619 B
Verilog

`timescale 1ns/1ps
module clk_enable_pulser_tb #(
VCD_DUMPFILE = ""
);
reg clk = 0;
reg rst = 1;
reg [3:0] sel;
wire clk_out;
wire en_out;
clk_enable_pulser cut (
.clk(clk),
.rst(rst),
.sel(sel),
.clk_out(clk_out),
.en_out(en_out)
);
reg [4:0] test_counter = 0;
always @ (posedge clk) begin
if (en_out) begin
test_counter <= test_counter + 1;
end
end
integer k;
initial begin
rst = 1;
clk = 0;
#10
rst = 0;
sel = 2;
for (k=0; k<15; k=k+1) begin
#5 clk = 1;
#5 clk = 0;
end
sel = 3;
for (k=0; k<31; k=k+1) begin
#5 clk = 1;
#5 clk = 0;
end
$dumpvars;
$finish;
end
endmodule