//--------------------------------------------------------------------------- // // ASSERT_FIFO_INDEX // //--------------------------------------------------------------------------- // NAME // ASSERT_FIFO_INDEX - ensure that a FIFO type structure will never // overflow or underflow. // //--------------------------------------------------------------------------- module assert_fifo_index (clk, reset_n, push, pop); // synopsys template parameter severity_level = 0; parameter depth=1; parameter push_width = 1; parameter pop_width = 1; parameter options=0; parameter msg="VIOLATION"; input clk, reset_n; input [push_width-1:0] push; input [pop_width-1:0] pop; //synopsys translate_off `ifdef ASSERT_ON // local parameters parameter no_push_pop = ((options & 2) != 0); parameter assert_name = "ASSERT_FIFO_INDEX"; integer error_count; integer cnt; initial begin cnt=0; error_count = 0; if (depth==0) ovl_error("Depth parameter value must be > 0"); end `include "ovl_header.h" `include "ovl_task.h" `ifdef ASSERT_INIT_MSG initial ovl_init_msg; // Call the User Defined Init Message Routine `endif 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 if ({push!=0,pop!=0} == 2'b10) begin // push if ((cnt + push) > depth) begin ovl_error("OVERFLOW"); end else begin cnt <= cnt + push; end end else if ({push!=0,pop!=0} == 2'b01) begin // pop if (cnt < pop) begin ovl_error("UNDERFLOW"); end else begin cnt <= cnt - pop; end end else if ({push!=0,pop!=0} == 2'b11) begin // push & pop if (no_push_pop) begin ovl_error("ILLEGAL PUSH AND POP"); end else begin if ((cnt + push - pop) > depth) begin ovl_error("OVERFLOW"); end if ((cnt + push) < pop) begin ovl_error("UNDERFLOW"); end else begin cnt <= cnt + push - pop; end end end end else begin cnt <= 0; end end `endif //synopsys translate_on endmodule