Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17258 Discussions

std_logic_vector VS unsigned

Altera_Forum
Honored Contributor II
1,621 Views

I have the following type definitions 

subtype msgBlock_t is std_logic_vector((Z-1) downto 0); subtype msgBlock_u_t is unsigned((Z-1) downto 0); type msgBlocks_t is array((K_B-1) downto 0) of msgBlock_t; type msgBlocks_u_t is array((K_B-1) downto 0) of msgBlock_u_t; signal shMsgBlocks_u: msgBlocks_u_t; signal shMsgBlocks: msgBlocks_t;  

 

I tried to convert the unsigned vector into a std_logic_vector using 

shMsgBlocks = msgBlocks_t(shMsgBlocks_u);  

but it doesn't work so now I'm using  

c_g: for i in 0 to K_B-1 generate c_g_i: shMsgBlocks(i) <= std_logic_vector(shMsgBlocks_u(i)); end generate c_g;  

 

but when I do a XOR operation: 

xor_L1: for i in 0 to (K_B/2)-1 generate xor_L1_i: out_xor_L1 <= shMsgBlocks(2*i) xor shMsgBlocks(2*i+1); end generate xor_L1;  

the following error appears 

 

Error (10327): VHDL error at lambda.vhd(112): can't determine definition of operator ""xor"" -- found 0 possible definitions 

 

I know that std_logic_vector has to be used for memories/registers, while the unsigned type for binary numbers without sign. 

I need to use the unsigned type in my circuit because of the rol (rotate left) function. 

I cannot avoid to mix the two types. 

What is better to do in these cases ?
0 Kudos
6 Replies
Altera_Forum
Honored Contributor II
904 Views

there is nothing wrong with unsigned for memories and registers. I avoid std_logic_vector whenever another type is more appropriate. 

 

You havent shown the definition of out_xor_L1.
0 Kudos
Altera_Forum
Honored Contributor II
904 Views

subtype msgBlock_t is std_logic_vector((Z-1) downto 0); type xorL1_t is array ((K_B/2)-1 downto 0) of msgBlock_t;

0 Kudos
Altera_Forum
Honored Contributor II
904 Views

Shouldn't there be an index for out_xor_L1, presumed it's of xorL1_t type (array of std_logic_vector)?

0 Kudos
Altera_Forum
Honored Contributor II
904 Views

The xor operation works properly between std_logic_vector or unsigned vectors. 

I need an array of unsigned vectors, that's why I'm using the subtype. 

I replaced all std_logic_vector declarations with unsigned ones and now it works. 

Thank you so much guys.
0 Kudos
Altera_Forum
Honored Contributor II
904 Views

Yes I fixed that error, now it works.

0 Kudos
Altera_Forum
Honored Contributor II
904 Views

Now it compiles. The problem is that I have a very long vector as input (unsigned(323 downto 0)) and so the Fitter gave me an error because there are not enough pins. Can I store this vector in a pre-initiliazed register ? Or is there something else I can do to avoid this problem?

0 Kudos
Reply