R
ramanand
Guest
I am having a problem in executing file's. it was compiled
successfully. But coming to simulation it is not reading the i/p
values from i/p FILE, it taking default values.
Please tell me the solution for the below code . Thanks to all
(iam using modelsim5.5a)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use STD.TEXTIO.ALL;
use IEEE.STD_LOGIC_TEXTIO.ALL;
entity fir16bit is
port(
clk:in std_logic;
-- 16 INPUT SAMPLES FOR 16 TAP FILTER
samp1,samp2,samp3,samp4,samp5,samp6,samp7,samp8,samp9,samp10,samp11,samp12,samp13,samp14,samp15,samp16:in
integer;
-- 16 INPUT CO-EFFICIENTS
coef1,coef2,coef3,coef4,coef5,coef6,coef7,coef8,coef9,coef10,coef11,coef12,coef13,coef14,coef15,coef16:in
integer;
sut integer
);
end fir16bit;
architecture Behavioral of fir16bit is
type a is array(1 to 16) of integer; -- ARRAY TO STORE INPUT SAMPLES
type c is array(1 to 16) of integer; -- ARRAY TO STORE INPUT
CO-EFFICIENTS
begin
process(clk)
variable p1,p2,p3,p4,p5,p6,p7,p8,q1,q2,q3,q4,r1,r2:integer;
variable x : a;
variable z : c;
variable j:integer range 1 to 17:=1;
--FILE DECLARATION TO READ INPUT CO-EFFIEICENTS
variable init :boolean :=false;
type ip_data_file is file of integer;
--
file ip_coeff : ip_data_file is in "test123.txt";-- I/P FILE
DECLARARTION
type col_matrix is array (1 to 17) of integer;
variable coeff :col_matrix;
variable i: integer range 1 to 17:=1;
begin
if(init = false)then
while (not endfile(ip_coeff)) and (i < 17)loop
read(ip_coeff, coeff(i)); -- i/p coeff's read in to
file:IP_CO_COEFF
i := i+1;
end loop;
init:=true;
end if;
if rising_edge(clk)then
x(1) := samp1;
x(2) := samp2;
x(3) := samp3;
x(4) := samp4;
x(5) := samp5;
x(6) := samp6;
x(7) := samp7;
x(8) := samp8;
x(9) := samp9;
x(10):= samp10;
x(11):= samp11;
x(12):= samp12;
x(13):= samp13;
x(14):= samp14;
x(15):= samp15;
x(16):= samp16;
--MULTIPLICATION OF CO-EFFICIENTS AND SAMPLES.
j:=1;
while (j < 17) loop
z(j) := x(j)* coeff(j);
j := j+1;
end loop;
-- ADDITIONS OF INDIVIDUL PRODUCT TERMS.
p1 := z(1)+z(2);
p2 := z(3)+z(4);
p3 := z(5)+z(6);
p4 := z(7)+z(8);
p5 := z(9)+z(10);
p6 := z(11)+z(12);
p7 := z(13)+z(14);
p8 := z(15)+z(16);
q1 := p1+p2;
q2 := p3+p4;
q3 := p5+p6;
q4 := p7+p8;
r1 := q1+q2;
r2 := q3+q4;
--FINAL OUTPUT ASSIGNMENT
s <= (r1+r2)
end if;
end process; end Behavioral;
successfully. But coming to simulation it is not reading the i/p
values from i/p FILE, it taking default values.
Please tell me the solution for the below code . Thanks to all
(iam using modelsim5.5a)
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
use STD.TEXTIO.ALL;
use IEEE.STD_LOGIC_TEXTIO.ALL;
entity fir16bit is
port(
clk:in std_logic;
-- 16 INPUT SAMPLES FOR 16 TAP FILTER
samp1,samp2,samp3,samp4,samp5,samp6,samp7,samp8,samp9,samp10,samp11,samp12,samp13,samp14,samp15,samp16:in
integer;
-- 16 INPUT CO-EFFICIENTS
coef1,coef2,coef3,coef4,coef5,coef6,coef7,coef8,coef9,coef10,coef11,coef12,coef13,coef14,coef15,coef16:in
integer;
sut integer
);
end fir16bit;
architecture Behavioral of fir16bit is
type a is array(1 to 16) of integer; -- ARRAY TO STORE INPUT SAMPLES
type c is array(1 to 16) of integer; -- ARRAY TO STORE INPUT
CO-EFFICIENTS
begin
process(clk)
variable p1,p2,p3,p4,p5,p6,p7,p8,q1,q2,q3,q4,r1,r2:integer;
variable x : a;
variable z : c;
variable j:integer range 1 to 17:=1;
--FILE DECLARATION TO READ INPUT CO-EFFIEICENTS
variable init :boolean :=false;
type ip_data_file is file of integer;
--
file ip_coeff : ip_data_file is in "test123.txt";-- I/P FILE
DECLARARTION
type col_matrix is array (1 to 17) of integer;
variable coeff :col_matrix;
variable i: integer range 1 to 17:=1;
begin
if(init = false)then
while (not endfile(ip_coeff)) and (i < 17)loop
read(ip_coeff, coeff(i)); -- i/p coeff's read in to
file:IP_CO_COEFF
i := i+1;
end loop;
init:=true;
end if;
if rising_edge(clk)then
x(1) := samp1;
x(2) := samp2;
x(3) := samp3;
x(4) := samp4;
x(5) := samp5;
x(6) := samp6;
x(7) := samp7;
x(8) := samp8;
x(9) := samp9;
x(10):= samp10;
x(11):= samp11;
x(12):= samp12;
x(13):= samp13;
x(14):= samp14;
x(15):= samp15;
x(16):= samp16;
--MULTIPLICATION OF CO-EFFICIENTS AND SAMPLES.
j:=1;
while (j < 17) loop
z(j) := x(j)* coeff(j);
j := j+1;
end loop;
-- ADDITIONS OF INDIVIDUL PRODUCT TERMS.
p1 := z(1)+z(2);
p2 := z(3)+z(4);
p3 := z(5)+z(6);
p4 := z(7)+z(8);
p5 := z(9)+z(10);
p6 := z(11)+z(12);
p7 := z(13)+z(14);
p8 := z(15)+z(16);
q1 := p1+p2;
q2 := p3+p4;
q3 := p5+p6;
q4 := p7+p8;
r1 := q1+q2;
r2 := q3+q4;
--FINAL OUTPUT ASSIGNMENT
s <= (r1+r2)
end if;
end process; end Behavioral;