I
Iwo Mergler
Guest
Hi,
This is an exercise in simplifying port maps in
testbench code.
I'm trying to use a record as a bus with signals
going in opposite directions. Is this possible
in VHDL?
Something like this:
type mytype is
record
cmd : with_the_flow type;
busy : against_the_flow type;
end record;
The idea is to have this record be an in-signal
for entity A and an out-signal for entity B.
Which makes signal.busy an out signal for entity
A and an in-signal for entity B.
I'm fairly sure that no such thing exists in VHDL.
To solve the problem, I tried to describe the
record as a resolved bus. The idea is to declare the
bus as inout signals for both entities and fix the
multiple driver problem by resolving the individual
record elements.
Entities A & B know which end of the bus they represent,
so only A ever drives signal.busy and only B ever drives
signal.cmd.
I think the problem boils down to having to resolve such
that the most recent assignment wins. Typical resolution
functions will look at the signal values, I would like
to look at the signal attributes.
Unfortunately, I don't seem to be able to get at the
attributes of the component signals of the record, only
the attributes of the record itself:
package test is
type cmd_t is (idle,read,write);
type operation_t is
record
cmd : cmd_t;
busy : boolean;
end record;
type op_vector is array (integer range <> of operation_t;
function op_resolve(ov : in op_vector) return operation_t;
subtype op_t is op_resolve operation_t;
end test;
package body test is
function op_resolve(ov : in op_vector) return operation_t is
variable f2p_i : integer := 0;
variable p2f_i : integer := 0;
variable result : operation_t;
begin
-- Current assignment wins
for i in ov'range loop -- OK
if ov(i).cmd'event then -- This breaks
f2p_i := i;
end if;
if ov(i).busy'event then
p2f_i := i;
end if;
end loop;
result.cmd := ov(f2p_i).cmd;
result.busy := ov(p2f_i).busy;
return result;
end function op_resolve;
end package body;
The compiler says
Model Technology ModelSim ALTERA vcom 6.1g Compiler 2006.08 Aug 12 2006
-- Loading package standard
-- Compiling package test
-- Compiling package body test
-- Loading package test
** Error: Z:/resolving.vhd(27): Attribute "event" requires a static signal
prefix.
** Error: Z:/resolving.vhd(30): Attribute "event" requires a static signal
prefix.
** Error: Z:/resolving.vhd(39): VHDL Compiler exiting
Is there a way to get at the record member attributes?
Kind regards,
Iwo
This is an exercise in simplifying port maps in
testbench code.
I'm trying to use a record as a bus with signals
going in opposite directions. Is this possible
in VHDL?
Something like this:
type mytype is
record
cmd : with_the_flow type;
busy : against_the_flow type;
end record;
The idea is to have this record be an in-signal
for entity A and an out-signal for entity B.
Which makes signal.busy an out signal for entity
A and an in-signal for entity B.
I'm fairly sure that no such thing exists in VHDL.
To solve the problem, I tried to describe the
record as a resolved bus. The idea is to declare the
bus as inout signals for both entities and fix the
multiple driver problem by resolving the individual
record elements.
Entities A & B know which end of the bus they represent,
so only A ever drives signal.busy and only B ever drives
signal.cmd.
I think the problem boils down to having to resolve such
that the most recent assignment wins. Typical resolution
functions will look at the signal values, I would like
to look at the signal attributes.
Unfortunately, I don't seem to be able to get at the
attributes of the component signals of the record, only
the attributes of the record itself:
package test is
type cmd_t is (idle,read,write);
type operation_t is
record
cmd : cmd_t;
busy : boolean;
end record;
type op_vector is array (integer range <> of operation_t;
function op_resolve(ov : in op_vector) return operation_t;
subtype op_t is op_resolve operation_t;
end test;
package body test is
function op_resolve(ov : in op_vector) return operation_t is
variable f2p_i : integer := 0;
variable p2f_i : integer := 0;
variable result : operation_t;
begin
-- Current assignment wins
for i in ov'range loop -- OK
if ov(i).cmd'event then -- This breaks
f2p_i := i;
end if;
if ov(i).busy'event then
p2f_i := i;
end if;
end loop;
result.cmd := ov(f2p_i).cmd;
result.busy := ov(p2f_i).busy;
return result;
end function op_resolve;
end package body;
The compiler says
Model Technology ModelSim ALTERA vcom 6.1g Compiler 2006.08 Aug 12 2006
-- Loading package standard
-- Compiling package test
-- Compiling package body test
-- Loading package test
** Error: Z:/resolving.vhd(27): Attribute "event" requires a static signal
prefix.
** Error: Z:/resolving.vhd(30): Attribute "event" requires a static signal
prefix.
** Error: Z:/resolving.vhd(39): VHDL Compiler exiting
Is there a way to get at the record member attributes?
Kind regards,
Iwo