一、设计原理
4位同步二进制加法计数器的工作原理是指当时钟信号clk的上升沿到来时,且复位信号clr低电平有效时,就把计数器的状态清0。
在clr复位信号无效(即此时高电平有效)的前提下,当clk的上升沿到来时,如果计数器原态是15,计数器回到0态,否则计数器的状态将加1
二、VHDL源程序
library ieee; use ieee.std_logic_1164.all; entity cnt4e is port(clk,clr:in std_logic; cout:out std_logic; q:buffer integer range 0 to 15); end cnt4e; architecture one of cnt4e is begin process(clk,clr) begin if clk'event and clk='1'then if clr='1'then if q=15 then q<=0; cout<='0'; elsif q=14 then q<=q+1; cout<='1'; else q<=q+1; end if; else q<=0; cout<='0'; end if; end if; end process; end one;
三、仿真波形图
VerilogHDL和一个的编程语言其实也差不多,关键在于首先要了解所搭的电路。不仅仅是纯语言思想,同时动手实践也相当重要。