Skip to content
Snippets Groups Projects
Commit 30a36213 authored by Wesley W. Terpstra's avatar Wesley W. Terpstra
Browse files

wishbone_pkg: fix ghdl compile errors due to loop over length of a variable

Variable lengths might change; standard forbids length in a loop.
Fixes:
  wishbone_pkg.vhd:1576:18: universal integer bound must be numeric literal or attribute
  wishbone_pkg.vhd:1613:18: universal integer bound must be numeric literal or attribute
  wishbone_pkg.vhd:1734:30: universal integer bound must be numeric literal or attribute
  wishbone_pkg.vhd:1771:16: universal integer bound must be numeric literal or attribute
  wishbone_pkg.vhd:1806:16: universal integer bound must be numeric literal or attribute
  wishbone_pkg.vhd:1817:16: universal integer bound must be numeric literal or attribute
parent 2f134e41
Branches
Tags
No related merge requests found
...@@ -1560,6 +1560,7 @@ package body wishbone_pkg is ...@@ -1560,6 +1560,7 @@ package body wishbone_pkg is
-- generates aligned address map for an sdb_record_array, accepts optional start offset -- generates aligned address map for an sdb_record_array, accepts optional start offset
function f_sdb_automap_array(sdb_array : t_sdb_record_array; start_offset : t_wishbone_address := (others => '0')) function f_sdb_automap_array(sdb_array : t_sdb_record_array; start_offset : t_wishbone_address := (others => '0'))
return t_sdb_record_array is return t_sdb_record_array is
constant len : natural := sdb_array'length;
variable this_rng : unsigned(63 downto 0) := (others => '0'); variable this_rng : unsigned(63 downto 0) := (others => '0');
variable prev_rng : unsigned(63 downto 0) := (others => '0'); variable prev_rng : unsigned(63 downto 0) := (others => '0');
variable prev_offs : unsigned(63 downto 0) := (others => '0'); variable prev_offs : unsigned(63 downto 0) := (others => '0');
...@@ -1573,7 +1574,7 @@ package body wishbone_pkg is ...@@ -1573,7 +1574,7 @@ package body wishbone_pkg is
prev_offs(start_offset'left downto 0) := unsigned(start_offset); prev_offs(start_offset'left downto 0) := unsigned(start_offset);
--traverse the array --traverse the array
for i in 0 to sdb_array'length-1 loop for i in 0 to len-1 loop
-- find the fitting extraction function by evaling the type byte. -- find the fitting extraction function by evaling the type byte.
-- could also use the component, but it's safer to use Wes' embed and extract functions. -- could also use the component, but it's safer to use Wes' embed and extract functions.
sdb_type := sdb_array(i)(7 downto 0); sdb_type := sdb_array(i)(7 downto 0);
...@@ -1602,6 +1603,7 @@ package body wishbone_pkg is ...@@ -1602,6 +1603,7 @@ package body wishbone_pkg is
-- find place for sdb rom on crossbar and return address. try to put it in an address gap. -- find place for sdb rom on crossbar and return address. try to put it in an address gap.
function f_sdb_create_rom_addr(sdb_array : t_sdb_record_array) return t_wishbone_address is function f_sdb_create_rom_addr(sdb_array : t_sdb_record_array) return t_wishbone_address is
constant len : natural := sdb_array'length;
constant rom_bytes : natural := (2**f_ceil_log2(sdb_array'length + 1)) * (c_sdb_device_length / 8); constant rom_bytes : natural := (2**f_ceil_log2(sdb_array'length + 1)) * (c_sdb_device_length / 8);
variable result : t_wishbone_address := (others => '0'); variable result : t_wishbone_address := (others => '0');
variable this_base, this_end : unsigned(63 downto 0) := (others => '0'); variable this_base, this_end : unsigned(63 downto 0) := (others => '0');
...@@ -1610,7 +1612,7 @@ package body wishbone_pkg is ...@@ -1610,7 +1612,7 @@ package body wishbone_pkg is
variable sdb_type : std_logic_vector(7 downto 0); variable sdb_type : std_logic_vector(7 downto 0);
begin begin
--traverse the array --traverse the array
for i in 0 to sdb_array'length-1 loop for i in 0 to len-1 loop
sdb_type := sdb_array(i)(7 downto 0); sdb_type := sdb_array(i)(7 downto 0);
if(sdb_type = x"01" or sdb_type = x"02") then if(sdb_type = x"01" or sdb_type = x"02") then
-- get -- get
...@@ -1729,9 +1731,10 @@ package body wishbone_pkg is ...@@ -1729,9 +1731,10 @@ package body wishbone_pkg is
variable s_norm : std_logic_vector(result'length*4-1 downto 0) := (others=>'0'); variable s_norm : std_logic_vector(result'length*4-1 downto 0) := (others=>'0');
variable cut : natural; variable cut : natural;
variable nibble: std_logic_vector(3 downto 0); variable nibble: std_logic_vector(3 downto 0);
constant len : natural := result'length;
begin begin
s_norm(s'length-1 downto 0) := s; s_norm(s'length-1 downto 0) := s;
for i in result'length-1 downto 0 loop for i in len-1 downto 0 loop
nibble := s_norm(i*4+3 downto i*4); nibble := s_norm(i*4+3 downto i*4);
case nibble is case nibble is
when "0000" => result(i+1) := '0'; when "0000" => result(i+1) := '0';
...@@ -1765,10 +1768,11 @@ package body wishbone_pkg is ...@@ -1765,10 +1768,11 @@ package body wishbone_pkg is
-- Converts string (hex number, without leading 0x) to std_logic_vector -- Converts string (hex number, without leading 0x) to std_logic_vector
function f_string2bits(s : string) return std_logic_vector is function f_string2bits(s : string) return std_logic_vector is
constant len : natural := s'length;
variable slv : std_logic_vector(s'length*4-1 downto 0); variable slv : std_logic_vector(s'length*4-1 downto 0);
variable nibble : std_logic_vector(3 downto 0); variable nibble : std_logic_vector(3 downto 0);
begin begin
for i in 0 to s'length-1 loop for i in 0 to len-1 loop
case s(i+1) is case s(i+1) is
when '0' => nibble := X"0"; when '0' => nibble := X"0";
when '1' => nibble := X"1"; when '1' => nibble := X"1";
...@@ -1801,9 +1805,10 @@ package body wishbone_pkg is ...@@ -1801,9 +1805,10 @@ package body wishbone_pkg is
-- Converts string to ascii (std_logic_vector) -- Converts string to ascii (std_logic_vector)
function f_string2svl (s : string) return std_logic_vector is function f_string2svl (s : string) return std_logic_vector is
constant len : natural := s'length;
variable slv : std_logic_vector((s'length * 8) - 1 downto 0); variable slv : std_logic_vector((s'length * 8) - 1 downto 0);
begin begin
for i in 0 to s'length-1 loop for i in 0 to len-1 loop
slv(slv'high-i*8 downto (slv'high-7)-i*8) := slv(slv'high-i*8 downto (slv'high-7)-i*8) :=
std_logic_vector(to_unsigned(character'pos(s(i+1)), 8)); std_logic_vector(to_unsigned(character'pos(s(i+1)), 8));
end loop; end loop;
...@@ -1812,9 +1817,10 @@ package body wishbone_pkg is ...@@ -1812,9 +1817,10 @@ package body wishbone_pkg is
-- Converts ascii (std_logic_vector) to string -- Converts ascii (std_logic_vector) to string
function f_slv2string (slv : std_logic_vector) return string is function f_slv2string (slv : std_logic_vector) return string is
constant len : natural := slv'length;
variable s : string(1 to slv'length/8); variable s : string(1 to slv'length/8);
begin begin
for i in 0 to (slv'length/8)-1 loop for i in 0 to (len/8)-1 loop
s(i+1) := character'val(to_integer(unsigned(slv(slv'high-i*8 downto (slv'high-7)-i*8)))); s(i+1) := character'val(to_integer(unsigned(slv(slv'high-i*8 downto (slv'high-7)-i*8))));
end loop; end loop;
return s; return s;
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment