Altera_Forum
Honored Contributor
11 years agoprocedure call problem
Hi,
I am having problems using procedures in my simulation. I create the procedure between architecture and begin. I then call the procedure concurrently in the body of the architecture. As I understand it when I call the procedure like this then then it will be evaluated when any of the input signals change, a bit like a process with a sensitivity list. When I simulate however it seems to only evaluate once. Here is a cut down of the code I am using:
ARCHITECTURE logic OF test_procedure IS
PROCEDURE read_stuff ( SIGNAL clk_i : IN std_logic;
SIGNAL reset_i : IN std_Logic;
SIGNAL empty : IN std_logic;
SIGNAL rdreq : OUT std_logic) IS
TYPE state_machine IS
(
check_empty,
clear_rdreq
);
VARIABLE state : state_machine;
BEGIN
IF(reset_i = '1') THEN
state := check_empty;
rdreq <= '0';
ELSIF(clk_i = '1' AND clk_i'EVENT) THEN
CASE state IS
WHEN check_empty =>
IF(empty = '0') THEN
rdreq <= '1';
state := clear_rdreq;
END IF;
WHEN clear_rdreq =>
rdreq <= '0';
state := check_empty;
END CASE;
END IF;
END PROCEDURE;
SIGNAL clk : std_logic;
SIGNAL reset : std_logic;
SIGNAL empty_signal : std_logic;
SIGNAL rdreq_signal : std_logic;
BEGIN
call_read_stuff : read_stuff
(
clk_i => clk,
reset_i => reset,
empty => empty_signal,
rdreq => rdreq_signal
);
END ARCHITECTURE;
The aim of the procedure is to read data from a fifo when it is not empty. I know I can do this with a process but I am trying to create a smaller reusable chunk that I can call in a generate as I have a few fifos that I want to pull data out of. This is for simulation only im not trying to create rtl from this. When I run my simulation the rdreq signal gets set when the empty flag goes low, however rdreq stays high, it doesnt seem to change to the second state and clear the rdreq signal and transition back to evaluate empty again. I also tried to do the same without using the state machine but had no more luck. Any suggestions would be appreciated. Thanks James