S
Subramanian Ramaswamy
Guest
I am trying to initialize a 16 bit shift register from a file which contains
"0000000000000000" using the following code. However, when simulating the
value in the file is not absorbed into the output or to the variable "val"
that I have used. If some one can help me figure out what the problem is, I
would appreciate it.
Thanks.
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use std.textio.all;
entity ShiftReg is
Port (d_in : in std_logic_vector(15 downto 0);
serial_in,ld,shift,clk,reset : in std_logic;
q : inout std_logic_vector(15 downto 0));
end entity ShiftReg;
architecture behavioral of ShiftReg is
subtype word is std_logic_vector(15 downto 0);
type initz is file of word;
begin
P: process (clk, shift, ld,reset)
file datain : initz open read_mode is "init.txt";
begin
if (reset='1') then
while not(endfile(datain)) loop
read(datain,val);
end loop;
q <=val;
elsif ( clk'event and clk ='1') then
if (shift = '0') and (ld='1') then
q <= d_in ;
elsif (shift = '1') then
q(14 downto 0) <= q(15 downto 1) ;
q(15) <= serial_in ;
end if;
end if;
end process P;
end architecture behavioral;
"0000000000000000" using the following code. However, when simulating the
value in the file is not absorbed into the output or to the variable "val"
that I have used. If some one can help me figure out what the problem is, I
would appreciate it.
Thanks.
library IEEE;
use IEEE.STD_LOGIC_1164.all;
use std.textio.all;
entity ShiftReg is
Port (d_in : in std_logic_vector(15 downto 0);
serial_in,ld,shift,clk,reset : in std_logic;
q : inout std_logic_vector(15 downto 0));
end entity ShiftReg;
architecture behavioral of ShiftReg is
subtype word is std_logic_vector(15 downto 0);
type initz is file of word;
begin
P: process (clk, shift, ld,reset)
file datain : initz open read_mode is "init.txt";
begin
if (reset='1') then
while not(endfile(datain)) loop
read(datain,val);
end loop;
q <=val;
elsif ( clk'event and clk ='1') then
if (shift = '0') and (ld='1') then
q <= d_in ;
elsif (shift = '1') then
q(14 downto 0) <= q(15 downto 1) ;
q(15) <= serial_in ;
end if;
end if;
end process P;
end architecture behavioral;