当前位置:文档之家› 十进制4位加法计数器设计

十进制4位加法计数器设计

洛阳理工学院



4






系别:电气工程与自动化系
姓名:李奇杰学号:B10041016
十进制4位加法计数器设计
设计要求:
设计一个十进制4位加法计数器设计
设计目的:
1.掌握EDA设计流程
2.熟练VHDL语法
3.理解层次化设计的内在含义和实现
设计原理
通过数电知识了解到十进制异步加法器的逻辑电路图如下
Q3
则可以通过对JK触发器以及与门的例化连接实现十进制异步加法器的设计
设计内容
JK
JK触发器的VHDL文本描述实现:
--JK触发器描述
library ieee;
use ieee.std_logic_1164.all;
entity jk_ff is
port(
j,k,clk: in std_logic;
q,qn:out std_logic
);
end jk_ff;
architecture one of jk_ff is signal q_s: std_logic;
begin
process(j,k,clk)
begin
if clk'event and clk='0' then
if j='0' and k='0' then
q_s <= q_s;
elsif j='0' and k='1' then
q_s <= '0';
elsif j='1' and k='0' then
q_s <= '1';
elsif j='1' and k='1' then
q_s <= not q_s;
end if;
end if;
end process;
q <= q_s;
qn <= not q_s;
end one;
元件门级电路:
与门VHDL文本描述实现:
--与门描述library ieee;
use ieee.std_logic_1164.all;
entity yumen2 is
port(
a,b:in std_logic;
co:out std_logic
);
end entity yumen2;
architecture one of yumen2 is
begin
co<= (a and b );
end architecture one;
门级电路:
十进制异步加法器例化元件文本实现:
library ieee; --JK触发器描述use ieee.std_logic_1164.all;
entity jk_ff is
port(
j,k,clk: in std_logic;
q,qn:out std_logic
);
end jk_ff;
architecture one of jk_ff is
signal q_s: std_logic;
begin
process(j,k,clk)
begin
if clk'event and clk='0' then
if j='0' and k='0' then
q_s <= q_s;
elsif j='0' and k='1' then
q_s <= '0';
elsif j='1' and k='0' then
q_s <= '1';
elsif j='1' and k='1' then
q_s <= not q_s;
end if;
end if;
end process;
q <= q_s;
qn <= not q_s;
end one;
--与门描述
library ieee;
use ieee.std_logic_1164.all;
entity yumen2 is
port(
a,b:in std_logic;
co:out std_logic
);
end entity yumen2;
architecture one of yumen2 is
begin
co<= (a and b );
end architecture one;
library ieee; --十进制加法计数器描述use ieee.std_logic_1164.all;
entity count10 is
port(
cp: in std_logic;
c:out std_logic;
q:out std_logic_vector(3 downto 0)
);
end entity count10;
architecture count of count10 is
--例化元件JK触发器component jk_ff
port(
j,k,clk: in std_logic;
q,qn:out std_logic
);
end component;
--例化元件与门component yumen2
port(
a,b:in std_logic;
co:out std_logic
);
end component;
signal d,e,f,g,h,i,v,l,z:std_logic;
signal ou:std_logic_vector(3 downto 0);
begin
jk1:jk_ff port map(j=>'1',k=>'1',clk=>cp,q=>e);
jk2:jk_ff port map(j=>f,k=>'1',clk=>e,q=>h);
jk3:jk_ff port map(j=>'1',k=>'1',clk=>h,q=>i);
jk4:jk_ff port map(j=>l,k=>'1',clk=>e,q=>z,qn=>f); ym1:yumen2 port map(a=>e,b=>z,co=>c);
ym2:yumen2 port map(a=>h,b=>i,co=>l);
q<=z&i&h&e; -- 信号输出
end architecture count;
门级电路:
波形仿真:
展开二进制显示:
无符十进制显示:
思考与改进:
该设计中可以直接把使用与门的地方改用and语法代替。

若不是用例化语句则该电路可以简单的用循环加法实现。

12月16日
电气工程与自动化系李奇杰
参考资料:
1.数字电子技术基础简明教程(第三版)清华大学电子学教研组高教出版社
2.EDA技术与VHDL(第三版)潘松黄继业清华大学出版社。

相关主题