69 lines
No EOL
2.4 KiB
VHDL
69 lines
No EOL
2.4 KiB
VHDL
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
use ieee.numeric_std.all;
|
|
use work.router_types.all;
|
|
|
|
package quadtree_components is
|
|
component Router is
|
|
generic (
|
|
num_paths_up : positive := 1;
|
|
num_paths_down : positive := 1;
|
|
npu_bit_size : natural := 2;
|
|
npd_bit_size : natural := 1;
|
|
level : natural := 1;
|
|
buffer_width : positive := 64;
|
|
buffer_depth : positive := 4;
|
|
fifo_ptr_size : positive := 3;
|
|
chip_x : std_logic_vector(4 downto 0);
|
|
chip_y : std_logic_vector(4 downto 0)
|
|
);
|
|
port (
|
|
clk : in std_logic;
|
|
arstN : in std_logic;
|
|
core_x : in std_logic_vector(DEST_ADDR_SIZE-1 downto 0);
|
|
core_y : in std_logic_vector(DEST_ADDR_SIZE-1 downto 0);
|
|
data_in : in t_DATA(num_paths_up+num_paths_down*4-1 downto 0);
|
|
rcv_reqs : in std_logic_vector(num_paths_up+num_paths_down*4-1 downto 0);
|
|
send_ack : in std_logic_vector(num_paths_up+num_paths_down*4-1 downto 0);
|
|
rcv_acks : out std_logic_vector(num_paths_up+num_paths_down*4-1 downto 0);
|
|
send_reqs : out std_logic_vector(num_paths_up+num_paths_down*4-1 downto 0);
|
|
data_out : out t_DATA(num_paths_up+num_paths_down*4-1 downto 0)
|
|
);
|
|
end component Router;
|
|
|
|
function calculate_num_routers (
|
|
top_level : in integer
|
|
) return integer;
|
|
|
|
function calculate_num_routers_qt (
|
|
level : in integer;
|
|
top_level : in integer
|
|
) return integer;
|
|
end package;
|
|
|
|
package body quadtree_components is
|
|
function calculate_num_routers(
|
|
top_level : in integer
|
|
) return integer is
|
|
variable num_routers : integer;
|
|
begin
|
|
num_routers := 0;
|
|
for i in 0 to top_level-1 loop
|
|
num_routers := num_routers + 4**i;
|
|
end loop;
|
|
return num_routers;
|
|
end function;
|
|
|
|
function calculate_num_routers_qt(
|
|
level : in integer;
|
|
top_level : in integer
|
|
) return integer is
|
|
variable num_routers : integer;
|
|
begin
|
|
num_routers := calculate_num_routers(top_level) - 1;
|
|
for i in 0 to top_level-level-1 loop
|
|
num_routers := (num_routers-4)/4;
|
|
end loop;
|
|
return num_routers;
|
|
end function;
|
|
end package body; |