【正文】
TART:out std_logic。 STATES:out std_logic_vector(3 downto 0))。architecture one of qdjb_sc issignal abc:std_logic_vector(4 downto 0)。 beginabc=Ramp。Bamp。D。139。039。039。039。039。039。039。039。 end if。139。139。139。139。 if tmp=39。 then CASE abc IS when 01000 = A1=39。 B1=39。 C1=39。 D1=39。 STATES=0001。039。039。039。039。139。039。039。 tmp=39。 EN=39。START=39。 when 00010 = A1=39。 B1=39。 C1=39。 D1=39。 STATES=0011。039。039。039。039。039。039。139。 tmp=39。 EN=39。START=39。 when 10000 = A1=39。 B1=39。 C1=39。 D1=39。 STATES=0000。039。039。039。039。039。039。039。 tmp=39。 END CASE。end process。2波形仿真:仿真圖說(shuō)明:第一階段,在RST、STA輸入高電平后,START、EN輸出高電平,系統(tǒng)可以進(jìn)行搶答。第二階段,當(dāng)RST輸入高電平,所有輸出端復(fù)位,然后C進(jìn)行了搶答,但輸出端沒(méi)有作出響應(yīng)。第三階段,當(dāng)RST輸入高電平,所有輸出端復(fù)位,當(dāng)STA輸入高電平,START、EN輸出高電平,A最先搶答,A1輸出高電平,同時(shí)START、EN改為輸出低電平,STATES[3..0]被鎖存為“0001”。clr為復(fù)位端,將計(jì)分起始分?jǐn)?shù)設(shè)為0。每按一次加1分,每組的分?jǐn)?shù)將在對(duì)應(yīng)的數(shù)碼管上顯示。use 。entity jf is port(clr: in std_logic。 chose: in std_logic_vector(3 downto 0)。 cc,dd: out std_logic_vector(3 downto 0))。architecture two of jf isbegin p1: process(add,chose) is variable a2:std_logic_vector(3 downto 0)。 variable c2:std_logic_vector(3 downto 0)。 begin if(clr=39。)then a2:=0000。 c2:=0000。 elsif(add39。139。 else a2:=a2+39。 end if。 else b2:=b2+39。 end if。 else c2:=c2+39。 end if。 else d2:=d2+39。 end if。 end if。 bb=b2。 dd=d2。end two。當(dāng)chose輸入為“0001”,add輸入高電平時(shí),aa+1,改為“0001”;當(dāng)chose輸入為“0010”,add輸入高電平時(shí),bb+1,改為“0001”;當(dāng)chose再次輸入“0001”,add輸入高電平時(shí),aa+1,改為“0010”。當(dāng)chose輸入為“0011”,add輸入高電平時(shí),cc+1,改為“0001”;當(dāng)chose輸入為“0100”,add輸入高電平時(shí),dd+1,改為“0001”;當(dāng)chose再次輸入“0100”,add輸入高電平時(shí),dd+1,改為“0010”。其中將初始值設(shè)置為5秒,clk為時(shí)鐘信號(hào),e