verilator/test_regress/t/t_assert_synth.v

117 lines
2.4 KiB
Systemverilog
Raw Normal View History

// DESCRIPTION: Verilator: Verilog Test module
//
// This file ONLY is placed under the Creative Commons Public Domain.
// SPDX-FileCopyrightText: 2005 Wilson Snyder
// SPDX-License-Identifier: CC0-1.0
2026-03-03 13:21:24 +01:00
module t (
input clk
);
2026-03-03 13:21:24 +01:00
reg a; initial a = 1'b1;
reg b_fc; initial b_fc = 1'b0;
reg b_pc; initial b_pc = 1'b0;
reg b_oh; initial b_oh = 1'b0;
reg b_oc; initial b_oc = 1'b0;
wire a_l = ~a;
wire b_oc_l = ~b_oc;
2026-03-03 13:21:24 +01:00
// Note we must ensure that full, parallel, etc, only fire during
// edges (not mid-cycle), and must provide a way to turn them off.
// SystemVerilog provides: $asserton and $assertoff.
2026-03-03 13:21:24 +01:00
// verilator lint_off CASEINCOMPLETE
2026-03-03 13:21:24 +01:00
always @* begin
// Note not all tools support directives on casez's
`ifdef ATTRIBUTES
2026-03-03 13:21:24 +01:00
case ({a,b_fc}) // synopsys full_case
`else
2026-03-03 13:21:24 +01:00
case ({a,b_fc})
`endif
2026-03-03 13:21:24 +01:00
2'b0_0: ;
2'b0_1: ;
2'b1_0: ;
// Note no default
endcase
priority case ({a,b_fc})
2'b0_0: ;
2'b0_1: ;
2'b1_0: ;
// Note no default
endcase
end
2026-03-03 13:21:24 +01:00
always @* begin
`ifdef ATTRIBUTES
2026-03-03 13:21:24 +01:00
case (1'b1) // synopsys full_case parallel_case
`else
`ifdef FAILING_FULL
2026-03-03 13:21:24 +01:00
case (1'b1) // synopsys parallel_case
`else
2026-03-03 13:21:24 +01:00
case (1'b1) // synopsys parallel_full
`endif
`endif
2026-03-03 13:21:24 +01:00
a: ;
b_pc: ;
endcase
end
2011-07-01 21:23:09 +02:00
`ifdef NOT_YET_VERILATOR // Unsupported
2026-03-03 13:21:24 +01:00
// ambit synthesis one_hot "a, b_oh"
// cadence one_cold "a_l, b_oc_l"
`endif
2026-03-03 13:21:24 +01:00
integer cyc; initial cyc=1;
always @ (posedge clk) begin
if (cyc!=0) begin
cyc <= cyc + 1;
if (cyc==1) begin
a <= 1'b1;
b_fc <= 1'b0;
b_pc <= 1'b0;
b_oh <= 1'b0;
b_oc <= 1'b0;
end
if (cyc==2) begin
a <= 1'b0;
b_fc <= 1'b1;
b_pc <= 1'b1;
b_oh <= 1'b1;
b_oc <= 1'b1;
end
if (cyc==3) begin
a <= 1'b1;
b_fc <= 1'b0;
b_pc <= 1'b0;
b_oh <= 1'b0;
b_oc <= 1'b0;
end
if (cyc==4) begin
`ifdef FAILING_FULL
2026-03-03 13:21:24 +01:00
b_fc <= 1'b1;
`endif
`ifdef FAILING_PARALLEL
2026-03-03 13:21:24 +01:00
b_pc <= 1'b1;
`endif
`ifdef FAILING_OH
2026-03-03 13:21:24 +01:00
b_oh <= 1'b1;
`endif
`ifdef FAILING_OC
2026-03-03 13:21:24 +01:00
b_oc <= 1'b1;
`endif
end
2026-03-03 13:21:24 +01:00
if (cyc==10) begin
$write("*-* All Finished *-*\n");
$finish;
end
end
end
initial begin : test_info
$info ("Start of $info test");
$info ("Middle of $info test");
$info ("End of $info test");
end : test_info
endmodule