2015-07-02 30 views
0

我是VHDL的新手,并且遵循xilinx提供的实验室,但是我在某个部分丢失了。在其中一个实验室中,我制作了一个2位宽的2to1多路复用器。在我现在的实验室中,我应该使用两个旧的多路复用器来构建3to1多路复用器。它并没有解释如何做到这一点,所以我在这个黑暗中刺伤。我收到以下错误代码。在VHDL中重新使用旧组件

[HDL 9-806]“end”附近的语法错误。 [“C:/ Nexys 4> Projects/lab1_5_dataflow/lab1_5_dataflow.srcs/sources_1/new/mux_2bit_3_to_1_dat> aflow.vhd”:48]

[HDL 9-806]在“;”附近出现语法错误。 [“C:/ Nexys 4> Projects/lab1_5_dataflow/lab1_5_dataflow.srcs/sources_1/new/mux_2bit_3_to_1_dat> aflow.vhd”:52]

[HDL 9-806]在“=>”附近出现语法错误。 [“C:/ Nexys 4> Projects/lab1_5_dataflow/lab1_5_dataflow.srcs/sources_1/new/mux_2bit_3_to_1_dat> aflow.vhd”:55]

[HDL 9-806]在“;”附近出现语法错误。 [“C:/ Nexys 4> Projects/lab1_5_dataflow/lab1_5_dataflow.srcs/sources_1/new/mux_2bit_3_to_1_dat> aflow.vhd”:59]

[HDL 9-806]在“=>”附近出现语法错误。 [ “C:/ Nexys 4>项目/ lab1_5_dataflow/lab1_5_dataflow.srcs/sources_1 /新/ mux_2bit_3_to_1_dat> aflow.vhd”:62]

这里是我的主源文件的代码。

library IEEE; 
use IEEE.STD_LOGIC_1164.ALL; 

entity mux_2bit_3_to_1_dataflow is 
Port (u : in STD_LOGIC_VECTOR (1 downto 0); 
     v : in STD_LOGIC_VECTOR (1 downto 0); 
     w : in STD_LOGIC_VECTOR (1 downto 0); 
     s : in STD_LOGIC_VECTOR (1 downto 0); 
     o : out STD_LOGIC_VECTOR (1 downto 0)); 
end mux_2bit_3_to_1_dataflow; 

architecture Behavioral of mux_2bit_3_to_1_dataflow is 
component mux_2bit_2_to_1 port 
(
    x, y : in STD_LOGIC_VECTOR; 
    s : in STD_LOGIC; 
    m : out STD_LOGIC_VECTOR 
) end component; 
signal a : STD_LOGIC_VECTOR; 
begin 
mux1 : mux_2bit_2_to_1 port map (
    x => u;           LINE 52 
    y => v; 
    s => s(1); 
    m => a            LINE 55 
); 

mux2 : mux_2bit_2_to_1 port map (
    x => a;           LINE 59 
    y => w; 
    s => s(0); 
    m => o;           LINE 62 
); 


end Behavioral; 

这里是我添加到项目中的2到1多路复用器的源文件。

entity mux_2bit_2_to_1 is 
Port (x : in STD_LOGIC_VECTOR (1 downto 0); 
     y : in STD_LOGIC_VECTOR (1 downto 0); 
     s : in STD_LOGIC; 
     m : out STD_LOGIC_VECTOR (1 downto 0)); 
end mux_2bit_2_to_1; 

architecture Behavioral of mux_2bit_2_to_1 is 

begin 
m(0) <= (x(0) and not s) or (y(0) and s); 
m(1) <= (x(1) and not s) or (y(1) and s); 


end Behavioral; 

回答

1

两件事。首先,你end component;之前错过一个分号:

component mux_2bit_2_to_1 
port (
    x, y : in STD_LOGIC_VECTOR; 
    s : in STD_LOGIC; 
    m : out STD_LOGIC_VECTOR 
); -- <--- semicolon here 
end component; 

第二件事,你在一个实例分配端口时,使用冒号:

mux1 : mux_2bit_2_to_1 port map (
    x => u, 
    y => v, 
    s => s(1), 
    m => a 
); 

最后,在你的第二个实例,你的最后一个端口上使用分号(m)。首先,在端口实例化上没有分号,其次,在最后一次分配时,在结束括号之前没有冒号。

+0

非常感谢您的帮助! –