ammassk
Member level 2
dear all
I wrote a code for memory. I am getting correct values in the out put. but its not coming in correct clock period.Initially there are undefined values for many number of clock cycles.datas are also repeating for some clock cycles in the middle. how can i solve this?
I wrote a code for memory. I am getting correct values in the out put. but its not coming in correct clock period.Initially there are undefined values for many number of clock cycles.datas are also repeating for some clock cycles in the middle. how can i solve this?
Code:
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
use ieee.std_logic_unsigned.all;
use IEEE.STD_LOGIC_ARITH.ALL;
USE ieee.numeric_std.ALL;
ENTITY read_rom IS
port(clk: in std_logic;
out1:out integer;
out2:out integer
);
END read_rom;
ARCHITECTURE beha OF read_rom IS
type memory_array is array(integer range 0 to 3 , integer range 0 to 7)of character;
constant mem:memory_array:=("01011001","11100100","00100111","10011010");
type mem_arrayi is array (integer range 0 to 3,integer range 0 to 3) of integer;
signal data_i:mem_arrayi;
type mem_arrayj is array (integer range 0 to 3,integer range 0 to 3) of integer;
signal data_j:mem_arrayj;
begin
process(clk)
variable i:integer:=0;
variable j:integer:=0;
variable k:integer:=0;
variable l:integer:=0;
begin
if(clk='1' and clk'event)then
if mem(j,i)='1' then
data_i(k,l)<=i;
data_j(k,l)<=j;
l:=l+1;
if l>3 then
l:=0;
k:=k+1;
if(k>3) then
k:=0;
-- else
end if;
-- else
end if;
i:=i+1;
if(i>7) then
i:=0;
j:=j+1;
if(j>3) then
j:=0;
-- else
end if;
--else
end if;
out1<=data_i(k,l);
out2<=data_j(k,l);
else
i:=i+1;
if(i>7) then
i:=0;
j:=j+1;
if(j>3) then
j:=0;
else
null;
end if;
else
null;
end if;
end if;
else
null;
end if;
end process;
end beha;
Last edited: