Subroutine in VHDL?

I'm trying to use a subroutine (subprogram procedure) in my testbench to (eventually) simulate processor reads and writes. When I compile and try to simulate(Xilinx ISE 6.1i and Modelsim) I get "# ERROR: testbench.vhd(34): Cannot drive signal in3 from this subprogram." Any idea why? Can it be corrected?

Thanks

Dan

LIBRARY ieee; USE ieee.std_logic_1164.ALL; USE ieee.numeric_std.ALL;

ENTITY testbench IS END testbench;

ARCHITECTURE behavior OF testbench IS COMPONENT tb_subroutine PORT( clk : IN std_logic; reset : IN std_logic; in1 : IN std_logic; in2 : IN std_logic; in3 : IN std_logic; out1 : OUT std_logic; out2 : OUT std_logic; out3 : OUT std_logic ); END COMPONENT;

SIGNAL clk : std_logic; SIGNAL reset : std_logic; SIGNAL in1 : std_logic; SIGNAL in2 : std_logic; SIGNAL in3 : std_logic; SIGNAL out1 : std_logic; SIGNAL out2 : std_logic; SIGNAL out3 : std_logic;

procedure set_in3 --subroutine begin in3 in1, in2 => in2, in3 => in3, out1 => out1, out2 => out2, out3 => out3 );

-- *** Test Bench - User Defined Section *** tb : PROCESS BEGIN reset

Reply to
Dan Kuechle
Loading thread data ...

The procedure may be out of the scope of the signals it is trying to drive. Related thread:

formatting link

-- Mike Treseler

Reply to
Mike Treseler

If you want to make a general purpose subprogram for testbenches and put it in a pacakge, you must have all of the IO on the subprogram interface. As a general rule of thumb for subprogram IO class use the following:

Inputs:

------ From UUT: Make them signals In general: If you use signal property ('event) must be a signal, otherwise make it a variable.

Outputs, InOuts:

---------------- To UUT: Make it a signal To process/other subprogram: variable (so value updates immediately) For synthesis: usually used directly in architecture, so make it a signal

You can cheat temporarily by putting the subprogram declaration in the process, but once you have more than one test architecture this means you will have to multiple copies of your testbench.

Cheers, Jim Lewis p.s. We have are offering our Comprehensive VHDL Introduction class in Huntsville, AL next week and we cover stuff just like the above. Details are at:

formatting link

-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Jim Lewis Director of Training mailto: snipped-for-privacy@SynthWorks.com SynthWorks Design Inc.

formatting link

1-503-590-4787

Expert VHDL Training for Hardware Design and Verification ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Dan Kuechle wrote:

Reply to
Jim Lewis

Try use TBGenerator

formatting link

Reply to
vladimir

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.