大家好,欢迎来到IT知识分享网。全加器的真值表如下:
该全加器程序由以下三个子程序构成
1)“f_adder”全加器程序
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY f_adder IS
PORT (ain,bin,cin:IN STD_LOGIC;
cout,sum:OUT STD_LOGIC);
END ENTITY f_adder;
ARCHITECTURE fd1 OF f_adder IS
COMPONENT h_adder
PORT (a,b:IN STD_LOGIC;
co,so:OUT STD_LOGIC);
END COMPONENT;
COMPONENT or2a
PORT(a,b:IN STD_LOGIC;
c: OUT STD_LOGIC);
END COMPONENT;
SIGNAL d,e,f : STD_LOGIC;
BEGIN
u1: h_adder PORT MAP(a=>ain,b=>bin,co=>d,so=>e);
u2: h_adder PORT MAP(a=>e,b=>cin,co=>f,so=>sum);
u3: or2a PORT MAP(a=>d,b=>f,c=>cout);
END ARCHITECTURE fd1;
IT知识分享网
2)“h_adder半加器程序”
IT知识分享网LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY h_adder IS
PORT (a,b:IN STD_LOGIC;
co,so:OUT STD_LOGIC);
END ENTITY h_adder;
ARCHITECTURE fh1 OF h_adder IS
BEGIN
so<=NOT(a XOR (NOT b));
co<=a AND B;
END ARCHITECTURE fh1;
3)“or2a 或门程序”
LIBRARY IEEE;
USE IEEE.STD_LOGIC_1164.ALL;
ENTITY or2a IS
PORT(a,b:IN STD_LOGIC;
c: OUT STD_LOGIC);
END ENTITY or2a;
ARCHITECTURE one OF or2a IS
BEGIN
c<=a OR b;
END ARCHITECTURE one;
程序仿真效果如下图
免责声明:本站所有文章内容,图片,视频等均是来源于用户投稿和互联网及文摘转载整编而成,不代表本站观点,不承担相关法律责任。其著作权各归其原作者或其出版社所有。如发现本站有涉嫌抄袭侵权/违法违规的内容,侵犯到您的权益,请在线联系站长,一经查实,本站将立刻删除。 本文来自网络,若有侵权,请联系删除,如若转载,请注明出处:https://yundeesoft.com/12473.html