【正文】
N 1250fenpinconstant m:integer:=625。beginprocess(clk_in)variable count:integer range 0 to 1249。beginif(clk_in39。event and clk_in=39。139。)thenif(count=1249)then count:=0。elsecount:=count+1。end if。if(countm)thenclk_out=39。039。elseclk_out=39。139。end if。end if。end process。end one。library ieee。use 。entity fenpin100 isport( clk_in:in std_logic。 clk_out:out std_logic )。end fenpin100。architecture one of fenpin100 is after fen pin ,the period is 2us(500khz) constant m:integer:=50。beginprocess(clk_in)variable count:integer range 0 to 99。if system clock is 20MHz,then 20000 fenpinbeginif(clk_in39。event and clk_in=39。139。)thenif(count=99)then count:=0。elsecount:=count+1。end if。if(countm)thenclk_out=39。039。elseclk_out=39。139。end if。end if。end process。end one。library ieee。use 。entity fenpin isport( clk_in:in std_logic。 clk_out:out std_logic)。end fenpin。architecture one of fenpin is after fen pin ,the period is (5khz) constant m:integer:=5000。beginprocess(clk_in)variable count:integer range 0 to 9999。if system clock is 20MHz,then 20000 fenpinbeginif(clk_in39。event and clk_in=39。139。)thenif(count=9999)then count:=0。elsecount:=count+1。end if。if(countm)thenclk_out=39。039。elseclk_out=39。139。end if。end if。end process。end one。library ieee。use 。use 。entity address is port( clk:in std_logic。 address_signal:out std_logic_vector(1 downto 0))。end 。architecture one of address is begin process(clk) variable q :integer range 0 to 3。 begin if clk39。event and clk=39。139。 then if(q=3) then q:=0。 else q:=q+1。 end if。 end if。address_signal=conv_std_logic_vector(q,2)。end process。end one 。LIBRARY IEEE。USE 。USE 。ENTITY AD_CTRL ISPORT( CLK,EOC:IN STD_LOGIC。 D:IN STD_LOGIC_VECTOR(7 DOWNTO 0)。 ALE,START,OE:OUT STD_LOGIC。 DOUT:OUT STD_LOGIC_VECTOR(7 DOWNTO 0))。 END AD_CTRL。 ARCHITECTURE behav OF AD_CTRL IS TYPE states is (st0,st1,st2,st3,st4)。 SIGNAL current_state,next_state:states:=st0。 SIGNAL LOCK:STD_LOGIC。 SIGNAL REG_0:STD_LOGIC_VECTOR(7 DOWNTO 0)。 BEGIN REG_0=D。COM: PROCESS(current_state,EOC) BEGIN CASE current_state IS WHEN st0=ALE=39。039。START=39。039。LOCK=39。139。OE=39。039。next_state=st1。 WHEN st1=ALE=39。139。START=39。139。LOCK=39。139。OE=39。039。next_state=st2。 WHEN st2=ALE=39。039。START=39。039。LOCK=39。039。OE=39。039。 IF (EOC=39。139。) THEN next_state=st3。 ELSE next_state=st2。 END IF。 WHEN st3=ALE=39。039。START=39。039。LOCK=39。039。OE=39。139。next_state=st4。 WHEN st4=ALE=39。039。START=39。039。LOCK=39。139。OE=39。139。next_state=st0。 WHEN OTHERS=next_state=st0。 END CASE。END PROCESS COM。REG: PROCESS(CLK) BEGIN IF(CLK39。EVENT AND CLK=39。139。) THEN current_state=next_state。 END IF。END PROCESS REG。LATCH1: PROCESS(LOCK) BEGIN IF LOCK=39。139。 AND LOCK39。EVENT THEN DOUT=REG_0。 END IF。END PROCESS LATCH1。END behav。20