F
Frank Buss
Guest
The following code works in Xilinx ISE 8.1:
adds: for i in 0 to bits - 1 generate
add(i) <= shift_add(i, bits, a) when b(i) = '1'
else to_unsigned(0, 2 * bits - 1);
end generate;
with this function definition (I need this complicated function, because
to_unsigned doesn't allow to generate 0 bits and I didn't found another
function) :
function shift_add(shift: integer; bits: integer; b: unsigned)
return unsigned is
variable result: unsigned(2 * bits - 1 downto 0);
begin
if shift < bits then
for i in 0 to bits - shift - 1 loop
result(2 * bits - 1 - i) := '0';
end loop;
end if;
for i in 0 to bits - 1 loop
result(i + shift) := b(i);
end loop;
if shift > 0 then
for i in 0 to shift - 1 loop
result(i) := '0';
end loop;
end if;
return result;
end shift_add;
If I want to inline the function, it doesn't work. Even a simple "if"
doesn't work:
adds: for i in 0 to bits - 1 generate
if i > 0 then
add(i) <= b"00000000";
end if;
end generate;
For this code I get the error "parse error, unexpected IF". Is there a bug
in my code or in ISE?
--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de
adds: for i in 0 to bits - 1 generate
add(i) <= shift_add(i, bits, a) when b(i) = '1'
else to_unsigned(0, 2 * bits - 1);
end generate;
with this function definition (I need this complicated function, because
to_unsigned doesn't allow to generate 0 bits and I didn't found another
function) :
function shift_add(shift: integer; bits: integer; b: unsigned)
return unsigned is
variable result: unsigned(2 * bits - 1 downto 0);
begin
if shift < bits then
for i in 0 to bits - shift - 1 loop
result(2 * bits - 1 - i) := '0';
end loop;
end if;
for i in 0 to bits - 1 loop
result(i + shift) := b(i);
end loop;
if shift > 0 then
for i in 0 to shift - 1 loop
result(i) := '0';
end loop;
end if;
return result;
end shift_add;
If I want to inline the function, it doesn't work. Even a simple "if"
doesn't work:
adds: for i in 0 to bits - 1 generate
if i > 0 then
add(i) <= b"00000000";
end if;
end generate;
For this code I get the error "parse error, unexpected IF". Is there a bug
in my code or in ISE?
--
Frank Buss, fb@frank-buss.de
http://www.frank-buss.de, http://www.it4-systems.de