【正文】
)概要描述(23句話描述你的工作)負(fù)責(zé)通用寄存器的改動(dòng),實(shí)質(zhì)上是通過(guò)實(shí)驗(yàn)4,將原來(lái)的獨(dú)立開(kāi)來(lái)的16個(gè)寄存器整合到一個(gè)regfile中,根據(jù)需求,還要在regfile中增加一個(gè)輸出端。最后需要總體將16位改成8位,并進(jìn)行總體調(diào)試。(4)相關(guān)的源代碼、電原理圖和其它說(shuō)明表格。、vhd文件內(nèi)容,以及相關(guān)電原理圖截圖、用于說(shuō)明的表格、用于說(shuō)明的示意圖等。(加注釋,特別是在參考材料的源代碼基礎(chǔ)上改動(dòng)之處,用藍(lán)色標(biāo)出)??梢圆糠謪⒄諈⒖疾牧系奈臋n寫(xiě)法。特別注意:如果沒(méi)被抽中去演示,則主要根據(jù)分工所對(duì)應(yīng)的這部分設(shè)計(jì)的撰寫(xiě)的內(nèi)容評(píng)分,因此要盡量詳細(xì)地介紹你的工作。(1) 寄存器、寄存器組和寄存器的選擇:本實(shí)驗(yàn)中的寄存器都為8位,帶有清零端和使能端,實(shí)際上在寫(xiě)VHDL程序時(shí),通用寄存器以及AR、IR、PC使用的都是同一個(gè)模板。按照我們的設(shè)計(jì),通用寄存器共有4個(gè),由指令的低4位的全部或其中的高2位或低2位來(lái)從寄存器組中選擇源寄存器和目的寄存器。采用24譯碼器選擇寄存器,再通過(guò)4選1邏輯控制選擇輸出的寄存器。其中創(chuàng)建reg接口,最終整合成一個(gè)regfile。另外,由控制邏輯給出1位控制信號(hào)reg_en連接到regfile中的write,控制是否對(duì)選中寄存器進(jìn)行寫(xiě)操作,也須由寄存器選擇器件給出對(duì)特定寄存器的寫(xiě)使能信號(hào)。不然若由一個(gè)使能信號(hào)控制全部4個(gè)寄存器將對(duì)實(shí)際不參與寫(xiě)操作的寄存器造成不穩(wěn)定的情況。為了便于調(diào)試時(shí)查看寄存器內(nèi)容,另外由外部輸入選定寄存器讀出其內(nèi)容,其中讀取通用寄存內(nèi)容的工作也由這個(gè)器件完成。由Quartus生成的bsf圖如下:其VHDL語(yǔ)言的行為描述如下:library ieee。use 。entity regfile is 實(shí)體描述port( DR : in std_logic_vector(1 downto 0)。 目的寄存器輸入 SR : in std_logic_vector(1 downto 0)。 源寄存器輸入 reg_sel : in std_logic_vector(1 downto 0)。 寄存器選擇 write : in std_logic。 使能端 clk : in std_logic。 時(shí)鐘 reset : in std_logic。 復(fù)位 d_input : in std_logic_vector(7 downto 0)。 監(jiān)聽(tīng)ALU的輸出 output_SR : out std_logic_vector(7 downto 0)。 源寄存器輸出 output_DR : out std_logic_vector(7 downto 0)。 目的寄存器輸出 output : out std_logic_vector(7 downto 0) 寄存器輸出)。end regfile。architecture struct of regfile is 實(shí)體行為描述ponent reg is port 寄存器端口 (reset : in std_logic。 d_input : in std_logic_vector(7 downto 0)。 clk : in std_logic。 write : in std_logic。 sel : in std_logic。 q_output : out std_logic_vector(7 downto 0) )。 end ponent。 ponent mux_4_to_1 is port 4選1端口 (input0, input1, input2, input3 : in std_logic_vector(7 downto 0)。 sel : in std_logic_vector(1 downto 0)。 out_put : out std_logic_vector(7 downto 0))。 end ponent。 ponent decoder_2_to_4 is port 24譯碼器端口 (sel : in std_logic_vector(1 downto 0)。 sel00 : out std_logic。 sel01 : out std_logic。 sel02 : out std_logic。 sel03 : out std_logic )。 end ponent。signal reg00,reg01,reg02,reg03:std_logic_vector(7 downto 0)。signal sel00,sel01,sel02,sel03:std_logic。begin Areg00: reg port map( 寄存器R0 reset =reset, d_input =d_input, clk =clk, write =write, sel =sel00, q_output =reg00 )。 Areg01: reg port map( 寄存器R1 reset =reset, d_input =d_input, clk =clk, write =write, sel =sel01, q_output =reg01 )。 Areg02: reg port map( 寄存器R2 reset =reset, d_input =d_input, clk =clk, write =write, sel =sel02, q_output =reg02 )。 Areg03: reg port map( 寄存器R3 reset =reset, d_input =d_input, clk =clk, write =write, sel =sel03, q_output =reg03 )。 des_decoder: decoder_2_to_4 port map( 24譯碼器 sel =DR, sel00 =sel00, sel01 =sel01, sel02 =sel02, sel03 =sel03 )。 muxA: mux_4_to_1 port map( 目的寄存器讀出使用的4選1選擇器 input0 =reg00, input1 =reg01, input2 =reg02, input3 =reg03, sel =DR, out_put =output_DR )。 muxB: mux_4_to_1 port map( 目的寄存器讀出使用的4選1選擇器 input0 =reg00, input1 =reg01, input2 =reg02, input3 =reg03, sel =SR, out_put =output_SR )。 muxC: mux_4_to_1 port map( 寄存器讀出使用的4選1選擇器 input0 =reg00, input1 =reg01, input2 =reg02, input3 =reg03, sel =reg_sel, out_put =output )。end struct。寄存器的VHDL語(yǔ)言如下: library ieee。 use 。 entity reg is port 實(shí)體描述 (reset : in std_logic。 d_input : in std_logic_vector(7 downto 0)。 clk : in std_logic。 write : in std_logic。 sel : in std_logic。 q_output : out std_logic_vector(7 downto 0) )。 end reg。 architecture a of reg is 實(shí)體行為描述 begin process(reset,clk) begin if reset = 39。039。 then q_output = x00。 elsif clk39。event and clk=39。039。 then 時(shí)鐘下降沿觸發(fā) if sel=39。139。 and write =39。139。 then 只有被選中且允許寫(xiě)時(shí)才將數(shù)據(jù)寫(xiě)入寄存器 q_output = d_input。 end if。 end if。 end process。 end a。對(duì)整體16位進(jìn)行8位改造library ieee。use 。entity timer is port( clk : in std_logic。 reset : in std_logic。 ins : in std_logic_vector(7 downto 0)。 output : out std_logic_vector(2 downto 0))。end timer。architecture behave of timer is type state_type is(s0,s1,s2,s3,s4,s5)。 signal state:state_type。begin process(clk,reset,ins) begin if reset=39。039。 then state=s0。 elsif (clk39。event and clk=39。139。) then case state is when s0= state=s1。 when s1= state=s2。 when s2= if (ins(7) = 39。139。 and ins(6) = 39。139。) then state=s4。 else state=s3。 end if。 when s3= state=s1。 when s4= state=s5。 when s5= state=s1。 end case。 end if。 end process。 process(state) begin case state is when s0= output=100。 when s1= output=000。 when s2= o