1 | -- ------------------------------------------------------------------
|
2 | -- file: frame_util_pkg.vhd
|
3 | -- ------------------------------------------------------------------
|
4 | library ieee;
|
5 | use ieee.std_logic_1164.all;
|
6 |
|
7 | package frame_util_pkg is
|
8 |
|
9 | -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
|
10 | -- Tx Data, Data_valid and underrun record
|
11 | type frame_typ is record
|
12 | bad_frame : boolean; -- does this frame contain an error?
|
13 | framelength : natural; -- length of data to send.
|
14 | gap : natural; -- gap before data will be send.
|
15 | end record;
|
16 | type frame_typ_ary is array (natural range <>) of frame_typ;
|
17 |
|
18 | end package frame_util_pkg;
|
19 |
|
20 | -- ------------------------------------------------------------------
|
21 | -- file: FILE_READ_FRAME_V2_0.vhd
|
22 | -- ------------------------------------------------------------------
|
23 | library ieee;
|
24 | use ieee.std_logic_1164.all;
|
25 | use std.textio.all;
|
26 |
|
27 | library tools;
|
28 | use tools.frame_util_pkg.all;
|
29 |
|
30 | entity FILE_READ_FRAME_V2_0 is
|
31 | generic (
|
32 | read_file : string;
|
33 | );
|
34 |
|
35 | port(
|
36 | clk : in std_logic;
|
37 | clken : in std_logic;
|
38 | rst_n : in std_logic;
|
39 | frame_data_o : out frame_typ_ary --[frame_util_pkg]
|
40 | );
|
41 | end FILE_READ_FRAME_V2_0;
|
42 |
|
43 |
|
44 | architecture read_from_file of FILE_READ_FRAME_V2_0 is
|
45 |
|
46 | file stimulus : text open read_mode is read_file;
|
47 |
|
48 | begin
|
49 |
|
50 | receive_data : process
|
51 | variable readLine_v : line;
|
52 | variable myTyp_v : frame_typ;
|
53 | begin
|
54 |
|
55 | while not endfile(stimulus) loop
|
56 | -- read data and control information from a file
|
57 | frame_data_o(INDEX) <= myTyp_v; --INDEX depending on content.
|
58 | end loop;
|
59 |
|
60 | end process;
|
61 | end architecture;
|
62 |
|
63 |
|
64 | -- ------------------------------------------------------------------
|
65 | -- file: tb_read_frames.vhd
|
66 | -- ------------------------------------------------------------------
|
67 | library ieee;
|
68 | use ieee.std_logic_1164.all;
|
69 | use ieee.std_logic_arith.all;
|
70 |
|
71 | library tools;
|
72 | use tools.frame_util_pkg.all;
|
73 |
|
74 | entity TB_READ_FRAMES is
|
75 | end TB_READ_FRAMES;
|
76 |
|
77 | architecture test of TB_READ_FRAMES is
|
78 |
|
79 | constant C_RX_FRAMES : natural := 10;
|
80 | constant C_TX_FRAMES : natural := 10;
|
81 | ------------------------------------------------------------------------------
|
82 | -- component instantiation
|
83 | ------------------------------------------------------------------------------
|
84 | component FILE_READ_FRAME_V2_0
|
85 | generic (
|
86 | read_file : string;
|
87 | );
|
88 |
|
89 | port(
|
90 | clk : in std_logic;
|
91 | clken : in std_logic;
|
92 | rst_n : in std_logic;
|
93 | frame_data_o : out frame_typ_ary --[frame_util_pkg]
|
94 | );
|
95 | end component;
|
96 |
|
97 | signal rst_n : std_logic;
|
98 | signal clk : std_logic := '0';
|
99 | signal data_rx_frames : frame_typ_ary(INDEX downto 0); -- <<--- HIER KRACHTS!
|
100 |
|
101 | begin
|
102 |
|
103 | rst_n <= '0', '1' after 10 ns;
|
104 | clk <= not clk after 10 ns;
|
105 |
|
106 |
|
107 |
|
108 | ------------------------------------------------------------------------------
|
109 | -- component declaration
|
110 | ------------------------------------------------------------------------------
|
111 | ALL_FRAMES : component FILE_READ_FRAME_V2_0
|
112 | generic map(
|
113 | read_file => "test.txt"
|
114 | )
|
115 | port map(
|
116 | clk => clk,
|
117 | clken => '0',
|
118 | rst_n => rst_n,
|
119 | frame_data_o => data_rx_frames
|
120 | );
|
121 |
|
122 |
|
123 | end test;
|