Help with procedure

W

Willem Oosthuizen

I use the following code in a process, and it works as intended.

if pci_trdyn /= '0' then
while pci_trdyn /= '0' loop
wait for clock_period;
end loop;
wait for clock_period;
else
wait for clock_period;
end if;

I would like to replace this code with

WaitSig(pci_trdyn ,'0',Clock_Period);

where WaitSig is defined as

procedure WaitSig(Sig,State : in std_logic; Clock_Period : in time) is
begin
if Sig /= State then
while Sig /= State loop
wait for clock_period;
end loop;
wait for clock_period;
else
wait for clock_period;
end if;
end procedure;

This does not work. Why? Is it because signals are not updated dynamically
while a procedure executes?
Is there another mechanism I can use to simplify my code?
 
E

Egbert Molenkamp

I think the problem is the procedure
procedure WaitSig(Sig,State : in std_logic; Clock_Period : in time) is

This is equal to:
procedure WaitSig( CONSTANT Sig,State : in std_logic; CONSTANT Clock_Period
: in time) is

and you don't want the constant value ("call by value") but since the value
of the signals
are changed when time progress you want probably the actual value ("call by
reference").
Make this explicit as follows:
procedure WaitSig(SIGNAL Sig,State : in std_logic; Clock_Period : in time)
is
(assuming that Clock_period is a constant value, otherwise add SIGNAL to for
'Clock_period')

Egbert Molenkamp
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,767
Messages
2,569,572
Members
45,046
Latest member
Gavizuho

Latest Threads

Top