OpenCores
URL https://opencores.org/ocsvn/astron_mm/astron_mm/trunk

Subversion Repositories astron_mm

[/] [astron_mm/] [trunk/] [mm_file_unb_pkg.vhd] - Blame information for rev 4

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 danv
-------------------------------------------------------------------------------
2
--
3 3 danv
-- Copyright 2020
4 2 danv
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
5
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
6 3 danv
-- 
7
-- Licensed under the Apache License, Version 2.0 (the "License");
8
-- you may not use this file except in compliance with the License.
9
-- You may obtain a copy of the License at
10
-- 
11
--     http://www.apache.org/licenses/LICENSE-2.0
12
-- 
13
-- Unless required by applicable law or agreed to in writing, software
14
-- distributed under the License is distributed on an "AS IS" BASIS,
15
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
-- See the License for the specific language governing permissions and
17
-- limitations under the License.
18 2 danv
--
19
-------------------------------------------------------------------------------
20
 
21
LIBRARY IEEE, common_pkg_lib;
22
USE common_pkg_lib.common_pkg.ALL;
23
USE common_pkg_lib.common_str_pkg.ALL;
24
USE work.mm_file_pkg.ALL;
25
 
26
PACKAGE mm_file_unb_pkg IS
27
 
28
  TYPE t_c_mmf_unb_sys IS RECORD
29
    nof_unb : NATURAL; -- Nof used UniBoard in our system [0..nof_unb-1]
30
    nof_fn  : NATURAL; -- Nof used FNs [0..nof_fn-1] per UniBoard
31
    nof_bn  : NATURAL; -- Nof used BNs [0..nof_fn-1] per UniBoard
32
  END RECORD;
33
 
34
  CONSTANT c_mmf_unb_nof_fn          : NATURAL := 4;
35
  CONSTANT c_mmf_unb_nof_bn          : NATURAL := 4;
36
  CONSTANT c_mmf_unb_nof_pn          : NATURAL := c_mmf_unb_nof_fn + c_mmf_unb_nof_bn;  -- = 8
37
 
38
  -- use fixed central directory to ease use of Python test case with Modelsim
39
  CONSTANT c_mmf_unb_file_path       : STRING := "$UNB/Software/python/sim/";
40
 
41
  -- create mmf file prefix that is unique per slave
42
  FUNCTION mmf_unb_file_prefix(sys: t_c_mmf_unb_sys; node: NATURAL) RETURN STRING;
43
  FUNCTION mmf_unb_file_prefix(             unb, node: NATURAL; node_type: STRING) RETURN STRING;  -- unb 0,1,..., node = 0:3 for FN or BN
44
  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
45
  FUNCTION mmf_unb_file_prefix(tb,          unb, node: NATURAL) RETURN STRING;  -- idem, with extra index tb = 0,1,... for use with multi testbench
46
  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
47
 
48
END mm_file_unb_pkg;
49
 
50
PACKAGE BODY mm_file_unb_pkg IS
51
 
52
  FUNCTION mmf_unb_file_prefix(sys: t_c_mmf_unb_sys; node: NATURAL) RETURN STRING IS
53
    -- This function is used to create files for node function instances that (can) run on
54
    -- an FN or a BN. One generate loop can be used for all node instances, no need to 
55
    -- use a separate FOR loop for the back nodes and the front nodes as this function
56
    -- determines the UniBoard index for you.
57
    VARIABLE v_nodes_per_board : NATURAL := sys.nof_fn + sys.nof_bn;
58
    VARIABLE v_board_index     : NATURAL := node/v_nodes_per_board;
59
    VARIABLE v_node_nr         : NATURAL := node REM v_nodes_per_board;
60
    VARIABLE v_node_type       : STRING(1 TO 2) := sel_a_b(v_node_nr>=sys.nof_fn, "BN", "FN");
61
    VARIABLE v_node_index      : NATURAL := sel_a_b(v_node_nr>=sys.nof_fn, v_node_nr-sys.nof_fn, v_node_nr);
62
  BEGIN
63
    RETURN mmf_slave_prefix(c_mmf_unb_file_path, "UNB", v_board_index, v_node_type, v_node_index);
64
  END;
65
 
66
  FUNCTION mmf_unb_file_prefix(unb, node: NATURAL; node_type: STRING) RETURN STRING IS
67
    -- Use this function and pass the UNB and node type BN 0:3 or node type FN 0:3 index.
68
  BEGIN
69
    RETURN mmf_slave_prefix(c_mmf_unb_file_path, "UNB", unb, node_type, node);
70
  END;
71
 
72
  FUNCTION mmf_unb_file_prefix(unb, node: NATURAL) RETURN STRING IS
73
    -- Use this function and pass the UNB and node 0:7 index.
74
    CONSTANT c_node_type       : STRING(1 TO 2) := sel_a_b(node>=c_mmf_unb_nof_fn, "BN", "FN");
75
    CONSTANT c_node_nr         : NATURAL := node MOD c_mmf_unb_nof_fn;  -- PN 0:3 --> FN 0:3, PN 4:7 --> BN 0:3
76
  BEGIN
77
    RETURN mmf_slave_prefix(c_mmf_unb_file_path, "UNB", unb, c_node_type, c_node_nr);
78
  END;
79
 
80
  FUNCTION mmf_unb_file_prefix(tb, unb, node: NATURAL) RETURN STRING IS
81
    -- Use this function and pass the UNB and node 0:7 index and a test bench index to allow file IO with multi tb.
82
    CONSTANT c_node_type       : STRING(1 TO 2) := sel_a_b(node>=c_mmf_unb_nof_fn, "BN", "FN");
83
    CONSTANT c_node_nr         : NATURAL := node MOD c_mmf_unb_nof_fn;  -- PN 0:3 --> FN 0:3, PN 4:7 --> BN 0:3
84
  BEGIN
85
    RETURN mmf_slave_prefix(c_mmf_unb_file_path, "TB", tb, "UNB", unb, c_node_type, c_node_nr);
86
  END;
87
 
88
  FUNCTION mmf_unb_file_prefix(tb, subrack, unb, node: NATURAL) RETURN STRING IS
89
    -- 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.
90
    CONSTANT c_node_type       : STRING(1 TO 2) := sel_a_b(node>=c_mmf_unb_nof_fn, "BN", "FN");
91
    CONSTANT c_node_nr         : NATURAL := node MOD c_mmf_unb_nof_fn;  -- PN 0:3 --> FN 0:3, PN 4:7 --> BN 0:3
92
  BEGIN
93
    RETURN mmf_slave_prefix(c_mmf_unb_file_path, "TB", tb, "SUBRACK", subrack, "UNB", unb, c_node_type, c_node_nr);
94
  END;
95
 
96
END mm_file_unb_pkg;
97
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.