1 |
2 |
danv |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
|
|
-- Copyright (C) 2012
|
4 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
|
|
--
|
7 |
|
|
-- This program is free software: you can redistribute it and/or modify
|
8 |
|
|
-- it under the terms of the GNU General Public License as published by
|
9 |
|
|
-- the Free Software Foundation, either version 3 of the License, or
|
10 |
|
|
-- (at your option) any later version.
|
11 |
|
|
--
|
12 |
|
|
-- This program is distributed in the hope that it will be useful,
|
13 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15 |
|
|
-- GNU General Public License for more details.
|
16 |
|
|
--
|
17 |
|
|
-- You should have received a copy of the GNU General Public License
|
18 |
|
|
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
|
19 |
|
|
--
|
20 |
|
|
-------------------------------------------------------------------------------
|
21 |
|
|
|
22 |
|
|
LIBRARY IEEE, common_pkg_lib;
|
23 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
24 |
|
|
USE common_pkg_lib.common_str_pkg.ALL;
|
25 |
|
|
USE work.mm_file_pkg.ALL;
|
26 |
|
|
|
27 |
|
|
PACKAGE mm_file_unb_pkg IS
|
28 |
|
|
|
29 |
|
|
TYPE t_c_mmf_unb_sys IS RECORD
|
30 |
|
|
nof_unb : NATURAL; -- Nof used UniBoard in our system [0..nof_unb-1]
|
31 |
|
|
nof_fn : NATURAL; -- Nof used FNs [0..nof_fn-1] per UniBoard
|
32 |
|
|
nof_bn : NATURAL; -- Nof used BNs [0..nof_fn-1] per UniBoard
|
33 |
|
|
END RECORD;
|
34 |
|
|
|
35 |
|
|
CONSTANT c_mmf_unb_nof_fn : NATURAL := 4;
|
36 |
|
|
CONSTANT c_mmf_unb_nof_bn : NATURAL := 4;
|
37 |
|
|
CONSTANT c_mmf_unb_nof_pn : NATURAL := c_mmf_unb_nof_fn + c_mmf_unb_nof_bn; -- = 8
|
38 |
|
|
|
39 |
|
|
-- use fixed central directory to ease use of Python test case with Modelsim
|
40 |
|
|
CONSTANT c_mmf_unb_file_path : STRING := "$UNB/Software/python/sim/";
|
41 |
|
|
|
42 |
|
|
-- create mmf file prefix that is unique per slave
|
43 |
|
|
FUNCTION mmf_unb_file_prefix(sys: t_c_mmf_unb_sys; node: NATURAL) RETURN STRING;
|
44 |
|
|
FUNCTION mmf_unb_file_prefix( unb, node: NATURAL; node_type: STRING) RETURN STRING; -- unb 0,1,..., node = 0:3 for FN or BN
|
45 |
|
|
FUNCTION mmf_unb_file_prefix( unb, node: NATURAL) RETURN STRING; -- unb 0,1,..., node = 0:7, with 0:3 for FN and 4:7 for BN
|
46 |
|
|
FUNCTION mmf_unb_file_prefix(tb, unb, node: NATURAL) RETURN STRING; -- idem, with extra index tb = 0,1,... for use with multi testbench
|
47 |
|
|
FUNCTION mmf_unb_file_prefix(tb, subrack, unb, node: NATURAL) RETURN STRING; -- idem, with extra index subrack = 0,1,... to support same local unb range per subrack
|
48 |
|
|
|
49 |
|
|
END mm_file_unb_pkg;
|
50 |
|
|
|
51 |
|
|
PACKAGE BODY mm_file_unb_pkg IS
|
52 |
|
|
|
53 |
|
|
FUNCTION mmf_unb_file_prefix(sys: t_c_mmf_unb_sys; node: NATURAL) RETURN STRING IS
|
54 |
|
|
-- This function is used to create files for node function instances that (can) run on
|
55 |
|
|
-- an FN or a BN. One generate loop can be used for all node instances, no need to
|
56 |
|
|
-- use a separate FOR loop for the back nodes and the front nodes as this function
|
57 |
|
|
-- determines the UniBoard index for you.
|
58 |
|
|
VARIABLE v_nodes_per_board : NATURAL := sys.nof_fn + sys.nof_bn;
|
59 |
|
|
VARIABLE v_board_index : NATURAL := node/v_nodes_per_board;
|
60 |
|
|
VARIABLE v_node_nr : NATURAL := node REM v_nodes_per_board;
|
61 |
|
|
VARIABLE v_node_type : STRING(1 TO 2) := sel_a_b(v_node_nr>=sys.nof_fn, "BN", "FN");
|
62 |
|
|
VARIABLE v_node_index : NATURAL := sel_a_b(v_node_nr>=sys.nof_fn, v_node_nr-sys.nof_fn, v_node_nr);
|
63 |
|
|
BEGIN
|
64 |
|
|
RETURN mmf_slave_prefix(c_mmf_unb_file_path, "UNB", v_board_index, v_node_type, v_node_index);
|
65 |
|
|
END;
|
66 |
|
|
|
67 |
|
|
FUNCTION mmf_unb_file_prefix(unb, node: NATURAL; node_type: STRING) RETURN STRING IS
|
68 |
|
|
-- Use this function and pass the UNB and node type BN 0:3 or node type FN 0:3 index.
|
69 |
|
|
BEGIN
|
70 |
|
|
RETURN mmf_slave_prefix(c_mmf_unb_file_path, "UNB", unb, node_type, node);
|
71 |
|
|
END;
|
72 |
|
|
|
73 |
|
|
FUNCTION mmf_unb_file_prefix(unb, node: NATURAL) RETURN STRING IS
|
74 |
|
|
-- Use this function and pass the UNB and node 0:7 index.
|
75 |
|
|
CONSTANT c_node_type : STRING(1 TO 2) := sel_a_b(node>=c_mmf_unb_nof_fn, "BN", "FN");
|
76 |
|
|
CONSTANT c_node_nr : NATURAL := node MOD c_mmf_unb_nof_fn; -- PN 0:3 --> FN 0:3, PN 4:7 --> BN 0:3
|
77 |
|
|
BEGIN
|
78 |
|
|
RETURN mmf_slave_prefix(c_mmf_unb_file_path, "UNB", unb, c_node_type, c_node_nr);
|
79 |
|
|
END;
|
80 |
|
|
|
81 |
|
|
FUNCTION mmf_unb_file_prefix(tb, unb, node: NATURAL) RETURN STRING IS
|
82 |
|
|
-- Use this function and pass the UNB and node 0:7 index and a test bench index to allow file IO with multi tb.
|
83 |
|
|
CONSTANT c_node_type : STRING(1 TO 2) := sel_a_b(node>=c_mmf_unb_nof_fn, "BN", "FN");
|
84 |
|
|
CONSTANT c_node_nr : NATURAL := node MOD c_mmf_unb_nof_fn; -- PN 0:3 --> FN 0:3, PN 4:7 --> BN 0:3
|
85 |
|
|
BEGIN
|
86 |
|
|
RETURN mmf_slave_prefix(c_mmf_unb_file_path, "TB", tb, "UNB", unb, c_node_type, c_node_nr);
|
87 |
|
|
END;
|
88 |
|
|
|
89 |
|
|
FUNCTION mmf_unb_file_prefix(tb, subrack, unb, node: NATURAL) RETURN STRING IS
|
90 |
|
|
-- Use this function and pass the UNB and node 0:7 index and a test bench index to allow file IO with multi subrack and multi tb.
|
91 |
|
|
CONSTANT c_node_type : STRING(1 TO 2) := sel_a_b(node>=c_mmf_unb_nof_fn, "BN", "FN");
|
92 |
|
|
CONSTANT c_node_nr : NATURAL := node MOD c_mmf_unb_nof_fn; -- PN 0:3 --> FN 0:3, PN 4:7 --> BN 0:3
|
93 |
|
|
BEGIN
|
94 |
|
|
RETURN mmf_slave_prefix(c_mmf_unb_file_path, "TB", tb, "SUBRACK", subrack, "UNB", unb, c_node_type, c_node_nr);
|
95 |
|
|
END;
|
96 |
|
|
|
97 |
|
|
END mm_file_unb_pkg;
|
98 |
|
|
|