VHDL語言編寫的帶同步置位/復位的D觸發器:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitytrigger_dis
port(clk,d,sreset,sset:instd_logic;--同步復位端sreset,同步置位端sset
q,qf:outstd_logic);
endentity;
architectureartoftrigger_dis
begin
process(clk,d,sreset,sset)
ifclk"eventandclk="1"then
ifsreset="1"thenq<="0";qf<="1";--同步復位端sreset,高電平有效,復位
elsifsset="1"thenq<="1";qf<="0";--同步置位端sset,高電平有效,置位
elseq<=d;qf<=not(d);
endif;
endprocess;
endart;
VHDL語言編寫的帶同步置位/復位的D觸發器:
libraryieee;
useieee.std_logic_1164.all;
useieee.std_logic_unsigned.all;
entitytrigger_dis
port(clk,d,sreset,sset:instd_logic;--同步復位端sreset,同步置位端sset
q,qf:outstd_logic);
endentity;
architectureartoftrigger_dis
begin
process(clk,d,sreset,sset)
begin
ifclk"eventandclk="1"then
ifsreset="1"thenq<="0";qf<="1";--同步復位端sreset,高電平有效,復位
elsifsset="1"thenq<="1";qf<="0";--同步置位端sset,高電平有效,置位
elseq<=d;qf<=not(d);
endif;
endif;
endprocess;
endart;