FPGA Central - World's 1st FPGA / CPLD Portal

FPGA Central

World's 1st FPGA Portal

 

Go Back   FPGA Groups > NewsGroup > FPGA

FPGA comp.arch.fpga newsgroup (usenet)

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 05-07-2006, 03:33 PM
Weng Tianxiang
Guest
 
Posts: n/a
Default The differences between behaviors of 'std_logic_vector' and 'unsigned'

Hi,
Based on suggestions from this group, when switching libraries from
USE ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
use ieee.std_logic_arith.all;

to
USE ieee.std_logic_1164.all;
use ieee.numeric_std.all;

this morning I really found a big new issue dealing with
'std_logic_vector' and 'unsigned'.

Here is the definition of 'unsigned' from ieee.numeric_std.vhd:
type UNSIGNED is array (NATURAL range <>) of STD_LOGIC;

Here is the definition of 'std_logic_vector' from ieee.stdlogic.vhd:
TYPE std_logic_vector IS ARRAY ( NATURAL RANGE <>) OF std_logic;

Actually one cannot see any big differences between 'unsigned' and
'std_logic_vector'.

But the following code shows big differences between the two's
behaviors within a generate loop:

signal A : unsigned(1 downto 0);
....

Generate_A : for I in 0 to 3 generate
ModuleX : port map (
...
A => A(I), <-- error due to A's range between 1-0 while I = 2
...
);
end generate;

signal A : std_logic_vector(1 downto 0);
....

Generate_A : for I in 0 to 3 generate
ModuleX : port map (
...
A => A(I), <-- no error, because integer I is between 3-0
-- and A's range is 3-0 due to its definition
of 2 bits
...
);
end generate;

Why?

Thank you.

Weng

Reply With Quote
  #2 (permalink)  
Old 05-07-2006, 04:10 PM
Mike Treseler
Guest
 
Posts: n/a
Default Re: The differences between behaviors of 'std_logic_vector' and 'unsigned'

Weng Tianxiang wrote:

> Actually one cannot see any big differences between 'unsigned' and
> 'std_logic_vector'.


The package contains much more than that type declaration.
Have a look at the functions that cover unsigned.

http://www.csee.umbc.edu/help/VHDL/p...umeric_std.vhd

-- Mike Treseler

Reply With Quote
  #3 (permalink)  
Old 05-07-2006, 04:30 PM
Weng Tianxiang
Guest
 
Posts: n/a
Default Re: The differences between behaviors of 'std_logic_vector' and 'unsigned'

Sorry! I found the error. The error is not related to what I have
thought,
it relates to situation:
std_logic => A(I),
In a generate loop as following:
Lable_A : for I in 0 to 3 generate
.... port map (
...
A => A(I),
...
);

A() must be declared as
signal A : unsigned(3 downto 0);

And it cannot be decleared as
signal A : unsigned(1 downto 0); <-- my error

Thank you.

Weng

Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

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 On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dividing a 24 bit std_logic_vector by a decimal number genlock FPGA 12 03-31-2005 11:26 PM
type states is std_logic_vector(4 downto 0); Preben Holm FPGA 2 03-17-2005 10:24 AM
std_logic_vector(0 downto 0) Brad Smallridge FPGA 2 11-12-2004 05:50 PM
std_logic_vector vs unsigned Chuck McManis FPGA 6 05-18-2004 04:07 PM


All times are GMT +1. The time now is 04:13 PM.


Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0
Copyright 2008 @ FPGA Central. All rights reserved