2014-11-13 02:01:45 -08:00
|
|
|
/*
|
|
|
|
|
2016-01-05 00:24:20 -08:00
|
|
|
Copyright (c) 2014-2016 Alex Forencich
|
2014-11-13 02:01:45 -08:00
|
|
|
|
|
|
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
of this software and associated documentation files (the "Software"), to deal
|
|
|
|
in the Software without restriction, including without limitation the rights
|
|
|
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
copies of the Software, and to permit persons to whom the Software is
|
|
|
|
furnished to do so, subject to the following conditions:
|
|
|
|
|
|
|
|
The above copyright notice and this permission notice shall be included in
|
|
|
|
all copies or substantial portions of the Software.
|
|
|
|
|
|
|
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY
|
|
|
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
THE SOFTWARE.
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Language: Verilog 2001
|
|
|
|
|
|
|
|
`timescale 1ns / 1ps
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AXI4-Stream 4 port arbitrated multiplexer (64 bit datapath)
|
|
|
|
*/
|
|
|
|
module axis_arb_mux_64_4 #
|
|
|
|
(
|
|
|
|
parameter DATA_WIDTH = 64,
|
|
|
|
parameter KEEP_WIDTH = (DATA_WIDTH/8),
|
|
|
|
// arbitration type: "PRIORITY" or "ROUND_ROBIN"
|
2014-11-16 02:00:27 -08:00
|
|
|
parameter ARB_TYPE = "PRIORITY",
|
|
|
|
// LSB priority: "LOW", "HIGH"
|
|
|
|
parameter LSB_PRIORITY = "HIGH"
|
2014-11-13 02:01:45 -08:00
|
|
|
)
|
|
|
|
(
|
|
|
|
input wire clk,
|
|
|
|
input wire rst,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AXI inputs
|
|
|
|
*/
|
|
|
|
input wire [DATA_WIDTH-1:0] input_0_axis_tdata,
|
|
|
|
input wire [KEEP_WIDTH-1:0] input_0_axis_tkeep,
|
|
|
|
input wire input_0_axis_tvalid,
|
|
|
|
output wire input_0_axis_tready,
|
|
|
|
input wire input_0_axis_tlast,
|
|
|
|
input wire input_0_axis_tuser,
|
|
|
|
|
|
|
|
input wire [DATA_WIDTH-1:0] input_1_axis_tdata,
|
|
|
|
input wire [KEEP_WIDTH-1:0] input_1_axis_tkeep,
|
|
|
|
input wire input_1_axis_tvalid,
|
|
|
|
output wire input_1_axis_tready,
|
|
|
|
input wire input_1_axis_tlast,
|
|
|
|
input wire input_1_axis_tuser,
|
|
|
|
|
|
|
|
input wire [DATA_WIDTH-1:0] input_2_axis_tdata,
|
|
|
|
input wire [KEEP_WIDTH-1:0] input_2_axis_tkeep,
|
|
|
|
input wire input_2_axis_tvalid,
|
|
|
|
output wire input_2_axis_tready,
|
|
|
|
input wire input_2_axis_tlast,
|
|
|
|
input wire input_2_axis_tuser,
|
|
|
|
|
|
|
|
input wire [DATA_WIDTH-1:0] input_3_axis_tdata,
|
|
|
|
input wire [KEEP_WIDTH-1:0] input_3_axis_tkeep,
|
|
|
|
input wire input_3_axis_tvalid,
|
|
|
|
output wire input_3_axis_tready,
|
|
|
|
input wire input_3_axis_tlast,
|
|
|
|
input wire input_3_axis_tuser,
|
|
|
|
|
|
|
|
/*
|
|
|
|
* AXI output
|
|
|
|
*/
|
|
|
|
output wire [DATA_WIDTH-1:0] output_axis_tdata,
|
|
|
|
output wire [KEEP_WIDTH-1:0] output_axis_tkeep,
|
|
|
|
output wire output_axis_tvalid,
|
|
|
|
input wire output_axis_tready,
|
|
|
|
output wire output_axis_tlast,
|
|
|
|
output wire output_axis_tuser
|
|
|
|
);
|
|
|
|
|
|
|
|
wire [3:0] request;
|
|
|
|
wire [3:0] acknowledge;
|
|
|
|
wire [3:0] grant;
|
2014-11-16 01:38:20 -08:00
|
|
|
wire grant_valid;
|
2014-11-13 02:01:45 -08:00
|
|
|
wire [1:0] grant_encoded;
|
|
|
|
|
|
|
|
assign acknowledge[0] = input_0_axis_tvalid & input_0_axis_tready & input_0_axis_tlast;
|
|
|
|
assign request[0] = input_0_axis_tvalid & ~acknowledge[0];
|
|
|
|
assign acknowledge[1] = input_1_axis_tvalid & input_1_axis_tready & input_1_axis_tlast;
|
|
|
|
assign request[1] = input_1_axis_tvalid & ~acknowledge[1];
|
|
|
|
assign acknowledge[2] = input_2_axis_tvalid & input_2_axis_tready & input_2_axis_tlast;
|
|
|
|
assign request[2] = input_2_axis_tvalid & ~acknowledge[2];
|
|
|
|
assign acknowledge[3] = input_3_axis_tvalid & input_3_axis_tready & input_3_axis_tlast;
|
|
|
|
assign request[3] = input_3_axis_tvalid & ~acknowledge[3];
|
|
|
|
|
|
|
|
// mux instance
|
|
|
|
axis_mux_64_4 #(
|
|
|
|
.DATA_WIDTH(DATA_WIDTH)
|
|
|
|
)
|
|
|
|
mux_inst (
|
|
|
|
.clk(clk),
|
|
|
|
.rst(rst),
|
|
|
|
.input_0_axis_tdata(input_0_axis_tdata),
|
|
|
|
.input_0_axis_tkeep(input_0_axis_tkeep),
|
|
|
|
.input_0_axis_tvalid(input_0_axis_tvalid & grant[0]),
|
|
|
|
.input_0_axis_tready(input_0_axis_tready),
|
|
|
|
.input_0_axis_tlast(input_0_axis_tlast),
|
|
|
|
.input_0_axis_tuser(input_0_axis_tuser),
|
|
|
|
.input_1_axis_tdata(input_1_axis_tdata),
|
|
|
|
.input_1_axis_tkeep(input_1_axis_tkeep),
|
|
|
|
.input_1_axis_tvalid(input_1_axis_tvalid & grant[1]),
|
|
|
|
.input_1_axis_tready(input_1_axis_tready),
|
|
|
|
.input_1_axis_tlast(input_1_axis_tlast),
|
|
|
|
.input_1_axis_tuser(input_1_axis_tuser),
|
|
|
|
.input_2_axis_tdata(input_2_axis_tdata),
|
|
|
|
.input_2_axis_tkeep(input_2_axis_tkeep),
|
|
|
|
.input_2_axis_tvalid(input_2_axis_tvalid & grant[2]),
|
|
|
|
.input_2_axis_tready(input_2_axis_tready),
|
|
|
|
.input_2_axis_tlast(input_2_axis_tlast),
|
|
|
|
.input_2_axis_tuser(input_2_axis_tuser),
|
|
|
|
.input_3_axis_tdata(input_3_axis_tdata),
|
|
|
|
.input_3_axis_tkeep(input_3_axis_tkeep),
|
|
|
|
.input_3_axis_tvalid(input_3_axis_tvalid & grant[3]),
|
|
|
|
.input_3_axis_tready(input_3_axis_tready),
|
|
|
|
.input_3_axis_tlast(input_3_axis_tlast),
|
|
|
|
.input_3_axis_tuser(input_3_axis_tuser),
|
|
|
|
.output_axis_tdata(output_axis_tdata),
|
|
|
|
.output_axis_tkeep(output_axis_tkeep),
|
|
|
|
.output_axis_tvalid(output_axis_tvalid),
|
|
|
|
.output_axis_tready(output_axis_tready),
|
|
|
|
.output_axis_tlast(output_axis_tlast),
|
|
|
|
.output_axis_tuser(output_axis_tuser),
|
2014-11-16 01:38:20 -08:00
|
|
|
.enable(grant_valid),
|
2014-11-13 02:01:45 -08:00
|
|
|
.select(grant_encoded)
|
|
|
|
);
|
|
|
|
|
|
|
|
// arbiter instance
|
|
|
|
arbiter #(
|
|
|
|
.PORTS(4),
|
|
|
|
.TYPE(ARB_TYPE),
|
2014-11-16 02:00:27 -08:00
|
|
|
.BLOCK("ACKNOWLEDGE"),
|
|
|
|
.LSB_PRIORITY(LSB_PRIORITY)
|
2014-11-13 02:01:45 -08:00
|
|
|
)
|
|
|
|
arb_inst (
|
|
|
|
.clk(clk),
|
|
|
|
.rst(rst),
|
|
|
|
.request(request),
|
|
|
|
.acknowledge(acknowledge),
|
|
|
|
.grant(grant),
|
2014-11-16 01:38:20 -08:00
|
|
|
.grant_valid(grant_valid),
|
2014-11-13 02:01:45 -08:00
|
|
|
.grant_encoded(grant_encoded)
|
|
|
|
);
|
|
|
|
|
|
|
|
endmodule
|