题目要求:
在文本编辑器中使用VHDL语言设计一个优先8-3编码器。在另一个新实体中将其定义成一个元件,通过元件例化的方式设计一个16-4优先编码器。文件命名为***164.vhd,器件设定为EP3C16F256C8。要求输入节点命名为d0…d15,低电平有效;输出节点命为A、B、C、D。进行波形仿真,验证功能正确。分析其出现竞争冒险的可能性。
文末有PDF格式的文件进行图文描述,并包含源文件
一、8-3线优先编码器代码
library ieee;
use ieee.std_logic_1164.all;
entity byl8_3 is
port(
Yex,C,B,A,Ys:out std_logic; --四个输出端
I:std_logic_vector(7 downto 0);--八个输入
S:in std_logic); --使能端
end entity byl8_3;
architecture BEHAV of byl8_3 is
begin
process(I,S)
begin
if(S='0')then --低电平有效
if(I(7)='0') then C<='0';B<='0';A<='0';Ys<='1'; Yex<='0';-----01111111 输出 000
elsif(I(6)='0') then C<='0';B<='0';A<='1';Ys<='1'; Yex<='0';-----x0111111 输出 001
elsif(I(5)='0') then C<='0';B<='1';A<='0';Ys<='1'; Yex<='0';-----xx011111 输出 010
elsif(I(4)='0') then C<='0';B<='1';A<='1';Ys<='1'; Yex<='0';-----xxx01111 输出 011
elsif(I(3)='0') then C<='1';B<='0';A<='0';Ys<='1'; Yex<='0';-----xxxx0111 输出 100
elsif(I(2)='0') then C<='1';B<='0';A<='1';Ys<='1'; Yex<='0';-----xxxxx011 输出 101
elsif(I(1)='0') then C<='1';B<='1';A<='0';Ys<='1'; Yex<='0';-----xxxxxx01 输出 110
elsif(I(0)='0') then C<='1';B<='1';A<='1';Ys<='1'; Yex<='0';-----xxxxxxx0 输出 111
else A<='1';B<='1';C<='1';Ys<='0'; Yex<='1';---------------------其他输入均输出 111
end if;
else
A<='1';B<='1';C<='1';Ys<='1'; Yex<='1'; -------------------------使能端无效
end if;
end process;
end BEHAV;
二、与非门
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY yufei IS
PORT(
a,b:IN STD_LOGIC;
y:OUT STD_LOGIC
);
END;
ARCHITECTURE behaver OF yufei IS
BEGIN
y <= a NAND b;
END behaver;
三、非门
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY not_gate IS
PORT(a:IN STD_LOGIC;
f:OUT STD_LOGIC);
END not_gate;
ARCHITECTURE not_gate_behavior OF not_gate IS
BEGIN
f<= NOT a;
END not_gate_behavior;
三、使用元件例化语句构成的16-4优先编码器
library ieee;
use ieee.std_logic_1164.all;
entity byl164 is------------------------------16-4译码器
port (
DO,C,B,A :out std_logic;-------------四个输出端
d:std_logic_vector( 0 TO 15);------------------16个输入端口
SI:in std_logic); --使能端
end entity byl164;
architecture BEHAV of byl164 is
-----------------------------------------------8-3译码器
COMPONENT byl8_3
port(
Yex,C,B,A,Ys:out std_logic; --四个输出端
I:std_logic_vector(7 downto 0);--八个输入
S:in std_logic--------------------使能端
);
END COMPONENT;
-----------------------------------------------2输入的与非门
comPONENT yufei
PORT(
a,b:IN STD_LOGIC;
y:OUT STD_LOGIC
);
END COMPONENT;
--------------------------------------------非门
comPONENT not_gate
PORT
(
a:IN STD_LOGIC;
f:OUT STD_LOGIC
);
END COMPONENT;
--------------------------------------------所使用到的中间变量
SIGNAL O,P,Q,R,T,U,V,Yex1,Yex2,YS2:STD_LOGIC;
begin--------------------------------------连接元器件构成16-4的译码器
U1:byl8_3 port map(S=>SI,I=>d(8 TO 15),Ys=>O,Yex=>Yex1,A=>P,B=>Q,C=>R);--------第一片8-3译码器的连接
U2:byl8_3 port map(S=>O,I=>d(0 TO 7),Ys=>YS2,Yex=>Yex2,A=>T,B=>U,C=>V);---------第二片8-3译码器的连接
n1:yufei port map(a=>T,b=>P,y=>A);------------------------------------与非门的连接
n2:yufei port map(a=>U,b=>Q,y=>B);
n3:yufei port map(a=>V,b=>R,y=>C);
n4:not_gate port map(Yex1,DO);-------------------------------------------或门的连接
end BEHAV;
链接:https://pan.baidu.com/s/1mkIgAZVL3zF7X8D0AlqLNg
提取码:m470