Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > VHDL > plese problem std_logic_vector

Reply
Thread Tools

plese problem std_logic_vector

 
 
Xin Xiao
Guest
Posts: n/a
 
      12-02-2007

I want to implement this:

entity Project1 is
Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
Input1 : in STD_LOGIC_VECTOR;
Input2: in STD_LOGIC_VECTOR;
Result: out STD_LOGIC_VECTOR);
end Project1;

I got error in STD_LOGIC_VECTOR, but I want no range in this vector. How can
i do this?

Xiao Xin

 
Reply With Quote
 
 
 
 
Vince
Guest
Posts: n/a
 
      12-02-2007
Xin Xiao a écrit:
>
> I want to implement this:
>
> entity Project1 is
> Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
> Input1 : in STD_LOGIC_VECTOR;
> Input2: in STD_LOGIC_VECTOR;
> Result: out STD_LOGIC_VECTOR);
> end Project1;
>
> I got error in STD_LOGIC_VECTOR, but I want no range in this vector. How can
> i do this?


You do that:

entity Project1 is
Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
Input1 : in STD_LOGIC;
Input2: in STD_LOGIC;
Result: out STD_LOGIC);
end Project1;


--
Vince
 
Reply With Quote
 
 
 
 
Symon
Guest
Posts: n/a
 
      12-02-2007
"Vince" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) ...
> Xin Xiao a écrit:
>>
>> I want to implement this:
>>
>> entity Project1 is
>> Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
>> Input1 : in STD_LOGIC_VECTOR;
>> Input2: in STD_LOGIC_VECTOR;
>> Result: out STD_LOGIC_VECTOR);
>> end Project1;
>>
>> I got error in STD_LOGIC_VECTOR, but I want no range in this vector. How
>> can
>> i do this?

>
> You do that:
>
> entity Project1 is
> Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
> Input1 : in STD_LOGIC;
> Input2: in STD_LOGIC;
> Result: out STD_LOGIC);
> end Project1;
>
>
> --
> Vince


or

Input1 : in STD_LOGIC_VECTOR(0 downto 0);

maybe?
HTH., Syms.


 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      12-03-2007
On Dec 2, 3:09 pm, "Symon" <(E-Mail Removed)> wrote:
> "Vince" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) ...
>
>
>
> > Xin Xiao a écrit:

>
> >> I want to implement this:

>
> >> entity Project1 is
> >> Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
> >> Input1 : in STD_LOGIC_VECTOR;
> >> Input2: in STD_LOGIC_VECTOR;
> >> Result: out STD_LOGIC_VECTOR);
> >> end Project1;

>
> >> I got error in STD_LOGIC_VECTOR, but I want no range in this vector. How
> >> can
> >> i do this?

>
> > You do that:

>
> > entity Project1 is
> > Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
> > Input1 : in STD_LOGIC;
> > Input2: in STD_LOGIC;
> > Result: out STD_LOGIC);
> > end Project1;

>
> > --
> > Vince

>
> or
>
> Input1 : in STD_LOGIC_VECTOR(0 downto 0);
>
> maybe?
> HTH., Syms.


By "want no range" do you mean you want undeclared range? If so, that
works fine, but not for the top level entity. If you have
unconstrained ports, their range is defined in the instantiation. A
top level entity is not instantiated anywhere, so there is no
definition for the range.

Andy
 
Reply With Quote
 
Xin Xiao
Guest
Posts: n/a
 
      12-03-2007
Yes Andy, this is what I meant.

mmm, Ok so I declared this range in my entity,

Input1 : in STD_LOGIC_VECTOR (7 downto 0);

Then I do something like this:

add(Input1, Result);

and procedure "add" is

procedure add (v : in std_logic_vector; res: out integer) is

alias v1 : std_logic_vector (7 downto 0) is v;

Am I correct if I assume that I should get the vector "Input1" in "v1"
after calling the procedure "add"?

Xiao


"Andy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
On Dec 2, 3:09 pm, "Symon" <(E-Mail Removed)> wrote:
> "Vince" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed) ...
>
>
>
> > Xin Xiao a écrit:

>
> >> I want to implement this:

>
> >> entity Project1 is
> >> Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
> >> Input1 : in STD_LOGIC_VECTOR;
> >> Input2: in STD_LOGIC_VECTOR;
> >> Result: out STD_LOGIC_VECTOR);
> >> end Project1;

>
> >> I got error in STD_LOGIC_VECTOR, but I want no range in this vector.
> >> How
> >> can
> >> i do this?

>
> > You do that:

>
> > entity Project1 is
> > Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
> > Input1 : in STD_LOGIC;
> > Input2: in STD_LOGIC;
> > Result: out STD_LOGIC);
> > end Project1;

>
> > --
> > Vince

>
> or
>
> Input1 : in STD_LOGIC_VECTOR(0 downto 0);
>
> maybe?
> HTH., Syms.


By "want no range" do you mean you want undeclared range? If so, that
works fine, but not for the top level entity. If you have
unconstrained ports, their range is defined in the instantiation. A
top level entity is not instantiated anywhere, so there is no
definition for the range.

Andy

 
Reply With Quote
 
Andy
Guest
Posts: n/a
 
      12-03-2007
On Dec 3, 8:59 am, "Xin Xiao" <(E-Mail Removed)> wrote:
> Yes Andy, this is what I meant.
>
> mmm, Ok so I declared this range in my entity,
>
> Input1 : in STD_LOGIC_VECTOR (7 downto 0);
>
> Then I do something like this:
>
> add(Input1, Result);
>
> and procedure "add" is
>
> procedure add (v : in std_logic_vector; res: out integer) is
>
> alias v1 : std_logic_vector (7 downto 0) is v;
>
> Am I correct if I assume that I should get the vector "Input1" in "v1"
> after calling the procedure "add"?
>
> Xiao
>
> "Andy" <(E-Mail Removed)> wrote in message
>
> news:(E-Mail Removed)...
> On Dec 2, 3:09 pm, "Symon" <(E-Mail Removed)> wrote:
>
>
>
> > "Vince" <(E-Mail Removed)> wrote in message

>
> >news:(E-Mail Removed) r...

>
> > > Xin Xiao a écrit:

>
> > >> I want to implement this:

>
> > >> entity Project1 is
> > >> Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
> > >> Input1 : in STD_LOGIC_VECTOR;
> > >> Input2: in STD_LOGIC_VECTOR;
> > >> Result: out STD_LOGIC_VECTOR);
> > >> end Project1;

>
> > >> I got error in STD_LOGIC_VECTOR, but I want no range in this vector.
> > >> How
> > >> can
> > >> i do this?

>
> > > You do that:

>
> > > entity Project1 is
> > > Port ( Code: in STD_LOGIC_VECTOR (2 downto 0);
> > > Input1 : in STD_LOGIC;
> > > Input2: in STD_LOGIC;
> > > Result: out STD_LOGIC);
> > > end Project1;

>
> > > --
> > > Vince

>
> > or

>
> > Input1 : in STD_LOGIC_VECTOR(0 downto 0);

>
> > maybe?
> > HTH., Syms.

>
> By "want no range" do you mean you want undeclared range? If so, that
> works fine, but not for the top level entity. If you have
> unconstrained ports, their range is defined in the instantiation. A
> top level entity is not instantiated anywhere, so there is no
> definition for the range.
>
> Andy


Yes, you are correct. I assume your example procedure is just an
academic exercise? Otherwise, the code will not elaborate if Input1 is
anything but 8 bits long. You can get the range (or length, etc.) of
an unconstrained port by using the appropriate attribute of it. In
this case, v'length would be 8 inside this instantiation of add(). A
better alias declaration would be:

alias v1: std_logic_vector(v'length - 1 downto 0) is v;

Which would normalize the range of v1 to be the correct length, but
with downto direction, and ending at 0, no matter what the index range
of input1 was (i.e. input1 might have been slv(8 to 15). This is
always a good thing to do inside architectures or subprograms with
unconstrained ports, if your implementation relies on a specific index
ordering, etc. Most folks do it with a variable declaration,
initialized to the value of the port, but either way works, so long as
your tool supports it.

variable v1 : std_logic_vector(v'length - 1 downto 0) := v;

Andy
 
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
Plese Can Somebody Solve This Boolean Question adilef2213 General Computer Support 0 11-01-2009 06:04 PM
inout std_logic_vector to array of std_logic_vector of generic length conversion... Thomas Rouam VHDL 6 11-09-2007 11:49 AM
Plese Help.... sam MCAD 1 05-25-2004 02:54 AM
Plese Help - NSW 2003 Pro Uninstall Has Replaced Folders With Gobbledy-Gook File Names :( GoLeafsGo Computer Support 12 01-28-2004 02:57 AM
plese help a newbie with an online database Andy, just Andy ASP .Net 1 01-27-2004 11:01 PM



Advertisments