欢迎大家来到IT世界,在知识的湖畔探索吧!
实验任务一:七段译码器(共阳极)
【实验代码】
七人表决:
library ieee;
use ieee.std_logic_1164.all;
entity vote is
port(a:in std_logic_vector(6 downto 0);
y:out std_logic);
end vote;
architecture info of vote is
begin process(a)
variable i:integer;
begin i:=0;
if(a(0)=’1′) then i:=i+1;
end if;
if(a(1)=’1′) then i:=i+1;
end if;
if(a(2)=’1′) then i:=i+1;
end if;
if(a(3)=’1′) then i:=i+1;
end if;
if(a(4)=’1′) then i:=i+1;
end if;
if(a(5)=’1′) then i:=i+1;
end if;
if(a(6)=’1′) then i:=i+1;
end if;
if(i>3)
then y<=’1′;
else y<=’0′;
end if;
end process;
end info;
实验任务二:八位二进制加法器
【实验代码】
Add_8:
LIBRARY IEEE;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity add_8 IS
port (A: IN STD_LOGIC_VECTOR(7 DOWNTO 0);
B: IN STD_LOGIC_VECTOR(7 DOWNTO 0);
CIN: IN STD_LOGIC;
SUM:out std_logic_vector(7 downto 0);
COUT: OUT STD_LOGIC);
end add_8;
ARCHITECTURE info OF add_8 IS
COMPONENT add_4
port(a,b:in std_logic_vector(3 downto 0);
cin:in std_logic;
cout:out std_logic;
sum:out std_logic_vector(3 downto 0));
END COMPONENT;
signal SC:std_logic;
begin
U1:add_4
port map(cin=>cin,a=>a(3 downto 0),b=>b(3 downto 0),cout=>sc,sum=>sum(3 downto 0));
U2:add_4
port map(cin=>sc,a=>a(7 downto 4),b=>b(7 downto 4),cout=>cout,sum=>sum(7 downto 4));
END ARCHITECTURE info;
Add_4 U1:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity add_4 is
port(a,b:in std_logic_vector(3 downto 0);
cin:in std_logic;
cout:out std_logic;
sum:out std_logic_vector(3 downto 0));
end entity add_4;
architecture info of add_4 is
signal data:std_logic_vector(4 downto 0);
begin
data<=(‘0’& a)+(‘0’ & b)+(“0000” & cin);
cout<=data(4);
sum<=data(3 downto 0);
end info;
Add4:U2
略
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://itzsg.com/18117.html