Here's a Verilog example of a pipelined round-robin arbiter controlling the read signal of N FIFOs based on their content depth exceeding a "data_ready" threshold. In this example, the FIFOs are of the FWFET (First Word Fall Through) type, and a valid bit is generated for pipelined output.
module fifo_arbiter(
input wire clk,
input wire reset,
input wire [3:0] fifo_depth, // Depth of each FIFO
input wire [7:0] fifo_threshold, // Threshold to trigger data_ready
output wire [3:0] fifo_data_ready, // Data ready status of each FIFO
output wire [3:0] fifo_valid, // Valid data in each FIFO
output wire [3:0] fifo_read, // Read control signal for each FIFO
input wire [3:0] fifo_output, // Output data from each FIFO
output wire [3:0] fifo_almost_full // Indicates if the FIFO is almost full
);
reg [3:0] last_selected; // Keep track of the last selected FIFO
reg [3:0] next_selected; // Calculate the next selected FIFO
reg [3:0] read_signal; // Combine all read signals
always @(posedge clk or posedge reset) begin
if (reset) begin
last_selected <= 0;
read_signal <= 0;
end else begin
next_selected <= (last_selected + 1) % 4; // Calculate the next FIFO to read
read_signal <= (fifo_data_ready & fifo_valid) << next_selected;
last_selected <= next_selected;
end
end
assign fifo_data_ready = (fifo_depth >= fifo_threshold); // Pipelined data ready
assign fifo_valid = (fifo_output != 0); // Generate valid bit for pipelined output
assign fifo_almost_full = (read_signal | fifo_data_ready) & ~fifo_valid;
assign fifo_read = read_signal(0) ? 1'b1 : 1'b0;
endmodule
This Verilog code defines a module called fifo_arbiter. The inputs include the clock (clk), reset (reset), depth of each FIFO (fifo_depth), threshold to trigger data ready (fifo_threshold), output data from each FIFO (fifo_output), and the output data from each FIFO (fifo_output). The outputs include the data ready status of each FIFO (fifo_data_ready), valid data in each FIFO (fifo_valid), read control signal for each FIFO (fifo_read), and the almost full status for each FIFO (fifo_almost_full).
The assign block calculates the fifo_data_ready signal based on the fifo_depth and fifo_threshold signals for pipelining. It also generates the fifo_valid bit for the pipelined output. The always block remains the same as the previous example. In the assign block, the code calculates the fifo_almost_full and fifo_read signals based on the and signals.