Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Connecting std_logic to std_logic_vector in component declaration

Reply
Thread Tools

Connecting std_logic to std_logic_vector in component declaration

 
 
Chris Jones
Guest
Posts: n/a
 
      01-29-2004
Hello,

I am using the System Generator tool from Xilinx to generate VHDL code
for a DSP design. The Sys Gen tool creates components that have all
signals defined as std_logic_vector even if they are a single bit, (0
downto 0).

At the next higher level, I had to create a bunch of dummy std_logic
vector signals that is assigned from a std_logic and then I use the
dummy signal in the component definition.

I did this to clear up errors pertaining to mixing types.

See code below ...


Is there a cleaner way to solve this problem?

Thanks,

Chris Jones
Engenium Technologies



----------------------------------------------

U3_MODEM: flex_modem
port map (
adc => ADC,
addrbus => Address,
ctrlregdataout => CtrlRegDataOut,
ctrlregen => CtrlRegEn_slv,
datain => DataIn,
dspwrite => WrPulse_slv,
profileen => ProfileEn_slv,
profiledataout => ProfileDataOut,
reqdataword => ReqDataWord_slv,
reset => (others => '0'),
rxdataout => RxDataOut,
rxgainhi => open,
txrxen => TxRxEn_slv);


-- Convert signals to standard_logic_vector in order
-- to connect to component
WrPulse_slv(0) <= WrPulse;
CtrlRegEn_slv(0) <= CtrlRegEn;
TxRxEn_slv(0) <= TxRxEn;
ProfileEn_slv(0) <= ProfileEn;
 
Reply With Quote
 
 
 
 
Jonathan Bromley
Guest
Posts: n/a
 
      01-29-2004
"Chris Jones" <> wrote in
message news: om...

> I am using the System Generator tool from Xilinx to generate VHDL code
> for a DSP design. The Sys Gen tool creates components that have all
> signals defined as std_logic_vector even if they are a single bit, (0
> downto 0).
>
> At the next higher level, I had to create a bunch of dummy std_logic
> vector signals that is assigned from a std_logic and then I use the
> dummy signal in the component definition.

[...]
>
> Is there a cleaner way to solve this problem?


Yes; use polymorphic conversion functions on the port map.

-- input conversion ---------------------------------------

function vectorize(s: std_logic) return std_logic_vector is
variable v: std_logic_vector(0 downto 0);
begin
v(0) := s;
return v;
end;

function vectorize(v: std_logic_vector) return std_logic_vector is
begin
return v;
end;

----Output conversion ---------------------------------------

.... can be very similar ...

function scalarize(v: in std_logic_vector) return std_ulogic is
begin
assert v'length = 1
report "scalarize: output port must be single bit!"
severity FAILURE;
return v(v'LEFT);
end;

-------------------------------------------------------------

OK, armed with these functions (in a package, I hope) you
can connect up either a std_logic or a std_logic_vector
to any suitable 1-bit vector port:

component blah
port (
a: in std_logic_vector(0 downto 0);
b: in std_logic_vector(0 downto 0);
c: out std_logic_vector(0 downto 0)
);
end component;

.....

signal s1, s2: std_logic;
signal v: std_logic_vector(0 downto 0);
--instantiation...
I1: blah port map (
a => vectorize(s1),
b => vectorize(v),
scalarize(c) => s2);

The conversion vectorize(v) is, of course, quite unnecessary;
but it has a certain symmetrical appeal, don't you think?

Cooler yet, you could make the component have ports to suit
your testbench, leave the entity with its silly one-bit
vector ports, and build a port map with conversion
functions in a configuration.

There's a really nice description of port-map conversion
functions in Ben Cohen's "VHDL Answers to Frequently
Asked Questions".
--

Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.



 
Reply With Quote
 
 
 
 
Jim Lewis
Guest
Posts: n/a
 
      01-29-2004

You should also be able to index array ports in
the association:

signal s1, s2: std_logic;
signal v: std_logic_vector(0 downto 0);

--instantiation...
I1: blah port map (
a(a'left) => s1,
b => v,
c(c'left) => s2);


Cheers,
Jim

An additional comment follows below.
--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~
Jim Lewis
Director of Training private.php?do=newpm&u=
SynthWorks Design Inc. http://www.SynthWorks.com
1-503-590-4787

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


Jonathan Bromley wrote:


> Cooler yet, you could make the component have ports to suit
> your testbench, leave the entity with its silly one-bit
> vector ports, and build a port map with conversion
> functions in a configuration.


Or of course you could also do bit association in the port
map in the configuration. This one is a little closer to
my heart as we did this after picking an ASIC vendor when
we were well into a project and learned that the ASIC
vendor required bit ports on the top level of the ASIC.
So rather than switching the ports of our design to bit
ports, we let the synthesis tool do this and fixed the
port mapping in the configuration that ran the gate
simulations.

However, in hind site, it would have been easier to
change the design source to bit ports rather than fussing
with the configurations. We also used configurations for
selecting test cases and mapping generics. The additional
requirement of either mapping the gate design with bit
ports or the original design with array ports ended up
doubling the number of configurations we had.


> There's a really nice description of port-map conversion
> functions in Ben Cohen's "VHDL Answers to Frequently
> Asked Questions".
> --
>
> Jonathan Bromley, Consultant
>
> DOULOS - Developing Design Know-how
> VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services
>
> Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
> Tel: +44 (0)1425 471223 mail:
> Fax: +44 (0)1425 471573 Web: http://www.doulos.com
>
> The contents of this message may contain personal views which
> are not the views of Doulos Ltd., unless specifically stated.
>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
array of STD_LOGIC to STD_LOGIC_VECTOR poulette VHDL 1 02-12-2009 11:46 PM
inout std_logic_vector to array of std_logic_vector of generic length conversion... Thomas Rouam VHDL 6 11-09-2007 11:49 AM
connecting std_logic inout ports and std_logic_vector inout port =?ISO-8859-15?Q?Fr=E9d=E9ric_Lochon?= VHDL 3 11-08-2007 03:55 AM
regarding conversion of form std_logic_vector to std_logic ekavirsrikanth@gmail.com VHDL 4 07-06-2007 08:34 AM
Connecting std_ulogic_vector to std_logic_vector Roel VHDL 3 02-01-2004 07:49 PM



Advertisments