Sign in

username:

password:



Not a member?

Search Comp.Arch.FPGA



Search tips

fpga by Keywords

Altera | ASIC | CPLD | Cyclone | DCM | DDR | DSP | Ethernet | ISE | JTAG | Linux | LVDS | Microblaze | ML310 | Modelsim | NIOS | OPB | PCI | Quartus | RocketIO | SDRAM | Spartan | Spartan3 | SRAM | Stratix | Verilog | VHDL | Virtex | Virtex-4 | Virtex-II | Xilinx | XST


Ads

See Also

DSPEmbedded SystemsElectronics

Comp.Arch.FPGA | Dumb VHDL Question -- Type Conversion

There are 14 messages in this thread.

You are currently looking at messages 0 to 10.

Dumb VHDL Question -- Type Conversion - Tim Wescott - 2010-07-16 15:07:00

How do I assign an integer value to 'signed' or
'unsigned' from the IEEE 
libraries?

I'm having this difficulty with my test benches.  Surely there's a set 
of library functions to do it, but I can't seem to figure out what they 
are!!

-- 

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.



Re: Dumb VHDL Question -- Type Conversion - Rob Gaddi - 2010-07-16 15:18:00

On 7/16/2010 12:07 PM, Tim Wescott wrote:
> How do I assign an integer value to 'signed' or 'unsigned' from the IEEE
> libraries?
>
> I'm having this difficulty with my test benches. Surely there's a set of
> library functions to do it, but I can't seem to figure out what they are!!
>

I'm assuming you're talking about numeric_std?

TO_SIGNED(intval, width) and TO_UNSIGNED(intval, width)

-- 
Rob Gaddi, Highland Technology
Email address is currently out of order
______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.

Re: Dumb VHDL Question -- Type Conversion - Tim Wescott - 2010-07-16 17:06:00

On 07/16/2010 12:18 PM, Rob Gaddi wrote:
> On 7/16/2010 12:07 PM, Tim Wescott wrote:
>> How do I assign an integer value to 'signed' or 'unsigned' from the IEEE
>> libraries?
>>
>> I'm having this difficulty with my test benches. Surely there's a set of
>> library functions to do it, but I can't seem to figure out what they
>> are!!
>>
>
> I'm assuming you're talking about numeric_std?
>
> TO_SIGNED(intval, width) and TO_UNSIGNED(intval, width)
>
That worked.  I seem to have a collision between libraries in my Xilinx ISE:

declaring both of the following:

USE ieee.numeric_std.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;

gets me a flood of errors, although I seem to be able to comment out the 
std_logic_arith.

I lack a good language/library reference*, or I'm stupidly not looking 
in the right place, else I'd be able to answer my questions by myself.

* By definition -- because a good reference would answer the question.

-- 

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.

Re: Dumb VHDL Question -- Type Conversion - MM - 2010-07-16 17:24:00

"Tim Wescott" <t...@seemywebsite.com> wrote in message 
news:j...@web-ster.com...
> I seem to have a collision between libraries in my Xilinx ISE:
>
> declaring both of the following:
>
> USE ieee.numeric_std.ALL;
> use IEEE.STD_LOGIC_ARITH.ALL;
>
> gets me a flood of errors, although I seem to be able to comment out the 
> std_logic_arith.
>

These two libs should never be used together. The former is a standard 
library, which should be used in new code, and the latter is a legacy 
Synopsys library which might be required when working with the existing 
code.

/Mikhail 



Re: Dumb VHDL Question -- Type Conversion - Tim Wescott - 2010-07-16 18:01:00

On 07/16/2010 02:24 PM, MM wrote:
> "Tim Wescott"<t...@seemywebsite.com>  wrote in message
> news:j...@web-ster.com...
>> I seem to have a collision between libraries in my Xilinx ISE:
>>
>> declaring both of the following:
>>
>> USE ieee.numeric_std.ALL;
>> use IEEE.STD_LOGIC_ARITH.ALL;
>>
>> gets me a flood of errors, although I seem to be able to comment out the
>> std_logic_arith.
>>
>
> These two libs should never be used together. The former is a standard
> library, which should be used in new code, and the latter is a legacy
> Synopsys library which might be required when working with the existing
> code.

Ah, Xilinx -- the latter is what Xilinx sticks in as boilerplate when 
you get lazy and tell it to just make you a test bench from a file.

Thanks for the tip.

-- 

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.

Re: Dumb VHDL Question -- Type Conversion - JustJohn - 2010-07-16 20:03:00

On Jul 16, 3:01=A0pm, Tim Wescott
<t...@seemywebsite.com> wrote:
> On 07/16/2010 02:24 PM, MM wrote:
>
>
>
>
>
> > "Tim Wescott"<t...@seemywebsite.com> =A0wrote in message
> >news:j...@web-ster.com...
> >> I seem to have a collision between libraries in my Xilinx ISE:
>
> >> declaring both of the following:
>
> >> USE ieee.numeric_std.ALL;
> >> use IEEE.STD_LOGIC_ARITH.ALL;
>
> >> gets me a flood of errors, although I seem to be able to comment out t=
he
> >> std_logic_arith.
>
> > These two libs should never be used together. The former is a standard
> > library, which should be used in new code, and the latter is a legacy
> > Synopsys library which might be required when working with the existing
> > code.
>
> Ah, Xilinx -- the latter is what Xilinx sticks in as boilerplate when
> you get lazy and tell it to just make you a test bench from a file.
>
> Thanks for the tip.
>
> --
>
> Tim Wescott
> Wescott Design Serviceshttp://www.wescottdesign.com
>
> Do you need to implement control loops in software?
> "Applied Control Theory for Embedded Systems" was written for you.
> See details athttp://www.wescottdesign.com/actfes/actfes.html- Hide quote=
d text -
>
> - Show quoted text -

It used to frustrate me no end the way ISE plugged in the wrong
library, until I found the script that does it and CHANGED it. Look
under Xilinx=3D>ISE=3D>data=3D>projnav=3D>scripts and modify file
"dpm_sourceTasks.tcl" to your liking. TCL syntax is fairly basic in
the area you'll want to change.
delete:
  puts $hFile "use IEEE.STD_LOGIC_ARITH.ALL;"
  puts $hFile "use IEEE.STD_LOGIC_UNSIGNED.ALL;"
add:
  puts $hFile "use ieee.numeric_std.all;"

Customize to add your own name, company header, etc.
Hopefully they haven't changed the framework in version 12.

HTH,
John

Re: Dumb VHDL Question -- Type Conversion - Charles Gardiner - 2010-07-17 06:02:00

Hi Tim,

a good quick reference is the "Qualis Ref Card":
http://www.google.de/url?sa=t&source=web&cd=1&ved=0CBwQFjAA&url=http%3A%2F
%2Fwww.vhdl.org%2Frassp%2Fvhdl%2Fguidelines%2Fvhdlqrc.pdf&rct=j&q=qualis%20vhdl%20
refcard&ei=qX1BTIHIN9ecOODYraQN&usg=AFQjCNFjtNN-k9EA-H4S1K1CZrW58cNRrQ

or just type "qualis vhdl refcard" into the market hegemonial browser if the
link
above is bent over 17 lines. It's the first hit (at leas it was for me)

Other references I use:
- VHDL Spec from IEEE
- Ashendon's Book

Or what I usually do, power up the Aldec activeHDL simulator (you can get a free
version from the Lattice website) and click on the Library manager. If you select
the IEEE libraries and go to the "Package Contents" window you get the
prototypes
for all functions and procedures.

This might of course work in modelsim too, I haven't tried.

Regards,
Charles

Re: Dumb VHDL Question -- Type Conversion - Charles Gardiner - 2010-07-17 06:10:00

Hi again Tim,

sorry, the reference card you are probably really looking for is under

http://www.google.de/url?sa=t&source=web&cd=1&ved=0CBwQFjAA&url=http%3A%2F
%2Fwww.vhdl.org%2Frassp%2Fvhdl%2Fguidelines%2F1164qrc.pdf&ei=_oBBTN7hKo2iOM6i7fAM&;
usg=AFQjCNHBm6d324gTZ40kvAWp6Lq0nB_5BQ

(or "qualis packages refcard" in the previously mentioned hegemonial search
engine)

Charles
______________________________
Join the blogging team on FPGARelated.com and earn rewards! Details Here.

Re: Dumb VHDL Question -- Type Conversion - Jonathan Bromley - 2010-07-17 10:03:00

On Fri, 16 Jul 2010 14:06:00 -0700, Tim Wescott
wrote:

>declaring both of the following:
>
>USE ieee.numeric_std.ALL;
>use IEEE.STD_LOGIC_ARITH.ALL;
>
>gets me a flood of errors, although I seem to be able to comment out the 
>std_logic_arith.

Right.  The two packages are somewhat similar.  For example they
both define types SIGNED and UNSIGNED, and they both define "+"
operators for those types.

In VHDL, if you "use .all" some packages and more than 
one of the packages defines the same identifier, then 
the identifier is hidden to spare you the embarrassment
of not knowing which one is being used.

You can still reach it.  For example, given your two
USE clauses, you could do

  signal S8: SIGNED(7 downto 0); -- Error, SIGNED is hidden
  signal S8: ieee.numeric_std.SIGNED(7 downto 0);  -- OK

and, indeed, 

  S8 <= S8 + 1;  -- ERROR: "+" operator definition is hidden
  S8 <= ieee.numeric_std."+"(S8, 1);  -- OK

but I suspect you would agree with me that neither of
these is a terribly good idea.

It's nice that JustJohn showed us how to defeat the silly 
Xilinx default use clauses - thanks for the tip!
-- 
Jonathan Bromley

Re: Dumb VHDL Question -- Type Conversion - JustJohn - 2010-07-17 21:21:00

On Jul 16, 5:03=A0pm, JustJohn
<justjohna...@gmail.com> wrote:
> On Jul 16, 3:01=A0pm, Tim Wescott <t...@seemywebsite.com> wrote:
>
>
>
>
>
> > On 07/16/2010 02:24 PM, MM wrote:
>
> > > "Tim Wescott"<t...@seemywebsite.com> =A0wrote in message
> > >news:j...@web-ster.com...
> > >> I seem to have a collision between libraries in my Xilinx ISE:
>
> > >> declaring both of the following:
>
> > >> USE ieee.numeric_std.ALL;
> > >> use IEEE.STD_LOGIC_ARITH.ALL;
>
> > > These two libs should never be used together. The former is a standar=
d
> > > library, which should be used in new code, and the latter is a legacy
> > > Synopsys library which might be required when working with the existi=
ng
> > > code.
>
> > Ah, Xilinx -- the latter is what Xilinx sticks in as boilerplate when
> > you get lazy and tell it to just make you a test bench from a file.
>
> > Thanks for the tip.
>
> > Tim Wescott
> > Wescott Design Serviceshttp://www.wescottdesign.com
>
> > Do you need to implement control loops in software?
> > "Applied Control Theory for Embedded Systems" was written for you.
> > See details athttp://www.wescottdesign.com/actfes/actfes.html-Hide quot=
ed text -
>
> > - Show quoted text -
>
> It used to frustrate me no end the way ISE plugged in the wrong
> library, until I found the script that does it and CHANGED it. Look
> under Xilinx=3D>ISE=3D>data=3D>projnav=3D>scripts and modify file
> "dpm_sourceTasks.tcl" to your liking. TCL syntax is fairly basic in
> the area you'll want to change.
> delete:
> =A0 puts $hFile "use IEEE.STD_LOGIC_ARITH.ALL;"
> =A0 puts $hFile "use IEEE.STD_LOGIC_UNSIGNED.ALL;"
> add:
> =A0 puts $hFile "use ieee.numeric_std.all;"
>
> Customize to add your own name, company header, etc.
> Hopefully they haven't changed the framework in version 12.
>
> HTH,
> John- Hide quoted text -
>
> - Show quoted text -

Umm, the tcl file I listed above is for regular vhdl modules. For
testbenches, the tcl'er is:
Xilinx->ver->ISE->data->testbnch2.tcl

| 1 | 2 | next