P
Patrick Erich
Guest
Hi,
I want to write a VHDL description in which the hardware generated
depends on some generic variables. For instance a register with
a_width inputs and y_width outputs; like so:
-------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity test is
generic ( a_width: integer;
y_width: integer);
port ( clk: in std_logic;
a : in std_logic_vector(a_width-1 downto 0);
y : out std_logic_vector(y_width-1 downto 0));
end test;
architecture behavior of test is
begin
lb0: process(clk)
begin
if (clk'event and clk='1') then
if (y_width > a_width) then
y(y_width-1 downto a_width) <= (others => '0');
y(a_width-1 downto 0) <= a;
else
y <= a(y_width-1 downto 0);
end if;
end if;
end process;
end behavior;
-------------------------------------------------------------------
This is what I want to do:
1) If y_width is larger than a_width, then I would like to store
the input a in the least significant bits of the register.
2) If y_width is smaller than (or equal to) a_width, then I would
like to store the least significant bits of a.
When using modelsim 5.6a (xilinx edition) to simulate, no problem
occurs as long as y_width is larger than a_width. On the other
hand, when I choose a_width to be larger than y_width modelsim
gives the following error:
# ** Fatal: (vsim-3421) Index 7 is out of range 3 downto 0.
# Time: 0 ps Iteration: 0 Region: /testbench/inst
# FATAL ERROR while loading design
# Error loading design
# Error: Error loading design
This description is synthesizeable according to xilinx's Project
Navigator 5.1i even with y_width smaller than a_width (only
warnings about unused inputs).
Can anyone explain to me please why modelsim is having a problem
with this description (while it is found to be synthesizeable)?
Thanks for your help,
Patrick Erich
This is the testbench
-------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity testbench is end testbench;
architecture behavior of testbench is
component test
generic ( a_width: integer;
y_width: integer);
port ( clk: in std_logic;
a: in std_logic_vector(a_width-1 downto 0);
y: out std_logic_vector(y_width-1 downto 0));
end component;
signal clk: std_logic;
signal a: std_logic_vector(7 downto 0);
signal y: std_logic_vector(3 downto 0);
begin
inst: test generic map (a_width => 8,
y_width => 4)
port map (clk, a, y);
clk <= '0' after 0 ns,
'1' after 10 ns when clk /= '1' else
'0' after 10 ns;
a <= "00000000" after 0 ns,
"11111111" after 60 ns;
end behavior;
-------------------------------------------------------------------
I want to write a VHDL description in which the hardware generated
depends on some generic variables. For instance a register with
a_width inputs and y_width outputs; like so:
-------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity test is
generic ( a_width: integer;
y_width: integer);
port ( clk: in std_logic;
a : in std_logic_vector(a_width-1 downto 0);
y : out std_logic_vector(y_width-1 downto 0));
end test;
architecture behavior of test is
begin
lb0: process(clk)
begin
if (clk'event and clk='1') then
if (y_width > a_width) then
y(y_width-1 downto a_width) <= (others => '0');
y(a_width-1 downto 0) <= a;
else
y <= a(y_width-1 downto 0);
end if;
end if;
end process;
end behavior;
-------------------------------------------------------------------
This is what I want to do:
1) If y_width is larger than a_width, then I would like to store
the input a in the least significant bits of the register.
2) If y_width is smaller than (or equal to) a_width, then I would
like to store the least significant bits of a.
When using modelsim 5.6a (xilinx edition) to simulate, no problem
occurs as long as y_width is larger than a_width. On the other
hand, when I choose a_width to be larger than y_width modelsim
gives the following error:
# ** Fatal: (vsim-3421) Index 7 is out of range 3 downto 0.
# Time: 0 ps Iteration: 0 Region: /testbench/inst
# FATAL ERROR while loading design
# Error loading design
# Error: Error loading design
This description is synthesizeable according to xilinx's Project
Navigator 5.1i even with y_width smaller than a_width (only
warnings about unused inputs).
Can anyone explain to me please why modelsim is having a problem
with this description (while it is found to be synthesizeable)?
Thanks for your help,
Patrick Erich
This is the testbench
-------------------------------------------------------------------
library ieee;
use ieee.std_logic_1164.all;
entity testbench is end testbench;
architecture behavior of testbench is
component test
generic ( a_width: integer;
y_width: integer);
port ( clk: in std_logic;
a: in std_logic_vector(a_width-1 downto 0);
y: out std_logic_vector(y_width-1 downto 0));
end component;
signal clk: std_logic;
signal a: std_logic_vector(7 downto 0);
signal y: std_logic_vector(3 downto 0);
begin
inst: test generic map (a_width => 8,
y_width => 4)
port map (clk, a, y);
clk <= '0' after 0 ns,
'1' after 10 ns when clk /= '1' else
'0' after 10 ns;
a <= "00000000" after 0 ns,
"11111111" after 60 ns;
end behavior;
-------------------------------------------------------------------