Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

debugging program

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
0
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;
 
Looks like you actually wanted the if statement for the reset signal to be:

if reset='1' then

instead of

if reset<='1' then

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top