VHDL中的组件声明错误

时间:2016-07-10 18:24:39

标签: vhdl quartus

我试图在VHDL文件中声明和使用组件,但Quartus II给了我以下错误:

Error (10482): VHDL error at operacao_mod_datapath.vhd(85): object "i_LD" is used but not declared
Error (10482): VHDL error at operacao_mod_datapath.vhd(86): object "i_IN" is used but not declared
Error (10482): VHDL error at operacao_mod_datapath.vhd(87): object "o_DOUT" is used but not declared
Error (10558): VHDL error at operacao_mod_datapath.vhd(87): cannot associate formal port "o_DOUT" of mode "out" with an expression

reg_in的VHDL文件是正确的,我总是声明这样的组件,Quartus从来没有给我这个错误。发生了什么事?

以下是代码:

library ieee;
    use ieee.std_logic_1164.all;
    use ieee.std_logic_unsigned.all;
    USE ieee.numeric_std.ALL;

entity operacao_mod_datapath is
port (
    i_RESET         : IN STD_LOGIC;                             -- Sinal para resetar a maquina de estados do contador
    i_CLOCK         : IN STD_ULOGIC;                            -- Clock
    i_LOAD_K        : IN STD_LOGIC;                             -- Sinal para carregar K
    i_LOAD_A        : IN STD_LOGIC; 
    i_LOAD_B        : IN STD_LOGIC; 
    i_LOAD_S        : IN STD_LOGIC;
    i_LOAD_CLEAR    : IN STD_LOGIC;                             -- Sinal para limpar K
    i_A             : IN UNSIGNED (7 downto 0);                 -- Entrada A
    i_B             : IN UNSIGNED (7 downto 0);                 -- Entrada B
    o_OUTS          : OUT INTEGER;                              -- Saida da operação aritmética
    o_COMP          : OUT STD_LOGIC                             -- Saída do comparador
    );
end operacao_mod_datapath;


architecture arch_1 of operacao_mod_datapath is



component array_multiplier is 
port (
    i_MULTIPLICAND : in unsigned(7 downto 0);          -- data input
    i_MULTIPLIER : in integer;                         -- data input
    o_DOUT : out std_logic_vector(15 downto 0));       -- data output
end component;  


component k_reg is 
port (
      i_CLR  : IN STD_LOGIC;
      i_CLK  : IN STD_ULOGIC;
      i_DINL : IN STD_LOGIC ;                   -- Sinal de load para carregar K
      i_DINK : IN INTEGER;                      -- Valor antigo de K
      o_DOUTK : BUFFER INTEGER                  -- saída S da operação de mod
    ); 
end component;  


component comparator is 
port (
    i_DINS : IN INTEGER;                         -- Entrada S (saída S da alu_mod)
    i_DINB : IN UNSIGNED (7 downto 0);           -- Entrada B (entrada do usuário)
    o_DOUT : OUT STD_LOGIC);                     -- Saída para informar o resultado da comparação
end component;  


component reg_in is
port    (
      i_LD    : IN STD_LOGIC;
      i_IN    : IN  UNSIGNED (7 downto 0);
      o_DOUT  : OUT UNSIGNED (7 downto 0)
      );  
end component;



component alu_mod is 
port (
    i_LD    : IN STD_LOGIC;                      -- sinal de load
    i_DINA  : IN UNSIGNED (7 downto 0);          -- Entrada A
    i_DINM  : IN STD_LOGIC_VECTOR(15 downto 0);  -- entrada do multiplicador
    o_DOUTS : OUT INTEGER                        -- saída S da operação de mod
 );                    
end component;

SIGNAL w_OUT0 : UNSIGNED (7 downto 0);
SIGNAL w_OUT1 : UNSIGNED (7 downto 0);
SIGNAL w_OUT2 : INTEGER;
SIGNAL w_OUT3 : STD_LOGIC_VECTOR (15 downto 0);
SIGNAL w_OUT4 : INTEGER;
SIGNAL w_OUT5 : STD_LOGIC;

begin 

u_0: reg_in port map (
                    i_LD <= i_LOAD_A,   
                    i_IN <= i_A,   
                    o_DOUT <= w_OUT0 
                  );


u_1: reg_in port map (
                    i_LD  <= i_LOAD_B,  
                    i_IN  <= i_B,  
                    o_DOUT <= w_OUT1  
                  );


u_2: array_multiplier port map (
                  i_MULTIPLICAND => w_OUT2,
                  i_MULTIPLIER   => w_OUT1,
                  o_DOUT         => w_OUT3
                  );


u_3: k_reg port map (
                 i_CLR    => i_RESET,
                 i_CLK    => i_CLOCK,
                 i_DINL   => i_LOAD_K,
                 i_DINK   => w_OUT2,
                 o_DOUTK  => w_OUT2
                 );

u_4: alu_mod port map (
                i_LD      => i_LOAD_S,
                i_DINA    => w_OUT0,
                i_DINM    => w_OUT3,
                o_DOUTS   => w_OUT4                   
                 );               


u_5: comparator port map (
                i_DINS   => w_OUT4,               
                i_DINB   => w_OUT1,        
                o_DOUT   => w_OUT5           
                 );

o_OUTS <= w_OUT4,
o_COMP <= w_OUT5;               


end arch_1;

2 个答案:

答案 0 :(得分:1)

再次查看代码后,我发现错误:

u_0: reg_in port map (
                    i_LD <= i_LOAD_A,   
                    i_IN <= i_A,   
                    o_DOUT <= w_OUT0 
                  );


u_1: reg_in port map (
                    i_LD  <= i_LOAD_B,  
                    i_IN  <= i_B,  
                    o_DOUT <= w_OUT1  
                  )

正确的是:

u_0: reg_in port map (
                    i_LD => i_LOAD_A,   
                    i_IN => i_A,   
                    o_DOUT => w_OUT0 
                  );


u_1: reg_in port map (
                    i_LD  => i_LOAD_B,  
                    i_IN  => i_B,  
                    o_DOUT => w_OUT1  
                  );

答案 1 :(得分:0)

您不仅需要声明组件,还需要对它们进行端口映射。端口映射是当您决定在代码中的各个模块之间路由信号时。一个模块的输出可以作为输入路由到另一个模块,这就是端口映射是什么,该工具通过“使用”来表示什么。