?? chufaqi.txt
字號:
時序電路是指它的輸出不僅取決于當時的輸入,而且也取決于過去的輸入,即過去輸入不同,則在當前的情況下,輸出也可能不同。時序電路的基礎電路是觸發器,能夠存儲一位二制信號的基本單元電路統稱為觸發器,計算機中常用的時序電路有計數器,寄存器和節拍分配器。D觸發器和JK觸發器是構成時序邏輯電路最基本存儲元件,為了實現記憶一位二值信號的功能,觸發器必須具備以下兩個特點:
1.具有兩個能自行保持的穩定狀態,用來表示邏輯狀態的0和1,或二進制的0和1。
2.根據不同的輸入信號可以置成1或0的狀態。根據觸發器的邏輯功能的不同分為RS觸發器,JK觸發器,T觸發器和D觸發器等[2]。
D觸發器的VHDL語言描述
library ieee;
use ieee.std_logic_1164.all;
entity dffr is
port(clk,clr,d:in std_logic;
q,qb:out std_logic);
end dffr;
architecture rtl of dffr is
signal qin: std_logic;
begin
qb<=not qin;
q<=qin;
process(clk,clr)
begin
if clr='1' then
qin<='0';
elsif clk'event and clk='1' then
qin<=d;
end if;
end process;
end rtl;
5.4.4 JK觸發器的VHDL語言描述
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity jk_ff is
port(j,k,clk:in std_logic;
q,qn:out std_logic);
end jk_ff;
architecture rtl of jk_ff is
signal q_temp,qn_temp:std_logic;
begin
process(clk,j,k)
begin
if clk'event and clk='0'then
if j='1'and k='0'then
q_temp<='1';
qn_temp<='0';
elsif j='0'and k='1'then
q_temp<='0';
qn_temp<='1';
elsif j='1' and k='1'then
q_temp<=not q_temp;
qn_temp<=not qn_temp;
else
q_temp<=q_temp;
qn_temp<=qn_temp;
end if;
end if;
q<=q_temp;
qn<=not q_temp;
end process;
end rtl;
5.4.5加/減脈沖控制器的頂層VHDL語言描述
程序如下[11]:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_unsigned.all;
entity idcount is
port(idclock,reset,inc,dec:in std_logic;
idout:out std_logic);
end idcount;
architecture behav of idcount is
component dffr
port(clk,clr,d:in std_logic;
q,qb:out std_logic);
end component;
component dffs
port(clk,clr,d:in std_logic;
q:out std_logic);
end component;
component dffb
port(clk,clr,d:in std_logic;
qb:out std_logic);
end component;
component jkffr
port(clk,clrn,j,k:in std_logic;
q,qn:out std_logic);
end component;
signal d7,d8,d9,d10,d11,d12:std_logic;
signal q1,qn1,q2,qn2,q3,qn3:std_logic;
signal q4,qn4,q5,q6:std_logic;
signal qn7,qn8,q9,qn9:std_logic;
begin
dff2:dffr port map(idclock,reset,dec,q2,qn2);
dff3:dffr port map(idclock,reset,q1,q3,qn3);
dff4:dffr port map(idclock,reset,q2,q4,qn4);
dff5:dffs port map(idclock,reset,q3,q5);
dff6:dffs port map(idclock,reset,q4,q6);
jk:jkffr port map (idclock,reset,qn7,qn8,q9,qn9);
d7<=q9 and qn1 and q3;
d8<=q9 and q5 and qn3;
d9<=d7 or d8;
d10<=qn9 and qn2 and q4;
d11<=qn9 and q6 and qn4;
d12<=d11 or d10;
dff7:dffb port map(idclock,reset,d9,qn7);
dff8:dffb port map (idclock,reset,d12,qn8);
idout<=(not idclock) or q9;
end behav;
5.4.6加/減脈沖控制器封裝模塊
5.4.7加/減脈沖控制器仿真波形
有圖可見,當來一個INC脈沖時,輸出相應的增加一個脈沖,而當來一個DEC脈沖時,則在輸出相應的減少一個脈沖。
5.4.8 N分頻器的VHDL語言描述
N分頻器則是一個簡單的除N 計數器。分頻器對脈沖加減電路的輸出脈沖再進行N分頻,得到整個環路的輸出信號Fout。同時,因為Fout = Clk/ 2 N = Fo ,因此通過改變分頻值N 可以得到不同的環路中心頻率Fo 。另外,模值N 的大小決定了DPLL 的鑒相靈敏度為π/ N 。以下描述以20分頻為例。其VHDL語言描述如下:
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_arith.all;
use ieee.std_logic_unsigned.all;
entity clkdiv is
generic(n:integer:=20);
port(clk: in std_logic;
clkout_3:buffer std_logic);
end clkdiv;
architecture a of clkdiv is
signal cnt1,cnt2:integer:=0;
signal outtemp : std_logic;
signal lout: std_logic;
signal out3:std_logic:='0';
begin
process(clk)
begin
if clk'event and clk='1'then
if cnt1=n-1 then
cnt1<=0;
else
cnt1<=cnt1+1;
end if;
end if;
end process;
process(clk)
begin
if clk'event and clk='0'then
if cnt2=n-1 then
cnt2<=0;
else
cnt2<=cnt2+1;
end if;
end if;
end process;
process(cnt1,cnt2 )
begin
if ((n mod 2)=1) then
if cnt1=1 then
if cnt2=0 then
outtemp<='1';
else outtemp<='0';
end if;
elsif cnt1=(n+1)/2 then
if cnt2=(n+1)/2 then outtemp<='1';
else outtemp<='0';
end if;
else outtemp<='0';
end if;
else
if cnt1=1 then
outtemp<='1';
elsif (cnt1=(n/2+1)) then
outtemp<='1';
else
outtemp<='0';
end if;
end if;
end process;
process(outtemp,clk)
begin
if ((n/=2) and (n/=1)) then
if outtemp'event and outtemp='1' then
clkout_3<=not clkout_3;
end if;
elsif (n=2) then
if(clk'event and clk='1')then
clkout_3<=not clkout_3;
end if;
else clkout_3<=clk;
end if;
end process;
end a;
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -