others and unconstrained array

M

MariuszK

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;
 
K

KJ

MariuszK said:
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
 
K

KJ

MariuszK said:
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
 
K

KJ

MariuszK said:
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
 
A

Allan Herriman

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
 
M

MariuszK

(e-mail address removed):











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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,150
Members
46,696
Latest member
BarbraOLog

Latest Threads

Top