A
Andy Peters
Guest
I'm baffled by how VHDL deals with procedures and driving signals, and
how some things are visible and others aren't. For example, in the
following skeleton a call to the parameterless procedure InitS() calls
the more-generic procedure Init() in order to initialize my signals s1
and s2. The idea is that the procedure InitS() is visible to other
modules in my test bench (its declaration is in a package) and I'm
trying to avoid passing a lot of signals around.
entity foo;
end entity foo;
architecture bar of foo is
signal s1 : std_logic;
signal s2 : std_logic;
-- initialize any two bits.
procedure Init (
signal b1 : out std_logic;
signal b2 : out std_logic ) is
begin
b1 <= '0';
b2 <= '0';
end procedure Init;
-- call InitS to initialize s1 and s2:
procedure InitS is
begin
Init(s1, s2);
end procedure InitS;
begin -- architecture bar of foo
... do whatever
end architecture bar;
When I compile this, I get
"Cannot drive signal 's1' from this subprogram." and
"Cannot drive signal 's2' from this subprogram." errors.
I realize problem here is that signals s1 and s2 are not available to
be assigned from a procedure if they're not passed in as out signal
parameters.
So, what's a reasonable workaround?
-a
[real e-mail: devel (at) latke (dot) net]
how some things are visible and others aren't. For example, in the
following skeleton a call to the parameterless procedure InitS() calls
the more-generic procedure Init() in order to initialize my signals s1
and s2. The idea is that the procedure InitS() is visible to other
modules in my test bench (its declaration is in a package) and I'm
trying to avoid passing a lot of signals around.
entity foo;
end entity foo;
architecture bar of foo is
signal s1 : std_logic;
signal s2 : std_logic;
-- initialize any two bits.
procedure Init (
signal b1 : out std_logic;
signal b2 : out std_logic ) is
begin
b1 <= '0';
b2 <= '0';
end procedure Init;
-- call InitS to initialize s1 and s2:
procedure InitS is
begin
Init(s1, s2);
end procedure InitS;
begin -- architecture bar of foo
... do whatever
end architecture bar;
When I compile this, I get
"Cannot drive signal 's1' from this subprogram." and
"Cannot drive signal 's2' from this subprogram." errors.
I realize problem here is that signals s1 and s2 are not available to
be assigned from a procedure if they're not passed in as out signal
parameters.
So, what's a reasonable workaround?
-a
[real e-mail: devel (at) latke (dot) net]