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

Reply

VHDL - others and unconstrained array

 
Thread Tools Search this Thread
Old 11-22-2008, 10:43 PM   #1
Default others and unconstrained array


Hello,

I have following error in line "out1 <= (others=>'0');"
BuffG.vhd : (47, 22): Keyword "others" is not allowed in unconstrained
array aggregate.

If out1 is constrained (out1: out STD_LOGIC_Vector(7 downto 0)
everything work. How can I change below code to have universal
unconstrained buffer with reset?

library IEEE;
use IEEE.STD_LOGIC_1164.all;

entity BuffG is
port(
CLK : in STD_LOGIC;
RST : in STD_LOGIC;
CE : in STD_LOGIC;
in1 : in STD_LOGIC_Vector;
out1: out STD_LOGIC_Vector
);
end BuffG;

architecture BuffG of BuffG is
begin
process(CLK)
begin
if rising_edge(CLK) then
if RST = '1' then
out1 <= (others=>'0');
elsif CE = '1' then
out1 <= in1;
end if;
end if;
end process;
end BuffG;


MariuszK
  Reply With Quote
Old 11-23-2008, 12:28 AM   #2
KJ
 
Posts: n/a
Default Re: others and unconstrained array

"MariuszK" <> wrote in message
news:58dc006e-749f-46ef-b310-...
> Hello,
>
> I have following error in line "out1 <= (others=>'0');"
> BuffG.vhd : (47, 22): Keyword "others" is not allowed in unconstrained
> array aggregate.
>
> If out1 is constrained (out1: out STD_LOGIC_Vector(7 downto 0)
> everything work. How can I change below code to have universal
> unconstrained buffer with reset?
>


One way would be by adding a function, either in the architecture or the
process, see below.

architecture BuffG of BuffG is
begin
process(CLK)
function Zeroit(V: std_logic_vector) return std_logic_vector is
variable RetVal: std_logic_vector(V'range) := (others => '0');
begin
return(RetVal);
end function Zeroit;
begin
if rising_edge(CLK) then
if RST = '1' then
out1 <= (others=>'0');
elsif CE = '1' then
out1 <= in1;
end if;
end if;
end process;
end BuffG;

KJ




KJ
  Reply With Quote
Old 11-23-2008, 01:37 AM   #3
KJ
 
Posts: n/a
Default Re: others and unconstrained array

"MariuszK" <> wrote in message
news:58dc006e-749f-46ef-b310-...
> Hello,
>
> I have following error in line "out1 <= (others=>'0');"
> BuffG.vhd : (47, 22): Keyword "others" is not allowed in unconstrained
> array aggregate.
>
> If out1 is constrained (out1: out STD_LOGIC_Vector(7 downto 0)
> everything work. How can I change below code to have universal
> unconstrained buffer with reset?
>


Another method is to define a constant inside the process or architecture
that is of the same size, see below.

architecture BuffG of BuffG is
begin
process(CLK)
constant Zeros: std_logic_vector(out1'range) := (others => '0');
begin
if rising_edge(CLK) then
if RST = '1' then
out1 <= Zeros;
elsif CE = '1' then
out1 <= in1;
end if;
end if;
end process;
end BuffG;

KJ




KJ
  Reply With Quote
Old 11-23-2008, 01:39 AM   #4
KJ
 
Posts: n/a
Default Re: others and unconstrained array

"MariuszK" <> wrote in message
news:58dc006e-749f-46ef-b310-...
> Hello,
>
> I have following error in line "out1 <= (others=>'0');"
> BuffG.vhd : (47, 22): Keyword "others" is not allowed in unconstrained
> array aggregate.
>
> If out1 is constrained (out1: out STD_LOGIC_Vector(7 downto 0)
> everything work. How can I change below code to have universal
> unconstrained buffer with reset?
>


One way would be by adding a function, either in the architecture or the
process, see below.

architecture BuffG of BuffG is
begin
process(CLK)
function Zeroit(V: std_logic_vector) return std_logic_vector is
variable RetVal: std_logic_vector(V'range) := (others => '0');
begin
return(RetVal);
end function Zeroit;
begin
if rising_edge(CLK) then
if RST = '1' then
out1 <= Zeroit(out1);
elsif CE = '1' then
out1 <= in1;
end if;
end if;
end process;
end BuffG;

KJ




KJ
  Reply With Quote
Old 11-23-2008, 02:42 AM   #5
Allan Herriman
 
Posts: n/a
Default Re: others and unconstrained array
MariuszK <> wrote in news:58dc006e-749f-46ef-
b310-:

> Hello,
>
> I have following error in line "out1 <= (others=>'0');"
> BuffG.vhd : (47, 22): Keyword "others" is not allowed in unconstrained
> array aggregate.
>
> If out1 is constrained (out1: out STD_LOGIC_Vector(7 downto 0)
> everything work. How can I change below code to have universal
> unconstrained buffer with reset?
>
> library IEEE;
> use IEEE.STD_LOGIC_1164.all;
>
> entity BuffG is
> port(
> CLK : in STD_LOGIC;
> RST : in STD_LOGIC;
> CE : in STD_LOGIC;
> in1 : in STD_LOGIC_Vector;
> out1: out STD_LOGIC_Vector
> );
> end BuffG;
>
> architecture BuffG of BuffG is
> begin
> process(CLK)
> begin
> if rising_edge(CLK) then
> if RST = '1' then
> out1 <= (others=>'0');
> elsif CE = '1' then
> out1 <= in1;
> end if;
> end if;
> end process;
> end BuffG;



Change the line:
out1 <= (others=>'0');

to:
out1 <= (out1'range =>'0');

Regards,
Allan


Allan Herriman
  Reply With Quote
Old 11-23-2008, 12:07 PM   #6
MariuszK
 
Posts: n/a
Default Re: others and unconstrained array
On 23 Lis, 03:42, Allan Herriman <allanherri...@hotmail.com> wrote:
> MariuszK <mariusz.kwicz...@gmail.com> wrote in news:58dc006e-749f-46ef-
> b310-b18217530...@h5g2000yqh.googlegroups.com:
>
>
>
>
>
> > Hello,

>
> > I have following error in line "out1 <= (others=>'0');"
> > BuffG.vhd : (47, 22): Keyword "others" is not allowed in unconstrained
> > array aggregate.

>
> > If out1 is constrained (out1: out STD_LOGIC_Vector(7 downto 0)
> > everything work. How can I change below code to have universal
> > unconstrained buffer with reset?

>
> > library IEEE;
> > use IEEE.STD_LOGIC_1164.all;

>
> > entity BuffG is
> > * *port(
> > * * * CLK : in *STD_LOGIC;
> > * * * RST : in *STD_LOGIC;
> > * * * CE *: in *STD_LOGIC;
> > * * * in1 : in *STD_LOGIC_Vector;
> > * * * out1: out STD_LOGIC_Vector
> > * * * );
> > end BuffG;

>
> > architecture BuffG of BuffG is
> > begin
> > * *process(CLK)
> > * *begin
> > * * * if rising_edge(CLK) then
> > * * * * *if RST = '1' then
> > * * * * * * out1 <= (others=>'0');
> > * * * * *elsif CE = '1' then
> > * * * * * * out1 <= in1;
> > * * * * *end if;
> > * * * end if;
> > * *end process;
> > end BuffG;

>
> Change the line:
> * * * * * * out1 <= (others=>'0');
>
> to:
> * * * * * * out1 <= (out1'range =>'0');
>
> Regards,
> Allan- Ukryj cytowany tekst -
>
> - Pokaż cytowany tekst -


Thank you All!
Attribute "'range" that's it what I need.

Best Regards,
Mariusz


MariuszK
  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