Hi all,
I'm trying to write a test bench for a fpga as follows:
...
signal a : std_logic;--connected to input a of fpga
signal b : std_logic;--connected to input b of fpga
...
begin
...
main_tb_process: process
begin
--initialization
a <= '0';
b <= '0';
...
--command1
a <= '1';
...
end process
My question is:
is there any way that I can simplify the step of initialization by writing a procedure that when called resets all fpga inputs ? like this :
procedure init_fpga
begin
a <= '0';
b <= '0';
end procedure;
begin
...
main_tb_process: process
begin
--initialization
init_fpga;
...
--command1
a <= '1';
...
end process
The problem is that I want to keep control of signals a and b in the main process for command1 etc.
PS. I'm doing this because it may be useful when fpga has A LOT of inputs.
Hi all,
I'm trying to write a test bench for a fpga as follows:
...
signal a : std_logic;--connected to input a of fpga
signal b : std_logic;--connected to input b of fpga
...
begin
...
main_tb_process: process
begin
--initialization
a <= '0';
b <= '0';
...
--command1
a <= '1';
...
end process
My question is:
is there any way that I can simplify the step of initialization by writing a procedure that when called resets all fpga inputs ? like this :
procedure init_fpga
begin
a <= '0';
b <= '0';
end procedure;
begin
...
main_tb_process: process
begin
--initialization
init_fpga;
...
--command1
a <= '1';
...
end process
The problem is that I want to keep control of signals a and b in the main process for command1 etc.
PS. I'm doing this because it may be useful when fpga has A LOT of inputs.
That works if fpga needs to be initialized only once, but what about the case when I want to initialize those signals (init fpga) AGAIN after running some commands ?
like this :
main_tb_process: process
begin
--initialization
init_fpga;
...
--command1
a <= '1';
--check something
...
init_fpga;
--command2
...
end process
It will work every time your fpga will be reconfigured and initilised. You can activate prog pin of fpga.of course if you dont want reconfigure youre fpga.then you will to conect all signal to some kind of reset logic. Another aproach will be to built a program that will analyse entire signals asigments and regenerate vhdl code.
It will work every time your fpga will be reconfigured and initilised. You can activate prog pin of fpga.of course if you dont want reconfigure youre fpga.then you will to conect all signal to some kind of reset logic. Another aproach will be to built a program that will analyse entire signals asigments and regenerate vhdl code.
That works if fpga needs to be initialized only once, but what about the case when I want to initialize those signals (init fpga) AGAIN after running some commands ?
like this :
main_tb_process: process
begin
--initialization
init_fpga;
...
--command1
a <= '1';
--check something
...
init_fpga;
--command2
...
end process
It's not clear to me why this can't be in a single process. You can create the init_fpga procedure and call it from main_tb_process whenever you want. That would be the simplest way from what you've described.
However, if you really do want to drive them from seperate processes, then what you basically need to do is to create an arbiter. Then every process that wants to take control of that signal would request control of the signals from the arbiter process. Think of it as being the same way that you would if you were designing a shared bus multi-processor system.
Is there any easier way to do that ?
I'm trying to shorten my test bench and this way I have to put all signal names in the list when calling init_fpga (it's not easy when fpga has many inputs (30 for example))
Also I have another question: is a wait statement in procedure always acceptable?
For example,
procedure init_fpga(x,y : out std_logic) is
begin
x <= '0';
wait for 10 ns;
y <= '0';
end procedure;
Now I see why it didn't work for me before (it's because I declared the procedure outside the main process where I call it and that's why I got this error "Cannot drive signal "..." from procedure)
Now it's working perfectly :
main_tb_process: process
procedure init_fpga
begin
a <= '0';
b <= '0';
end procedure;