-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathTop_test_power.vhd
179 lines (138 loc) · 5.72 KB
/
Top_test_power.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
library ieee;
use ieee.numeric_std.all;
use ieee.std_logic_1164.all;
use std.textio.all;
use ieee.std_logic_textio.all;
--- Componentslibrary ieee;
USE ieee.numeric_std.all;
USE ieee.std_logic_1164.all;
ENTITY Top_test_power IS
END;
ARCHITECTURE behavior OF Top_test_power IS
--use work.tb_pkg;
--- Components ---
COMPONENT Top_pad
port (
start : in std_logic;
clk : in std_logic;
reset : in std_logic;
input0 : in std_logic_vector(7 downto 0);
finish : out std_logic
);
END COMPONENT;
--- Signals HA ---
signal clk : std_logic := '0';
signal reset : std_logic := '1';
signal start : std_logic := '0';
signal input_pad : std_logic_vector(7 downto 0) := (others => '0');
signal finish : std_logic;
--- Signals ---
signal CS : std_logic := '1';
signal OE : std_logic := '1'; -- Try having this at 0 zero as well.
constant clk_period : time := 100 ns;
constant clk_period_half :time:= 50 ns;
--- X file ---
--file file_pointer : text;
--variable line_content : string(1 to 4);
--variable line_num : line;
--variable j : integer := 0;
--variable char : character:='0';
--file XCoeffFile : text open read_mode is"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli.txt";
-- variable XCoeffFileLine : line;
-- variable input_reg : std_logic_vector(191 downto 0);
-- variable coeff : std_logic_vector(7 downto 0);
-- variable i : natural;
BEGIN
process
file file_pointer : text;
variable line_content : string(1 to 8);
variable line_num : line;
variable j : integer := 0;
variable char : character := '0'; --Open the file read.txt from the specified location for reading(READ_MODE).
variable count_line : integer := 0;
variable counter : integer := 0;
begin
--while (count_line <= 23) loop --till the end of file is reached continue.
wait for clk_period*2 + clk_period_half;
--if(reset = '0') then
for counter in 0 to 9 loop
wait for clk_period + clk_period_half;
reset <= '0';
wait for clk_period+clk_period_half;
start <= '1';
wait for clk_period+ clk_period_half;
start <= '0';
if(counter = 0) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli.txt",READ_MODE);
elsif(counter = 1) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli1.txt",READ_MODE);
elsif(counter = 2) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli2.txt",READ_MODE);
elsif(counter = 3) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli3.txt",READ_MODE);
elsif(counter = 4) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli4.txt",READ_MODE);
elsif(counter = 5) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli5.txt",READ_MODE);
elsif(counter = 6) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli6.txt",READ_MODE);
elsif(counter = 7) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli7.txt",READ_MODE);
elsif(counter = 8) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli8.txt",READ_MODE);
elsif(counter = 9) then
file_open(file_pointer,"/h/dc/e/elt13ms1/matrixmult/assignment_resources/input_stimuli9.txt",READ_MODE);
end if;
--backup wait for clk_period*2;
while (not(endfile(file_pointer))) loop --till the end of file is reached continue.
readline (file_pointer,line_num); --Read the whole line from the file
--Read the contents of the line from the file into a variable.
READ (line_num,line_content);
--For each character in the line convert it to binary value.
--And then store it in a signal named 'bin_value'.
--wait until clk'event and clk='0';
for j in 0 to 7 loop
char := line_content(j+1);
if(char = '0' and count_line < 24) then
input_pad((7-j)) <= '0';
elsif(char = '1' and count_line < 24) then
input_pad((7-j)) <= '1';
end if;
end loop;
count_line := count_line + 1;
wait for clk_period; --after reading each line wait for 10ns.
end loop;
file_close(file_pointer); --after reading all the lines close the file.
wait for 17 us;
reset <= '1';
j := 0;
char := '0'; --Open the file read.txt from the specified location for reading(READ_MODE).
count_line:= 0;
end loop;
--end if;
end process;
--reset <= '0' after clk_period + clk_period_half;
--start <= '1' after clk_period + clk_period_half,
-- -- '0' after 5*clk_period + clk_period_half;
-- reset <= '1' after clk_period + clk_period_half,
-- '0' after 5*clk_period + clk_period_half;
--
-- start <= '1' after 6*clk_period + clk_period_half,
-- '0' after 10*clk_period + clk_period_half;
--- Connnect components ---
DUT: Top_pad PORT MAP (
start => start,
clk => clk,
reset => reset,
input0 => input_pad,
finish => finish
);
--wait until clk'event and clk='0';
seq: process
begin
clk <= '0';
wait for clk_period/2;
clk <= '1';
wait for clk_period/2;
end process;
END ARCHITECTURE;