【正文】
。 entity in9_out16 is port(operate_in_9 : in std_logic_vector(8 downto 0)。 use 。 operat e_in_9[ 8. . 0] operat e_ou t _16[ 15. . 0]in9_out 16ins t 1 圖 19 控制指令輸入轉(zhuǎn)換模塊的 VHDL 代碼 library ieee。為了方便操作,將波動(dòng)開(kāi)關(guān) K1~K9 接輸入控制指令 DIN 的高 9位,波動(dòng)開(kāi)關(guān) K11 和 K12分別接 Run 和 Reset 的輸入。 end behave。 end if。 state3state3state3state3 when others=null。139。 end case。139。139。139。139。139。139。139。139。139。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。 end if。 Gin=39。 Addsub=39。 when others=null。 when 111=R7out=39。 when 110=R6out=39。 when 101=R5out=39。 when 100=R4out=39。 when 011=R3out=39。 when 010=R2out=39。 when 001=R1out=39。 case (IR_buffer(2 downto 0)) is when 000=R0out=39。clear=39。Done=39。Addsub=39。Ain=39。 Gin=39。R7out=39。R6out=39。R5out=39。R4out=39。R3out=39。R2out=39。R1out=39。 R0out=39。R7in=39。R6in=39。R5in=39。R4in=39。R3in=39。R2in=39。R1in=39。 R0in=39。DINout=39。 Gout=39。 elsif (IR_buffer(8 downto 6)=011) then sub Rx,Ry state2 IRin=39。 Gin=39。 Addsub=39。 when others=null。 when 111=R7out=39。 when 110=R6out=39。 when 101=R5out=39。 when 100=R4out=39。 when 011=R3out=39。 when 010=R2out=39。 24 when 001=R1out=39。 case (IR_buffer(2 downto 0)) is when 000=R0out=39。clear=39。Done=39。Addsub=39。Ain=39。 Gin=39。R7out=39。R6out=39。R5out=39。R4out=39。R3out=39。R2out=39。R1out=39。 R0out=39。R7in=39。R6in=39。R5in=39。R4in=39。R3in=39。R2in=39。R1in=39。 R0in=39。DINout=39。 Gout=39。 elsif (IR_buffer(8 downto 6)=010) then add Rx,Ry state2 IRin=39。clear=39。Done=39。Addsub=39。Ain=39。 Gin=39。R7out=39。R6out=39。R5out=39。R4out=39。R3out=39。R2out=39。R1out=39。 R0out=39。R7in=39。R6in=39。R5in=39。R4in=39。R3in=39。R2in=39。R1in=39。 R0in=39。DINout=39。 Gout=39。 elsif (IR_buffer(8 downto 6)=001) then mvi without state2 IRin=39。clear=39。Done=39。Addsub=39。Ain=39。 Gin=39。R7out=39。R6out=39。R5out=39。R4out=39。R3out=39。R2out=39。R1out=39。 R0out=39。R7in=39。R6in=39。R5in=39。R4in=39。R3in=39。R2in=39。R1in=39。 R0in=39。DINout=39。 Gout=39。 ccccccccccccccccccccccccccccccccccccccccc state1 state2state2state2 when 10 = if(IR_buffer(8 downto 6)=000) then mv without state2 IRin=39。139。 end case。139。139。139。139。139。139。139。139。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。139。 end case。139。139。139。139。139。139。139。139。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。139。139。 end case。139。139。139。139。139。139。139。139。139。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。139。139。 end case。 end case。139。139。139。139。139。139。139。139。139。 end case。139。139。139。139。139。139。139。139。139。 end case。139。139。139。139。139。139。139。139。139。 21 end case。139。139。139。139。139。139。139。139。139。 end case。139。139。139。139。139。139。139。139。139。 end case。139。139。139。139。139。139。139。139。139。 end case。139。139。139。139。139。139。139。139。139。 end case。139。139。139。139。139。139。139。139。139。139。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。139。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。039。139。 begin process(Run,reset,count) begin IR_buffer=DIN_IR_9。 signal IR_buffer:std_logic_vector (8 downto 0)。 19 architecture behave of control is type state is (state0,state1,state2,state3)。 clear :out std_logic )。 Addsub :out std_logic。 Gin :out std_logic。 R0in,R1in,R2in,R3in,R4in,R5in,R6in,R7in:out std_logic。 Gout :out std_logic。 count :in std_logic_vector(1 downto 0)。 Reset :in std_logic。 use 。 use 。 18 控制單元 control 控制單元根據(jù)計(jì)數(shù)器發(fā)出的脈沖和 DIN 輸入的操作指令對(duì)整個(gè)系統(tǒng)的其他模塊進(jìn)行控制,完成指定的操作。 end process。 end case。 when1000000000=databuffer=R7in。 when0010000000=databuffer=R5in。 when0000100000=databuffer=R3in。 when0000001000=databuffer=R1in。 when0000000010=databuffer=Gin。DINout。R0outamp。R2outamp。R4outamp。R6outamp。 signal databuffer:std_logic_vector(15 downto 0)。 end multi。 DINout :in std_logic。 R7out :in std_logic。 R5out :in std_logic。 R3out :in std_logic。 R1out :in std_logic。 Gin :in std_logic_vector(15 downto 0)。 R7in :in std_logic_vector(15 downto 0)。 R5in :in std_logic_vector(15 downto 0)。 R3in :in std_logic_vector(15 downto 0)。 R1in :in std_logic_vector(15 downto 0)。 use 。 use 。來(lái)自控制單元的控制 信號(hào)為R0out~R7out、 Gout、 DINout,輸入數(shù)據(jù)位來(lái)自寄存器 R0~R寄存器 A、數(shù)據(jù)輸入端 DIN,當(dāng)控制信號(hào) 的某一位為 1 時(shí),將其對(duì)應(yīng)的輸入數(shù)據(jù)輸出到總線上。 end Behavior。 end process。 end if。 clear is effective count = 00。 then clear=39。) then if clear=39。event and clock=39。 architecture Behavior of upcount is signal count : std_logic_vector(1 downto 0)。 Q : out std_logic_vector(1 downto 0))。 use 。 c lea rc loc kQ[ 1. .0]upc ountins t5 圖 16 計(jì)數(shù)器 upcount 的 VHDL 代碼 library ieee。 15 計(jì)數(shù)器 upcount 計(jì)數(shù)器 upcount 用于產(chǎn)生控制單元的輸入脈沖,對(duì)控制單元的工作時(shí)序進(jìn)行控制 。 end process。 end if。 end if。) then databuffer=datain(15 downto 7)。) then if (IRin=39。event and clock=39。 architecture behave of IR is signal databuffer:std_logic_vector(8 downto 0)。 dataout:out std_logic_vector(8 downto 0) )。 entity IR is port( IRin,clock : in std_logic。