Skip to content
Snippets Groups Projects
Commit 31be1f04 authored by Maciej Lipinski's avatar Maciej Lipinski
Browse files

swcore[generic-azing]: generic simulation (for any number of ports) works,...

swcore[generic-azing]: generic simulation (for any number of ports) works, cleaned up, added README to testbenches, changed names to add clarity to the naming
parent 4e5db41e
Branches
Tags
No related merge requests found
Showing
with 104 additions and 6012 deletions
This diff is collapsed.
-------------------------------------------------------------------------------
-- Title : Lost Pck Deallocator
-- Project : WhiteRabbit switch
-------------------------------------------------------------------------------
-- File : swc_lost_pck_dealloc.vhd
-- Author : Maciej Lipinski
-- Company : CERN BE-Co-HT
-- Created : 2010-11-15
-- Last update: 2012-02-02
-- Platform : FPGA-generic
-- Standard : VHDL'87
-------------------------------------------------------------------------------
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -
--
--
-------------------------------------------------------------------------------
--
-- Copyright (c) 2010 Maciej Lipinski / CERN
--
-- This source file is free software; you can redistribute it
-- and/or modify it under the terms of the GNU Lesser General
-- Public License as published by the Free Software Foundation;
-- either version 2.1 of the License, or (at your option) any
-- later version.
--
-- This source is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the GNU Lesser General Public License for more
-- details.
--
-- You should have received a copy of the GNU Lesser General
-- Public License along with this source; if not, download it
-- from http://www.gnu.org/licenses/lgpl-2.1.html
--
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2010-11-15 1.0 mlipinsk Created
-- 2012-02-02 2.0 mlipinsk generic-azed
-------------------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
library work;
--use work.swc_swcore_pkg.all;
use work.genram_pkg.all;
entity swc_lost_pck_dealloc is
generic (
g_page_addr_width : integer --:= c_swc_page_addr_width;
);
port (
clk_i : in std_logic;
rst_n_i : in std_logic;
ib_force_free_i : in std_logic;
ib_force_free_done_o : out std_logic;
ib_force_free_pgaddr_i : in std_logic_vector(g_page_addr_width - 1 downto 0);
ob_force_free_i : in std_logic;
ob_force_free_done_o : out std_logic;
ob_force_free_pgaddr_i : in std_logic_vector(g_page_addr_width - 1 downto 0);
ll_read_addr_o : out std_logic_vector(g_page_addr_width -1 downto 0);
ll_read_data_i : in std_logic_vector(g_page_addr_width - 1 downto 0);
ll_read_req_o : out std_logic;
ll_read_valid_data_i : in std_logic;
mmu_force_free_o : out std_logic;
mmu_force_free_done_i : in std_logic;
mmu_force_free_pgaddr_o : out std_logic_vector(g_page_addr_width -1 downto 0)
);
end swc_lost_pck_dealloc;
architecture syn of swc_lost_pck_dealloc is
type t_state is (S_IDLE,
S_REQ_READ_FIFO,
S_READ_FIFO,
S_READ_NEXT_PAGE_ADDR,
S_FREE_CURRENT_PAGE_ADDR
);
signal state : t_state;
signal ib_force_free_done : std_logic;
signal ob_force_free_done : std_logic;
signal fifo_wr : std_logic;
signal fifo_data_in : std_logic_vector(g_page_addr_width - 1 downto 0);
signal fifo_full : std_logic;
signal fifo_empty : std_logic;
signal fifo_data_out : std_logic_vector(g_page_addr_width - 1 downto 0);
signal fifo_rd : std_logic;
signal fifo_clean : std_logic;
signal current_page : std_logic_vector(g_page_addr_width - 1 downto 0);
signal next_page : std_logic_vector(g_page_addr_width - 1 downto 0);
signal ll_read_req : std_logic;
signal mmu_force_free : std_logic;
signal ones : std_logic_vector(g_page_addr_width - 1 downto 0);
begin -- syn
ones <= (others => '1');
INPUT: process(clk_i, rst_n_i)
begin
if rising_edge(clk_i) then
if(rst_n_i = '0') then
ib_force_free_done <= '0';
ob_force_free_done <= '0';
fifo_wr <= '0';
fifo_data_in <= (others => '0');
else
-- serve Input request, unless it's already served ( ib_force_free_done = '1')
if(ib_force_free_i = '1' and fifo_full = '0' and ib_force_free_done = '0') then
fifo_wr <= '1';
fifo_data_in <= ib_force_free_pgaddr_i;
ib_force_free_done <= '1';
ob_force_free_done <= '0';
elsif(ob_force_free_done = '1' and fifo_full = '0') then
fifo_wr <= '1';
fifo_data_in <= ob_force_free_pgaddr_i;
ob_force_free_done <= '1';
ib_force_free_done <= '0';
else
fifo_wr <= '0';
fifo_data_in <= (others => '0');
ib_force_free_done <= '0';
ob_force_free_done <= '0';
end if;
end if;
end if;
end process;
U_FIFO: generic_sync_fifo
generic map(
g_data_width => g_page_addr_width,
g_size => 16
)
port map (
clk_i => clk_i,
rst_n_i => rst_n_i,
we_i => fifo_wr,
d_i => fifo_data_in,
rd_i => fifo_rd,
q_o => fifo_data_out,
empty_o => fifo_empty,
full_o => fifo_full,
count_o => open
);
fsm_force_free : process(clk_i, rst_n_i)
begin
if rising_edge(clk_i) then
if(rst_n_i = '0') then
--================================================
state <= S_IDLE;
fifo_rd <= '0';
current_page <= (others => '0');
next_page <= (others => '0');
ll_read_req <= '0';
mmu_force_free <= '0';
--================================================
else
-- main finite state machine
case state is
when S_IDLE =>
fifo_rd <= '0';
mmu_force_free <= '0';
if(fifo_empty = '0') then
fifo_rd <= '1';
state <= S_REQ_READ_FIFO;
end if;
when S_REQ_READ_FIFO =>
fifo_rd <= '0';
state <= S_READ_FIFO;
when S_READ_FIFO =>
current_page <= fifo_data_out;
ll_read_req <= '1';
state <= S_READ_NEXT_PAGE_ADDR;
when S_READ_NEXT_PAGE_ADDR =>
if(ll_read_valid_data_i = '1') then
ll_read_req <= '0';
state <= S_FREE_CURRENT_PAGE_ADDR;
next_page <= ll_read_data_i;
mmu_force_free <= '1';
end if;
when S_FREE_CURRENT_PAGE_ADDR =>
if(mmu_force_free_done_i = '1') then
mmu_force_free <= '0';
if(next_page = ones ) then
state <= S_IDLE;
else
current_page <= next_page;
ll_read_req <= '1';
state <= S_READ_NEXT_PAGE_ADDR;
end if;
end if;
when others =>
state <= S_IDLE;
fifo_rd <= '0';
current_page <= (others => '0');
next_page <= (others => '0');
ll_read_req <= '0';
mmu_force_free <= '0';
end case;
end if;
end if;
end process;
ll_read_addr_o <= current_page;
ll_read_req_o <= ll_read_req;
mmu_force_free_pgaddr_o <= current_page;
mmu_force_free_o <= mmu_force_free;
ib_force_free_done_o <= ib_force_free_done;
ob_force_free_done_o <= ob_force_free_done;
end syn;
This diff is collapsed.
......@@ -6,11 +6,11 @@ action = "simulation"
#files = "swc_core.v4.sv"
files = [
"xswc_core_7_ports_wrapper.vhd",
"xswcore_wrapper.svh",
"xswc_core.sv",
"xswcore_wrapper.v2.svh",
"xswc_core.v2.sv"
"swc_core_wrapper_7ports.vhd",
"xswc_core_wrapper_7ports.svh",
"swc_core_7ports.sv",
"swc_core_wrapper_generic.svh",
"swc_core_generic.sv"
]
#vlog_opt="+incdir+../../../sim "
......
-------------------------------------------------------------------------------
-- Title : README on testbenches
-- Project : WhiteRabbit switch
-------------------------------------------------------------------------------
-- File : README
-- Author : Maciej Lipinski
-- Company : CERN BE-Co-HT
-- Created : 2012-02-07
-- Last update: 2012-02-07
-- Platform : FPGA-generic
-- Standard : VHDL'87
-------------------------------------------------------------------------------
-- Description:
-------------------------------------------------------------------------------
-- Revisions :
-- Date Version Author Description
-- 2012-01-15 1.0 mlipinsk Created
-------------------------------------------------------------------------------
Currently used testbenches:
1. Generic
- it can be used for any number of ports, the number of ports is defined in swc_param_defs.svh
- it uses the parameters (i.e. number of ports) defined in swc_param_defs.svh
- simulate with: vsim main_generic
swc_core_generic.sv
|-> swc_core_wrapper_generic.svh
|-> swc_core.vhd
2. 7 ports
- it simulates swcore configured for 7 ports
- it uses hand made wrapper
- simulat with: vsim main_7ports
swc_core_7ports.sv
|->xswc_core_wrapper_7ports.svh
|->swc_core_wrapper_7ports.vhd
|->xswc_core.vhd
Currently unused testbenches [not tested if work]: all the rest (they might be useful for further
single components verification and tests later)
\ No newline at end of file
This diff is collapsed.
This diff is collapsed.
// Fabric emulator example, showing 2 fabric emulators connected together and exchanging packets.
`define c_clock_period 8
`define c_swc_page_addr_width 10
`define c_swc_usecount_width 4
`define c_wrsw_prio_width 3
`define c_swc_ctrl_width 4
`define c_swc_data_width 16
`define c_wrsw_num_ports 11
`timescale 1ns / 1ps
`include "fabric_emu.sv"
`define array_copy(a, ah, al, b, bl) \
for (k=al; k<=ah; k=k+1) a[k] <= b[bl+k-al];
module main;
reg clk = 0;
reg rst_n = 0;
//`WRF_WIRES(a_to_input_block); // Emu A to B fabric
wire [`c_wrsw_num_ports * 16- 1:0] a_to_input_block_data;
wire [`c_wrsw_num_ports * 4 - 1:0] a_to_input_block_ctrl;
// wire [`c_wrsw_num_ports - 1:0][15:0] a_to_input_block_data;
// wire [`c_wrsw_num_ports - 1:0][3 :0] a_to_input_block_ctrl;
wire [`c_wrsw_num_ports-1:0] a_to_input_block_bytesel;
wire [`c_wrsw_num_ports-1:0] a_to_input_block_dreq;
wire [`c_wrsw_num_ports-1:0] a_to_input_block_valid;
wire [`c_wrsw_num_ports-1:0] a_to_input_block_sof_p1;
wire [`c_wrsw_num_ports-1:0] a_to_input_block_eof_p1;
wire [`c_wrsw_num_ports-1:0] a_to_input_block_rerror_p1;
wire [`c_wrsw_num_ports-1:0] a_to_input_block_abort_p1;
wire [`c_wrsw_num_ports-1:0] a_to_input_block_terror_p1;
wire [`c_wrsw_num_ports-1:0] a_to_input_block_tabort_p1;
wire [`c_wrsw_num_ports * 16- 1:0] input_block_to_a_data;
wire [`c_wrsw_num_ports * 4 - 1:0] input_block_to_a_ctrl;
// wire [`c_wrsw_num_ports - 1:0][15:0] input_block_to_a_data;
// wire [`c_wrsw_num_ports:0][3 :0] input_block_to_a_ctrl;
wire [`c_wrsw_num_ports-1:0] input_block_to_a_bytesel;
wire [`c_wrsw_num_ports-1:0] input_block_to_a_dreq;
wire [`c_wrsw_num_ports-1:0] input_block_to_a_valid;
wire [`c_wrsw_num_ports-1:0] input_block_to_a_sof_p1;
wire [`c_wrsw_num_ports-1:0] input_block_to_a_eof_p1;
wire [`c_wrsw_num_ports-1:0] input_block_to_a_rerror_p1;
wire [`c_wrsw_num_ports-1:0] input_block_to_a_idle;
wire [`c_wrsw_num_ports-1:0] input_block_to_a_terror_p1;
wire [`c_wrsw_num_ports-1:0] input_block_to_a_tabort_p1;
`WRF_WIRES(ab); // Emu A to B fabric
`WRF_WIRES(ba); // And the other way around
// `WRF_PORTS_SINK_ARRAY(dupa);
reg [`c_wrsw_num_ports-1:0] rtu_rsp_valid = 0;
wire [`c_wrsw_num_ports-1:0] rtu_rsp_ack;
reg [`c_wrsw_num_ports * `c_wrsw_num_ports - 1 : 0] rtu_dst_port_mask = 0;
reg [`c_wrsw_num_ports-1:0] rtu_drop = 0;
reg [`c_wrsw_num_ports * `c_wrsw_prio_width -1 : 0] rtu_prio = 0;
// generate clock and reset signals
always #(`c_clock_period/2) clk <= ~clk;
initial begin
repeat(3) @(posedge clk);
rst_n = 1;
end
integer ports_read = 0;
swc_core
DUT (
.clk_i (clk),
.rst_n_i (rst_n),
//-------------------------------------------------------------------------------
//-- Fabric I/F
//-------------------------------------------------------------------------------
.tx_sof_p1_i (a_to_input_block_sof_p1),
.tx_eof_p1_i (a_to_input_block_eof_p1),
.tx_data_i (a_to_input_block_data),
.tx_ctrl_i (a_to_input_block_ctrl),
.tx_valid_i (a_to_input_block_valid),
.tx_bytesel_i (a_to_input_block_bytesel),
.tx_dreq_o (a_to_input_block_dreq),
.tx_abort_p1_i (a_to_input_block_abort_p1),
.tx_rerror_p1_i (a_to_input_block_rerror_p1),
//-------------------------------------------------------------------------------
//-- Fabric I/F : output (goes to the Endpoint)
//-------------------------------------------------------------------------------
.rx_sof_p1_o (input_block_to_a_sof_p1),
.rx_eof_p1_o (input_block_to_a_eof_p1),
.rx_dreq_i (input_block_to_a_dreq),
.rx_ctrl_o (input_block_to_a_ctrl),
.rx_data_o (input_block_to_a_data),
.rx_valid_o (input_block_to_a_valid),
.rx_bytesel_o (input_block_to_a_bytesel),
.rx_idle_o (input_block_to_a_idle),
.rx_rerror_p1_o (input_block_to_a_rerror_p1),
.rx_terror_p1_i (input_block_to_a_terror_p1),
.rx_tabort_p1_i (input_block_to_a_tabort_p1),// tx_rabort_p1_i ????????
//-------------------------------------------------------------------------------
//-- I/F with Routing Table Unit (RTU)
//-------------------------------------------------------------------------------
.rtu_rsp_valid_i (rtu_rsp_valid),
.rtu_rsp_ack_o (rtu_rsp_ack),
.rtu_dst_port_mask_i (rtu_dst_port_mask),
.rtu_drop_i (rtu_drop),
.rtu_prio_i (rtu_prio)
);
task wait_cycles;
input [31:0] ncycles;
begin : wait_body
integer i;
for(i=0;i<ncycles;i=i+1) @(posedge clk);
end
endtask // wait_cycles
fabric_emu test_input_block_0
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_CONNECT_SOURCE_ML(rx, a_to_input_block,0),
/*
.rx_data_o (a_to_input_block_data[15:0]),
.rx_ctrl_o (a_to_input_block_ctrl[15:0]),
.rx_bytesel_o (a_to_input_block_bytesel[0]),
.rx_dreq_i (a_to_input_block_dreq[0]),
.rx_valid_o (a_to_input_block_valid[0]),
.rx_sof_p1_o (a_to_input_block_sof_p1[0]),
.rx_eof_p1_o (a_to_input_block_eof_p1[0]),
.rx_rerror_p1_o (a_to_input_block_rerror_p1[0]),
.rx_terror_p1_i (1'b0),
.rx_tabort_p1_o (),
.rx_rabort_p1_i (1'b0),
.rx_idle_o (),
*/
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,0)
/*
.tx_data_i (input_block_to_a_data[15:0]),
.tx_ctrl_i (input_block_to_a_ctrl[15:0]),
.tx_bytesel_i (input_block_to_a_bytesel[0]),
.tx_dreq_o (input_block_to_a_dreq[0]),
.tx_valid_i (input_block_to_a_valid[0]),
.tx_sof_p1_i (input_block_to_a_sof_p1[0]),
.tx_eof_p1_i (input_block_to_a_eof_p1[0]),
.tx_rerror_p1_i (input_block_to_a_rerror_p1[0]),
.tx_terror_p1_o (input_block_to_a_terror_p1[0]),
.tx_rabort_p1_o (input_block_to_a_rabort_p1[0]),
.tx_idle_i (input_block_to_a_idle[0])
*/
);
fabric_emu test_input_block_1
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,1),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,1)
);
fabric_emu test_input_block_2
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,2),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,2)
);
fabric_emu test_input_block_3
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,3),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,3)
);
fabric_emu test_input_block_4
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,4),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,4)
);
fabric_emu test_input_block_5
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,5),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,5)
);
fabric_emu test_input_block_6
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,6),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,6)
);
fabric_emu test_input_block_7
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,7),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,7)
);
fabric_emu test_input_block_8
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,8),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,8)
);
fabric_emu test_input_block_9
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,9),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,9)
);
fabric_emu test_input_block_10
(
.clk_i(clk),
.rst_n_i(rst_n),
`WRF_FULL_CONNECT_SOURCE_ML(rx, a_to_input_block,10),
`WRF_FULL_CONNECT_SINK_ML(tx, input_block_to_a,10)
);
task set_rtu_rsp;
input [31:0] chan;
input valid;
input drop;
input [`c_wrsw_num_ports - 1:0] prio;
input [`c_wrsw_num_ports - 1:0] mask;
begin : wait_body
integer i;
integer k; // for the macro array_copy()
`array_copy(rtu_dst_port_mask,(chan+1)*`c_wrsw_num_ports - 1, chan*`c_wrsw_num_ports, mask ,0);
`array_copy(rtu_prio ,(chan+1)*`c_wrsw_prio_width - 1, chan*`c_wrsw_prio_width, prio, 0);
rtu_drop [ chan ] = drop;
rtu_rsp_valid [ chan ] = valid;
end
endtask // wait_cycles
task send_pck;
input ether_header_t hdr;
input int payload[];
input int length;
input [31:0] port;
input drop;
input [`c_wrsw_num_ports - 1:0] prio;
input [`c_wrsw_num_ports - 1:0] mask;
begin : send_pck_body
set_rtu_rsp(port,1,drop,prio,mask);
$display("Sending: port = %d, len = %d, drop = %d, prio = %d, mask = %x",port,length, drop, prio, mask);
case(port)
0: test_input_block_0.send(hdr, payload, length);
1: test_input_block_1.send(hdr, payload, length);
2: test_input_block_2.send(hdr, payload, length);
3: test_input_block_3.send(hdr, payload, length);
4: test_input_block_4.send(hdr, payload, length);
5: test_input_block_5.send(hdr, payload, length);
6: test_input_block_6.send(hdr, payload, length);
7: test_input_block_7.send(hdr, payload, length);
8: test_input_block_8.send(hdr, payload, length);
9: test_input_block_9.send(hdr, payload, length);
10:test_input_block_10.send(hdr, payload, length);
default: $display("ERROR: Wrong port number !!!");
endcase
end
endtask
initial begin
ether_header_t hdr;
int buffer[1024];
int i;
int port = 0;
wait(test_input_block_0.ready);
wait(test_input_block_1.ready);
wait(test_input_block_2.ready);
wait(test_input_block_3.ready);
wait(test_input_block_4.ready);
wait(test_input_block_5.ready);
wait(test_input_block_6.ready);
wait(test_input_block_7.ready);
wait(test_input_block_8.ready);
wait(test_input_block_9.ready);
wait(test_input_block_10.ready);
ports_read = 1;
hdr.src = 'h123456789abcdef;
hdr.dst = 'hcafeb1badeadbef;
hdr.ethertype = 1234;
hdr.is_802_1q = 0;
hdr.oob_type = `OOB_TYPE_RXTS;
hdr.timestamp_r = 10000;
hdr.timestamp_f = 4;
for(i=0;i<2000;i++)
buffer[i] = i;
//input ether_header_t hdr,
//input int payload[],
//input int length
//input [31:0] port;
//input drop;
//input [`c_wrsw_num_ports - 1:0] prio;
//input [`c_wrsw_num_ports - 1:0] mask;
wait_cycles(50);
//////////////// input port = 0 ////////////////
hdr.src = 'h123456789abcde0;
hdr.dst = 'hcafeb1badeadbe0;
for(i=200;i<1250;i=i+50)
begin
hdr.src = port;
hdr.port_id = port;
hdr.ethertype = i;
send_pck(hdr,buffer, i, port, (i/50)%20, (i/50)%7,(i/50)%11);
if(port == 3)
port = 0;
else
port++;
end
end
initial begin
ether_header_t hdr;
int buffer[1024];
int i;
int port = 4;
wait(ports_read);
hdr.src = 'h123456789abcdef;
hdr.dst = 'hcafeb1badeadbef;
hdr.ethertype = 1234;
hdr.is_802_1q = 0;
hdr.oob_type = `OOB_TYPE_RXTS;
hdr.timestamp_r = 10000;
hdr.timestamp_f = 4;
hdr.port_id = 5;
for(i=0;i<2000;i++)
buffer[i] = i;
//input ether_header_t hdr,
//input int payload[],
//input int length
//input [31:0] port;
//input drop;
//input [`c_wrsw_num_ports - 1:0] prio;
//input [`c_wrsw_num_ports - 1:0] mask;
wait_cycles(50);
//////////////// input port = 0 ////////////////
hdr.src = 'h123456789abcde0;
hdr.dst = 'hcafeb1badeadbe0;
for(i=200;i<1250;i=i+50)
begin
hdr.src = port;
hdr.port_id = port;
hdr.ethertype = i;
send_pck(hdr,buffer, i, port, (i/50)%20, (i/50)%7,(i/50)%11);
if(port == 7)
port = 4;
else
port++;
end
end
initial begin
ether_header_t hdr;
int buffer[1024];
int i;
int port = 8;
wait(ports_read);
hdr.src = 'h123456789abcdef;
hdr.dst = 'hcafeb1badeadbef;
hdr.ethertype = 1234;
hdr.is_802_1q = 0;
hdr.oob_type = `OOB_TYPE_RXTS;
hdr.timestamp_r = 10000;
hdr.timestamp_f = 4;
hdr.port_id = 5;
for(i=0;i<2000;i++)
buffer[i] = i;
//input ether_header_t hdr,
//input int payload[],
//input int length
//input [31:0] port;
//input drop;
//input [`c_wrsw_num_ports - 1:0] prio;
//input [`c_wrsw_num_ports - 1:0] mask;
wait_cycles(50);
//////////////// input port = 0 ////////////////
hdr.src = 'h123456789abcde0;
hdr.dst = 'hcafeb1badeadbe0;
for(i=200;i<1250;i=i+50)
begin
hdr.src = port;
hdr.port_id = port;
hdr.ethertype = i;
send_pck(hdr,buffer, i, port, (i/50)%20, (i/50)%7,(i/50)%11);
if(port == 10)
port = 8;
else
port++;
end
end
//////////////////////////////////////////////////////////
always @(posedge clk) if (rtu_rsp_ack != 0)
begin
rtu_rsp_valid = rtu_rsp_valid & !rtu_rsp_ack;
rtu_drop = rtu_drop & !rtu_rsp_ack;
end
// Check if there's anything received by EMU B
always @(posedge clk) if (test_input_block_0.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 0!");
test_input_block_0.receive(frame);
dump_frame_header("Receiving RX_0: ", frame);
end
always @(posedge clk) if (test_input_block_1.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 1!");
test_input_block_1.receive(frame);
dump_frame_header("Receiving RX_1: ", frame);
end
always @(posedge clk) if (test_input_block_2.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 2!");
test_input_block_2.receive(frame);
dump_frame_header("Receiving RX_2: ", frame);
end
always @(posedge clk) if (test_input_block_3.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 3!");
test_input_block_3.receive(frame);
dump_frame_header("Receiving RX_3: ", frame);
end
always @(posedge clk) if (test_input_block_4.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 4!");
test_input_block_4.receive(frame);
dump_frame_header("Receiving RX_4: ", frame);
end
always @(posedge clk) if (test_input_block_5.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 5!");
test_input_block_5.receive(frame);
dump_frame_header("Receiving RX_5: ", frame);
end
always @(posedge clk) if (test_input_block_6.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 6!");
test_input_block_6.receive(frame);
dump_frame_header("Receiving RX_6: ", frame);
end
always @(posedge clk) if (test_input_block_7.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 7!");
test_input_block_7.receive(frame);
dump_frame_header("Receiving RX_7: ", frame);
end
always @(posedge clk) if (test_input_block_8.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 8!");
test_input_block_8.receive(frame);
dump_frame_header("Receiving RX_8: ", frame);
end
always @(posedge clk) if (test_input_block_9.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 9!");
test_input_block_9.receive(frame);
dump_frame_header("Receiving RX_9: ", frame);
end
always @(posedge clk) if (test_input_block_10.poll())
begin
ether_frame_t frame;
// $display("Emulator test received a frame on port 10!");
test_input_block_10.receive(frame);
dump_frame_header("Receiving RX_10: ", frame);
end
endmodule // main
This diff is collapsed.
......@@ -16,7 +16,7 @@
`include "wb_packet_source.svh"
`include "wb_packet_sink.svh"
`include "xswcore_wrapper.svh"
`include "xswc_core_wrapper_7ports.svh"
typedef struct {
......@@ -39,7 +39,7 @@ int pg_dealloc_cnt[1024][20];
EthPacket swc_matrix[`c_wrsw_num_ports][`c_n_pcks_to_send];
module main;
module main_7ports;
......@@ -93,8 +93,8 @@ module main;
xswcore_wrapper
DUT_xswcore_wrapper (
xswc_core_wrapper_7ports
DUT_xswc_core_wrapper(
.clk_i (clk),
.rst_n_i (rst_n),
//-------------------------------------------------------------------------------
......@@ -524,22 +524,22 @@ wait_cycles(80000);
///////// Monitoring allocation of pages /////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
// always @(posedge clk) if(DUT.memory_management_unit.pg_addr_valid)
always @(posedge clk) if(DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_alloc & DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_done)
always @(posedge clk) if(DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_alloc & DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_done)
begin
int address;
int usecnt;
usecnt = DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_usecnt;
usecnt = DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_usecnt;
wait(DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_addr_valid);
wait(DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_addr_valid);
address = DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_addr_alloc;
address = DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_addr_alloc;
pg_alloc_cnt[address][pg_alloc_cnt[address][0]+1]= usecnt;
pg_alloc_cnt[address][0]++;
alloc_table[address].usecnt[alloc_table[address].cnt] = usecnt;
alloc_table[address].port[alloc_table[address].cnt] = DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.in_sel;
alloc_table[address].port[alloc_table[address].cnt] = DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.in_sel;
alloc_table[address].cnt++;
......@@ -551,11 +551,11 @@ wait_cycles(80000);
///////// Monitoring deallocation of pages /////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
always @(posedge clk) if(DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.alloc_core.tmp_dbg_dealloc)
always @(posedge clk) if(DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.alloc_core.tmp_dbg_dealloc)
begin
int address;
address = DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.alloc_core.tmp_page;
address = DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.alloc_core.tmp_page;
pg_dealloc_cnt[address][0]++;
......@@ -569,14 +569,14 @@ wait_cycles(80000);
///////// Monitoring freeing of pages /////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
always @(posedge clk) if(DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_free & DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_done)
always @(posedge clk) if(DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_free & DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_done)
begin
int address;
int port_mask;
int port;
port = DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.in_sel;
address = DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_addr;
port = DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.in_sel;
address = DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_addr;
port_mask = dealloc_table[address].port[dealloc_table[address].cnt ] ;
pg_dealloc_cnt[address][pg_dealloc_cnt[address][0] + 1]++;
......@@ -592,15 +592,15 @@ wait_cycles(80000);
///////// Monitoring setting of pages' usecnt /////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////////////////////////////
always @(posedge clk) if(DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_set_usecnt & DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_done)
always @(posedge clk) if(DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_set_usecnt & DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_done)
begin
int address;
address = DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_addr;
address = DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_addr;
pg_alloc_cnt[address][pg_alloc_cnt[address][0] + 1] = DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_usecnt;
pg_alloc_cnt[address][pg_alloc_cnt[address][0] + 1] = DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_usecnt;
alloc_table[address].usecnt[alloc_table[address].cnt - 1] = DUT_xswcore_wrapper.DUT_xswc_core_7_ports_wrapper.u_xswc_core.u_swc_core.memory_management_unit.pg_usecnt;;
alloc_table[address].usecnt[alloc_table[address].cnt - 1] = DUT_xswc_core_wrapper.DUT_swc_core_7ports_wrapper.U_xswc_core.memory_management_unit.pg_usecnt;;
end
......
......@@ -9,7 +9,7 @@
`include "wb_packet_source.svh"
`include "wb_packet_sink.svh"
`include "xswcore_wrapper.v2.svh"
`include "swc_core_wrapper_generic.svh"
`include "swc_param_defs.svh" // all swcore parameters here
`define DBG_ALLOC //if defined, the allocation debugging is active: we track the number of allocated
......@@ -33,7 +33,7 @@ int pg_dealloc_cnt[1024][2*`c_num_ports];
EthPacket swc_matrix[`c_num_ports][`c_n_pcks_to_send];
module main_v2;
module main_generic;
reg clk = 1'b0;
reg rst_n = 1'b0;
......@@ -72,7 +72,7 @@ module main_v2;
integer n_packets_to_send = `c_n_pcks_to_send;
integer dbg = 1;
xswcore_wrapper_v2
swc_core_wrapper_generic
DUT_xswcore_wrapper (
.clk_i (clk),
.rst_n_i (rst_n),
......
This diff is collapsed.
......@@ -2,11 +2,11 @@
-- Title : Switch Core V3
-- Project : WhiteRabbit switch
-------------------------------------------------------------------------------
-- File : xswc_core.vhd
-- File : swc_core_wrapper_7ports.vhd
-- Author : Maciej Lipinski
-- Company : CERN BE-Co-HT
-- Created : 2012-01-15
-- Last update: 2012-01-15
-- Last update: 2012-02-07
-- Platform : FPGA-generic
-- Standard : VHDL'87
-------------------------------------------------------------------------------
......@@ -38,6 +38,7 @@
-- Revisions :
-- Date Version Author Description
-- 2012-01-15 1.0 mlipinsk Created
-- 2012-02-07 1.1 mlipinsk changed name
-------------------------------------------------------------------------------
......@@ -50,7 +51,7 @@ use work.swc_swcore_pkg.all;
use work.wr_fabric_pkg.all;
use work.wrsw_shared_types_pkg.all;
entity xswc_core_7_ports_wrapper is
entity swc_core_wrapper_7ports is
generic
(
g_swc_num_ports : integer := 7;
......@@ -232,44 +233,10 @@ entity xswc_core_7_ports_wrapper is
rtu_prio_i : in std_logic_vector(g_swc_num_ports * g_swc_prio_width - 1 downto 0)
);
end xswc_core_7_ports_wrapper;
end swc_core_wrapper_7ports;
architecture rtl of xswc_core_7_ports_wrapper is
architecture rtl of swc_core_wrapper_7ports is
component xswc_core is
generic
(
g_num_ports : integer := g_swc_num_ports
);
port (
clk_i : in std_logic;
rst_n_i : in std_logic;
-------------------------------------------------------------------------------
-- Fabric I/F : input (comes from the Endpoint)
-------------------------------------------------------------------------------
snk_i : in t_wrf_sink_in_array(g_num_ports-1 downto 0);
snk_o : out t_wrf_sink_out_array(g_num_ports-1 downto 0);
-------------------------------------------------------------------------------
-- Fabric I/F : output (goes to the Endpoint)
-------------------------------------------------------------------------------
src_i : in t_wrf_source_in_array(g_num_ports-1 downto 0);
src_o : out t_wrf_source_out_array(g_num_ports-1 downto 0);
-------------------------------------------------------------------------------
-- I/F with Routing Table Unit (RTU)
-------------------------------------------------------------------------------
rtu_rsp_i : in t_rtu_response_array(g_num_ports - 1 downto 0);
rtu_ack_o : out std_logic_vector(g_num_ports - 1 downto 0)
);
end component;
signal snk_i : t_wrf_sink_in_array(g_swc_num_ports-1 downto 0);
signal snk_o : t_wrf_sink_out_array(g_swc_num_ports-1 downto 0);
......@@ -282,6 +249,21 @@ end component;
begin
U_xswc_core: xswc_core
generic map(
g_mem_size => 65536,
g_page_size => 64,
g_prio_num => 8,
g_max_pck_size => 10 * 1024,
g_num_ports => 7,
g_data_width => 16,
g_ctrl_width => 4,
g_pck_pg_free_fifo_size => ((65536/64)/2) ,
g_input_block_cannot_accept_data => "drop_pck",
g_output_block_per_prio_fifo_size => 64,
g_packet_mem_multiply => 16,
g_input_block_fifo_size => (2 * 16),
g_input_block_fifo_full_in_advance => ((2 * 16) - 3)
)
port map(
clk_i => clk_i,
rst_n_i => rst_n_i,
......
......@@ -5,7 +5,7 @@
`define array_assign(a, ah, al, b, bl) \
for (k=al; k<=ah; k=k+1) begin assign a[k] = b[bl+k-al]; end
module xswcore_wrapper_v2
module swc_core_wrapper_generic
(
clk_i,
rst_n_i,
......
This diff is collapsed.
# Current time Mon Oct 18 18:05:56 2010
# ModelSim Stack Trace
# Program = vish
# Id = "6.6a"
# Version = "2010.03"
# Date = "Mar 19 2010"
# Platform = linux
# 0 0x08184ff0: 'treew_TriggerEventQ + 0x160' in '/opt/modeltech/modeltech/bin/../linux/vish'
# 1 0x0812ded3: 'name_ValueCancelPendingEvents + 0x1043' in '/opt/modeltech/modeltech/bin/../linux/vish'
# 2 0x083b138c: 'TclServiceIdle + 0x48' in '/opt/modeltech/modeltech/bin/../linux/vish'
# 3 0x083a3a99: 'Tcl_DoOneEvent + 0x1ad' in '/opt/modeltech/modeltech/bin/../linux/vish'
# 4 0x082cd87d: 'Tk_MainLoop + 0x19' in '/opt/modeltech/modeltech/bin/../linux/vish'
# 5 0x082d4a50: 'Tk_MainEx + 0x298' in '/opt/modeltech/modeltech/bin/../linux/vish'
# 6 0x0816b0e8: 'vish_inner_loop + 0x238' in '/opt/modeltech/modeltech/bin/../linux/vish'
# 7 0x0816bde2: 'main + 0x862' in '/opt/modeltech/modeltech/bin/../linux/vish'
# 8 0xb74ddbd1: '_libc_start_main + 0xe1' in '/lib/tls/i686/cmov/libc.so.6'
# 9 0x080bc3fc: 'start + 0x1c' in '/opt/modeltech/modeltech/bin/../linux/vish'
# End of Stack Trace
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment