Guest_imported
New member
- Jan 1, 1970
- 0
hi,
I'm facing problem to run the whole program correctly. When the program found a peak, the program suppose to be reset and the program will start the loop of Check1 again and compare the value starting of YMEM(i). Now, i should start from value of n(where the array stop when the peak found). The peak will be zero and counter(ctr) will starts from zero again. But this doesn't work and the simulation stopped at 3250ns. Hope someone can help me out this time.
Thanks.
library IEEE;
use IEEE.std_logic_1164.all;
entity checkzero is
port (
clk: in std_logic;
Yin: in real range -1000.0 to 1000.0;
rw: in STD_LOGIC;
dataout: out std_logic
);
end checkzero;
architecture checkzero_arch of checkzero is
subtype MEM_SIZE is integer range 0 to 30;
subtype WORD_SIZE is real range -1000.0 to 1000.0;
type Y_MEMORY is array(MEM_SIZE) of WORD_SIZE;
signal n: integer;
signal X_Ready:std_logic;
signal peakfound:std_logic;
signal overflow:boolean;
signal reset:std_logic;
begin
C1: process
variable YMEM:Y_MEMORY;
variable i:integer;
variable sth1:real:=35.0;
variable RRhigh: real:=10.0;
variable ctr:integer;
begin
i:=0;
READ:loop
wait until (clk='1' and clk'event and rw='1');
YMEM(i):=Yin;
exit READ when (i=MEM_SIZE'high);
i:=i+1;
X_Ready<='0';
end loop;
X_Ready<='1';
i:=0;
ctr:=0;
Check1:loop
wait until (clk='1' and clk'event and X_Ready='1');
if YMEM(i) > sth1 then
if YMEM(i+1)<0.0 then
n<=i;
peakfound<='1';
reset<='1'; --reset the value when peak found
overflow<=false;
exit Check1;
else
reset<='0';
i:=i+1;
ctr:=ctr+1;
overflow<=false;
end if;
elsif
ctr>integer(RRhigh) then
overflow<=true;
ctr:=0;
end if;
if reset<='1' then
ctr:=0;
i:=n; --continue to compare the value of YMEM(i) from where it
stops
end if;
end loop;
i:=i+1;
dataout<=peakfound;
end process C1;
end checkzero_arch;
I'm facing problem to run the whole program correctly. When the program found a peak, the program suppose to be reset and the program will start the loop of Check1 again and compare the value starting of YMEM(i). Now, i should start from value of n(where the array stop when the peak found). The peak will be zero and counter(ctr) will starts from zero again. But this doesn't work and the simulation stopped at 3250ns. Hope someone can help me out this time.
Thanks.
library IEEE;
use IEEE.std_logic_1164.all;
entity checkzero is
port (
clk: in std_logic;
Yin: in real range -1000.0 to 1000.0;
rw: in STD_LOGIC;
dataout: out std_logic
);
end checkzero;
architecture checkzero_arch of checkzero is
subtype MEM_SIZE is integer range 0 to 30;
subtype WORD_SIZE is real range -1000.0 to 1000.0;
type Y_MEMORY is array(MEM_SIZE) of WORD_SIZE;
signal n: integer;
signal X_Ready:std_logic;
signal peakfound:std_logic;
signal overflow:boolean;
signal reset:std_logic;
begin
C1: process
variable YMEM:Y_MEMORY;
variable i:integer;
variable sth1:real:=35.0;
variable RRhigh: real:=10.0;
variable ctr:integer;
begin
i:=0;
READ:loop
wait until (clk='1' and clk'event and rw='1');
YMEM(i):=Yin;
exit READ when (i=MEM_SIZE'high);
i:=i+1;
X_Ready<='0';
end loop;
X_Ready<='1';
i:=0;
ctr:=0;
Check1:loop
wait until (clk='1' and clk'event and X_Ready='1');
if YMEM(i) > sth1 then
if YMEM(i+1)<0.0 then
n<=i;
peakfound<='1';
reset<='1'; --reset the value when peak found
overflow<=false;
exit Check1;
else
reset<='0';
i:=i+1;
ctr:=ctr+1;
overflow<=false;
end if;
elsif
ctr>integer(RRhigh) then
overflow<=true;
ctr:=0;
end if;
if reset<='1' then
ctr:=0;
i:=n; --continue to compare the value of YMEM(i) from where it
stops
end if;
end loop;
i:=i+1;
dataout<=peakfound;
end process C1;
end checkzero_arch;