diff --git a/tests/various/chformal_check.ys b/tests/various/chformal_check.ys new file mode 100644 index 00000000000..951543fa5e5 --- /dev/null +++ b/tests/various/chformal_check.ys @@ -0,0 +1,68 @@ +read_verilog -formal < clk2fflogic_effects.iv.log + +sort clk2fflogic_effects.iv.log > clk2fflogic_effects.iv.sorted.log +tail +3 clk2fflogic_effects.sim.log | sort > clk2fflogic_effects.sim.sorted.log +tail +3 clk2fflogic_effects.clk2fflogic.log | sort > clk2fflogic_effects.clk2fflogic.sorted.log + +cmp clk2fflogic_effects.iv.sorted.log clk2fflogic_effects.sim.sorted.log +cmp clk2fflogic_effects.iv.sorted.log clk2fflogic_effects.clk2fflogic.sorted.log diff --git a/tests/various/clk2fflogic_effects.sv b/tests/various/clk2fflogic_effects.sv new file mode 100644 index 00000000000..b571cf3fe7d --- /dev/null +++ b/tests/various/clk2fflogic_effects.sv @@ -0,0 +1,82 @@ +module top; + +(* gclk *) +reg gclk; + +reg clk = 0; +always @(posedge gclk) + clk <= !clk; + +reg [4:0] counter = 0; + +reg eff_0_trg = '0; +reg eff_0_en = '0; + +reg eff_1_trgA = '0; +reg eff_1_trgB = '0; +reg eff_1_en = '0; + +reg eff_2_trgA = '0; +reg eff_2_trgB = '0; +reg eff_2_en = '0; + +`ifdef FAST +always @(posedge gclk) begin +`else +always @(posedge clk) begin +`endif + counter <= counter + 1; + + eff_0_trg = 32'b00000000000000110011001100101010 >> counter; + eff_0_en <= 32'b00000000000001100000110110110110 >> counter; + + eff_1_trgA = 32'b00000000000000000011110000011110 >> counter; + eff_1_trgB = 32'b00000000000000001111000001111000 >> counter; + eff_1_en <= 32'b00000000000000001010101010101010 >> counter; + + eff_2_trgA = counter[0]; + eff_2_trgB = !counter[0]; + eff_2_en <= 32'b00000000000000000000001111111100 >> counter; +end + +always @(posedge eff_0_trg) + if (eff_0_en) + $display("%02d: eff0 +", counter); + +always @(negedge eff_0_trg) + if (eff_0_en) + $display("%02d: eff0 -", counter); + +always @(posedge eff_0_trg, negedge eff_0_trg) + if (eff_0_en) + $display("%02d: eff0 *", counter); + +always @(posedge eff_1_trgA, posedge eff_1_trgB) + if (eff_1_en) + $display("%02d: eff1 ++", counter); + +always @(posedge eff_1_trgA, negedge eff_1_trgB) + if (eff_1_en) + $display("%02d: eff1 +-", counter); + +always @(negedge eff_1_trgA, posedge eff_1_trgB) + if (eff_1_en) + $display("%02d: eff1 -+", counter); + +always @(negedge eff_1_trgA, negedge eff_1_trgB) + if (eff_1_en) + $display("%02d: eff1 --", counter); + +always @(posedge eff_2_trgA, posedge eff_2_trgB) + if (eff_2_en) + $display("repeated"); + +`ifdef __ICARUS__ +initial gclk = 0; +always @(gclk) gclk <= #5 !gclk; +always @(posedge gclk) + if (counter == 31) + $finish(0); +`endif + +endmodule