Som*_*ist 4 fpga vhdl hdl ghdl
我在使用 GHDL ( http://ghdl.readthedocs.io/en/latest/ ) 来模拟我的 VHDL 设计时遇到问题。因此,当我使用该命令ghdl -e Averager_tb用 GHDL 编译测试台时,我收到警告:
Averager_tb.VHD:33:3:warning: component instance "uut" is not bound
Averager_tb.VHD:11:14:warning: (in default configuration of averager_tb(behaviour))
Run Code Online (Sandbox Code Playgroud)
要编译用于模拟的测试平台,我使用以下命令:
ghdl -a Averager_tb.VHD # the test bench file is Averager_tb.VHD
ghdl -e Averager_tb # the entity for the test bench is Averager_tb
Run Code Online (Sandbox Code Playgroud)
并且我的设计的输出在整个测试平台中保持不变,我还发现设计中的打印语句没有被执行。
要执行已编译的测试台模拟,我使用以下命令:
ghdl -r Averager_tb
Run Code Online (Sandbox Code Playgroud)
然而,当我使用 Aldec Riviera Pro 2015.06 模拟器在http://www.edaplayground.com上模拟相同的测试平台时,我发现设计中的打印语句被执行并且输出按照我的预期发生变化。
为什么会这样,我该如何解决?
这是我设计中的实体声明
-- Entity Declaration in Design
entity Averager is
port (
clk : in std_logic;
ClockEnable : in std_logic;
Averager_In : in std_logic_vector(7 downto 0);
Averager_Out : out std_logic_vector(7 downto 0)
);
end Averager;
Run Code Online (Sandbox Code Playgroud)
下面是测试台:
-- TEST BENCH
architecture behaviour of Averager_tb is
signal X : real := 0.0; -- a real math variable initialized to 0
signal sine : real := 0.0; -- a real math variable initialized to 0
component Averager
port(
clk : in std_logic;
ClockEnable : in std_logic;
Averager_In : in std_logic_vector(7 downto 0);
Averager_Out : out std_logic_vector(7 downto 0)
);
end component;
signal clk : std_logic := '0';
signal ADC_clk : std_logic := '0';
signal Input : std_logic_vector(7 downto 0);
signal FPGAOutput : std_logic_vector(7 downto 0);
signal int_sine : integer;
constant clk_period : time := 5 ns;
begin
-- Instantiate the Unit Under Test (UUT)
UUT : Averager
port map (
clk => clk,
ClockEnable => ADC_clk,
Averager_In => Input,
Averager_Out => FPGAOutput
);
...
Run Code Online (Sandbox Code Playgroud)
想通了,这是一个愚蠢的错误,我忘了编译设计以及测试台。解决方案是像这样编译和运行:
ghdl -a Averager_Bettertb.VHD
ghdl -a Averager.VHD
ghdl -e Averager_tb
ghdl -r Averager_tb #--stop-time=10us
Run Code Online (Sandbox Code Playgroud)