http://blog.csdn.net/ys_073/article/details/8195312一、設(shè)計(jì)原理
4位同步二進(jìn)制加法計(jì)數(shù)器的工作原理是指當(dāng)時鐘信號clk的上升沿到來時,且復(fù)位信號clr低電平有效時,就把計(jì)數(shù)器的狀態(tài)清0。
在clr復(fù)位信號無效(即此時高電平有效)的前提下,當(dāng)clk的上升沿到來時,如果計(jì)數(shù)器原態(tài)是15,計(jì)數(shù)器回到0態(tài),否則計(jì)數(shù)器的狀態(tài)將加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和一個的編程語言其實(shí)也差不多,關(guān)鍵在于首先要了解所搭的電路。不僅僅是純語言思想,同時動手實(shí)踐也相當(dāng)重要。
|