You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

66 lines
2.0 KiB
Coq

// fifo, fifo
// , fifo, ,
module fifo_wr(
input wr_clk,
input rst,
input is_empty, // fifo, wr_clk,
input is_almost_full, //
input is_wr_rst_busy, // ,
//
output reg fifo_wr_en, //
output reg [7:0] fifo_wr_data //
);
// , is_empty , is_empty
reg is_empty_0;
reg is_empty_1;
always @(posedge wr_clk or negedge rst) begin
if (!rst) begin
is_empty_0 <= 1'b0;
is_empty_1 <= 1'b0;
end
else begin
is_empty_0 <= is_empty;
is_empty_1 <= is_empty_0;
end
end
// ,
always @(posedge wr_clk or negedge rst) begin
if (!rst) begin
fifo_wr_en <= 1'b0;
end
else if (!is_wr_rst_busy) begin // fifo
if (is_empty_1) begin // // ,
fifo_wr_en <= 1'b1;
end
else if(is_almost_full) begin // ,1,
// , ,
fifo_wr_en <= 1'b0;
end
else begin
end
end
else begin
end
end
//
always @(posedge wr_clk or negedge rst) begin
if (!rst) begin
fifo_wr_data <= 8'b0;
end
else if(fifo_wr_en && fifo_wr_data < 8'd254) begin // ip256, 255, 0~254
fifo_wr_data <= fifo_wr_data + 8'b1; // 253, 1 254, 0~254
end
else begin
fifo_wr_data <= 8'b0;
end
end
endmodule