双二选一多路选择器

  • 格式:pdf
  • 大小:54.83 KB
  • 文档页数:2

双⼆选⼀多路选择器

这是⼀个双⼆选1多路选择器的原理图,⽤VHDL语⾔描述,需要⽤到元器件例化语句。

⾸先编写2选⼀多路选择器。entity mux21a is

port(a,b,c:in bit;

y:out bit

);

end;

architecture bhv of mux21a is

begin

process(a,b,c)

begin

if s='0' then y<=a; else y<=b;

end if;

end process;

end architecture bhv;

其电路逻辑:当y输出⾼电平'1'时,s='0',a=1(b不考虑) s='1',b=1(a不考虑)

当y输出低电平‘0’时,s='0',a=0(b不考虑)

s='1',b=0(a不考虑)

双2选1多路选择器程序entity muxk is

port(a1,a2,a3,s0,s1:in bit;

outy:out bit

);

end;

architecture bhv of muxk is

component mux21a

port(a,b,s:in bit;

y:out bit

);

end component;

signal tmp:bit;

begin

u1:mux21a port map(a=>a2,b=>a3,s=>s0,y=>tmp);

u2:mux21a port map(a=>a1,b=>tmp,s=>s1,y=>outy);

end architecture bhv;其电路逻辑:当输出为⾼电平'1'时,s1=0.a1=1(s0,a2,a3不考虑) s1=1,s0=0,a2=1(a1,a3不考虑)

s0=1,a3=1(a1,a2不考虑)

当输出为低电平'0'时,s1=0,a1=0(s0,a2,a3不考虑)

s1=1, s0=0,a2=0(a1,a3不考虑)

s1=1,s0=1,a3=0(a1,a2不考虑)

VHDL例化语句

例化语句由两部分组成,第⼀部分是将⼀个现成的设计实体定义为⼀个元件,语句的功能是对待调⽤的这个元器件做出调⽤声明。格式如下:component 元件名 is

port(端⼝名)

end component;

元件定义语句必须放在结构体的architecture和begin之间。

端⼝信号的数据类型的定义必须与原设计实体⽂件⼀致,⽽且信号的排列⽅式也要与原来⼀致,包括端⼝模式、数据类型、功能定义等。

元件例化语句的第⼆部分则是此元件与当前设计实体(顶层⽂件)中元件间及端⼝的连接说明。

例化名:元件名 port map([端⼝名=>]连接端⼝名.....);port map是端⼝映射,或端⼝连接的意思。其中的“端⼝名”是在元件定义语句中的端⼝名表中已定义好元件端⼝的名字。

“=>”仅代表连接关系,不代表信号流动的⽅向。