1 |
2 |
danv |
-------------------------------------------------------------------------------
|
2 |
|
|
--
|
3 |
3 |
danv |
-- Copyright 2020
|
4 |
|
|
-- ASTRON (Netherlands Institute for Radio Astronomy) <http://www.astron.nl/>
|
5 |
|
|
-- P.O.Box 2, 7990 AA Dwingeloo, The Netherlands
|
6 |
|
|
--
|
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 |
|
|
-- Author :
|
22 |
|
|
-- D. van der Schuur May 2012 Original for Python - file IO - VHDL
|
23 |
|
|
-- E. Kooistra feb 2017 Added purpose and description
|
24 |
|
|
-- Added procedures for external control in a
|
25 |
|
|
-- pure VHDL test bench.
|
26 |
|
|
--
|
27 |
|
|
-- Purpose: Provide DUT access via MM bus through file IO per MM slave
|
28 |
|
|
-- Description:
|
29 |
|
|
-- This package provides file IO access to MM slaves and to the status of
|
30 |
|
|
-- the simulation:
|
31 |
|
|
--
|
32 |
|
|
-- 1) MM slave access
|
33 |
|
|
-- Access to MM slaves is provided by component mm_file.vhd that first calls
|
34 |
|
|
-- mmf_file_create() and loop forever calling mmf_mm_from_file(). Each MM
|
35 |
|
|
-- slave has a dedicated pair of request (.ctrl) and response (.stat) IO
|
36 |
|
|
-- files.
|
37 |
|
|
-- The mmf_file_create() creates the .ctrl file and mmf_mm_from_file() reads
|
38 |
|
|
-- it to check whether there is a WR or RD access request. For a WR request
|
39 |
|
|
-- the wr_data and wr_addr are read from the .ctrl and output on the MM bus
|
40 |
|
|
-- via mm_mosi. For a RD access request the rd_addr is read from the .ctrl
|
41 |
|
|
-- and output on the MM bus via mm_mosi. The after the read latency the
|
42 |
|
|
-- rd_data is written to the .stat file that is then created and closed.
|
43 |
|
|
--
|
44 |
|
|
-- wr rd _________ __________
|
45 |
|
|
-- mmf_mm_bus_wr() ---> ctrl file --->| |---mm_mosi-->| |
|
46 |
|
|
-- | mm_file | | MM slave |
|
47 |
|
|
-- mmf_mm_bus_rd() <--- stat file <---|___\_____|<--mm_miso---|__________|
|
48 |
|
|
-- rd wr \
|
49 |
|
|
-- \--> loop: mmf_mm_from_file()
|
50 |
|
|
--
|
51 |
|
|
-- The ctrl file is created by mm_file at initialization and recreated by
|
52 |
|
|
-- every call of mmf_mm_from_file().
|
53 |
|
|
-- The stat file is recreated by every call of mmf_mm_bus_rd().
|
54 |
|
|
--
|
55 |
|
|
-- 2) Simulator access
|
56 |
|
|
-- External access to the simulation is provided via a .ctrl file that
|
57 |
|
|
-- supports GET_SIM_TIME and then report the NOW time via the .stat file.
|
58 |
|
|
-- The simulation access is provided via a procedure mmf_poll_sim_ctrl_file()
|
59 |
|
|
-- that works similar component mm_file.vhd.
|
60 |
|
|
--
|
61 |
|
|
-- wr rd
|
62 |
|
|
-- |---> ctrl file --->|
|
63 |
|
|
-- mmf_sim_get_now()| |mmf_poll_sim_ctrl_file()
|
64 |
|
|
-- |<--- stat file <---| \
|
65 |
|
|
-- rd wr \
|
66 |
|
|
-- \--> loop: mmf_sim_ctrl_from_file()
|
67 |
|
|
--
|
68 |
|
|
-- The ctrl file is created by mmf_poll_sim_ctrl_file at initialization and
|
69 |
|
|
-- recreated by every call of mmf_sim_ctrl_from_file().
|
70 |
|
|
-- The stat file is recreated by every call of mmf_sim_get_now().
|
71 |
|
|
--
|
72 |
|
|
-- A) External control by a Python script
|
73 |
|
|
-- A Python script can issue requests via the .ctrl files to control the
|
74 |
|
|
-- simulation and read the .stat files. This models the MM access via a
|
75 |
|
|
-- Monitoring and Control protocol via 1GbE.
|
76 |
|
|
--
|
77 |
|
|
-- Internal procedures:
|
78 |
|
|
-- . mmf_file_create(filename: IN STRING);
|
79 |
|
|
-- . mmf_mm_from_file(SIGNAL mm_clk : IN STD_LOGIC;
|
80 |
|
|
-- . mmf_sim_ctrl_from_file(rd_filename: IN STRING;
|
81 |
|
|
--
|
82 |
|
|
-- External procedures (used in a VHDL design to provide access to the MM
|
83 |
|
|
-- slaves and simulation via file IO):
|
84 |
|
|
-- . mm_file.vhd --> instead of a procedure MM slave file IO uses a component
|
85 |
|
|
-- . mmf_poll_sim_ctrl_file()
|
86 |
|
|
--
|
87 |
|
|
-- B) External control by a VHDL process --> see tb_mm_file.vhd
|
88 |
|
|
-- Instead of a Python script the file IO access to the MM slaves can also
|
89 |
|
|
-- be used in a pure VHDL testbench. This is useful when the MM slave bus
|
90 |
|
|
-- signals (mm_mosi, mm_miso) are not available on the entity of the DUT
|
91 |
|
|
-- (device under test), which is typically the case when a complete FPGA
|
92 |
|
|
-- design needs to be simulated.
|
93 |
|
|
--
|
94 |
|
|
-- Internal procedures:
|
95 |
|
|
-- . mmf_wait_for_file_status()
|
96 |
|
|
-- . mmf_wait_for_file_empty()
|
97 |
|
|
-- . mmf_wait_for_file_not_empty()
|
98 |
|
|
--
|
99 |
|
|
-- External procedures (used in a VHDL test bench to provide access to the
|
100 |
|
|
-- MM slaves in a DUT VHDL design and simulation via file IO):
|
101 |
|
|
-- . mmf_mm_bus_wr()
|
102 |
|
|
-- . mmf_mm_bus_rd()
|
103 |
|
|
-- . mmf_sim_get_now()
|
104 |
|
|
--
|
105 |
|
|
-- External function to create unique sim.ctrl/sim.stat filename per test bench in a multi tb
|
106 |
|
|
-- . mmf_slave_prefix()
|
107 |
|
|
--
|
108 |
|
|
-- Remarks:
|
109 |
|
|
-- . The timing of the MM access in mmf_mm_bus_wr() and mmf_mm_bus_rd() and the
|
110 |
|
|
-- simulation access in mmf_sim_get_now() is not critical. The timing of the first
|
111 |
|
|
-- access depends on the tb. Due to falling_edge(mm_clk) in mmf_wait_for_file_*()
|
112 |
|
|
-- all subsequent accesses will start at falling_edge(mm_clk)
|
113 |
|
|
|
114 |
|
|
LIBRARY IEEE, common_pkg_lib, common_ram_lib;
|
115 |
|
|
USE IEEE.STD_LOGIC_1164.ALL;
|
116 |
|
|
USE IEEE.NUMERIC_STD.ALL;
|
117 |
|
|
USE common_pkg_lib.common_pkg.ALL;
|
118 |
|
|
USE common_pkg_lib.tb_common_pkg.ALL;
|
119 |
|
|
USE common_ram_lib.common_ram_pkg.ALL;
|
120 |
|
|
USE work.tb_common_mem_pkg.ALL;
|
121 |
|
|
USE std.textio.ALL;
|
122 |
|
|
USE IEEE.std_logic_textio.ALL;
|
123 |
|
|
USE common_pkg_lib.common_str_pkg.ALL;
|
124 |
|
|
|
125 |
|
|
PACKAGE mm_file_pkg IS
|
126 |
|
|
|
127 |
|
|
-- Constants used by mm_file.vhd
|
128 |
|
|
CONSTANT c_mmf_mm_clk_period : TIME := 100 ps; -- Default mm_clk period in simulation. Set much faster than DP clock to speed up
|
129 |
|
|
-- simulation of MM access. Without file IO throttling 100 ps is a good balance
|
130 |
|
|
-- between simulation speed and file IO rate.
|
131 |
|
|
CONSTANT c_mmf_mm_timeout : TIME := 1000 ns; -- Default MM file IO timeout period. Set large enough to account for MM-DP clock
|
132 |
|
|
-- domain crossing delays. Use 0 ns to disable file IO throttling, to have file IO
|
133 |
|
|
-- at the mm_clk rate.
|
134 |
|
|
CONSTANT c_mmf_mm_pause : TIME := 100 ns; -- Default MM file IO pause period after timeout. Balance between file IO rate
|
135 |
|
|
-- reduction and responsiveness to new MM access.
|
136 |
|
|
|
137 |
|
|
-- Procedure to (re)create empty file
|
138 |
|
|
PROCEDURE mmf_file_create(filename: IN STRING);
|
139 |
|
|
|
140 |
|
|
-- Procedure to perform an MM access from file
|
141 |
|
|
PROCEDURE mmf_mm_from_file(SIGNAL mm_clk : IN STD_LOGIC;
|
142 |
|
|
SIGNAL mm_rst : IN STD_LOGIC;
|
143 |
|
|
SIGNAL mm_mosi : OUT t_mem_mosi;
|
144 |
|
|
SIGNAL mm_miso : IN t_mem_miso;
|
145 |
|
|
rd_filename: IN STRING;
|
146 |
|
|
wr_filename: IN STRING;
|
147 |
|
|
rd_latency: IN NATURAL);
|
148 |
|
|
|
149 |
|
|
-- Procedure to process a simulation status request from the .ctrl file and provide response via the .stat file
|
150 |
|
|
PROCEDURE mmf_sim_ctrl_from_file(rd_filename: IN STRING;
|
151 |
|
|
wr_filename: IN STRING);
|
152 |
|
|
|
153 |
|
|
-- Procedure to poll the simulation status
|
154 |
|
|
PROCEDURE mmf_poll_sim_ctrl_file(rd_file_name: IN STRING;
|
155 |
|
|
wr_file_name: IN STRING);
|
156 |
|
|
|
157 |
|
|
-- Procedure to poll the simulation status
|
158 |
|
|
PROCEDURE mmf_poll_sim_ctrl_file(SIGNAL mm_clk : IN STD_LOGIC;
|
159 |
|
|
rd_file_name: IN STRING;
|
160 |
|
|
wr_file_name: IN STRING);
|
161 |
|
|
|
162 |
|
|
-- Procedures that keep reading the file until it has been made empty or not empty by some other program,
|
163 |
|
|
-- to ensure the file is ready for a new write access
|
164 |
|
|
PROCEDURE mmf_wait_for_file_status(rd_filename : IN STRING; -- file name with extension
|
165 |
|
|
exit_on_empty : IN BOOLEAN;
|
166 |
|
|
SIGNAL mm_clk : IN STD_LOGIC);
|
167 |
|
|
|
168 |
|
|
PROCEDURE mmf_wait_for_file_empty(rd_filename : IN STRING; -- file name with extension
|
169 |
|
|
SIGNAL mm_clk : IN STD_LOGIC);
|
170 |
|
|
PROCEDURE mmf_wait_for_file_not_empty(rd_filename : IN STRING; -- file name with extension
|
171 |
|
|
SIGNAL mm_clk : IN STD_LOGIC);
|
172 |
|
|
|
173 |
|
|
-- Procedure to issue a write access via the MM request .ctrl file
|
174 |
|
|
PROCEDURE mmf_mm_bus_wr(filename : IN STRING; -- file name without extension
|
175 |
|
|
wr_addr : IN INTEGER; -- use integer to support full 32 bit range
|
176 |
|
|
wr_data : IN INTEGER;
|
177 |
|
|
SIGNAL mm_clk : IN STD_LOGIC);
|
178 |
|
|
|
179 |
|
|
-- Procedure to issue a read access via the MM request .ctrl file and get the read data from the MM response file
|
180 |
|
|
PROCEDURE mmf_mm_bus_rd(filename : IN STRING; -- file name without extension
|
181 |
|
|
rd_latency : IN NATURAL;
|
182 |
|
|
rd_addr : IN INTEGER; -- use integer to support full 32 bit range
|
183 |
|
|
SIGNAL rd_data : OUT STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
|
184 |
|
|
SIGNAL mm_clk : IN STD_LOGIC);
|
185 |
|
|
-- . rd_latency = 1
|
186 |
|
|
PROCEDURE mmf_mm_bus_rd(filename : IN STRING;
|
187 |
|
|
rd_addr : IN INTEGER;
|
188 |
|
|
SIGNAL rd_data : OUT STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
|
189 |
|
|
SIGNAL mm_clk : IN STD_LOGIC);
|
190 |
|
|
|
191 |
|
|
-- Procedure that reads the rd_data every rd_interval until has the specified rd_value, the proc arguments can be understood as a sentence
|
192 |
|
|
PROCEDURE mmf_mm_wait_until_value(filename : IN STRING; -- file name without extension
|
193 |
|
|
rd_addr : IN INTEGER;
|
194 |
|
|
c_representation : IN STRING; -- treat rd_data as "SIGNED" or "UNSIGNED" 32 bit word
|
195 |
|
|
SIGNAL rd_data : INOUT STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
|
196 |
|
|
c_condition : IN STRING; -- ">", ">=", "=", "<=", "<", "/="
|
197 |
|
|
c_rd_value : IN INTEGER;
|
198 |
|
|
c_rd_interval : IN TIME;
|
199 |
|
|
SIGNAL mm_clk : IN STD_LOGIC);
|
200 |
|
|
|
201 |
|
|
-- Procedure to get NOW via simulator status
|
202 |
|
|
PROCEDURE mmf_sim_get_now(filename : IN STRING; -- file name without extension
|
203 |
|
|
SIGNAL rd_now : OUT STRING;
|
204 |
|
|
SIGNAL mm_clk : IN STD_LOGIC);
|
205 |
|
|
|
206 |
|
|
-- Functions to create prefixes for the mmf file filename
|
207 |
|
|
FUNCTION mmf_prefix(name : STRING; index : NATURAL) RETURN STRING; -- generic prefix name with index to be used for a file IO filename
|
208 |
|
|
FUNCTION mmf_tb_prefix(tb : INTEGER) RETURN STRING; -- fixed test bench prefix with index tb to allow file IO with multi tb
|
209 |
|
|
FUNCTION mmf_subrack_prefix(subrack : INTEGER) RETURN STRING; -- fixed subrack prefix with index subrack to allow file IO with multi subracks that use same unb numbers
|
210 |
|
|
|
211 |
|
|
-- Functions to create mmf file prefix that is unique per slave, for increasing number of hierarchy levels:
|
212 |
|
|
-- . return "filepath/s0_i0_"
|
213 |
|
|
-- . return "filepath/s0_i0_s1_i1_"
|
214 |
|
|
-- . return "filepath/s0_i0_s1_i1_s2_i2_"
|
215 |
|
|
-- . return "filepath/s0_i0_s1_i1_s2_i2_s3_i3_"
|
216 |
|
|
-- . return "filepath/s0_i0_s1_i1_s2_i2_s3_i3_s4_i4_"
|
217 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL) RETURN STRING;
|
218 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL) RETURN STRING;
|
219 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL) RETURN STRING;
|
220 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL; s3 : STRING; i3 : NATURAL) RETURN STRING;
|
221 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL; s3 : STRING; i3 : NATURAL; s4 : STRING; i4 : NATURAL) RETURN STRING;
|
222 |
|
|
|
223 |
|
|
CONSTANT c_mmf_local_dir_path : STRING := "mmfiles/"; -- local directory in project file build directory
|
224 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL) RETURN STRING;
|
225 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL) RETURN STRING;
|
226 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL) RETURN STRING;
|
227 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL; s3 : STRING; i3 : NATURAL) RETURN STRING;
|
228 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL; s3 : STRING; i3 : NATURAL; s4 : STRING; i4 : NATURAL) RETURN STRING;
|
229 |
|
|
|
230 |
|
|
----------------------------------------------------------------------------
|
231 |
|
|
-- Declare mm_file component to support positional generic and port mapping of many instances in a TB
|
232 |
|
|
----------------------------------------------------------------------------
|
233 |
|
|
COMPONENT mm_file
|
234 |
|
|
GENERIC(
|
235 |
|
|
g_file_prefix : STRING;
|
236 |
|
|
g_file_enable : STD_LOGIC := '1';
|
237 |
|
|
g_mm_rd_latency : NATURAL := 2;
|
238 |
|
|
g_mm_timeout : TIME := c_mmf_mm_timeout;
|
239 |
|
|
g_mm_pause : TIME := c_mmf_mm_pause
|
240 |
|
|
);
|
241 |
|
|
PORT (
|
242 |
|
|
mm_rst : IN STD_LOGIC;
|
243 |
|
|
mm_clk : IN STD_LOGIC;
|
244 |
|
|
mm_master_out : OUT t_mem_mosi;
|
245 |
|
|
mm_master_in : IN t_mem_miso
|
246 |
|
|
);
|
247 |
|
|
END COMPONENT;
|
248 |
|
|
|
249 |
|
|
END mm_file_pkg;
|
250 |
|
|
|
251 |
|
|
PACKAGE BODY mm_file_pkg IS
|
252 |
|
|
|
253 |
|
|
PROCEDURE mmf_file_create(filename: IN STRING) IS
|
254 |
|
|
FILE created_file : TEXT OPEN write_mode IS filename;
|
255 |
|
|
BEGIN
|
256 |
|
|
-- Write the file with nothing in it
|
257 |
|
|
write(created_file, "");
|
258 |
|
|
END;
|
259 |
|
|
|
260 |
|
|
PROCEDURE mmf_mm_from_file(SIGNAL mm_clk : IN STD_LOGIC;
|
261 |
|
|
SIGNAL mm_rst : IN STD_LOGIC;
|
262 |
|
|
SIGNAL mm_mosi : OUT t_mem_mosi;
|
263 |
|
|
SIGNAL mm_miso : IN t_mem_miso;
|
264 |
|
|
rd_filename: IN STRING;
|
265 |
|
|
wr_filename: IN STRING;
|
266 |
|
|
rd_latency: IN NATURAL) IS
|
267 |
|
|
FILE rd_file : TEXT;
|
268 |
|
|
FILE wr_file : TEXT;
|
269 |
|
|
|
270 |
|
|
VARIABLE open_status_rd: file_open_status;
|
271 |
|
|
VARIABLE open_status_wr: file_open_status;
|
272 |
|
|
|
273 |
|
|
VARIABLE rd_line : LINE;
|
274 |
|
|
VARIABLE wr_line : LINE;
|
275 |
|
|
|
276 |
|
|
-- Note: Both the address and the data are interpreted as 32-bit data!
|
277 |
|
|
-- This means one has to use leading zeros in the file when either is
|
278 |
|
|
-- less than 8 hex characters, e.g.:
|
279 |
|
|
-- (address) 0000000A
|
280 |
|
|
-- (data) DEADBEEF
|
281 |
|
|
-- ...as a hex address 'A' would fit in only 4 bits, causing an error in hread().
|
282 |
|
|
VARIABLE v_addr_slv : STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
|
283 |
|
|
VARIABLE v_data_slv : STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
|
284 |
|
|
|
285 |
|
|
VARIABLE v_rd_wr_str : STRING(1 TO 2); -- Contains 'RD' or 'WR'
|
286 |
|
|
|
287 |
|
|
BEGIN
|
288 |
|
|
|
289 |
|
|
proc_common_wait_until_low(mm_clk, mm_rst);
|
290 |
|
|
|
291 |
|
|
-- We have to open the file explicitely so we can check the status
|
292 |
|
|
file_open(open_status_rd, rd_file, rd_filename, read_mode);
|
293 |
|
|
|
294 |
|
|
-- open_status may throw an error if the file is being written to by some other program
|
295 |
|
|
IF open_status_rd=open_ok THEN
|
296 |
|
|
|
297 |
|
|
IF NOT endfile(rd_file) THEN
|
298 |
|
|
-- The file is not empty: process its contents
|
299 |
|
|
|
300 |
|
|
-- Read a line from it, first line indicates RD or WR
|
301 |
|
|
readline(rd_file, rd_line);
|
302 |
|
|
read(rd_line, v_rd_wr_str);
|
303 |
|
|
|
304 |
|
|
-- The second line represents the address offset:
|
305 |
|
|
readline(rd_file, rd_line);
|
306 |
|
|
hread(rd_line, v_addr_slv); -- read the string as HEX and assign to SLV.
|
307 |
|
|
|
308 |
|
|
-- Write only: The third line contains the data to write:
|
309 |
|
|
IF v_rd_wr_str="WR" THEN
|
310 |
|
|
readline(rd_file, rd_line);
|
311 |
|
|
hread(rd_line, v_data_slv); -- read the string as HEX and assign to SLV.
|
312 |
|
|
END IF;
|
313 |
|
|
|
314 |
|
|
-- We're done reading MM request from the .ctrl file.
|
315 |
|
|
-- Clear the .ctrl file by closing and recreating it, because we don't want to do the same
|
316 |
|
|
-- MM request again the next time this procedure is called.
|
317 |
|
|
file_close(rd_file);
|
318 |
|
|
mmf_file_create(rd_filename);
|
319 |
|
|
|
320 |
|
|
-- Execute the MM request to the MM slave
|
321 |
|
|
IF v_rd_wr_str="WR" THEN
|
322 |
|
|
print_str("[" & time_to_str(now) & "] " & rd_filename & ": Writing 0x" & slv_to_hex(v_data_slv) & " to address 0x" & slv_to_hex(v_addr_slv));
|
323 |
|
|
-- Treat 32 bit hex data from file as 32 bit VHDL INTEGER, so need to use signed TO_SINT() to avoid out of NATURAL range
|
324 |
|
|
-- warning in simulation due to '1' sign bit, because unsigned VHDL NATURAL only fits 31 bits
|
325 |
|
|
proc_mem_mm_bus_wr(TO_UINT(v_addr_slv), TO_SINT(v_data_slv), mm_clk, mm_miso, mm_mosi);
|
326 |
|
|
|
327 |
|
|
ELSIF v_rd_wr_str="RD" THEN
|
328 |
|
|
proc_mem_mm_bus_rd(TO_UINT(v_addr_slv), mm_clk, mm_miso, mm_mosi);
|
329 |
|
|
IF rd_latency>0 THEN
|
330 |
|
|
proc_mem_mm_bus_rd_latency(rd_latency, mm_clk);
|
331 |
|
|
END IF;
|
332 |
|
|
v_data_slv := mm_miso.rddata(31 DOWNTO 0);
|
333 |
|
|
print_str("[" & time_to_str(now) & "] " & rd_filename & ": Reading from address 0x" & slv_to_hex(v_addr_slv) & ": 0x" & slv_to_hex(v_data_slv));
|
334 |
|
|
|
335 |
|
|
-- Write the RD response read data to the .stat file
|
336 |
|
|
file_open(open_status_wr, wr_file, wr_filename, write_mode);
|
337 |
|
|
hwrite(wr_line, v_data_slv);
|
338 |
|
|
writeline(wr_file, wr_line);
|
339 |
|
|
file_close(wr_file);
|
340 |
|
|
END IF;
|
341 |
|
|
|
342 |
|
|
ELSE
|
343 |
|
|
-- Nothing to process; wait one MM clock cycle.
|
344 |
|
|
proc_common_wait_some_cycles(mm_clk, 1);
|
345 |
|
|
END IF;
|
346 |
|
|
|
347 |
|
|
ELSE
|
348 |
|
|
REPORT "mmf_mm_from_file() could not open " & rd_filename & " at " & time_to_str(now) SEVERITY NOTE;
|
349 |
|
|
-- Try again next time; wait one MM clock cycle.
|
350 |
|
|
proc_common_wait_some_cycles(mm_clk, 1);
|
351 |
|
|
END IF;
|
352 |
|
|
|
353 |
|
|
-- The END implicitely close the rd_file, if still necessary.
|
354 |
|
|
END;
|
355 |
|
|
|
356 |
|
|
|
357 |
|
|
PROCEDURE mmf_sim_ctrl_from_file(rd_filename: IN STRING;
|
358 |
|
|
wr_filename: IN STRING) IS
|
359 |
|
|
|
360 |
|
|
FILE rd_file : TEXT;
|
361 |
|
|
FILE wr_file : TEXT;
|
362 |
|
|
|
363 |
|
|
VARIABLE open_status_rd: file_open_status;
|
364 |
|
|
VARIABLE open_status_wr: file_open_status;
|
365 |
|
|
|
366 |
|
|
VARIABLE rd_line : LINE;
|
367 |
|
|
VARIABLE wr_line : LINE;
|
368 |
|
|
|
369 |
|
|
VARIABLE v_rd_wr_str : STRING(1 TO 12); -- "GET_SIM_TIME"
|
370 |
|
|
|
371 |
|
|
BEGIN
|
372 |
|
|
|
373 |
|
|
-- We have to open the file explicitely so we can check the status
|
374 |
|
|
file_open(open_status_rd, rd_file, rd_filename, read_mode);
|
375 |
|
|
|
376 |
|
|
-- open_status may throw an error if the file is being written to by some other program
|
377 |
|
|
IF open_status_rd=open_ok THEN
|
378 |
|
|
|
379 |
|
|
IF NOT endfile(rd_file) THEN
|
380 |
|
|
-- The file is not empty: process its contents
|
381 |
|
|
|
382 |
|
|
-- Read a line from it, interpret the simulation request
|
383 |
|
|
readline(rd_file, rd_line);
|
384 |
|
|
read(rd_line, v_rd_wr_str);
|
385 |
|
|
|
386 |
|
|
-- We're done reading this simulation request .ctrl file. Clear the file by closing and recreating it.
|
387 |
|
|
file_close(rd_file);
|
388 |
|
|
mmf_file_create(rd_filename);
|
389 |
|
|
|
390 |
|
|
-- Execute the simulation request
|
391 |
|
|
IF v_rd_wr_str="GET_SIM_TIME" THEN
|
392 |
|
|
-- Write the GET_SIM_TIME response time NOW to the .stat file
|
393 |
|
|
file_open(open_status_wr, wr_file, wr_filename, write_mode);
|
394 |
|
|
write(wr_line, time_to_str(now));
|
395 |
|
|
writeline(wr_file, wr_line);
|
396 |
|
|
file_close(wr_file);
|
397 |
|
|
END IF;
|
398 |
|
|
|
399 |
|
|
ELSE
|
400 |
|
|
-- Nothing to process; wait in procedure mmf_poll_sim_ctrl_file
|
401 |
|
|
NULL;
|
402 |
|
|
END IF;
|
403 |
|
|
|
404 |
|
|
ELSE
|
405 |
|
|
REPORT "mmf_mm_from_file() could not open " & rd_filename & " at " & time_to_str(now) SEVERITY NOTE;
|
406 |
|
|
-- Try again next time; wait in procedure mmf_poll_sim_ctrl_file
|
407 |
|
|
END IF;
|
408 |
|
|
|
409 |
|
|
-- The END implicitely close the rd_file, if still necessary.
|
410 |
|
|
END;
|
411 |
|
|
|
412 |
|
|
|
413 |
|
|
PROCEDURE mmf_poll_sim_ctrl_file(rd_file_name: IN STRING; wr_file_name : IN STRING) IS
|
414 |
|
|
BEGIN
|
415 |
|
|
-- Create the ctrl file that we're going to read from
|
416 |
|
|
print_str("[" & time_to_str(now) & "] " & rd_file_name & ": Created" );
|
417 |
|
|
mmf_file_create(rd_file_name);
|
418 |
|
|
|
419 |
|
|
WHILE TRUE LOOP
|
420 |
|
|
mmf_sim_ctrl_from_file(rd_file_name, wr_file_name);
|
421 |
|
|
WAIT FOR 1 ns;
|
422 |
|
|
END LOOP;
|
423 |
|
|
|
424 |
|
|
END;
|
425 |
|
|
|
426 |
|
|
|
427 |
|
|
PROCEDURE mmf_poll_sim_ctrl_file(SIGNAL mm_clk : IN STD_LOGIC;
|
428 |
|
|
rd_file_name: IN STRING; wr_file_name : IN STRING) IS
|
429 |
|
|
BEGIN
|
430 |
|
|
-- Create the ctrl file that we're going to read from
|
431 |
|
|
print_str("[" & time_to_str(now) & "] " & rd_file_name & ": Created" );
|
432 |
|
|
mmf_file_create(rd_file_name);
|
433 |
|
|
|
434 |
|
|
WHILE TRUE LOOP
|
435 |
|
|
mmf_sim_ctrl_from_file(rd_file_name, wr_file_name);
|
436 |
|
|
proc_common_wait_some_cycles(mm_clk, 1);
|
437 |
|
|
END LOOP;
|
438 |
|
|
|
439 |
|
|
END;
|
440 |
|
|
|
441 |
|
|
|
442 |
|
|
PROCEDURE mmf_wait_for_file_status(rd_filename : IN STRING; -- file name with extension
|
443 |
|
|
exit_on_empty : IN BOOLEAN;
|
444 |
|
|
SIGNAL mm_clk : IN STD_LOGIC) IS
|
445 |
|
|
FILE rd_file : TEXT;
|
446 |
|
|
VARIABLE open_status_rd : file_open_status;
|
447 |
|
|
VARIABLE v_endfile : BOOLEAN;
|
448 |
|
|
BEGIN
|
449 |
|
|
-- Check on falling_edge(mm_clk) because mmf_mm_from_file() operates on rising_edge(mm_clk)
|
450 |
|
|
-- Note: In fact the file IO also works fine when rising_edge() is used, but then
|
451 |
|
|
-- tb_tb_mm_file.vhd takes about 1% more mm_clk cycles
|
452 |
|
|
WAIT UNTIL falling_edge(mm_clk);
|
453 |
|
|
|
454 |
|
|
-- Keep reading the file until it has become empty by some other program
|
455 |
|
|
WHILE TRUE LOOP
|
456 |
|
|
-- Open the file in read mode to check whether it is empty
|
457 |
|
|
file_open(open_status_rd, rd_file, rd_filename, read_mode);
|
458 |
|
|
-- open_status may throw an error if the file is being written to by some other program
|
459 |
|
|
IF open_status_rd=open_ok THEN
|
460 |
|
|
v_endfile := endfile(rd_file);
|
461 |
|
|
file_close(rd_file);
|
462 |
|
|
IF exit_on_empty THEN
|
463 |
|
|
IF v_endfile THEN
|
464 |
|
|
-- The file is empty; continue
|
465 |
|
|
EXIT;
|
466 |
|
|
ELSE
|
467 |
|
|
-- The file is not empty; wait one MM clock cycle.
|
468 |
|
|
WAIT UNTIL falling_edge(mm_clk);
|
469 |
|
|
END IF;
|
470 |
|
|
ELSE
|
471 |
|
|
IF v_endfile THEN
|
472 |
|
|
-- The file is empty; wait one MM clock cycle.
|
473 |
|
|
WAIT UNTIL falling_edge(mm_clk);
|
474 |
|
|
ELSE
|
475 |
|
|
-- The file is not empty; continue
|
476 |
|
|
EXIT;
|
477 |
|
|
END IF;
|
478 |
|
|
END IF;
|
479 |
|
|
ELSE
|
480 |
|
|
REPORT "mmf_wait_for_file_status() could not open " & rd_filename & " at " & time_to_str(now) SEVERITY NOTE;
|
481 |
|
|
WAIT UNTIL falling_edge(mm_clk);
|
482 |
|
|
END IF;
|
483 |
|
|
END LOOP;
|
484 |
|
|
-- The END implicitely close the file, if still necessary.
|
485 |
|
|
END;
|
486 |
|
|
|
487 |
|
|
PROCEDURE mmf_wait_for_file_empty(rd_filename : IN STRING; -- file name with extension
|
488 |
|
|
SIGNAL mm_clk : IN STD_LOGIC) IS
|
489 |
|
|
BEGIN
|
490 |
|
|
mmf_wait_for_file_status(rd_filename, TRUE, mm_clk);
|
491 |
|
|
END;
|
492 |
|
|
|
493 |
|
|
PROCEDURE mmf_wait_for_file_not_empty(rd_filename : IN STRING; -- file name with extension
|
494 |
|
|
SIGNAL mm_clk : IN STD_LOGIC) IS
|
495 |
|
|
BEGIN
|
496 |
|
|
mmf_wait_for_file_status(rd_filename, FALSE, mm_clk);
|
497 |
|
|
END;
|
498 |
|
|
|
499 |
|
|
PROCEDURE mmf_mm_bus_wr(filename : IN STRING; -- file name without extension
|
500 |
|
|
wr_addr : IN INTEGER; -- use integer to support full 32 bit range
|
501 |
|
|
wr_data : IN INTEGER;
|
502 |
|
|
SIGNAL mm_clk : IN STD_LOGIC) IS
|
503 |
|
|
CONSTANT ctrl_filename : STRING := filename & ".ctrl";
|
504 |
|
|
FILE ctrl_file : TEXT;
|
505 |
|
|
VARIABLE open_status_wr : file_open_status;
|
506 |
|
|
VARIABLE wr_line : LINE;
|
507 |
|
|
|
508 |
|
|
BEGIN
|
509 |
|
|
-- Write MM WR access to the .ctrl file.
|
510 |
|
|
-- The MM device is ready for a new MM request, because any previous MM request has finished at
|
511 |
|
|
-- mmf_mm_bus_wr() or mmf_mm_bus_rd() procedure exit, therefore just overwrite the .ctrl file.
|
512 |
|
|
file_open(open_status_wr, ctrl_file, ctrl_filename, write_mode);
|
513 |
|
|
-- open_status may throw an error if the file is being written to by some other program
|
514 |
|
|
IF open_status_wr=open_ok THEN
|
515 |
|
|
write(wr_line, STRING'("WR"));
|
516 |
|
|
writeline(ctrl_file, wr_line);
|
517 |
|
|
hwrite(wr_line, TO_SVEC(wr_addr, c_word_w));
|
518 |
|
|
writeline(ctrl_file, wr_line);
|
519 |
|
|
hwrite(wr_line, TO_SVEC(wr_data, c_word_w));
|
520 |
|
|
writeline(ctrl_file, wr_line);
|
521 |
|
|
file_close(ctrl_file);
|
522 |
|
|
ELSE
|
523 |
|
|
REPORT "mmf_mm_bus_wr() could not open " & ctrl_filename & " at " & time_to_str(now) SEVERITY NOTE;
|
524 |
|
|
END IF;
|
525 |
|
|
|
526 |
|
|
-- Prepare for next MM request
|
527 |
|
|
-- Keep reading the .ctrl file until it is empty, to ensure that the MM device is ready for a new MM request
|
528 |
|
|
mmf_wait_for_file_empty(ctrl_filename, mm_clk);
|
529 |
|
|
|
530 |
|
|
-- The END implicitely close the ctrl_file, if still necessary.
|
531 |
|
|
END;
|
532 |
|
|
|
533 |
|
|
PROCEDURE mmf_mm_bus_rd(filename : IN STRING; -- file name without extension
|
534 |
|
|
rd_latency : IN NATURAL;
|
535 |
|
|
rd_addr : IN INTEGER; -- use integer to support full 32 bit range
|
536 |
|
|
SIGNAL rd_data : OUT STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
|
537 |
|
|
SIGNAL mm_clk : IN STD_LOGIC) IS
|
538 |
|
|
CONSTANT ctrl_filename : STRING := filename & ".ctrl";
|
539 |
|
|
CONSTANT stat_filename : STRING := filename & ".stat";
|
540 |
|
|
FILE ctrl_file : TEXT;
|
541 |
|
|
FILE stat_file : TEXT;
|
542 |
|
|
VARIABLE open_status_wr : file_open_status;
|
543 |
|
|
VARIABLE open_status_rd : file_open_status;
|
544 |
|
|
VARIABLE wr_line : LINE;
|
545 |
|
|
VARIABLE rd_line : LINE;
|
546 |
|
|
VARIABLE v_rd_data : STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
|
547 |
|
|
|
548 |
|
|
BEGIN
|
549 |
|
|
-- Clear the .stat file by recreating it, because we don't want to do read old file data again
|
550 |
|
|
mmf_file_create(stat_filename);
|
551 |
|
|
|
552 |
|
|
-- Write MM RD access to the .ctrl file.
|
553 |
|
|
-- The MM device is ready for a new MM request, because any previous MM request has finished at
|
554 |
|
|
-- mmf_mm_bus_wr() or mmf_mm_bus_rd() procedure exit, therefore just overwrite the .ctrl file.
|
555 |
|
|
file_open(open_status_wr, ctrl_file, ctrl_filename, write_mode);
|
556 |
|
|
-- open_status may throw an error if the file is being written to by some other program
|
557 |
|
|
IF open_status_wr=open_ok THEN
|
558 |
|
|
write(wr_line, STRING'("RD"));
|
559 |
|
|
writeline(ctrl_file, wr_line);
|
560 |
|
|
hwrite(wr_line, TO_SVEC(rd_addr, c_word_w));
|
561 |
|
|
writeline(ctrl_file, wr_line);
|
562 |
|
|
file_close(ctrl_file);
|
563 |
|
|
ELSE
|
564 |
|
|
REPORT "mmf_mm_bus_rd() could not open " & ctrl_filename & " at " & time_to_str(now) SEVERITY FAILURE;
|
565 |
|
|
END IF;
|
566 |
|
|
|
567 |
|
|
-- Wait until the MM RD access has written the read data to the .stat file
|
568 |
|
|
mmf_wait_for_file_not_empty(stat_filename, mm_clk);
|
569 |
|
|
|
570 |
|
|
-- Read the MM RD access read data from the .stat file
|
571 |
|
|
file_open(open_status_rd, stat_file, stat_filename, read_mode);
|
572 |
|
|
-- open_status may throw an error if the file is being written to by some other program
|
573 |
|
|
IF open_status_rd=open_ok THEN
|
574 |
|
|
readline(stat_file, rd_line);
|
575 |
|
|
hread(rd_line, v_rd_data);
|
576 |
|
|
file_close(stat_file);
|
577 |
|
|
rd_data <= v_rd_data;
|
578 |
|
|
-- wait to ensure rd_data has got v_rd_data, otherwise rd_data still holds the old data on procedure exit
|
579 |
|
|
-- the wait should be < mm_clk period/2 to not affect the read rate
|
580 |
|
|
WAIT FOR 1 fs;
|
581 |
|
|
ELSE
|
582 |
|
|
REPORT "mmf_mm_bus_rd() could not open " & stat_filename & " at " & time_to_str(now) SEVERITY FAILURE;
|
583 |
|
|
END IF;
|
584 |
|
|
|
585 |
|
|
-- No need to prepare for next MM request, because:
|
586 |
|
|
-- . the .ctrl file must already be empty because the .stat file was there
|
587 |
|
|
-- . the .stat file will be cleared on this procedure entry
|
588 |
|
|
|
589 |
|
|
-- The END implicitely closes the files, if still necessary
|
590 |
|
|
END;
|
591 |
|
|
|
592 |
|
|
-- rd_latency = 1
|
593 |
|
|
PROCEDURE mmf_mm_bus_rd(filename : IN STRING;
|
594 |
|
|
rd_addr : IN INTEGER;
|
595 |
|
|
SIGNAL rd_data : OUT STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
|
596 |
|
|
SIGNAL mm_clk : IN STD_LOGIC) IS
|
597 |
|
|
BEGIN
|
598 |
|
|
mmf_mm_bus_rd(filename, 1, rd_addr, rd_data, mm_clk);
|
599 |
|
|
END;
|
600 |
|
|
|
601 |
|
|
PROCEDURE mmf_mm_wait_until_value(filename : IN STRING; -- file name without extension
|
602 |
|
|
rd_addr : IN INTEGER;
|
603 |
|
|
c_representation : IN STRING; -- treat rd_data as "SIGNED" or "UNSIGNED" 32 bit word
|
604 |
|
|
SIGNAL rd_data : INOUT STD_LOGIC_VECTOR(c_word_w-1 DOWNTO 0);
|
605 |
|
|
c_condition : IN STRING; -- ">", ">=", "=", "<=", "<", "/="
|
606 |
|
|
c_rd_value : IN INTEGER;
|
607 |
|
|
c_rd_interval : IN TIME;
|
608 |
|
|
SIGNAL mm_clk : IN STD_LOGIC) IS
|
609 |
|
|
BEGIN
|
610 |
|
|
WHILE TRUE LOOP
|
611 |
|
|
-- Read current
|
612 |
|
|
mmf_mm_bus_rd(filename, rd_addr, rd_data, mm_clk); -- only read low part
|
613 |
|
|
IF c_representation="SIGNED" THEN
|
614 |
|
|
IF c_condition=">" THEN IF TO_SINT(rd_data)> c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
615 |
|
|
ELSIF c_condition=">=" THEN IF TO_SINT(rd_data)>=c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
616 |
|
|
ELSIF c_condition="/=" THEN IF TO_SINT(rd_data)/=c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
617 |
|
|
ELSIF c_condition="<=" THEN IF TO_SINT(rd_data)<=c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
618 |
|
|
ELSIF c_condition="<" THEN IF TO_SINT(rd_data)< c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
619 |
|
|
ELSE IF TO_SINT(rd_data) =c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF; -- default: "="
|
620 |
|
|
END IF;
|
621 |
|
|
ELSE -- default: UNSIGED
|
622 |
|
|
IF c_condition=">" THEN IF TO_UINT(rd_data)> c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
623 |
|
|
ELSIF c_condition=">=" THEN IF TO_UINT(rd_data)>=c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
624 |
|
|
ELSIF c_condition="/=" THEN IF TO_UINT(rd_data)/=c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
625 |
|
|
ELSIF c_condition="<=" THEN IF TO_UINT(rd_data)<=c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
626 |
|
|
ELSIF c_condition="<" THEN IF TO_UINT(rd_data)< c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF;
|
627 |
|
|
ELSE IF TO_UINT(rd_data) =c_rd_value THEN EXIT; ELSE WAIT FOR c_rd_interval; END IF; -- default: "="
|
628 |
|
|
END IF;
|
629 |
|
|
END IF;
|
630 |
|
|
END LOOP;
|
631 |
|
|
END mmf_mm_wait_until_value;
|
632 |
|
|
|
633 |
|
|
|
634 |
|
|
PROCEDURE mmf_sim_get_now(filename : IN STRING; -- file name without extension
|
635 |
|
|
SIGNAL rd_now : OUT STRING;
|
636 |
|
|
SIGNAL mm_clk : IN STD_LOGIC) IS
|
637 |
|
|
CONSTANT ctrl_filename : STRING := filename & ".ctrl";
|
638 |
|
|
CONSTANT stat_filename : STRING := filename & ".stat";
|
639 |
|
|
FILE ctrl_file : TEXT;
|
640 |
|
|
FILE stat_file : TEXT;
|
641 |
|
|
VARIABLE open_status_wr : file_open_status;
|
642 |
|
|
VARIABLE open_status_rd : file_open_status;
|
643 |
|
|
VARIABLE wr_line : LINE;
|
644 |
|
|
VARIABLE rd_line : LINE;
|
645 |
|
|
VARIABLE v_rd_now : STRING(rd_now'RANGE);
|
646 |
|
|
|
647 |
|
|
BEGIN
|
648 |
|
|
-- Clear the sim.stat file by recreating it, because we don't want to do read old simulator status again
|
649 |
|
|
mmf_file_create(stat_filename);
|
650 |
|
|
|
651 |
|
|
-- Write GET_SIM_TIME to the sim.ctrl file
|
652 |
|
|
-- The simulation is ready for a new simulation status request, because any previous simulation status request has finished at
|
653 |
|
|
-- mmf_sim_get_now() procedure exit, therefore just overwrite the .ctrl file.
|
654 |
|
|
file_open(open_status_wr, ctrl_file, ctrl_filename, write_mode);
|
655 |
|
|
-- open_status may throw an error if the file is being written to by some other program
|
656 |
|
|
IF open_status_wr=open_ok THEN
|
657 |
|
|
write(wr_line, STRING'("GET_SIM_TIME"));
|
658 |
|
|
writeline(ctrl_file, wr_line);
|
659 |
|
|
file_close(ctrl_file);
|
660 |
|
|
ELSE
|
661 |
|
|
REPORT "mmf_sim_get_now() could not open " & ctrl_filename & " at " & time_to_str(now) SEVERITY FAILURE;
|
662 |
|
|
END IF;
|
663 |
|
|
|
664 |
|
|
-- Wait until the simulation has written the simulation status to the sim.stat file
|
665 |
|
|
mmf_wait_for_file_not_empty(stat_filename, mm_clk);
|
666 |
|
|
|
667 |
|
|
-- Read the GET_SIM_TIME simulation status from the .stat file
|
668 |
|
|
file_open(open_status_rd, stat_file, stat_filename, read_mode);
|
669 |
|
|
-- open_status may throw an error if the file is being written to by some other program
|
670 |
|
|
IF open_status_rd=open_ok THEN
|
671 |
|
|
readline(stat_file, rd_line);
|
672 |
|
|
read(rd_line, v_rd_now);
|
673 |
|
|
file_close(stat_file);
|
674 |
|
|
rd_now <= v_rd_now;
|
675 |
|
|
print_str("GET_SIM_TIME = " & v_rd_now & " at " & time_to_str(now));
|
676 |
|
|
ELSE
|
677 |
|
|
REPORT "mmf_sim_get_now() could not open " & stat_filename & " at " & time_to_str(now) SEVERITY FAILURE;
|
678 |
|
|
END IF;
|
679 |
|
|
|
680 |
|
|
-- No need to prepare for next simulation status request, because:
|
681 |
|
|
-- . the .ctrl file must already be empty because the .stat file was there
|
682 |
|
|
-- . the .stat file will be cleared on this procedure entry
|
683 |
|
|
|
684 |
|
|
-- The END implicitely closes the files, if still necessary
|
685 |
|
|
END;
|
686 |
|
|
|
687 |
|
|
-- Functions to create prefixes for the mmf file filename
|
688 |
|
|
FUNCTION mmf_prefix(name : STRING; index : NATURAL) RETURN STRING IS
|
689 |
|
|
BEGIN
|
690 |
|
|
RETURN name & "_" & int_to_str(index) & "_";
|
691 |
|
|
END;
|
692 |
|
|
|
693 |
|
|
FUNCTION mmf_tb_prefix(tb : INTEGER) RETURN STRING IS
|
694 |
|
|
BEGIN
|
695 |
|
|
RETURN mmf_prefix("TB", tb);
|
696 |
|
|
END;
|
697 |
|
|
|
698 |
|
|
FUNCTION mmf_subrack_prefix(subrack : INTEGER) RETURN STRING IS
|
699 |
|
|
BEGIN
|
700 |
|
|
RETURN mmf_prefix("SUBRACK", subrack);
|
701 |
|
|
END;
|
702 |
|
|
|
703 |
|
|
-- Functions to create mmf file prefix that is unique per slave, for increasing number of hierarchy levels:
|
704 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL) RETURN STRING IS
|
705 |
|
|
BEGIN
|
706 |
|
|
RETURN dir_path & mmf_prefix(s0, i0);
|
707 |
|
|
END;
|
708 |
|
|
|
709 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL) RETURN STRING IS
|
710 |
|
|
BEGIN
|
711 |
|
|
RETURN dir_path & mmf_prefix(s0, i0) & mmf_prefix(s1, i1);
|
712 |
|
|
END;
|
713 |
|
|
|
714 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL) RETURN STRING IS
|
715 |
|
|
BEGIN
|
716 |
|
|
RETURN dir_path & mmf_prefix(s0, i0) & mmf_prefix(s1, i1) & mmf_prefix(s2, i2);
|
717 |
|
|
END;
|
718 |
|
|
|
719 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL; s3 : STRING; i3 : NATURAL) RETURN STRING IS
|
720 |
|
|
BEGIN
|
721 |
|
|
RETURN dir_path & mmf_prefix(s0, i0) & mmf_prefix(s1, i1) & mmf_prefix(s2, i2) & mmf_prefix(s3, i3);
|
722 |
|
|
END;
|
723 |
|
|
|
724 |
|
|
FUNCTION mmf_slave_prefix(dir_path, s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL; s3 : STRING; i3 : NATURAL; s4 : STRING; i4 : NATURAL) RETURN STRING IS
|
725 |
|
|
BEGIN
|
726 |
|
|
RETURN dir_path & mmf_prefix(s0, i0) & mmf_prefix(s1, i1) & mmf_prefix(s2, i2) & mmf_prefix(s3, i3) & mmf_prefix(s4, i4);
|
727 |
|
|
END;
|
728 |
|
|
|
729 |
|
|
-- Use local dir_path
|
730 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL) RETURN STRING IS
|
731 |
|
|
BEGIN
|
732 |
|
|
RETURN c_mmf_local_dir_path & mmf_prefix(s0, i0);
|
733 |
|
|
END;
|
734 |
|
|
|
735 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL) RETURN STRING IS
|
736 |
|
|
BEGIN
|
737 |
|
|
RETURN c_mmf_local_dir_path & mmf_prefix(s0, i0) & mmf_prefix(s1, i1);
|
738 |
|
|
END;
|
739 |
|
|
|
740 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL) RETURN STRING IS
|
741 |
|
|
BEGIN
|
742 |
|
|
RETURN c_mmf_local_dir_path & mmf_prefix(s0, i0) & mmf_prefix(s1, i1) & mmf_prefix(s2, i2);
|
743 |
|
|
END;
|
744 |
|
|
|
745 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL; s3 : STRING; i3 : NATURAL) RETURN STRING IS
|
746 |
|
|
BEGIN
|
747 |
|
|
RETURN c_mmf_local_dir_path & mmf_prefix(s0, i0) & mmf_prefix(s1, i1) & mmf_prefix(s2, i2) & mmf_prefix(s3, i3);
|
748 |
|
|
END;
|
749 |
|
|
|
750 |
|
|
FUNCTION mmf_slave_prefix(s0 : STRING; i0 : NATURAL; s1 : STRING; i1 : NATURAL; s2 : STRING; i2 : NATURAL; s3 : STRING; i3 : NATURAL; s4 : STRING; i4 : NATURAL) RETURN STRING IS
|
751 |
|
|
BEGIN
|
752 |
|
|
RETURN c_mmf_local_dir_path & mmf_prefix(s0, i0) & mmf_prefix(s1, i1) & mmf_prefix(s2, i2) & mmf_prefix(s3, i3) & mmf_prefix(s4, i4);
|
753 |
|
|
END;
|
754 |
|
|
|
755 |
|
|
END mm_file_pkg;
|
756 |
|
|
|