【正文】
when s1= output=000。 end process。 end case。 when s4= state=s5。 end if。) then state=s4。 and ins(6) = 39。 when s2= if (ins(7) = 39。) then case state is when s0= state=s1。event and clk=39。 then state=s0。begin process(clk,reset,ins) begin if reset=39。architecture behave of timer is type state_type is(s0,s1,s2,s3,s4,s5)。 output : out std_logic_vector(2 downto 0))。 reset : in std_logic。use 。 end a。 end if。 then 只有被選中且允許寫時才將數(shù)據(jù)寫入寄存器 q_output = d_input。 and write =39。 then 時鐘下降沿觸發(fā) if sel=39。event and clk=39。 then q_output = x00。 architecture a of reg is 實體行為描述 begin process(reset,clk) begin if reset = 39。 q_output : out std_logic_vector(7 downto 0) )。 write : in std_logic。 d_input : in std_logic_vector(7 downto 0)。 use 。end struct。 muxB: mux_4_to_1 port map( 目的寄存器讀出使用的4選1選擇器 input0 =reg00, input1 =reg01, input2 =reg02, input3 =reg03, sel =SR, out_put =output_SR )。 des_decoder: decoder_2_to_4 port map( 24譯碼器 sel =DR, sel00 =sel00, sel01 =sel01, sel02 =sel02, sel03 =sel03 )。 Areg02: reg port map( 寄存器R2 reset =reset, d_input =d_input, clk =clk, write =write, sel =sel02, q_output =reg02 )。begin Areg00: reg port map( 寄存器R0 reset =reset, d_input =d_input, clk =clk, write =write, sel =sel00, q_output =reg00 )。signal reg00,reg01,reg02,reg03:std_logic_vector(7 downto 0)。 sel03 : out std_logic )。 sel01 : out std_logic。 ponent decoder_2_to_4 is port 24譯碼器端口 (sel : in std_logic_vector(1 downto 0)。 out_put : out std_logic_vector(7 downto 0))。 ponent mux_4_to_1 is port 4選1端口 (input0, input1, input2, input3 : in std_logic_vector(7 downto 0)。 q_output : out std_logic_vector(7 downto 0) )。 write : in std_logic。 d_input : in std_logic_vector(7 downto 0)。end regfile。 源寄存器輸出 output_DR : out std_logic_vector(7 downto 0)。 復(fù)位 d_input : in std_logic_vector(7 downto 0)。 使能端 clk : in std_logic。 源寄存器輸入 reg_sel : in std_logic_vector(1 downto 0)。entity regfile is 實體描述port( DR : in std_logic_vector(1 downto 0)。由Quartus生成的bsf圖如下:其VHDL語言的行為描述如下:library ieee。不然若由一個使能信號控制全部4個寄存器將對實際不參與寫操作的寄存器造成不穩(wěn)定的情況。其中創(chuàng)建reg接口,最終整合成一個regfile。按照我們的設(shè)計,通用寄存器共有4個,由指令的低4位的全部或其中的高2位或低2位來從寄存器組中選擇源寄存器和目的寄存器。特別注意:如果沒被抽中去演示,則主要根據(jù)分工所對應(yīng)的這部分設(shè)計的撰寫的內(nèi)容評分,因此要盡量詳細地介紹你的工作。(加注釋,特別是在參考材料的源代碼基礎(chǔ)上改動之處,用藍色標出)。(4)相關(guān)的源代碼、電原理圖和其它說明表格。是(1)修改后是否編譯通過(指加到整個小組的系統(tǒng)里)是(2)修改后是否可運行(指加到整個小組的系統(tǒng)里)是(3)概要描述(23句話描述你的工作)負責(zé)通用寄存器的改動,實質(zhì)上是通過實驗4,將原來的獨立開來的16個寄存器整合到一個regfile中,根據(jù)需求,還要在regfile中增加一個輸出端。end behave。 end case。 when others= alu_cin=39。139。039。end t1。 sci:in std_logic_vector(1 downto 0)。use 。end behave。 end case。 when others= alu_sr=00000000。 when 101= alu_sr=00000000。 when 100= alu_sr=00000000。 when 011= alu_sr=offset。 when 010= alu_sr=00000000。 when 001= alu_sr=sr。architecture behave of bus_mux is 行為描述begin process(alu_in_sel,data,pc,offset,sr,dr) begin case alu_in_sel is 翻譯上表中內(nèi)容 when 000= alu_sr=sr。 alu_sr,alu_dr : out std_logic_vector(7 downto 0))。entity bus_mux is 實體描述 port(alu_in_sel : in std_logic_vector(2 downto 0)。在3位控制信號的控制下它進行ALU 模塊A、B端輸入的選擇:I5I4I3ALU_AALU_B000SRDR001SR00100DR011OFFSETPC1000PC1010DATA: 其VHDL語言的行為描述如下:(這部分主要改成8位通路)library ieee。另外要注意的是,只有算術(shù)運算需要考慮進位和溢出標志位,邏輯運算,除非帶C移位和循環(huán),否則無需考慮這兩個標志位。根據(jù)這一說明,可以這樣判斷V和C標志位的值:V:如果正數(shù)(符號位為0)與正數(shù)之和為負數(shù)(符號位為1),或是負數(shù)與負數(shù)之和為正數(shù),則發(fā)生了溢出,V置1;C:兩數(shù)之和大于11111111,則產(chǎn)生了進位,C置1;被減數(shù)小于減數(shù),則產(chǎn)生借位,C置1。進位標志CF:記錄運算時從最高有效位產(chǎn)生的進位值,例如,執(zhí)行加法指令時,最高有效位有進位時置1,否則置0。這部分主要要注意的地方就是標志位C和V的數(shù)值。 end process。039。 相應(yīng)的改成8位 when 110= c = b(0)。 end if。 else c=39。 when 001= if ba then c=39。039。139。 temp3:=result_add8_3。 end case。 when others= v=39。039。139。139。039。039。039。139。139。 end if。 else s=39。 then s=39。置標志位S,判斷運算結(jié)果的符號位(最高位) if temp2(7) = 39。039。139。 alu_out = temp2。 when others= temp2 := 00000000。 for I in 6 downto 0 loop 相應(yīng)的改成8位,循環(huán)實現(xiàn)左移 temp2(I) := b(I+1)。 when 110= temp2(7) := 39。 for I in 7 downto 1 loop 相應(yīng)的改成8位,循環(huán)實現(xiàn)左移 temp2(I) := b(I1)。 when 101= temp2(0) := 39。 when 011= temp2 := a or b。 temp2 := result_add8_1。 temp2 := result_add8。cin。variable temp2,temp3 :std_logic_vector(7 downto 0)。 元件例話語句,標號名要唯一,用port map語句調(diào)用8位加法器,并且port map語句只能在進程之外調(diào)用。 when alu_func=001 else 做減法或者減1時,最低位置為1 cin。 c_in_3 = 39。a_in_3 = result_add8_2。做減法或者減1時,最低位置為1 f_add_2: adder8bit port map( a_in_2,b_in_2,result_add8_2,c_in_2)。139。 b_in_2 = not b when alu_func=000 else b。 元件例化語句,標號名要唯一,用port map語句調(diào)用8位加法器,并且port map語句只能在進程之外調(diào)用。 when alu_func=001 else cin。c_in_1=39。 a_in_1=result_add8。 f_add: adder8bit port map( a_in,b_in,result_add8,c_in)。139