Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > Aggregate for SLV

Reply
Thread Tools

Aggregate for SLV

 
 
xipn
Guest
Posts: n/a
 
      10-27-2006
Hi all,
Is it any tricky way how to extend std_logic_vector by means of aggregate?

Example:
A : STD_LOGIC_VECTOR(3 DOWNTO 0);
B : STD_LOGIC_VECTOR(6 DOWNTO 0);

Something like (see code below)
B <= (5 downto 2 => A, others => '0');

Of course there are a lot of ways how to code it (consequent
assignments, loop,... ) but aggregate would be nice.
Thanks for comments.

-------------------------------------------------------------------------------
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

ENTITY test IS

END ENTITY test;

ARCHITECTURE tb OF test IS

BEGIN -- ARCHITECTURE tb

PROCESS IS

VARIABLE v_x : STD_LOGIC_VECTOR(3 DOWNTO 0) := "1100";
VARIABLE v_y : STD_LOGIC_VECTOR(6 DOWNTO 0);

FUNCTION vec2str(vec : STD_LOGIC_VECTOR) RETURN STRING IS
VARIABLE result : STRING(vec'LEFT + 1 DOWNTO 1);
BEGIN

FOR i IN vec'reverse_range LOOP
IF (vec(i) = '1') THEN
result(i + 1) := '1';
ELSIF (vec(i) = '0') THEN
result(i + 1) := '0';
ELSE
result(i + 1) := 'X';
END IF;
END LOOP;
RETURN result;
END;

BEGIN -- PROCESS

v_y := (5 DOWNTO 2 => '1',OTHERS => '0');
-- v_y := (5 DOWNTO 2 => v_x ,OTHERS => '0');

REPORT "Y = " & vec2str(v_y) & " X = " & vec2str(v_x);
WAIT;

END PROCESS;


END ARCHITECTURE tb;
-------------------------------------------------------------------------------
-- vsim -c test
-- run 1
 
Reply With Quote
 
 
 
 
Paul Uiterlinden
Guest
Posts: n/a
 
      10-29-2006
xipn wrote:

> Hi all,
> Is it any tricky way how to extend std_logic_vector by means of
> aggregate?
>
> Example:
> A : STD_LOGIC_VECTOR(3 DOWNTO 0);
> B : STD_LOGIC_VECTOR(6 DOWNTO 0);
>
> Something like (see code below)
> B <= (5 downto 2 => A, others => '0');
>
> Of course there are a lot of ways how to code it (consequent
> assignments, loop,... ) but aggregate would be nice.


With one assignment, using concatenation:
B <= '0' & A & "00";

With two assignments:
B <= (others => '0');
B(5 downto 2) <= A;

--
Paul.
www.aimcom.nl
email address: switch x and s
 
Reply With Quote
 
 
 
 
KJ
Guest
Posts: n/a
 
      10-30-2006

"Paul Uiterlinden" <> wrote in message
news:454529c7$0$12516$847b8a10@dreader23...
> xipn wrote:
>
>> Hi all,
>> Is it any tricky way how to extend std_logic_vector by means of
>> aggregate?
>>
>> Example:
>> A : STD_LOGIC_VECTOR(3 DOWNTO 0);
>> B : STD_LOGIC_VECTOR(6 DOWNTO 0);
>>
>> Something like (see code below)
>> B <= (5 downto 2 => A, others => '0');
>>

> With one assignment, using concatenation:
> B <= '0' & A & "00";
>
> With two assignments:
> B <= (others => '0');
> B(5 downto 2) <= A;


The 'With two assignments' approach will only work when within a process

process(A)
begin
B <= (others => '0');
B(5 downto 2) <= A;
end process;

If used as concurrent statements, then both lines will be driving all 7 bits
of signal 'B'.

KJ


 
Reply With Quote
 
KJ
Guest
Posts: n/a
 
      10-30-2006
> If used as concurrent statements, then both lines will be driving all 7
> bits of signal 'B'.
>


Oops, meant to say only bits 5 downto 2 of signal B will have multiple
drivers not all 7

KJ



 
Reply With Quote
 
Paul Uiterlinden
Guest
Posts: n/a
 
      10-30-2006
KJ wrote:


>> With two assignments:
>> B <= (others => '0');
>> B(5 downto 2) <= A;

>
> The 'With two assignments' approach will only work when within a
> process
>
> process(A)
> begin
> B <= (others => '0');
> B(5 downto 2) <= A;
> end process;


You're right, I forgot to mention that. Thanks for the addition.

--
Paul.
www.aimcom.nl
email address: switch x and s
 
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
Integer to SLV type conversion? Brandon VHDL 2 09-01-2005 01:44 AM
Dilemna w/ generic port of type array of slv Brandon VHDL 5 08-06-2005 06:50 PM
Problem with single bit slv salman sheikh VHDL 2 07-02-2004 02:32 PM
Compare pairs of bits between two slv's ? Tony Benham VHDL 3 11-02-2003 12:29 PM
Integer to slv stephen henry VHDL 4 09-11-2003 06:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57