SummerCart64/fw/v1/rtl/sd/sd_fifo.v

48 lines
1.1 KiB
Coq
Raw Normal View History

module sd_fifo (
input i_clk,
input i_reset,
input i_fifo_flush,
input i_fifo_push,
input i_fifo_pop,
output o_fifo_empty,
output o_fifo_full,
output reg o_fifo_underrun,
output reg o_fifo_overrun,
2021-02-09 23:58:02 +01:00
output [8:0] o_fifo_items,
input [31:0] i_fifo_data,
output [31:0] o_fifo_data
);
2021-02-17 00:24:31 +01:00
wire [7:0] w_fifo_items;
assign o_fifo_items = {o_fifo_full, w_fifo_items};
fifo_sd fifo_sd_inst (
.clock(i_clk),
.sclr(i_reset || i_fifo_flush),
.wrreq(i_fifo_push),
.rdreq(i_fifo_pop),
.empty(o_fifo_empty),
.full(o_fifo_full),
.usedw(w_fifo_items),
.data(i_fifo_data),
.q(o_fifo_data)
);
always @(posedge i_clk) begin
2021-02-17 00:24:31 +01:00
if (i_reset || i_fifo_flush) begin
o_fifo_underrun <= 1'b0;
o_fifo_overrun <= 1'b0;
end else begin
2021-02-17 00:24:31 +01:00
if (o_fifo_empty && i_fifo_pop) begin
o_fifo_underrun <= 1'b1;
end
2021-02-17 00:24:31 +01:00
if (o_fifo_full && i_fifo_push) begin
o_fifo_overrun <= 1'b1;
end
end
end
endmodule