//--------------------------------------------------------------------------- // // ASSERT_FRAME // //--------------------------------------------------------------------------- // NAME // ASSERT_FRAME - Ensure cycle time relationship between start_event // and test_expr evaluating true // // USAGE // assert_frame // #(severity_level, min_cks, max_cks, flag, options, msg) // inst_name (clk, reset_n, start_event, test_expr); // //--------------------------------------------------------------------------- module assert_frame (clk, reset_n, start_event, test_expr); // synopsys template parameter severity_level=0; parameter min_cks=0; parameter max_cks=0; parameter flag=0; parameter options = 0; parameter msg="VIOLATION"; input clk; input reset_n; input start_event; input test_expr; //synopsys translate_off `ifdef ASSERT_ON // local parameters parameter assert_name = "ASSERT_FRAME"; parameter num_cks = (max_cks>min_cks)?max_cks:min_cks; parameter FRAME_START = 1'b0; parameter FRAME_CHECK = 1'b1; parameter FLAG_IGNORE_NEW_START = 2'b00; parameter FLAG_RESET_ON_START = 2'b01; parameter FLAG_ERR_ON_START = 2'b10; parameter START_flag=flag & 2'b11; parameter EDGE_flag=flag & 3'b100; reg r_state; reg r_start_event; integer error_count; initial error_count = 0; `include "ovl_task.h" `ifdef ASSERT_INIT_MSG initial ovl_init_msg; // Call the User Defined Init Message Routine `endif initial begin // *** NEW STATIC CHECK FOR MIN/MAX and flag *** if (~((START_flag == FLAG_IGNORE_NEW_START) || (START_flag == FLAG_RESET_ON_START) || (START_flag == FLAG_ERR_ON_START))) begin ovl_error("illegal flag parameter"); end if (max_cks && (max_cks < min_cks)) begin ovl_error("min_cks > max_cks"); end r_state=FRAME_START; r_start_event = 1'b0; end integer ii; reg r_test_expr; initial r_test_expr = 1'b0; always @(posedge clk) begin r_start_event <= start_event; if (EDGE_flag) r_test_expr <= test_expr; end always @(posedge clk) begin `ifdef ASSERT_GLOBAL_RESET if (`ASSERT_GLOBAL_RESET != 1'b0) begin `else if (reset_n != 0) begin // active low reset `endif case (r_state) FRAME_START: // assert_frame() behaves like assert_implication() // when min_cks==0 and max_cks==0 if ((min_cks==0) && (max_cks==0)) begin if ((start_event==1'b1) && (test_expr==1'b0)) begin // FAIL, it does not behave like assert_implication() ovl_error(""); end end // wait for start_event (0->1) else if ((r_start_event == 1'b0) && (start_event == 1'b1)) begin r_state <= FRAME_CHECK; ii <= 1; end FRAME_CHECK: // start_event (0->1) has occurred // start checking begin // Count clock ticks if ((r_start_event == 1'b0) && (start_event == 1'b1)) begin // start_event (0->1) happens again -- re-started!!! if (START_flag == FLAG_IGNORE_NEW_START) begin if (max_cks) ii <= ii + 1; else if (ii < min_cks) ii <= ii + 1; end else if (START_flag == FLAG_RESET_ON_START) ii <= 1; else if (START_flag == FLAG_ERR_ON_START) begin ovl_error("illegal start event"); r_state <= FRAME_START; end end else begin if (max_cks) ii <= ii + 1; else if (ii < min_cks) ii <= ii + 1; end // Check for (0,0), (0,M), (m,0), (m,M) conditions if (min_cks == 0) begin if (max_cks == 0) begin // (0,0): (min_cks==0, max_cks==0) // This condition is UN-REACHABLE!!! ovl_error(""); r_state <= FRAME_START; end else begin // max_cks > 0 // (0,M): (min_cks==0, max_cks>0) if ((r_test_expr==1'b0) && (test_expr == 1'b1)) begin // OK, ckeck is done. Go to FRAME_START state for next check. r_state <= FRAME_START; end else begin if (ii == max_cks) begin // FAIL, test_expr does not happen at/before max_cks ovl_error(""); r_state <= FRAME_START; end end end end else begin // min_cks > 0 if (max_cks == 0) begin // (m,0): (min_cks>0, max_cks==0) if ((r_test_expr==1'b0) && (test_expr == 1'b1)) begin // FAIL, test_expr should not happen before min_cks ovl_error(""); r_state <= FRAME_START; end else begin if (ii == min_cks) begin // OK, test_expr does not happen before min_cks r_state <= FRAME_START; end end end else begin // max_cks > 0 // (m,M): (min_cks>0, max_cks>0) if ((r_test_expr==1'b0) && (test_expr == 1'b1)) begin r_state <= FRAME_START; if (ii < min_cks) begin // FAIL, test_expr should not happen before min_cks ovl_error(""); end // else OK, we are done!!! end else begin if (ii == max_cks) begin // FAIL, test_expr does not happen at/before max_cks ovl_error(""); r_state <= FRAME_START; end end end end end endcase end else begin r_state <= FRAME_START; end end // always `endif endmodule