Tests: Add setuphold test

Signed-off-by: Bartłomiej Chmiel <bchmiel@antmicro.com>
This commit is contained in:
Bartłomiej Chmiel 2025-02-21 16:44:18 +01:00 committed by Krzysztof Sychla
parent ce058cc432
commit b4d2f6d2b1
2 changed files with 67 additions and 0 deletions

18
test_regress/t/t_setuphold.py Executable file
View File

@ -0,0 +1,18 @@
#!/usr/bin/env python3
# DESCRIPTION: Verilator: Verilog Test driver/expect definition
#
# Copyright 2025 by Wilson Snyder. This program is free software; you
# can redistribute it and/or modify it under the terms of either the GNU
# Lesser General Public License Version 3 or the Perl Artistic License
# Version 2.0.
# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
import vltest_bootstrap
test.scenarios('simulator')
test.compile()
test.execute()
test.passes()

View File

@ -0,0 +1,49 @@
// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain, for
// any use, without warranty, 2025 by Antmicro.
// SPDX-License-Identifier: CC0-1.0
module t (/*AUTOARG*/
// Inputs
clk,
d
);
input clk;
input d;
wire delayed_CLK;
wire delayed_D;
reg notifier;
logic[3:0] sh1 = 1;
logic[3:0] sh2 = 2;
logic[3:0] sh3 = 3;
logic[3:0] sh4 = 4;
int cyc = 0;
specify
$setuphold (posedge clk, negedge d, 0, 0, notifier,,, delayed_CLK, delayed_D);
$setuphold (posedge sh1, negedge sh3, 0, 0, notifier,,, sh2, sh4);
$setuphold (posedge clk, negedge d, 0, 0);
endspecify
initial begin
if (sh1 != sh2 || sh3 != sh4) begin
$stop;
end
end
always @(posedge clk) begin
cyc <= cyc + 1;
$display("%d %d", clk, delayed_CLK);
if (delayed_CLK != clk || delayed_D != d) begin
$stop;
end
if (cyc == 10) begin
$display("*-* All Finished *-*");
$finish;
end
end
endmodule