ghostridergr
Member level 1
Well this is my code:
my problem is that test remains UUUUUUUUUUUUUUUUUUUUUUUUUU and more my last element from input2.txt isn't stored in inp2 array (but i can see its value on signal b). So given as an input 3 elements in both txt's my array's contain values in inp1(0),inp1(1),inp1(2), inp2(0),inp2(1) as it should be, but not in inp2(2).
Can anyone help?
Code:
library IEEE;
use IEEE.std_logic_1164.all;
use STD.TEXTIO.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;
entity tb_file_test is
generic
(
N :integer := 8
);
end tb_file_test;
architecture TB_ARCHITECTURE of tb_file_test is
file IN_1_VECTORS: TEXT open READ_MODE is "input_1.txt";
file IN_2_VECTORS: TEXT open READ_MODE is "input_2.txt";
file OUT_VECTORS: TEXT open WRITE_MODE is "output.txt";
--here
type matrix is array(natural range<>) of signed(N-1 downto 0);
signal inp1,inp2: matrix(0 to 124);
signal a,b: signed(N-1 downto 0):= (others=>'0');
signal test:std_logic_vector(3*N-1 downto 0);
function sum_of_square( a1,b1: in signed(N-1 downto 0); previous_sum:in std_logic_vector(3*N-1 downto 0))return std_logic_vector is
variable temp_sum:std_logic_vector(3*N-1 downto 0):=(others=>'0');
variable diff: signed(N-1 downto 0):=(others=>'0');
variable square_diff: std_logic_vector(2*N-1 downto 0):=(others=>'0');
begin
temp_sum:=previous_sum;
diff:=a1-b1;
square_diff:=ext(diff*diff,2*N);
temp_sum:=ext(temp_sum+square_diff,3*N);
return temp_sum;
end sum_of_square;
begin
process
variable IN_BUF: LINE;
variable OUT_BUF: LINE;
variable a_var,b_var : bit_vector(N-1 downto 0):= (others=>'0');
variable i,j: integer;
begin
i:=0;
j:=0;
while not ENDFILE(IN_1_VECTORS) loop
READLINE(IN_1_VECTORS,IN_BUF);
READ(IN_BUF,a_var);
a<=signed(to_stdlogicvector(a_var));
wait for 10 ns;
inp1(i)<=a;
i:=i+1;
end loop;
while not ENDFILE(IN_2_VECTORS) loop
READLINE(IN_2_VECTORS,IN_BUF);
READ(IN_BUF,b_var);
b<=signed(to_stdlogicvector(b_var));
wait for 10 ns;
inp2(j)<=b;
j:=j+1;
end loop;
test<=ext(sum_of_square("00001000","00000001","000000000000000000000000"),3*N);
end process;
end TB_ARCHITECTURE;
my problem is that test remains UUUUUUUUUUUUUUUUUUUUUUUUUU and more my last element from input2.txt isn't stored in inp2 array (but i can see its value on signal b). So given as an input 3 elements in both txt's my array's contain values in inp1(0),inp1(1),inp1(2), inp2(0),inp2(1) as it should be, but not in inp2(2).
Can anyone help?