【问题标题】:VHDL Getting a simulation fatal error in the loading design in modelsimVHDL在modelsim的加载设计中获得一个仿真致命错误
【发布时间】:2019-11-27 20:52:50
【问题描述】:

(是的,我知道有更简单的方法,是的,我的教授要求很长的路要走。) 以下是我的 1 位加法器/减法器的代码。

library ieee;
use ieee.std_logic_1164.all;

entity FA1Bit is
    port(x,y,Cin: in std_logic;
         op: in std_logic;
         S, Cout: out std_logic);
end FA1Bit;

architecture FA1Bit_arch of FA1Bit is

begin
    behavior : PROCESS(op,x,y,Cin)
    begin
    if op = '0' then --if we're adding the bits;
        if Cin = '0' then
            if x = y then
                S <= '0';
                if (x= '1' and y = '1') then
                    Cout <= '1';
                else --if x = 0 and y = 0;
                    Cout <= '0';
                end if;
            else --if x not equal to y;
                S <= '1';
                Cout <= '0';
            end if;
        else --if Cin = 1 then;
            if x = y then
                S <= '1';
                if (x= '1' and y = '1') then
                    Cout <= '1';
                else --if x = 0 and y = 0;
                    Cout <= '0';
                end if;
            else --if x not equal to y;
                S <= '0';
                Cout <= '1';
            end if;
        end if;

    else -- if we're subtracting bits (op = 1);
        if Cin = '0' then
            if x = y then
                Cout <= '0';
                S <= '0';
            elsif (x ='1' and y = '0') then
                Cout <= '0';
                S <= '1';
            else --if x not equal to y;
                S <= '1';
                Cout <= '1';
            end if;
        else --if Cin = 1 then;
            if x = y then
                Cout <= '1';
                S <= '1';
            elsif (x ='1' and y = '0') then
                Cout <= '0';
                S <= '0';
            else --if x not equal to y;
                S <= '0';
                Cout <= '1';
            end if;
        end if;
    end if;
    end PROCESS;

end FA1Bit_arch; 

现在我在这段代码的 4 位加法器/减法器中使用这个组件:

library IEEE;
use IEEE.std_logic_1164.all;
entity FA4Bit is
port (
X : in STD_LOGIC_VECTOR(3 downto 0);
Y : in STD_LOGIC_VECTOR(3 downto 0);
C0: in STD_LOGIC;
S : out STD_LOGIC_VECTOR(3 downto 0);
C4: out STD_LOGIC;
OP1: in STD_LOGIC_VECTOR(3 DOWNTO 0));
end FA4Bit;

architecture FA4Bit_arch of FA4Bit is
component FA1bit
port ( X: in STD_LOGIC; Y: in STD_LOGIC; CIN : in STD_LOGIC;
SI : out STD_LOGIC; COUT: out STD_LOGIC;
OPA : in STD_LOGIC);
end component;
signal C : std_logic_vector(1 to 3);
begin
U1: FA1bit port map (X=>X(0), Y=>Y(0), CIN=> C0, SI=>S(0), COUT=>C(1), OPA => OP1(0));
U2: FA1bit port map (X=>X(1), Y=>Y(1), CIN=> C(1), SI=>S(1), COUT=>C(2), OPA => OP1(1));
U3: FA1bit port map (X=>X(2), Y=>Y(2), CIN=> C(2), SI=>S(2), COUT=>C(3), OPA => OP1(2));
U4: FA1bit port map (X=>X(3), Y=>Y(3), CIN=> C(3), SI=>S(3), COUT=>C4, OPA => OP1(3));

end FA4Bit_arch;

以下测试平台的所有编译结果都完全相同。

library ieee;
use ieee.std_logic_1164.all;

entity FA4Bit_tb is
end ;
architecture arch of FA4Bit_tb is
component FA4Bit
    port ( X1 : in std_logic_vector(3 downto 0);
    Y : in std_logic_vector(3 downto 0);
    C0 : in std_logic;
    S : out std_logic_vector(3 downto 0);
    C4 : out std_logic;
    OP1: in std_logic_vector(3 downto 0));
end component;

signal X : std_logic_vector(3 downto 0) := "0000";
signal Y : std_logic_vector(3 downto 0) := "0000";
signal C0 : std_logic := '0';
signal opa: std_logic_vector(3 downto 0) := (others=>'0');
signal S : std_logic_vector(3 downto 0);
signal C4 : std_logic;

begin
    UUT : FA4Bit
    port map (X1 => X, Y => Y, C0 => C0, S => S, C4 => C4, OP1=> opa);

X <= not X after 5 ns;
Y <= not Y after 7 ns; 
opa <= not opa after 9 ns;

end arch;

但是,我在加载设计中收到 FATAL ERROR。

# ** Fatal: (vsim-3817) Port "X" of entity "fa4bit" is not in the component being instantiated.
#    Time: 0 ns  Iteration: 0  Instance: /fa4bit_tb/UUT File: C:/Users/Omar/Desktop/320 PROJECT 3ANJAD HAL MARRA/FA4Bit.vhd Line: 5
# FATAL ERROR while loading design
# Error loading design

【问题讨论】:

  • 没错,你不能在组件X1中重命名端口,不同于实体X!
  • 为什么每个 1 位加法器/减法器都有一个个性化的运算值?单个 opa 位可以引导 4 位加法器/减法器。所有三个实体和架构对似乎都以不同的风格编写。一致的样式(空格、线条、缩进、条件周围的括号和大写)可以帮助突出错误。通用和端口子句可以从实体声明复制到组件声明,反之亦然(自下而上与自上而下)。

标签: vhdl simulation modelsim


【解决方案1】:

这是我讨厌组件实例化的原因之一。在您的组件实例化中,该端口称为X1,而不是X。重命名为 X 应该可以解决此问题。然后你有几个类似的问题需要修复(OPS FA1bit)。

如果你使用实体实例化,那么很多这样的问题就会消失。

【讨论】:

  • 我还是个初学者,想了解更多关于这两种实例化的区别,可以给个链接吗?非常感谢。
  • 查找直接实例化。从 vhdl 93 开始,您可以直接从库中实例化实体。您只需要用于 verilog 代码或网表的组件。优点是当您遇到像您这样的问题时,这是一个语法错误,而不是映射错误。在综合或大模拟中,语法错误是在几秒钟内发现的,映射可能需要几分钟。
  • 使用保留字entity 的组件实例化(标准中没有提到直接实例化)只会将拼写错误的几率降低三分之一。您也可以复制有问题的实体到组件声明。有多种工具可用于从实体声明创建组件声明和组件实例化通用和端口映射方面,包括一些编辑器 VHDL 包。您在架构中会遇到错误的信号端口名称,一些编辑器包也会注意这一点。组件声明启用配置规范。
  • @Tricky 您实际上可以直接实例化 Verilog 模块,只需要在库中显式编译文件,这在 modelsim iirc 中对于 Verilog 不是必需的。
  • @O.Sinno 直接实例化是在 1993 年推出的。同时,在 [Verilog] 标签中,将会有无数仍在教授的大学生提出的问题一种在 2001 年被取代的 Verilog 编码风格。这些大学教授曾经更新他们的课程材料吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-10
  • 1970-01-01
  • 2011-10-20
  • 1970-01-01
相关资源
最近更新 更多