2014-02-18 65 views
0

这两个vhdl码有什么区别?这2个vhdl码有什么区别

首先

library IEEE; 
use IEEE.Std_Logic_1164.all; 

entity mux4 is 
port(
    in1, in2, in3, in4 : in std_logic; 
    ctrl: in std_logic_vector(1 downto 0); 
    sai: out std_logic 
    ); 
end mux4; 

architecture mux_bhv of mux4 is 
begin 
    process(in1, in2, in3, in4, ctrl) 
     begin case ctrl is 
      when "00" => sai <= in1; 
      when "01" => sai <= in2; 
      when "10" => sai <= in3; 
      when "11" => sai <= in4; 
      when others => null; 
     end case; 
    end process; 
end mux_bhv; 

library IEEE; 
use IEEE.Std_Logic_1164.all; 

entity mux4x1 is 
    port(w, x, y, z: in std_logic_vector(7 downto 0); 
     s: in std_logic_vector(1 downto 0); 
     m: out std_logic_vector(7 downto 0) 
     ); 
end mux4x1; 

architecture circuito of mux4x1 is 
begin 
    m <= w when s = "00" else 
     x when s = "01" else 
     y when s = "10" else 
     z; 
end circuito; 
+0

我的代码没有被构建,所以我将它们上传到了pastebin:http://pastebin.com/mvDVnUNn http://pastebin.com/GQFh9uBZ –

+0

我知道它们都是多路复用器,但是它们之间有区别代码? –

+0

您是否考虑过由综合产生的电路差异,还是模拟差异?一个是'std_logic'与另一个'std_logic_vector(7 downto 0)'之间的多路复用器之间的多路复用器;我认为这不是一个明显的差异,就像你之后... –

回答

0

另外一个微小的差别,除了std_logic VS std_logic_vector是在模拟:第二多路复用器的输出m设置为zs是“11”,并且当s包含任何非零/一个值(即Z,X的,H,L,...)。

在第一个多路复用器中,当ctrl包含非零/一个值时,输出sai未更新。

再次,这只是一个模拟的区别。

1

第一个节目:

library IEEE; 
use IEEE.Std_Logic_1164.all; 

entity mux4 is 
port(
in1, in2, in3, in4 : in std_logic; 
ctrl: in std_logic_vector(1 downto 0); 
sai: out std_logic 
); 
end mux4; 

architecture mux_bhv of mux4 is 
begin 
process(in1, in2, in3, in4, ctrl) 
    begin case ctrl is 
     when "00" => sai <= in1; 
     when "01" => sai <= in2; 
     when "10" => sai <= in3; 
     when "11" => sai <= in4; 
     when others => null; 
    end case; 
end process; 
end mux_bhv; 

你有四个二进制一个位输入,一个两位的选择线和一个放。所以,那是你的港口声明。然后在您的体系结构中: 使用案例供选择。所以,正如您在输入中声明的那样,选择行是ctrl。当它是00时,选择第一个输入。如果您选择CTRL“01”,然后就通过第二输入等..

library IEEE; 
use IEEE.Std_Logic_1164.all; 

entity mux4x1 is 
port(w, x, y, z: in std_logic_vector(7 downto 0); 
    s: in std_logic_vector(1 downto 0); 
    m: out std_logic_vector(7 downto 0) 
    ); 
end mux4x1; 

architecture circuito of mux4x1 is 
begin 
m <= w when s = "00" else 
    x when s = "01" else 
    y when s = "10" else 
    z; 
end circuito; 

同样的想法4-1 multiplixer,但在这里,你的输入和输出是7位,而不是只在一个位。我希望你得到它^ _ ^。

0

如上所述“在第一个多路复用器中,当ctrl包含非零/一个值时,输出sai不会更新。
由于这种缺乏分配,大多数软件工具将创建一个中间(可能是不受欢迎的)锁存器。第二个代码中没有发生的事情,其中​​分配了所有可能的值。