Files
retroSoC/tests/rtl/clock_frequency_monitor_tb.sv
T
maksyuki 98eb8ebad6 feat: add comprehensive tests for AXI4 components and lifecycle controllers
- Implemented tests for AXI4 async bridge functionality, including transfer and warm flush scenarios.
- Added tests for AXI4 data crossbar to validate concurrent outstanding requests and ACL handling.
- Introduced clock frequency monitor tests to ensure detection of clock stop and restart events.
- Developed tests for extension DMA master to verify copy operations, tail strobe behavior, and timeout handling.
- Created tests for HP lifecycle controller to validate drain, flush, and forced reset functionalities.
- Updated existing test scripts to include new RTL components and ensure proper simulation configurations.
2026-08-30 13:15:10 +08:00

59 lines
1.6 KiB
Systemverilog

`timescale 1ns / 1ps
module clock_frequency_monitor_tb;
logic ref_clk_i = 1'b0;
logic monitored_clk_i = 1'b0;
logic rst_n_i = 1'b0;
logic clear_fault_i = 1'b0;
logic run_monitored = 1'b1;
logic alive_o;
logic fault_o;
logic [7:0] edge_delta_o;
always #5 ref_clk_i = ~ref_clk_i;
always begin
#2;
if (run_monitored) monitored_clk_i = ~monitored_clk_i;
else monitored_clk_i = 1'b0;
end
clock_frequency_monitor #(
.CounterWidth(8),
.WindowCycles(8)
) u_dut (
.ref_clk_i (ref_clk_i),
.ref_rst_n_i (rst_n_i),
.monitored_clk_i (monitored_clk_i),
.monitored_rst_n_i(rst_n_i),
.clear_fault_i (clear_fault_i),
.alive_o (alive_o),
.fault_o (fault_o),
.edge_delta_o (edge_delta_o)
);
initial begin
repeat (2) @(posedge ref_clk_i);
rst_n_i = 1'b1;
repeat (20) @(posedge ref_clk_i);
if (!alive_o || fault_o || (edge_delta_o == 8'd0)) begin
$fatal(1, "running clock was not measured as alive");
end
run_monitored = 1'b0;
wait (fault_o);
if (alive_o) $fatal(1, "stopped clock remained alive");
@(negedge ref_clk_i);
clear_fault_i = 1'b1;
@(negedge ref_clk_i);
clear_fault_i = 1'b0;
@(negedge ref_clk_i);
if (fault_o) $fatal(1, "clock fault did not clear");
run_monitored = 1'b1;
repeat (12) @(posedge ref_clk_i);
if (!alive_o) $fatal(1, "restarted clock did not recover activity status");
$display("Clock frequency activity and sticky fault test passed");
$finish;
end
endmodule