1
0
mirror of https://github.com/corundum/corundum.git synced 2025-01-30 08:32:52 +08:00

Convert generated crosspoint to verilog parametrized crosspoint

This commit is contained in:
Alex Forencich 2018-10-24 13:44:39 -07:00
parent 553547f661
commit fe77db822d
7 changed files with 523 additions and 1641 deletions

View File

@ -1,227 +0,0 @@
#!/usr/bin/env python
"""
Generates an AXI Stream crosspoint switch with the specified number of ports
"""
from __future__ import print_function
import argparse
import math
from jinja2 import Template
def main():
parser = argparse.ArgumentParser(description=__doc__.strip())
parser.add_argument('-p', '--ports', type=int, default=[4], nargs='+', help="number of ports")
parser.add_argument('-n', '--name', type=str, help="module name")
parser.add_argument('-o', '--output', type=str, help="output file name")
args = parser.parse_args()
try:
generate(**args.__dict__)
except IOError as ex:
print(ex)
exit(1)
def generate(ports=4, name=None, output=None):
if type(ports) is int:
m = n = ports
elif len(ports) == 1:
m = n = ports[0]
else:
m, n = ports
if name is None:
name = "axis_crosspoint_{0}x{1}".format(m, n)
if output is None:
output = name + ".v"
print("Opening file '{0}'...".format(output))
output_file = open(output, 'w')
print("Generating {0}x{1} port AXI Stream crosspoint {2}...".format(m, n, name))
select_width = int(math.ceil(math.log(m, 2)))
t = Template(u"""/*
Copyright (c) 2014-2018 Alex Forencich
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 {{m}}x{{n}} crosspoint
*/
module {{name}} #
(
parameter DATA_WIDTH = 8,
parameter KEEP_ENABLE = (DATA_WIDTH>8),
parameter KEEP_WIDTH = (DATA_WIDTH/8),
parameter LAST_ENABLE = 1,
parameter ID_ENABLE = 0,
parameter ID_WIDTH = 8,
parameter DEST_ENABLE = 0,
parameter DEST_WIDTH = 8,
parameter USER_ENABLE = 1,
parameter USER_WIDTH = 1
)
(
input wire clk,
input wire rst,
/*
* AXI Stream inputs
*/
{%- for p in range(m) %}
input wire [DATA_WIDTH-1:0] input_{{p}}_axis_tdata,
input wire [KEEP_WIDTH-1:0] input_{{p}}_axis_tkeep,
input wire input_{{p}}_axis_tvalid,
input wire input_{{p}}_axis_tlast,
input wire [ID_WIDTH-1:0] input_{{p}}_axis_tid,
input wire [DEST_WIDTH-1:0] input_{{p}}_axis_tdest,
input wire [USER_WIDTH-1:0] input_{{p}}_axis_tuser,
{% endfor %}
/*
* AXI Stream outputs
*/
{%- for p in range(n) %}
output wire [DATA_WIDTH-1:0] output_{{p}}_axis_tdata,
output wire [KEEP_WIDTH-1:0] output_{{p}}_axis_tkeep,
output wire output_{{p}}_axis_tvalid,
output wire output_{{p}}_axis_tlast,
output wire [ID_WIDTH-1:0] output_{{p}}_axis_tid,
output wire [DEST_WIDTH-1:0] output_{{p}}_axis_tdest,
output wire [USER_WIDTH-1:0] output_{{p}}_axis_tuser,
{% endfor %}
/*
* Control
*/
{%- for p in range(n) %}
input wire [{{w-1}}:0] output_{{p}}_select{% if not loop.last %},{% endif %}
{%- endfor %}
);
{% for p in range(m) %}
reg [DATA_WIDTH-1:0] input_{{p}}_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] input_{{p}}_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg input_{{p}}_axis_tvalid_reg = 1'b0;
reg input_{{p}}_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] input_{{p}}_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] input_{{p}}_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] input_{{p}}_axis_tuser_reg = {USER_WIDTH{1'b0}};
{% endfor %}
{%- for p in range(n) %}
reg [DATA_WIDTH-1:0] output_{{p}}_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] output_{{p}}_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg output_{{p}}_axis_tvalid_reg = 1'b0;
reg output_{{p}}_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] output_{{p}}_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] output_{{p}}_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] output_{{p}}_axis_tuser_reg = {USER_WIDTH{1'b0}};
{% endfor %}
{%- for p in range(n) %}
reg [{{w-1}}:0] output_{{p}}_select_reg = {{w}}'d0;
{%- endfor %}
{% for p in range(n) %}
assign output_{{p}}_axis_tdata = output_{{p}}_axis_tdata_reg;
assign output_{{p}}_axis_tkeep = KEEP_ENABLE ? output_{{p}}_axis_tkeep_reg : {KEEP_WIDTH{1'b1}};
assign output_{{p}}_axis_tvalid = output_{{p}}_axis_tvalid_reg;
assign output_{{p}}_axis_tlast = LAST_ENABLE ? output_{{p}}_axis_tlast_reg : 1'b1;
assign output_{{p}}_axis_tid = ID_ENABLE ? output_{{p}}_axis_tid_reg : {ID_WIDTH{1'b0}};
assign output_{{p}}_axis_tdest = DEST_ENABLE ? output_{{p}}_axis_tdest_reg : {DEST_WIDTH{1'b0}};
assign output_{{p}}_axis_tuser = USER_ENABLE ? output_{{p}}_axis_tuser_reg : {USER_WIDTH{1'b0}};
{% endfor %}
always @(posedge clk) begin
if (rst) begin
{%- for p in range(n) %}
output_{{p}}_select_reg <= {{w}}'d0;
{%- endfor %}
{% for p in range(m) %}
input_{{p}}_axis_tvalid_reg <= 1'b0;
{%- endfor %}
{% for p in range(n) %}
output_{{p}}_axis_tvalid_reg <= 1'b0;
{%- endfor %}
end else begin
{%- for p in range(m) %}
input_{{p}}_axis_tvalid_reg <= input_{{p}}_axis_tvalid;
{%- endfor %}
{% for p in range(n) %}
output_{{p}}_select_reg <= output_{{p}}_select;
{%- endfor %}
{%- for p in range(n) %}
case (output_{{p}}_select_reg)
{%- for q in range(m) %}
{{w}}'d{{q}}: output_{{p}}_axis_tvalid_reg <= input_{{q}}_axis_tvalid_reg;
{%- endfor %}
endcase
{%- endfor %}
end
{%- for p in range(m) %}
input_{{p}}_axis_tdata_reg <= input_{{p}}_axis_tdata;
input_{{p}}_axis_tkeep_reg <= input_{{p}}_axis_tkeep;
input_{{p}}_axis_tlast_reg <= input_{{p}}_axis_tlast;
input_{{p}}_axis_tid_reg <= input_{{p}}_axis_tid;
input_{{p}}_axis_tdest_reg <= input_{{p}}_axis_tdest;
input_{{p}}_axis_tuser_reg <= input_{{p}}_axis_tuser;
{%- endfor %}
{%- for p in range(n) %}
case (output_{{p}}_select_reg)
{%- for q in range(m) %}
{{w}}'d{{q}}: begin
output_{{p}}_axis_tdata_reg <= input_{{q}}_axis_tdata_reg;
output_{{p}}_axis_tkeep_reg <= input_{{q}}_axis_tkeep_reg;
output_{{p}}_axis_tlast_reg <= input_{{q}}_axis_tlast_reg;
output_{{p}}_axis_tid_reg <= input_{{q}}_axis_tid_reg;
output_{{p}}_axis_tdest_reg <= input_{{q}}_axis_tdest_reg;
output_{{p}}_axis_tuser_reg <= input_{{q}}_axis_tuser_reg;
end
{%- endfor %}
endcase
{%- endfor %}
end
endmodule
""")
output_file.write(t.render(
m=m,
n=n,
w=select_width,
name=name
))
print("Done")
if __name__ == "__main__":
main()

139
rtl/axis_crosspoint.v Normal file
View File

@ -0,0 +1,139 @@
/*
Copyright (c) 2014-2018 Alex Forencich
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 crosspoint
*/
module axis_crosspoint #
(
parameter S_COUNT = 4,
parameter M_COUNT = 4,
parameter DATA_WIDTH = 8,
parameter KEEP_ENABLE = (DATA_WIDTH>8),
parameter KEEP_WIDTH = (DATA_WIDTH/8),
parameter LAST_ENABLE = 1,
parameter ID_ENABLE = 0,
parameter ID_WIDTH = 8,
parameter DEST_ENABLE = 0,
parameter DEST_WIDTH = 8,
parameter USER_ENABLE = 1,
parameter USER_WIDTH = 1
)
(
input wire clk,
input wire rst,
/*
* AXI Stream inputs
*/
input wire [S_COUNT*DATA_WIDTH-1:0] s_axis_tdata,
input wire [S_COUNT*KEEP_WIDTH-1:0] s_axis_tkeep,
input wire [S_COUNT-1:0] s_axis_tvalid,
input wire [S_COUNT-1:0] s_axis_tlast,
input wire [S_COUNT*ID_WIDTH-1:0] s_axis_tid,
input wire [S_COUNT*DEST_WIDTH-1:0] s_axis_tdest,
input wire [S_COUNT*USER_WIDTH-1:0] s_axis_tuser,
/*
* AXI Stream outputs
*/
output wire [M_COUNT*DATA_WIDTH-1:0] m_axis_tdata,
output wire [M_COUNT*KEEP_WIDTH-1:0] m_axis_tkeep,
output wire [M_COUNT-1:0] m_axis_tvalid,
output wire [M_COUNT-1:0] m_axis_tlast,
output wire [M_COUNT*ID_WIDTH-1:0] m_axis_tid,
output wire [M_COUNT*DEST_WIDTH-1:0] m_axis_tdest,
output wire [M_COUNT*USER_WIDTH-1:0] m_axis_tuser,
/*
* Control
*/
input wire [M_COUNT*$clog2(S_COUNT)-1:0] select
);
parameter CL_S_COUNT = $clog2(S_COUNT);
reg [S_COUNT*DATA_WIDTH-1:0] s_axis_tdata_reg = {S_COUNT*DATA_WIDTH{1'b0}};
reg [S_COUNT*KEEP_WIDTH-1:0] s_axis_tkeep_reg = {S_COUNT*KEEP_WIDTH{1'b0}};
reg [S_COUNT-1:0] s_axis_tvalid_reg = {S_COUNT{1'b0}};
reg [S_COUNT-1:0] s_axis_tlast_reg = {S_COUNT{1'b0}};
reg [S_COUNT*ID_WIDTH-1:0] s_axis_tid_reg = {S_COUNT*ID_WIDTH{1'b0}};
reg [S_COUNT*DEST_WIDTH-1:0] s_axis_tdest_reg = {S_COUNT*DEST_WIDTH{1'b0}};
reg [S_COUNT*USER_WIDTH-1:0] s_axis_tuser_reg = {S_COUNT*USER_WIDTH{1'b0}};
reg [M_COUNT*DATA_WIDTH-1:0] m_axis_tdata_reg = {M_COUNT*DATA_WIDTH{1'b0}};
reg [M_COUNT*KEEP_WIDTH-1:0] m_axis_tkeep_reg = {M_COUNT*KEEP_WIDTH{1'b0}};
reg [M_COUNT-1:0] m_axis_tvalid_reg = {M_COUNT{1'b0}};
reg [M_COUNT-1:0] m_axis_tlast_reg = {M_COUNT{1'b0}};
reg [M_COUNT*ID_WIDTH-1:0] m_axis_tid_reg = {M_COUNT*ID_WIDTH{1'b0}};
reg [M_COUNT*DEST_WIDTH-1:0] m_axis_tdest_reg = {M_COUNT*DEST_WIDTH{1'b0}};
reg [M_COUNT*USER_WIDTH-1:0] m_axis_tuser_reg = {M_COUNT*USER_WIDTH{1'b0}};
reg [M_COUNT*CL_S_COUNT-1:0] select_reg = {M_COUNT*CL_S_COUNT{1'b0}};
assign m_axis_tdata = m_axis_tdata_reg;
assign m_axis_tkeep = KEEP_ENABLE ? m_axis_tkeep_reg : {M_COUNT*KEEP_WIDTH{1'b1}};
assign m_axis_tvalid = m_axis_tvalid_reg;
assign m_axis_tlast = LAST_ENABLE ? m_axis_tlast_reg : {M_COUNT{1'b1}};
assign m_axis_tid = ID_ENABLE ? m_axis_tid_reg : {M_COUNT*ID_WIDTH{1'b0}};
assign m_axis_tdest = DEST_ENABLE ? m_axis_tdest_reg : {M_COUNT*DEST_WIDTH{1'b0}};
assign m_axis_tuser = USER_ENABLE ? m_axis_tuser_reg : {M_COUNT*USER_WIDTH{1'b0}};
integer i;
always @(posedge clk) begin
if (rst) begin
s_axis_tvalid_reg <= {S_COUNT{1'b0}};
m_axis_tvalid_reg <= {S_COUNT{1'b0}};
select_reg <= {M_COUNT*CL_S_COUNT{1'b0}};
end else begin
s_axis_tvalid_reg <= s_axis_tvalid;
for (i = 0; i < M_COUNT; i = i + 1) begin
m_axis_tvalid_reg[i] = s_axis_tvalid_reg[select_reg[i*CL_S_COUNT +: CL_S_COUNT]];
end
select_reg <= select;
end
s_axis_tdata_reg <= s_axis_tdata;
s_axis_tkeep_reg <= s_axis_tkeep;
s_axis_tlast_reg <= s_axis_tlast;
s_axis_tid_reg <= s_axis_tid;
s_axis_tdest_reg <= s_axis_tdest;
s_axis_tuser_reg <= s_axis_tuser;
for (i = 0; i < M_COUNT; i = i + 1) begin
m_axis_tdata_reg[i*DATA_WIDTH +: DATA_WIDTH] <= s_axis_tdata_reg[select_reg[i*CL_S_COUNT +: CL_S_COUNT]*DATA_WIDTH +: DATA_WIDTH];
m_axis_tkeep_reg[i*KEEP_WIDTH +: KEEP_WIDTH] <= s_axis_tkeep_reg[select_reg[i*CL_S_COUNT +: CL_S_COUNT]*KEEP_WIDTH +: KEEP_WIDTH];
m_axis_tlast_reg[i] <= s_axis_tlast_reg[select_reg[i*CL_S_COUNT +: CL_S_COUNT]];
m_axis_tid_reg[i*ID_WIDTH +: ID_WIDTH] <= s_axis_tid_reg[select_reg[i*CL_S_COUNT +: CL_S_COUNT]*ID_WIDTH +: ID_WIDTH];
m_axis_tdest_reg[i*DEST_WIDTH +: DEST_WIDTH] <= s_axis_tdest_reg[select_reg[i*CL_S_COUNT +: CL_S_COUNT]*DEST_WIDTH +: DEST_WIDTH];
m_axis_tuser_reg[i*USER_WIDTH +: USER_WIDTH] <= s_axis_tuser_reg[select_reg[i*CL_S_COUNT +: CL_S_COUNT]*USER_WIDTH +: USER_WIDTH];
end
end
endmodule

View File

@ -1,454 +0,0 @@
/*
Copyright (c) 2014-2018 Alex Forencich
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 4x4 crosspoint
*/
module axis_crosspoint_4x4 #
(
parameter DATA_WIDTH = 8,
parameter KEEP_ENABLE = (DATA_WIDTH>8),
parameter KEEP_WIDTH = (DATA_WIDTH/8),
parameter LAST_ENABLE = 1,
parameter ID_ENABLE = 0,
parameter ID_WIDTH = 8,
parameter DEST_ENABLE = 0,
parameter DEST_WIDTH = 8,
parameter USER_ENABLE = 1,
parameter USER_WIDTH = 1
)
(
input wire clk,
input wire rst,
/*
* AXI Stream 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,
input wire input_0_axis_tlast,
input wire [ID_WIDTH-1:0] input_0_axis_tid,
input wire [DEST_WIDTH-1:0] input_0_axis_tdest,
input wire [USER_WIDTH-1:0] 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,
input wire input_1_axis_tlast,
input wire [ID_WIDTH-1:0] input_1_axis_tid,
input wire [DEST_WIDTH-1:0] input_1_axis_tdest,
input wire [USER_WIDTH-1:0] 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,
input wire input_2_axis_tlast,
input wire [ID_WIDTH-1:0] input_2_axis_tid,
input wire [DEST_WIDTH-1:0] input_2_axis_tdest,
input wire [USER_WIDTH-1:0] 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,
input wire input_3_axis_tlast,
input wire [ID_WIDTH-1:0] input_3_axis_tid,
input wire [DEST_WIDTH-1:0] input_3_axis_tdest,
input wire [USER_WIDTH-1:0] input_3_axis_tuser,
/*
* AXI Stream outputs
*/
output wire [DATA_WIDTH-1:0] output_0_axis_tdata,
output wire [KEEP_WIDTH-1:0] output_0_axis_tkeep,
output wire output_0_axis_tvalid,
output wire output_0_axis_tlast,
output wire [ID_WIDTH-1:0] output_0_axis_tid,
output wire [DEST_WIDTH-1:0] output_0_axis_tdest,
output wire [USER_WIDTH-1:0] output_0_axis_tuser,
output wire [DATA_WIDTH-1:0] output_1_axis_tdata,
output wire [KEEP_WIDTH-1:0] output_1_axis_tkeep,
output wire output_1_axis_tvalid,
output wire output_1_axis_tlast,
output wire [ID_WIDTH-1:0] output_1_axis_tid,
output wire [DEST_WIDTH-1:0] output_1_axis_tdest,
output wire [USER_WIDTH-1:0] output_1_axis_tuser,
output wire [DATA_WIDTH-1:0] output_2_axis_tdata,
output wire [KEEP_WIDTH-1:0] output_2_axis_tkeep,
output wire output_2_axis_tvalid,
output wire output_2_axis_tlast,
output wire [ID_WIDTH-1:0] output_2_axis_tid,
output wire [DEST_WIDTH-1:0] output_2_axis_tdest,
output wire [USER_WIDTH-1:0] output_2_axis_tuser,
output wire [DATA_WIDTH-1:0] output_3_axis_tdata,
output wire [KEEP_WIDTH-1:0] output_3_axis_tkeep,
output wire output_3_axis_tvalid,
output wire output_3_axis_tlast,
output wire [ID_WIDTH-1:0] output_3_axis_tid,
output wire [DEST_WIDTH-1:0] output_3_axis_tdest,
output wire [USER_WIDTH-1:0] output_3_axis_tuser,
/*
* Control
*/
input wire [1:0] output_0_select,
input wire [1:0] output_1_select,
input wire [1:0] output_2_select,
input wire [1:0] output_3_select
);
reg [DATA_WIDTH-1:0] input_0_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] input_0_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg input_0_axis_tvalid_reg = 1'b0;
reg input_0_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] input_0_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] input_0_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] input_0_axis_tuser_reg = {USER_WIDTH{1'b0}};
reg [DATA_WIDTH-1:0] input_1_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] input_1_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg input_1_axis_tvalid_reg = 1'b0;
reg input_1_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] input_1_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] input_1_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] input_1_axis_tuser_reg = {USER_WIDTH{1'b0}};
reg [DATA_WIDTH-1:0] input_2_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] input_2_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg input_2_axis_tvalid_reg = 1'b0;
reg input_2_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] input_2_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] input_2_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] input_2_axis_tuser_reg = {USER_WIDTH{1'b0}};
reg [DATA_WIDTH-1:0] input_3_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] input_3_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg input_3_axis_tvalid_reg = 1'b0;
reg input_3_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] input_3_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] input_3_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] input_3_axis_tuser_reg = {USER_WIDTH{1'b0}};
reg [DATA_WIDTH-1:0] output_0_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] output_0_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg output_0_axis_tvalid_reg = 1'b0;
reg output_0_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] output_0_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] output_0_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] output_0_axis_tuser_reg = {USER_WIDTH{1'b0}};
reg [DATA_WIDTH-1:0] output_1_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] output_1_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg output_1_axis_tvalid_reg = 1'b0;
reg output_1_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] output_1_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] output_1_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] output_1_axis_tuser_reg = {USER_WIDTH{1'b0}};
reg [DATA_WIDTH-1:0] output_2_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] output_2_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg output_2_axis_tvalid_reg = 1'b0;
reg output_2_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] output_2_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] output_2_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] output_2_axis_tuser_reg = {USER_WIDTH{1'b0}};
reg [DATA_WIDTH-1:0] output_3_axis_tdata_reg = {DATA_WIDTH{1'b0}};
reg [KEEP_WIDTH-1:0] output_3_axis_tkeep_reg = {KEEP_WIDTH{1'b0}};
reg output_3_axis_tvalid_reg = 1'b0;
reg output_3_axis_tlast_reg = 1'b0;
reg [ID_WIDTH-1:0] output_3_axis_tid_reg = {ID_WIDTH{1'b0}};
reg [DEST_WIDTH-1:0] output_3_axis_tdest_reg = {DEST_WIDTH{1'b0}};
reg [USER_WIDTH-1:0] output_3_axis_tuser_reg = {USER_WIDTH{1'b0}};
reg [1:0] output_0_select_reg = 2'd0;
reg [1:0] output_1_select_reg = 2'd0;
reg [1:0] output_2_select_reg = 2'd0;
reg [1:0] output_3_select_reg = 2'd0;
assign output_0_axis_tdata = output_0_axis_tdata_reg;
assign output_0_axis_tkeep = KEEP_ENABLE ? output_0_axis_tkeep_reg : {KEEP_WIDTH{1'b1}};
assign output_0_axis_tvalid = output_0_axis_tvalid_reg;
assign output_0_axis_tlast = LAST_ENABLE ? output_0_axis_tlast_reg : 1'b1;
assign output_0_axis_tid = ID_ENABLE ? output_0_axis_tid_reg : {ID_WIDTH{1'b0}};
assign output_0_axis_tdest = DEST_ENABLE ? output_0_axis_tdest_reg : {DEST_WIDTH{1'b0}};
assign output_0_axis_tuser = USER_ENABLE ? output_0_axis_tuser_reg : {USER_WIDTH{1'b0}};
assign output_1_axis_tdata = output_1_axis_tdata_reg;
assign output_1_axis_tkeep = KEEP_ENABLE ? output_1_axis_tkeep_reg : {KEEP_WIDTH{1'b1}};
assign output_1_axis_tvalid = output_1_axis_tvalid_reg;
assign output_1_axis_tlast = LAST_ENABLE ? output_1_axis_tlast_reg : 1'b1;
assign output_1_axis_tid = ID_ENABLE ? output_1_axis_tid_reg : {ID_WIDTH{1'b0}};
assign output_1_axis_tdest = DEST_ENABLE ? output_1_axis_tdest_reg : {DEST_WIDTH{1'b0}};
assign output_1_axis_tuser = USER_ENABLE ? output_1_axis_tuser_reg : {USER_WIDTH{1'b0}};
assign output_2_axis_tdata = output_2_axis_tdata_reg;
assign output_2_axis_tkeep = KEEP_ENABLE ? output_2_axis_tkeep_reg : {KEEP_WIDTH{1'b1}};
assign output_2_axis_tvalid = output_2_axis_tvalid_reg;
assign output_2_axis_tlast = LAST_ENABLE ? output_2_axis_tlast_reg : 1'b1;
assign output_2_axis_tid = ID_ENABLE ? output_2_axis_tid_reg : {ID_WIDTH{1'b0}};
assign output_2_axis_tdest = DEST_ENABLE ? output_2_axis_tdest_reg : {DEST_WIDTH{1'b0}};
assign output_2_axis_tuser = USER_ENABLE ? output_2_axis_tuser_reg : {USER_WIDTH{1'b0}};
assign output_3_axis_tdata = output_3_axis_tdata_reg;
assign output_3_axis_tkeep = KEEP_ENABLE ? output_3_axis_tkeep_reg : {KEEP_WIDTH{1'b1}};
assign output_3_axis_tvalid = output_3_axis_tvalid_reg;
assign output_3_axis_tlast = LAST_ENABLE ? output_3_axis_tlast_reg : 1'b1;
assign output_3_axis_tid = ID_ENABLE ? output_3_axis_tid_reg : {ID_WIDTH{1'b0}};
assign output_3_axis_tdest = DEST_ENABLE ? output_3_axis_tdest_reg : {DEST_WIDTH{1'b0}};
assign output_3_axis_tuser = USER_ENABLE ? output_3_axis_tuser_reg : {USER_WIDTH{1'b0}};
always @(posedge clk) begin
if (rst) begin
output_0_select_reg <= 2'd0;
output_1_select_reg <= 2'd0;
output_2_select_reg <= 2'd0;
output_3_select_reg <= 2'd0;
input_0_axis_tvalid_reg <= 1'b0;
input_1_axis_tvalid_reg <= 1'b0;
input_2_axis_tvalid_reg <= 1'b0;
input_3_axis_tvalid_reg <= 1'b0;
output_0_axis_tvalid_reg <= 1'b0;
output_1_axis_tvalid_reg <= 1'b0;
output_2_axis_tvalid_reg <= 1'b0;
output_3_axis_tvalid_reg <= 1'b0;
end else begin
input_0_axis_tvalid_reg <= input_0_axis_tvalid;
input_1_axis_tvalid_reg <= input_1_axis_tvalid;
input_2_axis_tvalid_reg <= input_2_axis_tvalid;
input_3_axis_tvalid_reg <= input_3_axis_tvalid;
output_0_select_reg <= output_0_select;
output_1_select_reg <= output_1_select;
output_2_select_reg <= output_2_select;
output_3_select_reg <= output_3_select;
case (output_0_select_reg)
2'd0: output_0_axis_tvalid_reg <= input_0_axis_tvalid_reg;
2'd1: output_0_axis_tvalid_reg <= input_1_axis_tvalid_reg;
2'd2: output_0_axis_tvalid_reg <= input_2_axis_tvalid_reg;
2'd3: output_0_axis_tvalid_reg <= input_3_axis_tvalid_reg;
endcase
case (output_1_select_reg)
2'd0: output_1_axis_tvalid_reg <= input_0_axis_tvalid_reg;
2'd1: output_1_axis_tvalid_reg <= input_1_axis_tvalid_reg;
2'd2: output_1_axis_tvalid_reg <= input_2_axis_tvalid_reg;
2'd3: output_1_axis_tvalid_reg <= input_3_axis_tvalid_reg;
endcase
case (output_2_select_reg)
2'd0: output_2_axis_tvalid_reg <= input_0_axis_tvalid_reg;
2'd1: output_2_axis_tvalid_reg <= input_1_axis_tvalid_reg;
2'd2: output_2_axis_tvalid_reg <= input_2_axis_tvalid_reg;
2'd3: output_2_axis_tvalid_reg <= input_3_axis_tvalid_reg;
endcase
case (output_3_select_reg)
2'd0: output_3_axis_tvalid_reg <= input_0_axis_tvalid_reg;
2'd1: output_3_axis_tvalid_reg <= input_1_axis_tvalid_reg;
2'd2: output_3_axis_tvalid_reg <= input_2_axis_tvalid_reg;
2'd3: output_3_axis_tvalid_reg <= input_3_axis_tvalid_reg;
endcase
end
input_0_axis_tdata_reg <= input_0_axis_tdata;
input_0_axis_tkeep_reg <= input_0_axis_tkeep;
input_0_axis_tlast_reg <= input_0_axis_tlast;
input_0_axis_tid_reg <= input_0_axis_tid;
input_0_axis_tdest_reg <= input_0_axis_tdest;
input_0_axis_tuser_reg <= input_0_axis_tuser;
input_1_axis_tdata_reg <= input_1_axis_tdata;
input_1_axis_tkeep_reg <= input_1_axis_tkeep;
input_1_axis_tlast_reg <= input_1_axis_tlast;
input_1_axis_tid_reg <= input_1_axis_tid;
input_1_axis_tdest_reg <= input_1_axis_tdest;
input_1_axis_tuser_reg <= input_1_axis_tuser;
input_2_axis_tdata_reg <= input_2_axis_tdata;
input_2_axis_tkeep_reg <= input_2_axis_tkeep;
input_2_axis_tlast_reg <= input_2_axis_tlast;
input_2_axis_tid_reg <= input_2_axis_tid;
input_2_axis_tdest_reg <= input_2_axis_tdest;
input_2_axis_tuser_reg <= input_2_axis_tuser;
input_3_axis_tdata_reg <= input_3_axis_tdata;
input_3_axis_tkeep_reg <= input_3_axis_tkeep;
input_3_axis_tlast_reg <= input_3_axis_tlast;
input_3_axis_tid_reg <= input_3_axis_tid;
input_3_axis_tdest_reg <= input_3_axis_tdest;
input_3_axis_tuser_reg <= input_3_axis_tuser;
case (output_0_select_reg)
2'd0: begin
output_0_axis_tdata_reg <= input_0_axis_tdata_reg;
output_0_axis_tkeep_reg <= input_0_axis_tkeep_reg;
output_0_axis_tlast_reg <= input_0_axis_tlast_reg;
output_0_axis_tid_reg <= input_0_axis_tid_reg;
output_0_axis_tdest_reg <= input_0_axis_tdest_reg;
output_0_axis_tuser_reg <= input_0_axis_tuser_reg;
end
2'd1: begin
output_0_axis_tdata_reg <= input_1_axis_tdata_reg;
output_0_axis_tkeep_reg <= input_1_axis_tkeep_reg;
output_0_axis_tlast_reg <= input_1_axis_tlast_reg;
output_0_axis_tid_reg <= input_1_axis_tid_reg;
output_0_axis_tdest_reg <= input_1_axis_tdest_reg;
output_0_axis_tuser_reg <= input_1_axis_tuser_reg;
end
2'd2: begin
output_0_axis_tdata_reg <= input_2_axis_tdata_reg;
output_0_axis_tkeep_reg <= input_2_axis_tkeep_reg;
output_0_axis_tlast_reg <= input_2_axis_tlast_reg;
output_0_axis_tid_reg <= input_2_axis_tid_reg;
output_0_axis_tdest_reg <= input_2_axis_tdest_reg;
output_0_axis_tuser_reg <= input_2_axis_tuser_reg;
end
2'd3: begin
output_0_axis_tdata_reg <= input_3_axis_tdata_reg;
output_0_axis_tkeep_reg <= input_3_axis_tkeep_reg;
output_0_axis_tlast_reg <= input_3_axis_tlast_reg;
output_0_axis_tid_reg <= input_3_axis_tid_reg;
output_0_axis_tdest_reg <= input_3_axis_tdest_reg;
output_0_axis_tuser_reg <= input_3_axis_tuser_reg;
end
endcase
case (output_1_select_reg)
2'd0: begin
output_1_axis_tdata_reg <= input_0_axis_tdata_reg;
output_1_axis_tkeep_reg <= input_0_axis_tkeep_reg;
output_1_axis_tlast_reg <= input_0_axis_tlast_reg;
output_1_axis_tid_reg <= input_0_axis_tid_reg;
output_1_axis_tdest_reg <= input_0_axis_tdest_reg;
output_1_axis_tuser_reg <= input_0_axis_tuser_reg;
end
2'd1: begin
output_1_axis_tdata_reg <= input_1_axis_tdata_reg;
output_1_axis_tkeep_reg <= input_1_axis_tkeep_reg;
output_1_axis_tlast_reg <= input_1_axis_tlast_reg;
output_1_axis_tid_reg <= input_1_axis_tid_reg;
output_1_axis_tdest_reg <= input_1_axis_tdest_reg;
output_1_axis_tuser_reg <= input_1_axis_tuser_reg;
end
2'd2: begin
output_1_axis_tdata_reg <= input_2_axis_tdata_reg;
output_1_axis_tkeep_reg <= input_2_axis_tkeep_reg;
output_1_axis_tlast_reg <= input_2_axis_tlast_reg;
output_1_axis_tid_reg <= input_2_axis_tid_reg;
output_1_axis_tdest_reg <= input_2_axis_tdest_reg;
output_1_axis_tuser_reg <= input_2_axis_tuser_reg;
end
2'd3: begin
output_1_axis_tdata_reg <= input_3_axis_tdata_reg;
output_1_axis_tkeep_reg <= input_3_axis_tkeep_reg;
output_1_axis_tlast_reg <= input_3_axis_tlast_reg;
output_1_axis_tid_reg <= input_3_axis_tid_reg;
output_1_axis_tdest_reg <= input_3_axis_tdest_reg;
output_1_axis_tuser_reg <= input_3_axis_tuser_reg;
end
endcase
case (output_2_select_reg)
2'd0: begin
output_2_axis_tdata_reg <= input_0_axis_tdata_reg;
output_2_axis_tkeep_reg <= input_0_axis_tkeep_reg;
output_2_axis_tlast_reg <= input_0_axis_tlast_reg;
output_2_axis_tid_reg <= input_0_axis_tid_reg;
output_2_axis_tdest_reg <= input_0_axis_tdest_reg;
output_2_axis_tuser_reg <= input_0_axis_tuser_reg;
end
2'd1: begin
output_2_axis_tdata_reg <= input_1_axis_tdata_reg;
output_2_axis_tkeep_reg <= input_1_axis_tkeep_reg;
output_2_axis_tlast_reg <= input_1_axis_tlast_reg;
output_2_axis_tid_reg <= input_1_axis_tid_reg;
output_2_axis_tdest_reg <= input_1_axis_tdest_reg;
output_2_axis_tuser_reg <= input_1_axis_tuser_reg;
end
2'd2: begin
output_2_axis_tdata_reg <= input_2_axis_tdata_reg;
output_2_axis_tkeep_reg <= input_2_axis_tkeep_reg;
output_2_axis_tlast_reg <= input_2_axis_tlast_reg;
output_2_axis_tid_reg <= input_2_axis_tid_reg;
output_2_axis_tdest_reg <= input_2_axis_tdest_reg;
output_2_axis_tuser_reg <= input_2_axis_tuser_reg;
end
2'd3: begin
output_2_axis_tdata_reg <= input_3_axis_tdata_reg;
output_2_axis_tkeep_reg <= input_3_axis_tkeep_reg;
output_2_axis_tlast_reg <= input_3_axis_tlast_reg;
output_2_axis_tid_reg <= input_3_axis_tid_reg;
output_2_axis_tdest_reg <= input_3_axis_tdest_reg;
output_2_axis_tuser_reg <= input_3_axis_tuser_reg;
end
endcase
case (output_3_select_reg)
2'd0: begin
output_3_axis_tdata_reg <= input_0_axis_tdata_reg;
output_3_axis_tkeep_reg <= input_0_axis_tkeep_reg;
output_3_axis_tlast_reg <= input_0_axis_tlast_reg;
output_3_axis_tid_reg <= input_0_axis_tid_reg;
output_3_axis_tdest_reg <= input_0_axis_tdest_reg;
output_3_axis_tuser_reg <= input_0_axis_tuser_reg;
end
2'd1: begin
output_3_axis_tdata_reg <= input_1_axis_tdata_reg;
output_3_axis_tkeep_reg <= input_1_axis_tkeep_reg;
output_3_axis_tlast_reg <= input_1_axis_tlast_reg;
output_3_axis_tid_reg <= input_1_axis_tid_reg;
output_3_axis_tdest_reg <= input_1_axis_tdest_reg;
output_3_axis_tuser_reg <= input_1_axis_tuser_reg;
end
2'd2: begin
output_3_axis_tdata_reg <= input_2_axis_tdata_reg;
output_3_axis_tkeep_reg <= input_2_axis_tkeep_reg;
output_3_axis_tlast_reg <= input_2_axis_tlast_reg;
output_3_axis_tid_reg <= input_2_axis_tid_reg;
output_3_axis_tdest_reg <= input_2_axis_tdest_reg;
output_3_axis_tuser_reg <= input_2_axis_tuser_reg;
end
2'd3: begin
output_3_axis_tdata_reg <= input_3_axis_tdata_reg;
output_3_axis_tkeep_reg <= input_3_axis_tkeep_reg;
output_3_axis_tlast_reg <= input_3_axis_tlast_reg;
output_3_axis_tid_reg <= input_3_axis_tid_reg;
output_3_axis_tdest_reg <= input_3_axis_tdest_reg;
output_3_axis_tuser_reg <= input_3_axis_tuser_reg;
end
endcase
end
endmodule

View File

@ -27,9 +27,10 @@ from myhdl import *
import os import os
import axis_ep import axis_ep
import math
module = 'axis_crosspoint_4x4' module = 'axis_crosspoint'
testbench = 'test_%s' % module testbench = 'test_%s_4x4' % module
srcs = [] srcs = []
@ -43,6 +44,8 @@ build_cmd = "iverilog -o %s.vvp %s" % (testbench, src)
def bench(): def bench():
# Parameters # Parameters
S_COUNT = 4
M_COUNT = 4
DATA_WIDTH = 8 DATA_WIDTH = 8
KEEP_ENABLE = (DATA_WIDTH>8) KEEP_ENABLE = (DATA_WIDTH>8)
KEEP_WIDTH = (DATA_WIDTH/8) KEEP_WIDTH = (DATA_WIDTH/8)
@ -59,207 +62,92 @@ def bench():
rst = Signal(bool(0)) rst = Signal(bool(0))
current_test = Signal(intbv(0)[8:]) current_test = Signal(intbv(0)[8:])
input_0_axis_tdata = Signal(intbv(0)[DATA_WIDTH:]) s_axis_tdata_list = [Signal(intbv(0)[DATA_WIDTH:]) for i in range(S_COUNT)]
input_0_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:]) s_axis_tkeep_list = [Signal(intbv(1)[KEEP_WIDTH:]) for i in range(S_COUNT)]
input_0_axis_tvalid = Signal(bool(0)) s_axis_tvalid_list = [Signal(bool(0)) for i in range(S_COUNT)]
input_0_axis_tlast = Signal(bool(0)) s_axis_tlast_list = [Signal(bool(0)) for i in range(S_COUNT)]
input_0_axis_tid = Signal(intbv(0)[ID_WIDTH:]) s_axis_tid_list = [Signal(intbv(0)[ID_WIDTH:]) for i in range(S_COUNT)]
input_0_axis_tdest = Signal(intbv(0)[DEST_WIDTH:]) s_axis_tdest_list = [Signal(intbv(0)[DEST_WIDTH:]) for i in range(S_COUNT)]
input_0_axis_tuser = Signal(intbv(0)[USER_WIDTH:]) s_axis_tuser_list = [Signal(intbv(0)[USER_WIDTH:]) for i in range(S_COUNT)]
input_1_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
input_1_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
input_1_axis_tvalid = Signal(bool(0))
input_1_axis_tlast = Signal(bool(0))
input_1_axis_tid = Signal(intbv(0)[ID_WIDTH:])
input_1_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
input_1_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
input_2_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
input_2_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
input_2_axis_tvalid = Signal(bool(0))
input_2_axis_tlast = Signal(bool(0))
input_2_axis_tid = Signal(intbv(0)[ID_WIDTH:])
input_2_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
input_2_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
input_3_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
input_3_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
input_3_axis_tvalid = Signal(bool(0))
input_3_axis_tlast = Signal(bool(0))
input_3_axis_tid = Signal(intbv(0)[ID_WIDTH:])
input_3_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
input_3_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
output_0_select = Signal(intbv(0)[2:]) s_axis_tdata = ConcatSignal(*reversed(s_axis_tdata_list))
output_1_select = Signal(intbv(0)[2:]) s_axis_tkeep = ConcatSignal(*reversed(s_axis_tkeep_list))
output_2_select = Signal(intbv(0)[2:]) s_axis_tvalid = ConcatSignal(*reversed(s_axis_tvalid_list))
output_3_select = Signal(intbv(0)[2:]) s_axis_tlast = ConcatSignal(*reversed(s_axis_tlast_list))
s_axis_tid = ConcatSignal(*reversed(s_axis_tid_list))
s_axis_tdest = ConcatSignal(*reversed(s_axis_tdest_list))
s_axis_tuser = ConcatSignal(*reversed(s_axis_tuser_list))
select_list = [Signal(intbv(0)[math.ceil(math.log(S_COUNT, 2)):]) for i in range(M_COUNT)]
select = ConcatSignal(*reversed(select_list))
# Outputs # Outputs
output_0_axis_tdata = Signal(intbv(0)[DATA_WIDTH:]) m_axis_tdata = Signal(intbv(0)[M_COUNT*DATA_WIDTH:])
output_0_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:]) m_axis_tkeep = Signal(intbv(0xf)[M_COUNT*KEEP_WIDTH:])
output_0_axis_tvalid = Signal(bool(0)) m_axis_tvalid = Signal(intbv(0)[M_COUNT:])
output_0_axis_tlast = Signal(bool(0)) m_axis_tlast = Signal(intbv(0)[M_COUNT:])
output_0_axis_tid = Signal(intbv(0)[ID_WIDTH:]) m_axis_tid = Signal(intbv(0)[M_COUNT*ID_WIDTH:])
output_0_axis_tdest = Signal(intbv(0)[DEST_WIDTH:]) m_axis_tdest = Signal(intbv(0)[M_COUNT*DEST_WIDTH:])
output_0_axis_tuser = Signal(intbv(0)[USER_WIDTH:]) m_axis_tuser = Signal(intbv(0)[M_COUNT*USER_WIDTH:])
output_1_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
output_1_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:]) m_axis_tdata_list = [m_axis_tdata((i+1)*DATA_WIDTH, i*DATA_WIDTH) for i in range(M_COUNT)]
output_1_axis_tvalid = Signal(bool(0)) m_axis_tkeep_list = [m_axis_tkeep((i+1)*KEEP_WIDTH, i*KEEP_WIDTH) for i in range(M_COUNT)]
output_1_axis_tlast = Signal(bool(0)) m_axis_tvalid_list = [m_axis_tvalid(i) for i in range(M_COUNT)]
output_1_axis_tid = Signal(intbv(0)[ID_WIDTH:]) m_axis_tlast_list = [m_axis_tlast(i) for i in range(M_COUNT)]
output_1_axis_tdest = Signal(intbv(0)[DEST_WIDTH:]) m_axis_tid_list = [m_axis_tid((i+1)*ID_WIDTH, i*ID_WIDTH) for i in range(M_COUNT)]
output_1_axis_tuser = Signal(intbv(0)[USER_WIDTH:]) m_axis_tdest_list = [m_axis_tdest((i+1)*DEST_WIDTH, i*DEST_WIDTH) for i in range(M_COUNT)]
output_2_axis_tdata = Signal(intbv(0)[DATA_WIDTH:]) m_axis_tuser_list = [m_axis_tuser((i+1)*USER_WIDTH, i*USER_WIDTH) for i in range(M_COUNT)]
output_2_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
output_2_axis_tvalid = Signal(bool(0))
output_2_axis_tlast = Signal(bool(0))
output_2_axis_tid = Signal(intbv(0)[ID_WIDTH:])
output_2_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
output_2_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
output_3_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
output_3_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
output_3_axis_tvalid = Signal(bool(0))
output_3_axis_tlast = Signal(bool(0))
output_3_axis_tid = Signal(intbv(0)[ID_WIDTH:])
output_3_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
output_3_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
# sources and sinks # sources and sinks
source_0_pause = Signal(bool(0)) source_pause_list = []
source_1_pause = Signal(bool(0)) source_list = []
source_2_pause = Signal(bool(0)) source_logic_list = []
source_3_pause = Signal(bool(0)) sink_pause_list = []
sink_0_pause = Signal(bool(0)) sink_list = []
sink_1_pause = Signal(bool(0)) sink_logic_list = []
sink_2_pause = Signal(bool(0))
sink_3_pause = Signal(bool(0))
source_0 = axis_ep.AXIStreamSource() for k in range(S_COUNT):
s = axis_ep.AXIStreamSource()
p = Signal(bool(0))
source_0_logic = source_0.create_logic( source_list.append(s)
source_pause_list.append(p)
source_logic_list.append(s.create_logic(
clk, clk,
rst, rst,
tdata=input_0_axis_tdata, tdata=s_axis_tdata_list[k],
tkeep=input_0_axis_tkeep, tkeep=s_axis_tkeep_list[k],
tvalid=input_0_axis_tvalid, tvalid=s_axis_tvalid_list[k],
tlast=input_0_axis_tlast, tlast=s_axis_tlast_list[k],
tid=input_0_axis_tid, tid=s_axis_tid_list[k],
tdest=input_0_axis_tdest, tdest=s_axis_tdest_list[k],
tuser=input_0_axis_tuser, tuser=s_axis_tuser_list[k],
pause=source_0_pause, pause=p,
name='source_0' name='source_%d' % k
) ))
source_1 = axis_ep.AXIStreamSource() for k in range(M_COUNT):
s = axis_ep.AXIStreamSink()
p = Signal(bool(0))
source_1_logic = source_1.create_logic( sink_list.append(s)
sink_pause_list.append(p)
sink_logic_list.append(s.create_logic(
clk, clk,
rst, rst,
tdata=input_1_axis_tdata, tdata=m_axis_tdata_list[k],
tkeep=input_1_axis_tkeep, tkeep=m_axis_tkeep_list[k],
tvalid=input_1_axis_tvalid, tvalid=m_axis_tvalid_list[k],
tlast=input_1_axis_tlast, tlast=m_axis_tlast_list[k],
tid=input_1_axis_tid, tid=m_axis_tid_list[k],
tdest=input_1_axis_tdest, tdest=m_axis_tdest_list[k],
tuser=input_1_axis_tuser, tuser=m_axis_tuser_list[k],
pause=source_1_pause, pause=p,
name='source_1' name='sink_%d' % k
) ))
source_2 = axis_ep.AXIStreamSource()
source_2_logic = source_2.create_logic(
clk,
rst,
tdata=input_2_axis_tdata,
tkeep=input_2_axis_tkeep,
tvalid=input_2_axis_tvalid,
tlast=input_2_axis_tlast,
tid=input_2_axis_tid,
tdest=input_2_axis_tdest,
tuser=input_2_axis_tuser,
pause=source_2_pause,
name='source_2'
)
source_3 = axis_ep.AXIStreamSource()
source_3_logic = source_3.create_logic(
clk,
rst,
tdata=input_3_axis_tdata,
tkeep=input_3_axis_tkeep,
tvalid=input_3_axis_tvalid,
tlast=input_3_axis_tlast,
tid=input_3_axis_tid,
tdest=input_3_axis_tdest,
tuser=input_3_axis_tuser,
pause=source_3_pause,
name='source_3'
)
sink_0 = axis_ep.AXIStreamSink()
sink_0_logic = sink_0.create_logic(
clk,
rst,
tdata=output_0_axis_tdata,
tkeep=output_0_axis_tkeep,
tvalid=output_0_axis_tvalid,
tlast=output_0_axis_tlast,
tid=output_0_axis_tid,
tdest=output_0_axis_tdest,
tuser=output_0_axis_tuser,
pause=sink_0_pause,
name='sink_0'
)
sink_1 = axis_ep.AXIStreamSink()
sink_1_logic = sink_1.create_logic(
clk,
rst,
tdata=output_1_axis_tdata,
tkeep=output_1_axis_tkeep,
tvalid=output_1_axis_tvalid,
tlast=output_1_axis_tlast,
tid=output_1_axis_tid,
tdest=output_1_axis_tdest,
tuser=output_1_axis_tuser,
pause=sink_1_pause,
name='sink_1'
)
sink_2 = axis_ep.AXIStreamSink()
sink_2_logic = sink_2.create_logic(
clk,
rst,
tdata=output_2_axis_tdata,
tkeep=output_2_axis_tkeep,
tvalid=output_2_axis_tvalid,
tlast=output_2_axis_tlast,
tid=output_2_axis_tid,
tdest=output_2_axis_tdest,
tuser=output_2_axis_tuser,
pause=sink_2_pause,
name='sink_2'
)
sink_3 = axis_ep.AXIStreamSink()
sink_3_logic = sink_3.create_logic(
clk,
rst,
tdata=output_3_axis_tdata,
tkeep=output_3_axis_tkeep,
tvalid=output_3_axis_tvalid,
tlast=output_3_axis_tlast,
tid=output_3_axis_tid,
tdest=output_3_axis_tdest,
tuser=output_3_axis_tuser,
pause=sink_3_pause,
name='sink_3'
)
# DUT # DUT
if os.system(build_cmd): if os.system(build_cmd):
@ -271,68 +159,23 @@ def bench():
rst=rst, rst=rst,
current_test=current_test, current_test=current_test,
input_0_axis_tdata=input_0_axis_tdata, s_axis_tdata=s_axis_tdata,
input_0_axis_tkeep=input_0_axis_tkeep, s_axis_tkeep=s_axis_tkeep,
input_0_axis_tvalid=input_0_axis_tvalid, s_axis_tvalid=s_axis_tvalid,
input_0_axis_tlast=input_0_axis_tlast, s_axis_tlast=s_axis_tlast,
input_0_axis_tid=input_0_axis_tid, s_axis_tid=s_axis_tid,
input_0_axis_tdest=input_0_axis_tdest, s_axis_tdest=s_axis_tdest,
input_0_axis_tuser=input_0_axis_tuser, s_axis_tuser=s_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,
input_1_axis_tlast=input_1_axis_tlast,
input_1_axis_tid=input_1_axis_tid,
input_1_axis_tdest=input_1_axis_tdest,
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,
input_2_axis_tlast=input_2_axis_tlast,
input_2_axis_tid=input_2_axis_tid,
input_2_axis_tdest=input_2_axis_tdest,
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,
input_3_axis_tlast=input_3_axis_tlast,
input_3_axis_tid=input_3_axis_tid,
input_3_axis_tdest=input_3_axis_tdest,
input_3_axis_tuser=input_3_axis_tuser,
output_0_axis_tdata=output_0_axis_tdata, m_axis_tdata=m_axis_tdata,
output_0_axis_tkeep=output_0_axis_tkeep, m_axis_tkeep=m_axis_tkeep,
output_0_axis_tvalid=output_0_axis_tvalid, m_axis_tvalid=m_axis_tvalid,
output_0_axis_tlast=output_0_axis_tlast, m_axis_tlast=m_axis_tlast,
output_0_axis_tid=output_0_axis_tid, m_axis_tid=m_axis_tid,
output_0_axis_tdest=output_0_axis_tdest, m_axis_tdest=m_axis_tdest,
output_0_axis_tuser=output_0_axis_tuser, m_axis_tuser=m_axis_tuser,
output_1_axis_tdata=output_1_axis_tdata,
output_1_axis_tkeep=output_1_axis_tkeep,
output_1_axis_tvalid=output_1_axis_tvalid,
output_1_axis_tlast=output_1_axis_tlast,
output_1_axis_tid=output_1_axis_tid,
output_1_axis_tdest=output_1_axis_tdest,
output_1_axis_tuser=output_1_axis_tuser,
output_2_axis_tdata=output_2_axis_tdata,
output_2_axis_tkeep=output_2_axis_tkeep,
output_2_axis_tvalid=output_2_axis_tvalid,
output_2_axis_tlast=output_2_axis_tlast,
output_2_axis_tid=output_2_axis_tid,
output_2_axis_tdest=output_2_axis_tdest,
output_2_axis_tuser=output_2_axis_tuser,
output_3_axis_tdata=output_3_axis_tdata,
output_3_axis_tkeep=output_3_axis_tkeep,
output_3_axis_tvalid=output_3_axis_tvalid,
output_3_axis_tlast=output_3_axis_tlast,
output_3_axis_tid=output_3_axis_tid,
output_3_axis_tdest=output_3_axis_tdest,
output_3_axis_tuser=output_3_axis_tuser,
output_0_select=output_0_select, select=select
output_1_select=output_1_select,
output_2_select=output_2_select,
output_3_select=output_3_select
) )
@always(delay(4)) @always(delay(4))
@ -356,37 +199,37 @@ def bench():
print("test 1: 0123 -> 0123") print("test 1: 0123 -> 0123")
current_test.next = 1 current_test.next = 1
output_0_select.next = 0 select_list[0].next = 0
output_1_select.next = 1 select_list[1].next = 1
output_2_select.next = 2 select_list[2].next = 2
output_3_select.next = 3 select_list[3].next = 3
test_frame0 = axis_ep.AXIStreamFrame(b'\x01\x00\x00\xFF\x01\x02\x03\x04', id=0, dest=0) test_frame0 = axis_ep.AXIStreamFrame(b'\x01\x00\x00\xFF\x01\x02\x03\x04', id=0, dest=0)
test_frame1 = axis_ep.AXIStreamFrame(b'\x01\x01\x01\xFF\x01\x02\x03\x04', id=1, dest=1) test_frame1 = axis_ep.AXIStreamFrame(b'\x01\x01\x01\xFF\x01\x02\x03\x04', id=1, dest=1)
test_frame2 = axis_ep.AXIStreamFrame(b'\x01\x02\x02\xFF\x01\x02\x03\x04', id=2, dest=2) test_frame2 = axis_ep.AXIStreamFrame(b'\x01\x02\x02\xFF\x01\x02\x03\x04', id=2, dest=2)
test_frame3 = axis_ep.AXIStreamFrame(b'\x01\x03\x03\xFF\x01\x02\x03\x04', id=3, dest=3) test_frame3 = axis_ep.AXIStreamFrame(b'\x01\x03\x03\xFF\x01\x02\x03\x04', id=3, dest=3)
source_0.send(test_frame0) source_list[0].send(test_frame0)
source_1.send(test_frame1) source_list[1].send(test_frame1)
source_2.send(test_frame2) source_list[2].send(test_frame2)
source_3.send(test_frame3) source_list[3].send(test_frame3)
yield sink_0.wait() yield sink_list[0].wait()
rx_frame0 = sink_0.recv() rx_frame0 = sink_list[0].recv()
assert rx_frame0 == test_frame0 assert rx_frame0 == test_frame0
yield sink_1.wait() yield sink_list[1].wait()
rx_frame1 = sink_1.recv() rx_frame1 = sink_list[1].recv()
assert rx_frame1 == test_frame1 assert rx_frame1 == test_frame1
yield sink_2.wait() yield sink_list[2].wait()
rx_frame2 = sink_2.recv() rx_frame2 = sink_list[2].recv()
assert rx_frame2 == test_frame2 assert rx_frame2 == test_frame2
yield sink_3.wait() yield sink_list[3].wait()
rx_frame3 = sink_3.recv() rx_frame3 = sink_list[3].recv()
assert rx_frame3 == test_frame3 assert rx_frame3 == test_frame3
@ -396,37 +239,37 @@ def bench():
print("test 2: 0123 -> 3210") print("test 2: 0123 -> 3210")
current_test.next = 2 current_test.next = 2
output_0_select.next = 3 select_list[0].next = 3
output_1_select.next = 2 select_list[1].next = 2
output_2_select.next = 1 select_list[2].next = 1
output_3_select.next = 0 select_list[3].next = 0
test_frame0 = axis_ep.AXIStreamFrame(b'\x02\x00\x03\xFF\x01\x02\x03\x04', id=0, dest=3) test_frame0 = axis_ep.AXIStreamFrame(b'\x02\x00\x03\xFF\x01\x02\x03\x04', id=0, dest=3)
test_frame1 = axis_ep.AXIStreamFrame(b'\x02\x01\x02\xFF\x01\x02\x03\x04', id=1, dest=2) test_frame1 = axis_ep.AXIStreamFrame(b'\x02\x01\x02\xFF\x01\x02\x03\x04', id=1, dest=2)
test_frame2 = axis_ep.AXIStreamFrame(b'\x02\x02\x01\xFF\x01\x02\x03\x04', id=2, dest=1) test_frame2 = axis_ep.AXIStreamFrame(b'\x02\x02\x01\xFF\x01\x02\x03\x04', id=2, dest=1)
test_frame3 = axis_ep.AXIStreamFrame(b'\x02\x03\x00\xFF\x01\x02\x03\x04', id=3, dest=0) test_frame3 = axis_ep.AXIStreamFrame(b'\x02\x03\x00\xFF\x01\x02\x03\x04', id=3, dest=0)
source_0.send(test_frame0) source_list[0].send(test_frame0)
source_1.send(test_frame1) source_list[1].send(test_frame1)
source_2.send(test_frame2) source_list[2].send(test_frame2)
source_3.send(test_frame3) source_list[3].send(test_frame3)
yield sink_0.wait() yield sink_list[0].wait()
rx_frame0 = sink_0.recv() rx_frame0 = sink_list[0].recv()
assert rx_frame0 == test_frame3 assert rx_frame0 == test_frame3
yield sink_1.wait() yield sink_list[1].wait()
rx_frame1 = sink_1.recv() rx_frame1 = sink_list[1].recv()
assert rx_frame1 == test_frame2 assert rx_frame1 == test_frame2
yield sink_2.wait() yield sink_list[2].wait()
rx_frame2 = sink_2.recv() rx_frame2 = sink_list[2].recv()
assert rx_frame2 == test_frame1 assert rx_frame2 == test_frame1
yield sink_3.wait() yield sink_list[3].wait()
rx_frame3 = sink_3.recv() rx_frame3 = sink_list[3].recv()
assert rx_frame3 == test_frame0 assert rx_frame3 == test_frame0
@ -436,31 +279,31 @@ def bench():
print("test 3: 0000 -> 0123") print("test 3: 0000 -> 0123")
current_test.next = 3 current_test.next = 3
output_0_select.next = 0 select_list[0].next = 0
output_1_select.next = 0 select_list[1].next = 0
output_2_select.next = 0 select_list[2].next = 0
output_3_select.next = 0 select_list[3].next = 0
test_frame0 = axis_ep.AXIStreamFrame(b'\x03\x00\xFF\xFF\x01\x02\x03\x04', id=0, dest=0) test_frame0 = axis_ep.AXIStreamFrame(b'\x03\x00\xFF\xFF\x01\x02\x03\x04', id=0, dest=0)
source_0.send(test_frame0) source_list[0].send(test_frame0)
yield sink_0.wait() yield sink_list[0].wait()
rx_frame0 = sink_0.recv() rx_frame0 = sink_list[0].recv()
assert rx_frame0 == test_frame0 assert rx_frame0 == test_frame0
yield sink_1.wait() yield sink_list[1].wait()
rx_frame1 = sink_1.recv() rx_frame1 = sink_list[1].recv()
assert rx_frame1 == test_frame0 assert rx_frame1 == test_frame0
yield sink_2.wait() yield sink_list[2].wait()
rx_frame2 = sink_2.recv() rx_frame2 = sink_list[2].recv()
assert rx_frame2 == test_frame0 assert rx_frame2 == test_frame0
yield sink_3.wait() yield sink_list[3].wait()
rx_frame3 = sink_3.recv() rx_frame3 = sink_list[3].recv()
assert rx_frame3 == test_frame0 assert rx_frame3 == test_frame0

View File

@ -27,11 +27,13 @@ THE SOFTWARE.
`timescale 1ns / 1ps `timescale 1ns / 1ps
/* /*
* Testbench for axis_crosspoint_4x4 * Testbench for axis_crosspoint
*/ */
module test_axis_crosspoint_4x4; module test_axis_crosspoint_4x4;
// Parameters // Parameters
parameter S_COUNT = 4;
parameter M_COUNT = 4;
parameter DATA_WIDTH = 8; parameter DATA_WIDTH = 8;
parameter KEEP_ENABLE = (DATA_WIDTH>8); parameter KEEP_ENABLE = (DATA_WIDTH>8);
parameter KEEP_WIDTH = (DATA_WIDTH/8); parameter KEEP_WIDTH = (DATA_WIDTH/8);
@ -48,69 +50,24 @@ reg clk = 0;
reg rst = 0; reg rst = 0;
reg [7:0] current_test = 0; reg [7:0] current_test = 0;
reg [DATA_WIDTH-1:0] input_0_axis_tdata = 0; reg [S_COUNT*DATA_WIDTH-1:0] s_axis_tdata = 0;
reg [KEEP_WIDTH-1:0] input_0_axis_tkeep = 0; reg [S_COUNT*KEEP_WIDTH-1:0] s_axis_tkeep = 0;
reg input_0_axis_tvalid = 0; reg [S_COUNT-1:0] s_axis_tvalid = 0;
reg input_0_axis_tlast = 0; reg [S_COUNT-1:0] s_axis_tlast = 0;
reg [ID_WIDTH-1:0] input_0_axis_tid = 0; reg [S_COUNT*ID_WIDTH-1:0] s_axis_tid = 0;
reg [DEST_WIDTH-1:0] input_0_axis_tdest = 0; reg [S_COUNT*DEST_WIDTH-1:0] s_axis_tdest = 0;
reg [USER_WIDTH-1:0] input_0_axis_tuser = 0; reg [S_COUNT*USER_WIDTH-1:0] s_axis_tuser = 0;
reg [DATA_WIDTH-1:0] input_1_axis_tdata = 0;
reg [KEEP_WIDTH-1:0] input_1_axis_tkeep = 0;
reg input_1_axis_tvalid = 0;
reg input_1_axis_tlast = 0;
reg [ID_WIDTH-1:0] input_1_axis_tid = 0;
reg [DEST_WIDTH-1:0] input_1_axis_tdest = 0;
reg [USER_WIDTH-1:0] input_1_axis_tuser = 0;
reg [DATA_WIDTH-1:0] input_2_axis_tdata = 0;
reg [KEEP_WIDTH-1:0] input_2_axis_tkeep = 0;
reg input_2_axis_tvalid = 0;
reg input_2_axis_tlast = 0;
reg [ID_WIDTH-1:0] input_2_axis_tid = 0;
reg [DEST_WIDTH-1:0] input_2_axis_tdest = 0;
reg [USER_WIDTH-1:0] input_2_axis_tuser = 0;
reg [DATA_WIDTH-1:0] input_3_axis_tdata = 0;
reg [KEEP_WIDTH-1:0] input_3_axis_tkeep = 0;
reg input_3_axis_tvalid = 0;
reg input_3_axis_tlast = 0;
reg [ID_WIDTH-1:0] input_3_axis_tid = 0;
reg [DEST_WIDTH-1:0] input_3_axis_tdest = 0;
reg [USER_WIDTH-1:0] input_3_axis_tuser = 0;
reg [1:0] output_0_select = 0; reg [M_COUNT*$clog2(S_COUNT)-1:0] select = 0;
reg [1:0] output_1_select = 0;
reg [1:0] output_2_select = 0;
reg [1:0] output_3_select = 0;
// Outputs // Outputs
wire [DATA_WIDTH-1:0] output_0_axis_tdata; wire [M_COUNT*DATA_WIDTH-1:0] m_axis_tdata;
wire [KEEP_WIDTH-1:0] output_0_axis_tkeep; wire [M_COUNT*KEEP_WIDTH-1:0] m_axis_tkeep;
wire output_0_axis_tvalid; wire [M_COUNT-1:0] m_axis_tvalid;
wire output_0_axis_tlast; wire [M_COUNT-1:0] m_axis_tlast;
wire [ID_WIDTH-1:0] output_0_axis_tid; wire [M_COUNT*ID_WIDTH-1:0] m_axis_tid;
wire [DEST_WIDTH-1:0] output_0_axis_tdest; wire [M_COUNT*DEST_WIDTH-1:0] m_axis_tdest;
wire [USER_WIDTH-1:0] output_0_axis_tuser; wire [M_COUNT*USER_WIDTH-1:0] m_axis_tuser;
wire [DATA_WIDTH-1:0] output_1_axis_tdata;
wire [KEEP_WIDTH-1:0] output_1_axis_tkeep;
wire output_1_axis_tvalid;
wire output_1_axis_tlast;
wire [ID_WIDTH-1:0] output_1_axis_tid;
wire [DEST_WIDTH-1:0] output_1_axis_tdest;
wire [USER_WIDTH-1:0] output_1_axis_tuser;
wire [DATA_WIDTH-1:0] output_2_axis_tdata;
wire [KEEP_WIDTH-1:0] output_2_axis_tkeep;
wire output_2_axis_tvalid;
wire output_2_axis_tlast;
wire [ID_WIDTH-1:0] output_2_axis_tid;
wire [DEST_WIDTH-1:0] output_2_axis_tdest;
wire [USER_WIDTH-1:0] output_2_axis_tuser;
wire [DATA_WIDTH-1:0] output_3_axis_tdata;
wire [KEEP_WIDTH-1:0] output_3_axis_tkeep;
wire output_3_axis_tvalid;
wire output_3_axis_tlast;
wire [ID_WIDTH-1:0] output_3_axis_tid;
wire [DEST_WIDTH-1:0] output_3_axis_tdest;
wire [USER_WIDTH-1:0] output_3_axis_tuser;
initial begin initial begin
// myhdl integration // myhdl integration
@ -118,68 +75,23 @@ initial begin
clk, clk,
rst, rst,
current_test, current_test,
input_0_axis_tdata, s_axis_tdata,
input_0_axis_tkeep, s_axis_tkeep,
input_0_axis_tvalid, s_axis_tvalid,
input_0_axis_tlast, s_axis_tlast,
input_0_axis_tid, s_axis_tid,
input_0_axis_tdest, s_axis_tdest,
input_0_axis_tuser, s_axis_tuser,
input_1_axis_tdata, select
input_1_axis_tkeep,
input_1_axis_tvalid,
input_1_axis_tlast,
input_1_axis_tid,
input_1_axis_tdest,
input_1_axis_tuser,
input_2_axis_tdata,
input_2_axis_tkeep,
input_2_axis_tvalid,
input_2_axis_tlast,
input_2_axis_tid,
input_2_axis_tdest,
input_2_axis_tuser,
input_3_axis_tdata,
input_3_axis_tkeep,
input_3_axis_tvalid,
input_3_axis_tlast,
input_3_axis_tid,
input_3_axis_tdest,
input_3_axis_tuser,
output_0_select,
output_1_select,
output_2_select,
output_3_select
); );
$to_myhdl( $to_myhdl(
output_0_axis_tdata, m_axis_tdata,
output_0_axis_tkeep, m_axis_tkeep,
output_0_axis_tvalid, m_axis_tvalid,
output_0_axis_tlast, m_axis_tlast,
output_0_axis_tid, m_axis_tid,
output_0_axis_tdest, m_axis_tdest,
output_0_axis_tuser, m_axis_tuser
output_1_axis_tdata,
output_1_axis_tkeep,
output_1_axis_tvalid,
output_1_axis_tlast,
output_1_axis_tid,
output_1_axis_tdest,
output_1_axis_tuser,
output_2_axis_tdata,
output_2_axis_tkeep,
output_2_axis_tvalid,
output_2_axis_tlast,
output_2_axis_tid,
output_2_axis_tdest,
output_2_axis_tuser,
output_3_axis_tdata,
output_3_axis_tkeep,
output_3_axis_tvalid,
output_3_axis_tlast,
output_3_axis_tid,
output_3_axis_tdest,
output_3_axis_tuser
); );
// dump file // dump file
@ -187,7 +99,9 @@ initial begin
$dumpvars(0, test_axis_crosspoint_4x4); $dumpvars(0, test_axis_crosspoint_4x4);
end end
axis_crosspoint_4x4 #( axis_crosspoint #(
.S_COUNT(S_COUNT),
.M_COUNT(M_COUNT),
.DATA_WIDTH(DATA_WIDTH), .DATA_WIDTH(DATA_WIDTH),
.KEEP_ENABLE(KEEP_ENABLE), .KEEP_ENABLE(KEEP_ENABLE),
.KEEP_WIDTH(KEEP_WIDTH), .KEEP_WIDTH(KEEP_WIDTH),
@ -203,68 +117,23 @@ UUT (
.clk(clk), .clk(clk),
.rst(rst), .rst(rst),
// AXI inputs // AXI inputs
.input_0_axis_tdata(input_0_axis_tdata), .s_axis_tdata(s_axis_tdata),
.input_0_axis_tkeep(input_0_axis_tkeep), .s_axis_tkeep(s_axis_tkeep),
.input_0_axis_tvalid(input_0_axis_tvalid), .s_axis_tvalid(s_axis_tvalid),
.input_0_axis_tlast(input_0_axis_tlast), .s_axis_tlast(s_axis_tlast),
.input_0_axis_tid(input_0_axis_tid), .s_axis_tid(s_axis_tid),
.input_0_axis_tdest(input_0_axis_tdest), .s_axis_tdest(s_axis_tdest),
.input_0_axis_tuser(input_0_axis_tuser), .s_axis_tuser(s_axis_tuser),
.input_1_axis_tdata(input_1_axis_tdata), // AXI output
.input_1_axis_tkeep(input_1_axis_tkeep), .m_axis_tdata(m_axis_tdata),
.input_1_axis_tvalid(input_1_axis_tvalid), .m_axis_tkeep(m_axis_tkeep),
.input_1_axis_tlast(input_1_axis_tlast), .m_axis_tvalid(m_axis_tvalid),
.input_1_axis_tid(input_1_axis_tid), .m_axis_tlast(m_axis_tlast),
.input_1_axis_tdest(input_1_axis_tdest), .m_axis_tid(m_axis_tid),
.input_1_axis_tuser(input_1_axis_tuser), .m_axis_tdest(m_axis_tdest),
.input_2_axis_tdata(input_2_axis_tdata), .m_axis_tuser(m_axis_tuser),
.input_2_axis_tkeep(input_2_axis_tkeep),
.input_2_axis_tvalid(input_2_axis_tvalid),
.input_2_axis_tlast(input_2_axis_tlast),
.input_2_axis_tid(input_2_axis_tid),
.input_2_axis_tdest(input_2_axis_tdest),
.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),
.input_3_axis_tlast(input_3_axis_tlast),
.input_3_axis_tid(input_3_axis_tid),
.input_3_axis_tdest(input_3_axis_tdest),
.input_3_axis_tuser(input_3_axis_tuser),
// AXI outputs
.output_0_axis_tdata(output_0_axis_tdata),
.output_0_axis_tkeep(output_0_axis_tkeep),
.output_0_axis_tvalid(output_0_axis_tvalid),
.output_0_axis_tlast(output_0_axis_tlast),
.output_0_axis_tid(output_0_axis_tid),
.output_0_axis_tdest(output_0_axis_tdest),
.output_0_axis_tuser(output_0_axis_tuser),
.output_1_axis_tdata(output_1_axis_tdata),
.output_1_axis_tkeep(output_1_axis_tkeep),
.output_1_axis_tvalid(output_1_axis_tvalid),
.output_1_axis_tlast(output_1_axis_tlast),
.output_1_axis_tid(output_1_axis_tid),
.output_1_axis_tdest(output_1_axis_tdest),
.output_1_axis_tuser(output_1_axis_tuser),
.output_2_axis_tdata(output_2_axis_tdata),
.output_2_axis_tkeep(output_2_axis_tkeep),
.output_2_axis_tvalid(output_2_axis_tvalid),
.output_2_axis_tlast(output_2_axis_tlast),
.output_2_axis_tid(output_2_axis_tid),
.output_2_axis_tdest(output_2_axis_tdest),
.output_2_axis_tuser(output_2_axis_tuser),
.output_3_axis_tdata(output_3_axis_tdata),
.output_3_axis_tkeep(output_3_axis_tkeep),
.output_3_axis_tvalid(output_3_axis_tvalid),
.output_3_axis_tlast(output_3_axis_tlast),
.output_3_axis_tid(output_3_axis_tid),
.output_3_axis_tdest(output_3_axis_tdest),
.output_3_axis_tuser(output_3_axis_tuser),
// Control // Control
.output_0_select(output_0_select), .select(select)
.output_1_select(output_1_select),
.output_2_select(output_2_select),
.output_3_select(output_3_select)
); );
endmodule endmodule

View File

@ -27,9 +27,10 @@ from myhdl import *
import os import os
import axis_ep import axis_ep
import math
module = 'axis_crosspoint_4x4' module = 'axis_crosspoint'
testbench = 'test_%s_64' % module testbench = 'test_%s_4x4_64' % module
srcs = [] srcs = []
@ -43,6 +44,8 @@ build_cmd = "iverilog -o %s.vvp %s" % (testbench, src)
def bench(): def bench():
# Parameters # Parameters
S_COUNT = 4
M_COUNT = 4
DATA_WIDTH = 64 DATA_WIDTH = 64
KEEP_ENABLE = (DATA_WIDTH>8) KEEP_ENABLE = (DATA_WIDTH>8)
KEEP_WIDTH = (DATA_WIDTH/8) KEEP_WIDTH = (DATA_WIDTH/8)
@ -59,207 +62,92 @@ def bench():
rst = Signal(bool(0)) rst = Signal(bool(0))
current_test = Signal(intbv(0)[8:]) current_test = Signal(intbv(0)[8:])
input_0_axis_tdata = Signal(intbv(0)[DATA_WIDTH:]) s_axis_tdata_list = [Signal(intbv(0)[DATA_WIDTH:]) for i in range(S_COUNT)]
input_0_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:]) s_axis_tkeep_list = [Signal(intbv(1)[KEEP_WIDTH:]) for i in range(S_COUNT)]
input_0_axis_tvalid = Signal(bool(0)) s_axis_tvalid_list = [Signal(bool(0)) for i in range(S_COUNT)]
input_0_axis_tlast = Signal(bool(0)) s_axis_tlast_list = [Signal(bool(0)) for i in range(S_COUNT)]
input_0_axis_tid = Signal(intbv(0)[ID_WIDTH:]) s_axis_tid_list = [Signal(intbv(0)[ID_WIDTH:]) for i in range(S_COUNT)]
input_0_axis_tdest = Signal(intbv(0)[DEST_WIDTH:]) s_axis_tdest_list = [Signal(intbv(0)[DEST_WIDTH:]) for i in range(S_COUNT)]
input_0_axis_tuser = Signal(intbv(0)[USER_WIDTH:]) s_axis_tuser_list = [Signal(intbv(0)[USER_WIDTH:]) for i in range(S_COUNT)]
input_1_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
input_1_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
input_1_axis_tvalid = Signal(bool(0))
input_1_axis_tlast = Signal(bool(0))
input_1_axis_tid = Signal(intbv(0)[ID_WIDTH:])
input_1_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
input_1_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
input_2_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
input_2_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
input_2_axis_tvalid = Signal(bool(0))
input_2_axis_tlast = Signal(bool(0))
input_2_axis_tid = Signal(intbv(0)[ID_WIDTH:])
input_2_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
input_2_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
input_3_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
input_3_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
input_3_axis_tvalid = Signal(bool(0))
input_3_axis_tlast = Signal(bool(0))
input_3_axis_tid = Signal(intbv(0)[ID_WIDTH:])
input_3_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
input_3_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
output_0_select = Signal(intbv(0)[2:]) s_axis_tdata = ConcatSignal(*reversed(s_axis_tdata_list))
output_1_select = Signal(intbv(0)[2:]) s_axis_tkeep = ConcatSignal(*reversed(s_axis_tkeep_list))
output_2_select = Signal(intbv(0)[2:]) s_axis_tvalid = ConcatSignal(*reversed(s_axis_tvalid_list))
output_3_select = Signal(intbv(0)[2:]) s_axis_tlast = ConcatSignal(*reversed(s_axis_tlast_list))
s_axis_tid = ConcatSignal(*reversed(s_axis_tid_list))
s_axis_tdest = ConcatSignal(*reversed(s_axis_tdest_list))
s_axis_tuser = ConcatSignal(*reversed(s_axis_tuser_list))
select_list = [Signal(intbv(0)[math.ceil(math.log(S_COUNT, 2)):]) for i in range(M_COUNT)]
select = ConcatSignal(*reversed(select_list))
# Outputs # Outputs
output_0_axis_tdata = Signal(intbv(0)[DATA_WIDTH:]) m_axis_tdata = Signal(intbv(0)[M_COUNT*DATA_WIDTH:])
output_0_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:]) m_axis_tkeep = Signal(intbv(0xf)[M_COUNT*KEEP_WIDTH:])
output_0_axis_tvalid = Signal(bool(0)) m_axis_tvalid = Signal(intbv(0)[M_COUNT:])
output_0_axis_tlast = Signal(bool(0)) m_axis_tlast = Signal(intbv(0)[M_COUNT:])
output_0_axis_tid = Signal(intbv(0)[ID_WIDTH:]) m_axis_tid = Signal(intbv(0)[M_COUNT*ID_WIDTH:])
output_0_axis_tdest = Signal(intbv(0)[DEST_WIDTH:]) m_axis_tdest = Signal(intbv(0)[M_COUNT*DEST_WIDTH:])
output_0_axis_tuser = Signal(intbv(0)[USER_WIDTH:]) m_axis_tuser = Signal(intbv(0)[M_COUNT*USER_WIDTH:])
output_1_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
output_1_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:]) m_axis_tdata_list = [m_axis_tdata((i+1)*DATA_WIDTH, i*DATA_WIDTH) for i in range(M_COUNT)]
output_1_axis_tvalid = Signal(bool(0)) m_axis_tkeep_list = [m_axis_tkeep((i+1)*KEEP_WIDTH, i*KEEP_WIDTH) for i in range(M_COUNT)]
output_1_axis_tlast = Signal(bool(0)) m_axis_tvalid_list = [m_axis_tvalid(i) for i in range(M_COUNT)]
output_1_axis_tid = Signal(intbv(0)[ID_WIDTH:]) m_axis_tlast_list = [m_axis_tlast(i) for i in range(M_COUNT)]
output_1_axis_tdest = Signal(intbv(0)[DEST_WIDTH:]) m_axis_tid_list = [m_axis_tid((i+1)*ID_WIDTH, i*ID_WIDTH) for i in range(M_COUNT)]
output_1_axis_tuser = Signal(intbv(0)[USER_WIDTH:]) m_axis_tdest_list = [m_axis_tdest((i+1)*DEST_WIDTH, i*DEST_WIDTH) for i in range(M_COUNT)]
output_2_axis_tdata = Signal(intbv(0)[DATA_WIDTH:]) m_axis_tuser_list = [m_axis_tuser((i+1)*USER_WIDTH, i*USER_WIDTH) for i in range(M_COUNT)]
output_2_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
output_2_axis_tvalid = Signal(bool(0))
output_2_axis_tlast = Signal(bool(0))
output_2_axis_tid = Signal(intbv(0)[ID_WIDTH:])
output_2_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
output_2_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
output_3_axis_tdata = Signal(intbv(0)[DATA_WIDTH:])
output_3_axis_tkeep = Signal(intbv(1)[KEEP_WIDTH:])
output_3_axis_tvalid = Signal(bool(0))
output_3_axis_tlast = Signal(bool(0))
output_3_axis_tid = Signal(intbv(0)[ID_WIDTH:])
output_3_axis_tdest = Signal(intbv(0)[DEST_WIDTH:])
output_3_axis_tuser = Signal(intbv(0)[USER_WIDTH:])
# sources and sinks # sources and sinks
source_0_pause = Signal(bool(0)) source_pause_list = []
source_1_pause = Signal(bool(0)) source_list = []
source_2_pause = Signal(bool(0)) source_logic_list = []
source_3_pause = Signal(bool(0)) sink_pause_list = []
sink_0_pause = Signal(bool(0)) sink_list = []
sink_1_pause = Signal(bool(0)) sink_logic_list = []
sink_2_pause = Signal(bool(0))
sink_3_pause = Signal(bool(0))
source_0 = axis_ep.AXIStreamSource() for k in range(S_COUNT):
s = axis_ep.AXIStreamSource()
p = Signal(bool(0))
source_0_logic = source_0.create_logic( source_list.append(s)
source_pause_list.append(p)
source_logic_list.append(s.create_logic(
clk, clk,
rst, rst,
tdata=input_0_axis_tdata, tdata=s_axis_tdata_list[k],
tkeep=input_0_axis_tkeep, tkeep=s_axis_tkeep_list[k],
tvalid=input_0_axis_tvalid, tvalid=s_axis_tvalid_list[k],
tlast=input_0_axis_tlast, tlast=s_axis_tlast_list[k],
tid=input_0_axis_tid, tid=s_axis_tid_list[k],
tdest=input_0_axis_tdest, tdest=s_axis_tdest_list[k],
tuser=input_0_axis_tuser, tuser=s_axis_tuser_list[k],
pause=source_0_pause, pause=p,
name='source_0' name='source_%d' % k
) ))
source_1 = axis_ep.AXIStreamSource() for k in range(M_COUNT):
s = axis_ep.AXIStreamSink()
p = Signal(bool(0))
source_1_logic = source_1.create_logic( sink_list.append(s)
sink_pause_list.append(p)
sink_logic_list.append(s.create_logic(
clk, clk,
rst, rst,
tdata=input_1_axis_tdata, tdata=m_axis_tdata_list[k],
tkeep=input_1_axis_tkeep, tkeep=m_axis_tkeep_list[k],
tvalid=input_1_axis_tvalid, tvalid=m_axis_tvalid_list[k],
tlast=input_1_axis_tlast, tlast=m_axis_tlast_list[k],
tid=input_1_axis_tid, tid=m_axis_tid_list[k],
tdest=input_1_axis_tdest, tdest=m_axis_tdest_list[k],
tuser=input_1_axis_tuser, tuser=m_axis_tuser_list[k],
pause=source_1_pause, pause=p,
name='source_1' name='sink_%d' % k
) ))
source_2 = axis_ep.AXIStreamSource()
source_2_logic = source_2.create_logic(
clk,
rst,
tdata=input_2_axis_tdata,
tkeep=input_2_axis_tkeep,
tvalid=input_2_axis_tvalid,
tlast=input_2_axis_tlast,
tid=input_2_axis_tid,
tdest=input_2_axis_tdest,
tuser=input_2_axis_tuser,
pause=source_2_pause,
name='source_2'
)
source_3 = axis_ep.AXIStreamSource()
source_3_logic = source_3.create_logic(
clk,
rst,
tdata=input_3_axis_tdata,
tkeep=input_3_axis_tkeep,
tvalid=input_3_axis_tvalid,
tlast=input_3_axis_tlast,
tid=input_3_axis_tid,
tdest=input_3_axis_tdest,
tuser=input_3_axis_tuser,
pause=source_3_pause,
name='source_3'
)
sink_0 = axis_ep.AXIStreamSink()
sink_0_logic = sink_0.create_logic(
clk,
rst,
tdata=output_0_axis_tdata,
tkeep=output_0_axis_tkeep,
tvalid=output_0_axis_tvalid,
tlast=output_0_axis_tlast,
tid=output_0_axis_tid,
tdest=output_0_axis_tdest,
tuser=output_0_axis_tuser,
pause=sink_0_pause,
name='sink_0'
)
sink_1 = axis_ep.AXIStreamSink()
sink_1_logic = sink_1.create_logic(
clk,
rst,
tdata=output_1_axis_tdata,
tkeep=output_1_axis_tkeep,
tvalid=output_1_axis_tvalid,
tlast=output_1_axis_tlast,
tid=output_1_axis_tid,
tdest=output_1_axis_tdest,
tuser=output_1_axis_tuser,
pause=sink_1_pause,
name='sink_1'
)
sink_2 = axis_ep.AXIStreamSink()
sink_2_logic = sink_2.create_logic(
clk,
rst,
tdata=output_2_axis_tdata,
tkeep=output_2_axis_tkeep,
tvalid=output_2_axis_tvalid,
tlast=output_2_axis_tlast,
tid=output_2_axis_tid,
tdest=output_2_axis_tdest,
tuser=output_2_axis_tuser,
pause=sink_2_pause,
name='sink_2'
)
sink_3 = axis_ep.AXIStreamSink()
sink_3_logic = sink_3.create_logic(
clk,
rst,
tdata=output_3_axis_tdata,
tkeep=output_3_axis_tkeep,
tvalid=output_3_axis_tvalid,
tlast=output_3_axis_tlast,
tid=output_3_axis_tid,
tdest=output_3_axis_tdest,
tuser=output_3_axis_tuser,
pause=sink_3_pause,
name='sink_3'
)
# DUT # DUT
if os.system(build_cmd): if os.system(build_cmd):
@ -271,68 +159,23 @@ def bench():
rst=rst, rst=rst,
current_test=current_test, current_test=current_test,
input_0_axis_tdata=input_0_axis_tdata, s_axis_tdata=s_axis_tdata,
input_0_axis_tkeep=input_0_axis_tkeep, s_axis_tkeep=s_axis_tkeep,
input_0_axis_tvalid=input_0_axis_tvalid, s_axis_tvalid=s_axis_tvalid,
input_0_axis_tlast=input_0_axis_tlast, s_axis_tlast=s_axis_tlast,
input_0_axis_tid=input_0_axis_tid, s_axis_tid=s_axis_tid,
input_0_axis_tdest=input_0_axis_tdest, s_axis_tdest=s_axis_tdest,
input_0_axis_tuser=input_0_axis_tuser, s_axis_tuser=s_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,
input_1_axis_tlast=input_1_axis_tlast,
input_1_axis_tid=input_1_axis_tid,
input_1_axis_tdest=input_1_axis_tdest,
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,
input_2_axis_tlast=input_2_axis_tlast,
input_2_axis_tid=input_2_axis_tid,
input_2_axis_tdest=input_2_axis_tdest,
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,
input_3_axis_tlast=input_3_axis_tlast,
input_3_axis_tid=input_3_axis_tid,
input_3_axis_tdest=input_3_axis_tdest,
input_3_axis_tuser=input_3_axis_tuser,
output_0_axis_tdata=output_0_axis_tdata, m_axis_tdata=m_axis_tdata,
output_0_axis_tkeep=output_0_axis_tkeep, m_axis_tkeep=m_axis_tkeep,
output_0_axis_tvalid=output_0_axis_tvalid, m_axis_tvalid=m_axis_tvalid,
output_0_axis_tlast=output_0_axis_tlast, m_axis_tlast=m_axis_tlast,
output_0_axis_tid=output_0_axis_tid, m_axis_tid=m_axis_tid,
output_0_axis_tdest=output_0_axis_tdest, m_axis_tdest=m_axis_tdest,
output_0_axis_tuser=output_0_axis_tuser, m_axis_tuser=m_axis_tuser,
output_1_axis_tdata=output_1_axis_tdata,
output_1_axis_tkeep=output_1_axis_tkeep,
output_1_axis_tvalid=output_1_axis_tvalid,
output_1_axis_tlast=output_1_axis_tlast,
output_1_axis_tid=output_1_axis_tid,
output_1_axis_tdest=output_1_axis_tdest,
output_1_axis_tuser=output_1_axis_tuser,
output_2_axis_tdata=output_2_axis_tdata,
output_2_axis_tkeep=output_2_axis_tkeep,
output_2_axis_tvalid=output_2_axis_tvalid,
output_2_axis_tlast=output_2_axis_tlast,
output_2_axis_tid=output_2_axis_tid,
output_2_axis_tdest=output_2_axis_tdest,
output_2_axis_tuser=output_2_axis_tuser,
output_3_axis_tdata=output_3_axis_tdata,
output_3_axis_tkeep=output_3_axis_tkeep,
output_3_axis_tvalid=output_3_axis_tvalid,
output_3_axis_tlast=output_3_axis_tlast,
output_3_axis_tid=output_3_axis_tid,
output_3_axis_tdest=output_3_axis_tdest,
output_3_axis_tuser=output_3_axis_tuser,
output_0_select=output_0_select, select=select
output_1_select=output_1_select,
output_2_select=output_2_select,
output_3_select=output_3_select
) )
@always(delay(4)) @always(delay(4))
@ -356,37 +199,37 @@ def bench():
print("test 1: 0123 -> 0123") print("test 1: 0123 -> 0123")
current_test.next = 1 current_test.next = 1
output_0_select.next = 0 select_list[0].next = 0
output_1_select.next = 1 select_list[1].next = 1
output_2_select.next = 2 select_list[2].next = 2
output_3_select.next = 3 select_list[3].next = 3
test_frame0 = axis_ep.AXIStreamFrame(b'\x01\x00\x00\xFF\x01\x02\x03\x04', id=0, dest=0) test_frame0 = axis_ep.AXIStreamFrame(b'\x01\x00\x00\xFF\x01\x02\x03\x04', id=0, dest=0)
test_frame1 = axis_ep.AXIStreamFrame(b'\x01\x01\x01\xFF\x01\x02\x03\x04', id=1, dest=1) test_frame1 = axis_ep.AXIStreamFrame(b'\x01\x01\x01\xFF\x01\x02\x03\x04', id=1, dest=1)
test_frame2 = axis_ep.AXIStreamFrame(b'\x01\x02\x02\xFF\x01\x02\x03\x04', id=2, dest=2) test_frame2 = axis_ep.AXIStreamFrame(b'\x01\x02\x02\xFF\x01\x02\x03\x04', id=2, dest=2)
test_frame3 = axis_ep.AXIStreamFrame(b'\x01\x03\x03\xFF\x01\x02\x03\x04', id=3, dest=3) test_frame3 = axis_ep.AXIStreamFrame(b'\x01\x03\x03\xFF\x01\x02\x03\x04', id=3, dest=3)
source_0.send(test_frame0) source_list[0].send(test_frame0)
source_1.send(test_frame1) source_list[1].send(test_frame1)
source_2.send(test_frame2) source_list[2].send(test_frame2)
source_3.send(test_frame3) source_list[3].send(test_frame3)
yield sink_0.wait() yield sink_list[0].wait()
rx_frame0 = sink_0.recv() rx_frame0 = sink_list[0].recv()
assert rx_frame0 == test_frame0 assert rx_frame0 == test_frame0
yield sink_1.wait() yield sink_list[1].wait()
rx_frame1 = sink_1.recv() rx_frame1 = sink_list[1].recv()
assert rx_frame1 == test_frame1 assert rx_frame1 == test_frame1
yield sink_2.wait() yield sink_list[2].wait()
rx_frame2 = sink_2.recv() rx_frame2 = sink_list[2].recv()
assert rx_frame2 == test_frame2 assert rx_frame2 == test_frame2
yield sink_3.wait() yield sink_list[3].wait()
rx_frame3 = sink_3.recv() rx_frame3 = sink_list[3].recv()
assert rx_frame3 == test_frame3 assert rx_frame3 == test_frame3
@ -396,37 +239,37 @@ def bench():
print("test 2: 0123 -> 3210") print("test 2: 0123 -> 3210")
current_test.next = 2 current_test.next = 2
output_0_select.next = 3 select_list[0].next = 3
output_1_select.next = 2 select_list[1].next = 2
output_2_select.next = 1 select_list[2].next = 1
output_3_select.next = 0 select_list[3].next = 0
test_frame0 = axis_ep.AXIStreamFrame(b'\x02\x00\x03\xFF\x01\x02\x03\x04', id=0, dest=3) test_frame0 = axis_ep.AXIStreamFrame(b'\x02\x00\x03\xFF\x01\x02\x03\x04', id=0, dest=3)
test_frame1 = axis_ep.AXIStreamFrame(b'\x02\x01\x02\xFF\x01\x02\x03\x04', id=1, dest=2) test_frame1 = axis_ep.AXIStreamFrame(b'\x02\x01\x02\xFF\x01\x02\x03\x04', id=1, dest=2)
test_frame2 = axis_ep.AXIStreamFrame(b'\x02\x02\x01\xFF\x01\x02\x03\x04', id=2, dest=1) test_frame2 = axis_ep.AXIStreamFrame(b'\x02\x02\x01\xFF\x01\x02\x03\x04', id=2, dest=1)
test_frame3 = axis_ep.AXIStreamFrame(b'\x02\x03\x00\xFF\x01\x02\x03\x04', id=3, dest=0) test_frame3 = axis_ep.AXIStreamFrame(b'\x02\x03\x00\xFF\x01\x02\x03\x04', id=3, dest=0)
source_0.send(test_frame0) source_list[0].send(test_frame0)
source_1.send(test_frame1) source_list[1].send(test_frame1)
source_2.send(test_frame2) source_list[2].send(test_frame2)
source_3.send(test_frame3) source_list[3].send(test_frame3)
yield sink_0.wait() yield sink_list[0].wait()
rx_frame0 = sink_0.recv() rx_frame0 = sink_list[0].recv()
assert rx_frame0 == test_frame3 assert rx_frame0 == test_frame3
yield sink_1.wait() yield sink_list[1].wait()
rx_frame1 = sink_1.recv() rx_frame1 = sink_list[1].recv()
assert rx_frame1 == test_frame2 assert rx_frame1 == test_frame2
yield sink_2.wait() yield sink_list[2].wait()
rx_frame2 = sink_2.recv() rx_frame2 = sink_list[2].recv()
assert rx_frame2 == test_frame1 assert rx_frame2 == test_frame1
yield sink_3.wait() yield sink_list[3].wait()
rx_frame3 = sink_3.recv() rx_frame3 = sink_list[3].recv()
assert rx_frame3 == test_frame0 assert rx_frame3 == test_frame0
@ -436,31 +279,31 @@ def bench():
print("test 3: 0000 -> 0123") print("test 3: 0000 -> 0123")
current_test.next = 3 current_test.next = 3
output_0_select.next = 0 select_list[0].next = 0
output_1_select.next = 0 select_list[1].next = 0
output_2_select.next = 0 select_list[2].next = 0
output_3_select.next = 0 select_list[3].next = 0
test_frame0 = axis_ep.AXIStreamFrame(b'\x03\x00\xFF\xFF\x01\x02\x03\x04', id=0, dest=0) test_frame0 = axis_ep.AXIStreamFrame(b'\x03\x00\xFF\xFF\x01\x02\x03\x04', id=0, dest=0)
source_0.send(test_frame0) source_list[0].send(test_frame0)
yield sink_0.wait() yield sink_list[0].wait()
rx_frame0 = sink_0.recv() rx_frame0 = sink_list[0].recv()
assert rx_frame0 == test_frame0 assert rx_frame0 == test_frame0
yield sink_1.wait() yield sink_list[1].wait()
rx_frame1 = sink_1.recv() rx_frame1 = sink_list[1].recv()
assert rx_frame1 == test_frame0 assert rx_frame1 == test_frame0
yield sink_2.wait() yield sink_list[2].wait()
rx_frame2 = sink_2.recv() rx_frame2 = sink_list[2].recv()
assert rx_frame2 == test_frame0 assert rx_frame2 == test_frame0
yield sink_3.wait() yield sink_list[3].wait()
rx_frame3 = sink_3.recv() rx_frame3 = sink_list[3].recv()
assert rx_frame3 == test_frame0 assert rx_frame3 == test_frame0

View File

@ -27,11 +27,13 @@ THE SOFTWARE.
`timescale 1ns / 1ps `timescale 1ns / 1ps
/* /*
* Testbench for axis_crosspoint_4x4 * Testbench for axis_crosspoint
*/ */
module test_axis_crosspoint_4x4_64; module test_axis_crosspoint_4x4_64;
// Parameters // Parameters
parameter S_COUNT = 4;
parameter M_COUNT = 4;
parameter DATA_WIDTH = 64; parameter DATA_WIDTH = 64;
parameter KEEP_ENABLE = (DATA_WIDTH>8); parameter KEEP_ENABLE = (DATA_WIDTH>8);
parameter KEEP_WIDTH = (DATA_WIDTH/8); parameter KEEP_WIDTH = (DATA_WIDTH/8);
@ -48,69 +50,24 @@ reg clk = 0;
reg rst = 0; reg rst = 0;
reg [7:0] current_test = 0; reg [7:0] current_test = 0;
reg [DATA_WIDTH-1:0] input_0_axis_tdata = 0; reg [S_COUNT*DATA_WIDTH-1:0] s_axis_tdata = 0;
reg [KEEP_WIDTH-1:0] input_0_axis_tkeep = 0; reg [S_COUNT*KEEP_WIDTH-1:0] s_axis_tkeep = 0;
reg input_0_axis_tvalid = 0; reg [S_COUNT-1:0] s_axis_tvalid = 0;
reg input_0_axis_tlast = 0; reg [S_COUNT-1:0] s_axis_tlast = 0;
reg [ID_WIDTH-1:0] input_0_axis_tid = 0; reg [S_COUNT*ID_WIDTH-1:0] s_axis_tid = 0;
reg [DEST_WIDTH-1:0] input_0_axis_tdest = 0; reg [S_COUNT*DEST_WIDTH-1:0] s_axis_tdest = 0;
reg [USER_WIDTH-1:0] input_0_axis_tuser = 0; reg [S_COUNT*USER_WIDTH-1:0] s_axis_tuser = 0;
reg [DATA_WIDTH-1:0] input_1_axis_tdata = 0;
reg [KEEP_WIDTH-1:0] input_1_axis_tkeep = 0;
reg input_1_axis_tvalid = 0;
reg input_1_axis_tlast = 0;
reg [ID_WIDTH-1:0] input_1_axis_tid = 0;
reg [DEST_WIDTH-1:0] input_1_axis_tdest = 0;
reg [USER_WIDTH-1:0] input_1_axis_tuser = 0;
reg [DATA_WIDTH-1:0] input_2_axis_tdata = 0;
reg [KEEP_WIDTH-1:0] input_2_axis_tkeep = 0;
reg input_2_axis_tvalid = 0;
reg input_2_axis_tlast = 0;
reg [ID_WIDTH-1:0] input_2_axis_tid = 0;
reg [DEST_WIDTH-1:0] input_2_axis_tdest = 0;
reg [USER_WIDTH-1:0] input_2_axis_tuser = 0;
reg [DATA_WIDTH-1:0] input_3_axis_tdata = 0;
reg [KEEP_WIDTH-1:0] input_3_axis_tkeep = 0;
reg input_3_axis_tvalid = 0;
reg input_3_axis_tlast = 0;
reg [ID_WIDTH-1:0] input_3_axis_tid = 0;
reg [DEST_WIDTH-1:0] input_3_axis_tdest = 0;
reg [USER_WIDTH-1:0] input_3_axis_tuser = 0;
reg [1:0] output_0_select = 0; reg [M_COUNT*$clog2(S_COUNT)-1:0] select = 0;
reg [1:0] output_1_select = 0;
reg [1:0] output_2_select = 0;
reg [1:0] output_3_select = 0;
// Outputs // Outputs
wire [DATA_WIDTH-1:0] output_0_axis_tdata; wire [M_COUNT*DATA_WIDTH-1:0] m_axis_tdata;
wire [KEEP_WIDTH-1:0] output_0_axis_tkeep; wire [M_COUNT*KEEP_WIDTH-1:0] m_axis_tkeep;
wire output_0_axis_tvalid; wire [M_COUNT-1:0] m_axis_tvalid;
wire output_0_axis_tlast; wire [M_COUNT-1:0] m_axis_tlast;
wire [ID_WIDTH-1:0] output_0_axis_tid; wire [M_COUNT*ID_WIDTH-1:0] m_axis_tid;
wire [DEST_WIDTH-1:0] output_0_axis_tdest; wire [M_COUNT*DEST_WIDTH-1:0] m_axis_tdest;
wire [USER_WIDTH-1:0] output_0_axis_tuser; wire [M_COUNT*USER_WIDTH-1:0] m_axis_tuser;
wire [DATA_WIDTH-1:0] output_1_axis_tdata;
wire [KEEP_WIDTH-1:0] output_1_axis_tkeep;
wire output_1_axis_tvalid;
wire output_1_axis_tlast;
wire [ID_WIDTH-1:0] output_1_axis_tid;
wire [DEST_WIDTH-1:0] output_1_axis_tdest;
wire [USER_WIDTH-1:0] output_1_axis_tuser;
wire [DATA_WIDTH-1:0] output_2_axis_tdata;
wire [KEEP_WIDTH-1:0] output_2_axis_tkeep;
wire output_2_axis_tvalid;
wire output_2_axis_tlast;
wire [ID_WIDTH-1:0] output_2_axis_tid;
wire [DEST_WIDTH-1:0] output_2_axis_tdest;
wire [USER_WIDTH-1:0] output_2_axis_tuser;
wire [DATA_WIDTH-1:0] output_3_axis_tdata;
wire [KEEP_WIDTH-1:0] output_3_axis_tkeep;
wire output_3_axis_tvalid;
wire output_3_axis_tlast;
wire [ID_WIDTH-1:0] output_3_axis_tid;
wire [DEST_WIDTH-1:0] output_3_axis_tdest;
wire [USER_WIDTH-1:0] output_3_axis_tuser;
initial begin initial begin
// myhdl integration // myhdl integration
@ -118,68 +75,23 @@ initial begin
clk, clk,
rst, rst,
current_test, current_test,
input_0_axis_tdata, s_axis_tdata,
input_0_axis_tkeep, s_axis_tkeep,
input_0_axis_tvalid, s_axis_tvalid,
input_0_axis_tlast, s_axis_tlast,
input_0_axis_tid, s_axis_tid,
input_0_axis_tdest, s_axis_tdest,
input_0_axis_tuser, s_axis_tuser,
input_1_axis_tdata, select
input_1_axis_tkeep,
input_1_axis_tvalid,
input_1_axis_tlast,
input_1_axis_tid,
input_1_axis_tdest,
input_1_axis_tuser,
input_2_axis_tdata,
input_2_axis_tkeep,
input_2_axis_tvalid,
input_2_axis_tlast,
input_2_axis_tid,
input_2_axis_tdest,
input_2_axis_tuser,
input_3_axis_tdata,
input_3_axis_tkeep,
input_3_axis_tvalid,
input_3_axis_tlast,
input_3_axis_tid,
input_3_axis_tdest,
input_3_axis_tuser,
output_0_select,
output_1_select,
output_2_select,
output_3_select
); );
$to_myhdl( $to_myhdl(
output_0_axis_tdata, m_axis_tdata,
output_0_axis_tkeep, m_axis_tkeep,
output_0_axis_tvalid, m_axis_tvalid,
output_0_axis_tlast, m_axis_tlast,
output_0_axis_tid, m_axis_tid,
output_0_axis_tdest, m_axis_tdest,
output_0_axis_tuser, m_axis_tuser
output_1_axis_tdata,
output_1_axis_tkeep,
output_1_axis_tvalid,
output_1_axis_tlast,
output_1_axis_tid,
output_1_axis_tdest,
output_1_axis_tuser,
output_2_axis_tdata,
output_2_axis_tkeep,
output_2_axis_tvalid,
output_2_axis_tlast,
output_2_axis_tid,
output_2_axis_tdest,
output_2_axis_tuser,
output_3_axis_tdata,
output_3_axis_tkeep,
output_3_axis_tvalid,
output_3_axis_tlast,
output_3_axis_tid,
output_3_axis_tdest,
output_3_axis_tuser
); );
// dump file // dump file
@ -187,7 +99,9 @@ initial begin
$dumpvars(0, test_axis_crosspoint_4x4_64); $dumpvars(0, test_axis_crosspoint_4x4_64);
end end
axis_crosspoint_4x4 #( axis_crosspoint #(
.S_COUNT(S_COUNT),
.M_COUNT(M_COUNT),
.DATA_WIDTH(DATA_WIDTH), .DATA_WIDTH(DATA_WIDTH),
.KEEP_ENABLE(KEEP_ENABLE), .KEEP_ENABLE(KEEP_ENABLE),
.KEEP_WIDTH(KEEP_WIDTH), .KEEP_WIDTH(KEEP_WIDTH),
@ -203,68 +117,23 @@ UUT (
.clk(clk), .clk(clk),
.rst(rst), .rst(rst),
// AXI inputs // AXI inputs
.input_0_axis_tdata(input_0_axis_tdata), .s_axis_tdata(s_axis_tdata),
.input_0_axis_tkeep(input_0_axis_tkeep), .s_axis_tkeep(s_axis_tkeep),
.input_0_axis_tvalid(input_0_axis_tvalid), .s_axis_tvalid(s_axis_tvalid),
.input_0_axis_tlast(input_0_axis_tlast), .s_axis_tlast(s_axis_tlast),
.input_0_axis_tid(input_0_axis_tid), .s_axis_tid(s_axis_tid),
.input_0_axis_tdest(input_0_axis_tdest), .s_axis_tdest(s_axis_tdest),
.input_0_axis_tuser(input_0_axis_tuser), .s_axis_tuser(s_axis_tuser),
.input_1_axis_tdata(input_1_axis_tdata), // AXI output
.input_1_axis_tkeep(input_1_axis_tkeep), .m_axis_tdata(m_axis_tdata),
.input_1_axis_tvalid(input_1_axis_tvalid), .m_axis_tkeep(m_axis_tkeep),
.input_1_axis_tlast(input_1_axis_tlast), .m_axis_tvalid(m_axis_tvalid),
.input_1_axis_tid(input_1_axis_tid), .m_axis_tlast(m_axis_tlast),
.input_1_axis_tdest(input_1_axis_tdest), .m_axis_tid(m_axis_tid),
.input_1_axis_tuser(input_1_axis_tuser), .m_axis_tdest(m_axis_tdest),
.input_2_axis_tdata(input_2_axis_tdata), .m_axis_tuser(m_axis_tuser),
.input_2_axis_tkeep(input_2_axis_tkeep),
.input_2_axis_tvalid(input_2_axis_tvalid),
.input_2_axis_tlast(input_2_axis_tlast),
.input_2_axis_tid(input_2_axis_tid),
.input_2_axis_tdest(input_2_axis_tdest),
.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),
.input_3_axis_tlast(input_3_axis_tlast),
.input_3_axis_tid(input_3_axis_tid),
.input_3_axis_tdest(input_3_axis_tdest),
.input_3_axis_tuser(input_3_axis_tuser),
// AXI outputs
.output_0_axis_tdata(output_0_axis_tdata),
.output_0_axis_tkeep(output_0_axis_tkeep),
.output_0_axis_tvalid(output_0_axis_tvalid),
.output_0_axis_tlast(output_0_axis_tlast),
.output_0_axis_tid(output_0_axis_tid),
.output_0_axis_tdest(output_0_axis_tdest),
.output_0_axis_tuser(output_0_axis_tuser),
.output_1_axis_tdata(output_1_axis_tdata),
.output_1_axis_tkeep(output_1_axis_tkeep),
.output_1_axis_tvalid(output_1_axis_tvalid),
.output_1_axis_tlast(output_1_axis_tlast),
.output_1_axis_tid(output_1_axis_tid),
.output_1_axis_tdest(output_1_axis_tdest),
.output_1_axis_tuser(output_1_axis_tuser),
.output_2_axis_tdata(output_2_axis_tdata),
.output_2_axis_tkeep(output_2_axis_tkeep),
.output_2_axis_tvalid(output_2_axis_tvalid),
.output_2_axis_tlast(output_2_axis_tlast),
.output_2_axis_tid(output_2_axis_tid),
.output_2_axis_tdest(output_2_axis_tdest),
.output_2_axis_tuser(output_2_axis_tuser),
.output_3_axis_tdata(output_3_axis_tdata),
.output_3_axis_tkeep(output_3_axis_tkeep),
.output_3_axis_tvalid(output_3_axis_tvalid),
.output_3_axis_tlast(output_3_axis_tlast),
.output_3_axis_tid(output_3_axis_tid),
.output_3_axis_tdest(output_3_axis_tdest),
.output_3_axis_tuser(output_3_axis_tuser),
// Control // Control
.output_0_select(output_0_select), .select(select)
.output_1_select(output_1_select),
.output_2_select(output_2_select),
.output_3_select(output_3_select)
); );
endmodule endmodule