Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - to_stdlogicvector and to_unsigned

 
Thread Tools Search this Thread
Old 06-05-2008, 02:29 PM   #1
Post to_stdlogicvector and to_unsigned


HI all,

I'm new to the newsgroup.

I'm starting with VHDL and I'm working with ISE Foundation 8.2i.

Implementing the following code from the "Essential VHDL" book, from Sundar Rajan, I've got 2 errors that I don't know how to solve:
/////////////////////////////////////////////////////////
library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.numeric_std.all;

entity asyncLdCnt is port (
loadVal: in std_logic_vector(3 downto 0);
clk, load: in std_logic;
q: out std_logic_vector(3 downto 0)
);
end asyncLdCnt;

architecture rtl of asyncLdCnt is
signal qLocal: unsigned(3 downto 0):="0000";
begin

process (clk, load, loadVal) begin
if (load = '1') then
qLocal <= to_unsigned(loadVal);
elsif (clk'event and clk = '1' ) then
qLocal <= qLocal + 1;
end if;
end process;

q <= to_stdlogicvector(qLocal);

end rtl;
//////////////////////////////////////////////////////
Compiling vhdl file "D:/11-VHDL/Proyectos/Cap7/ldcnta.vhd" in Library work.
ERROR:HDLParsers:3324 - "D:/11-VHDL/Proyectos/Cap7/ldcnta.vhd" Line 22. IN mode Formal SIZE of to_unsigned with no default value must be associated with an actual value.
ERROR:HDLParsers:808 - "D:/11-VHDL/Proyectos/Cap7/ldcnta.vhd" Line 28. to_stdlogicvector can not have such operands in this context.
///////////////////////////////////////////////////////
I've tried writing the size of qLocal and q (3 downto 0) but it hasn't worked.

Any help would be appreciated. Thanks in advance!


seinal
seinal is offline   Reply With Quote
Old 06-05-2008, 03:42 PM   #2
jeppe
Senior Member
 
Join Date: Mar 2008
Location: Denmark
Posts: 245
Default
q <= conv_std_logic_vector(qLocal,4); -- Try this

Jeppe


jeppe
jeppe is offline   Reply With Quote
Old 06-06-2008, 07:24 AM   #3
seinal
Junior Member
 
Join Date: Jun 2008
Posts: 2
Default library/function issue
Hi,

Problem resolved. Thank you Jeppe!

Using the conv_std_logic_vector(qlocal,4) with the library
ieee.std_logic_arith.all
To solve the problem with "to_unsigned" function, looking at its definition in the "ieee.numeric_std" library, it is defined as a conversion from INTEGER to UNSIGNED, not from STD_LOGIC_VECTOR (SLV).

So to solve that conversion I've used 2 functions:

qLocal <= conv_unsigned(conv_integer(loadVal),4);--to_unsigned(loadVal)

I have had to add the library "ieee.std_logic_unsigned.all" in order to use conv_unsigned function.

If someone knows a way for converting in 1 step from SLV to unsigned, please advise.

Thanks


seinal
seinal is offline   Reply With Quote
Old 06-06-2008, 07:47 AM   #4
jeppe
Senior Member
 
Join Date: Mar 2008
Location: Denmark
Posts: 245
Default
Glad to learn your problem solved.
It will be ok to use two conversion function - it won't cost you extra hardware as the function mostly because of the strong type-dependiency of VHDL.

Jeppe


jeppe
jeppe is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

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




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

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