【正文】
y=startstop,keyo=startstop1)。step2(0)=step1(0) and y1。step(0)=step2(0) and ss。 then t:=39。 case t is when 39。 when 39。 when others=null。伺服電機部分/**/換向模塊library IEEE。 Unment the following lines to use the declarations that are provided for instantiating Xilinx primitive ponents.library UNISIM。 正轉(zhuǎn)/反轉(zhuǎn)輸出 yin:in std_logic )。begin if key=39。y2=39。139。 end process。 end if。yf=39。=y=39。039。 end process。use 。entity anjian is Port (clk,add,sub,rst:in std_logic。beginprocess(clk,rst) 按鍵檢測脈沖產(chǎn)生模塊variable t:integer range 0 to 1499999。039。139。 end if。begin if rst=39。event and clkk=39。 then if con1=99 then con1:=con1+1。 then if con1=1 then con1:=con11。con=con1。use 。use 。 PWM脈沖輸出end pwm。begin if clk39。t:=1。end process。 then t:=0000000。event and clkk=39。 end if。139。end Behavioral。use 。 占空比輸入 clk:in std_logic。architecture Behavioral of disp issignal d1,d2:std_logic_vector(11 downto 0)。beginprocess(clk) 位選掃描信號產(chǎn)生模塊variable t:integer range 0 to 79999:=0。 end if。 else d1(3 downto 0)=0000。 else d1(11 downto 8)=0000。 if conv_integer(d1(11 downto 8))*100+conv_integer(d1(7 downto 4))*10+conv_integer(d1(3 downto 0))=conv_integer(con) then d2=d1。process(clkk) 位選信號variable t:std_logic_vector(1 downto 0):=00。 when 01=shift=1011。 data_ledin=d2(7 downto 4)。 t:=00。 end if。1 when0010=data_led=10100100。5 when0110=data_led=10000010。9 when others=data_led=11111111。end Behavioral。use 。系統(tǒng)時鐘/輸入按鍵 keyo:out std_logic )。begin if clk39。 clkk=39。039。debunce:blocksignal d0,d1,s,r:std_logic。 then if clkk=39。 s=d0 and d1。 end process。differetial:block signal d1,d0:std_logic。 then d1=d0。diff=d0 and not d1。/**/頂層控制模塊library IEEE。 Unment the following lines to use the declarations that are provided for instantiating Xilinx primitive ponents.library UNISIM。 系統(tǒng)時鐘 shift:out std_logic_vector(3 downto 0)。步進電機控制脈沖end top。 data_led:out std_logic_vector(7 downto 0) )。 shift:out std_logic_vector(3 downto 0)。 keyo:out std_logic )。signal shift15,rst5,clk:std_logic。 end if。=addp=add。startstopp=startstop。139。139。data_led=data_ledp。139。139。139。rsts=rst5。 when others=null。begin if rising_edge(clock) then if t100000 then t:=t+1。139。rst5=39。039。sel1=39。 elsif t500000 then t:=t+1。039。rst5=39。rst5=rst。clk=clock。end Behavioral。u2:step_top port map (clk=clk,add=adds,sub=subs,sel=sels,step=stepout,rst=rsts, shift=shifts,data_led=data_leds,startstop=startstops)。 end if。 else t:=700000。sel1=39。139。rst5=39。139。 elsif t300000 then t:=t+1。sel1=39。039。end process。 shift=shifts。subs=sub。139。139。039。139。139。139。selp=sel。process(sel1,add,sub,sel,rst5,startstop,shiftp,data_ledp,shifts,data_leds) 按鍵/顯示切換模塊begin case sel1 is when 39。signal data_ledp,data_leds:std_logic_vector(7 downto 0)。signal key,addp,subp,selp,rstp,adds,subs,sels,sel1,sel2,rsts:std_logic。end ponent pwms。ponent pwms is Port (clk,rst,add,sub,set,startstop:in std_logic。 step:out std_logic_vector(3 downto 0)。 七段數(shù)碼管輸出 pwmout:out std_logic_vector(1 downto 0)。entity top isPort (rst,add,sub,sel,shift1,startstop:in std_logic。use 。keyo=diff。 end if。event and clk=39。 ndly=s nor dly。 end if。 then d1=d0。event and clk=39。 end if。 else t:=t+1。139。architecture Behavioral of anjianqd issignal clkk,dly,ndly,diff:std_logic。use 。use 。 end case。7 when1000=data_led=10000000。3 when0100=data_led=10011001。process (data_ledin) 譯碼 begin case data_ledin is when0000=data_led=11000000。 shift=1111。 when 11=shift=1110。 t:=t+1。 data_ledin=1111。 end if。 end if。 else d1(7 downto 4)=0000。end process。t:=0。039。 七段數(shù)碼管 shift:out std_logic_vector(3 downto 0) )。use 。use 。 end if。039。 then if t100 then t:=t+1。139。beginif rst=39。 end if。139。039。 系統(tǒng)時鐘/復(fù)位 con:in std_logic_vector(6 downto 0)。use 。 end Behavioral。 end if。 elsif sub=39。 then if add=39。 then con1:=0000000。end process。t:=0。 elsif clk39。039。占空比計數(shù)結(jié)果輸出end anjian。 Unment the following lines to use the declarations that are provided for instantiating Xilinx primitive ponents.library UNISIM。/**/按鍵控制模塊library IEEE。039。yf=yin and y2。 when 39。039。039。 end if。 else t:=32000000。 then t:=0。architecture Behavioral of ztsdpwm issignal y2,y1,yf1:std_logic。entity ztsdpwm is Port (clk,key:in std_logic。use 。end process。=ss=39。=ss=39。 elsif rising_edge(startstop1) then t:=not t。begin if rst=39。step(2)=step2(2) and ss。step2(2)=step1(2) and y1。u4:ztsd port map (clk=clk,key=sel1,y=y1,sel=sel2,rst=rst)。signal step1,step2:std_logic_vector(3 downto 0)。 shift:out std_logic_vector(3 downt