(最新版)VHDL,CPU实验报告

合集下载

cpu实验报告 VHDL 东大

cpu实验报告 VHDL 东大

Computer Organization and ArchitectureCourse Design——CPU DesignSchool of Information Science and EngineeringSoutheast UniversityMAY 2011TABLE OF CONTENTSPurposeInstruction SetInternal Registers and MemoryALUMicroprogrammed Control UnitCPU Design1.Architecture of CPU2.Control Signals3.Contents of ROM(microprogram and control signals) 4.contents of RAM(instructions to run)Simulation of the CPU1.The overview of top-level entity2.The waveform of the simulation of the CPUAppendix(CPU design in VHDL language)PurposeThe purpose of this project is to design a simple CPU (Central Processing Unit). This CPU has basic instruction set, and we will utilize its instruction set to generate a very simple program to verify its performance. For simplicity, we will only consider the relationship among the CPU, registers, memory and instruction set. That is to say we only need consider the following items: Read/Write Registers, Read/Write Memory and Execute the instructions.At least four parts constitute a simple CPU: the control unit, the internal registers, the ALU and instruction set, which are the main aspects of our project design and will be studied.Instruction SetSingle-address instruction format is used in our simple CPU design. The instruction word contains two sections: the operation code (opcode), which defines the function of instructions (addition, subtraction, logic operations, etc.); the address part, in most instructions, the address part contains the memory location of the datum to be operated, we called it direct addressing. In some instructions, the address part is the operand, which is called immediate addressing.For simplicity, the size of memory is 256×16 in the computer. The instruction word has 16 bits. The opcode part has 8 bits and address part has 8 bits. The instruction word format can be expressed in Figure 4Figure 4 the instruction formatThe opcode of the relevant instructions are listed in Table 1.In Table 1, the notation [x] represents the contents of the location x in the memory. For example, the instruction word 00000011101110012 (03B916) means that the CPU adds word at location B916 in memory into the accumulator (ACC); the instruction word 00000101000001112 (050716) means if the sign bit of the ACC (ACC [15]) is 0, the CPU will use the address part of the instruction as the address of next instruction, if the sign bit is 1, the CPU will increase the program counter (PC) and use its content as the address of the next instruction.INSTRUCTION OPCODE COMMENTSSTORE X 00000001 ACC→[X]LOAD X 00000010 [X]→ACCADD X 00000011 ACC+[X]→ACCSUB X 00000100 ACC-[X]→ACCJMPGEZ X 00000101 If ACC≥0 then X→PC else PC+1→PCJMP X 00000110 X→PCHALT 00000111 Halt a programMPY X 00001000 ACC×[X]→ACC,MRDIV X 00001001 ACC÷[X]→ACC,DRAND X 00001010 ACC and [X]→ACCOR X 00001011 ACC or [X]→ACCNOT X 00001100 NOT [X]→ACCSHIFTR 00001101 SHIFT ACC to Right 1 bit,Logic ShiftSHIFTL 00001110 SHIFT ACC to Left 1 bit,Logic Shift………………All the instructions except the Division instruction must be supported in your design.It is better if you can implement the instruction: DIV X. Also, you can design more instructions if needed.Internal Registers and MemoryMAR (Memory Address Register)MAR contains the memory location of the word to be read from the memory or written into the memory. Here, READ operation is denoted as the CPU reads from memory, and WRITE operation is denoted as the CPU writes to memory. In our design, MAR has 8 bits to access one of 256 addresses of the memory.MBR (Memory Buffer Register)MBR contains the value to be stored in memory or the last value read from memory. MBR is connected to the address lines of the system bus. In our design, MBR has 16 bits.PC (Program Counter)PC keeps track of the instructions to be used in the program. In our design, PC has 8 bits.IR (Instruction Register)IR contains the opcode part of an instruction. In our design, IR has 8 bits.BR (Buffer Register)BR is used as an input of ALU, it holds other operand for ALU. In our design, BR has 16 bitsAll the registers are positive-edge-triggered.All the reset signals for the registers are synchronized to the clock signal..ALUALU (Arithmetic Logic Unit) is a calculation unit which accomplishes basic arithmetic and logic operations. In our design, some operations are supported which are listed as follows in table 2.Table 2 ALU OperationsADD ACC<-ACC+BR Add BR to ACCSUB ACC<-ACC-BR SUB BR from ACCSRL ACC<-SRL(ACC) Shift ACC to the left by 1 bitSRR ACC<-SRR(ACC) Shift ACC to the right by 1 bitAND ACC<-ACC and BR AND operationOR ACC<-ACC or BR OR operationNOT ACC<-not(ACC) NOT operationMPY ACC<-ACC*BR Multiply operationMicroprogrammed Control UnitWe have learnt the knowledge of Microprogrammed control unit. Here, we only review some terms and basic structures.In the Microprogrammed control, the microprogram consists of some microinstructions and the microprogram is stored in control memory that generates all the control signals required to execute the instruction set correctly. The microinstruction contains some micro-operations which are executed at the same time.Figure 2 Control Unit Micro-architectureFigure 2 shows the key elements of such an implementation. The set of microinstructions is stored in the control memory. The control address register contains the address of the next microinstructions to be read. When a microinstruction is read from the control memory, it is transferred to a control buffer register. The register connects to the control lines emanating from the control unit. Thus, reading a microinstruction from the control memory is the same as executing that microinstruction. The third element shown in the figure is a sequencing unit that loads the control address register and issues a read command.CPU Design1.Architecture of CPUFigure 3 CPU data path and control signalsFigure 3 indicates a simple CPU architecture and its use of a variety of internal data paths and control signals. Our CPU design should be based on this architecture.You should determine the control signals according to the CPU architecture and your design. An example is given below to show the procedure, this example describes the control unit design for the LOAD instruction.First, we need determine the control flowchart of the LOAD instruction2.Control SignalsAt first,we determined the control signals according to the CPU architecture and our design.as shown in Table 3.Table 3 Control Bit for the Micro-operationsBit in Control Memory Micro-operation Meaningc0 CAR<-CAR+1 Control Address Incrementc1 CAR<-*** Control Address Redirection,c2 CAR<-0 Reset Control Address to zero positionc3 MBR<-MEMORY Memory Content to MBRc4 IR<-MBR[15..8] Copy MBR[15..8] to IR for OPCODEc5 MAR<-MBR[7..0] Copy MBR[7..0] to MAR for addressc6 PC<-PC+1 Increment PC for indicating positionc7 BR<-MBR Copy MBR data to BR for buffer to ALUc8 ACC<-0 Reset ACC register to zeroc9 MBR<-ACC Copy ACC value to MBRc10 MAR<-PC Copy PC value to MAR for next addressc11 PC<-MBR[7..0] Copy MAR[7..0] to PCc12 MBR<-PC Copy PC value to MBR for next addressc13c14c15 memory<-MBR Copy ACC value to Memoryc16c17c18c19c20 ACC<-ACC+BR Add BR to ACCc21 ACC<-ACC-BR SUB BR from ACCc22 ACC<-SRL(ACC) Shift ACC to the left by 1 bitc23 ACC<-SRR(ACC) Shift ACC to the right by 1 bitc24 ACC<-ACC and BR AND operationc25 ACC<-ACC or BR OR operationc26 ACC<-not(ACC) NOT operationc27 ACC<-ACC*BR Multiply operation3.Contents of ROM(microprogram and control signals)Then according to the control flowcharts for each instruction we can get the microprogram and corresponding control signals descriptions for each instruction.And in order to memory the control signals we use a lpm_rom to implement ROM with only address input and data output with size is 256×32. Contents in ROM can change opcode to microprogram and corresponding control signals. Table 4 shows the contents of the ROM, which functions as the Control Memory.Table 4 Microprograms of the Instruction SetLOAD XMBR<=memroy,CAR<=CAR+1 C3,C0 00000009IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011CAR<=*** C1 00000002MAR<=MBR[7..0],PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061MBR<=memroy,,CAR<=CAR+1 C3,C0 00000009BR<=MBR,ACC<=0,CAR<=CAR+1 C7,C8,C0 00000181ACC<=ACC+BR,CAR<=CAR+1 C20,C0 00100001MAR<=PC,CAR<=0 C10,C2 00000404STORE XMBR<=memroy,CAR<=CAR+1 C3,C0 00000009IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011CAR<=*** C1 00000002MAR<=MBR[7..0], PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061MBR<=ACC,CAR<=CAR+1 C9,C0 00000201Memroy<=MBR,CAR<=CAR+1 C15,C0 00008001MAR<=PC,CAR<=0 C10,C2 00000404ADD XMBR<=memroy,CAR<=CAR+1 C3,C0 00000009 IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011 CAR<=*** C1 00000002 MAR<=MBR[7..0],PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061 MBR<=memroy,CAR<=CAR+1 C3,C0 00000005 BR<=MBR,CAR<=CAR+1 C7,C0 00000081 ACC<=ACC+BR,CAR<=CAR+1 C20,C0 00100001 MAR<=PC,CAR<=0 C10,C2 00000404SUB XMBR<=memroy,CAR<=CAR+1 C3,C0 00000009 IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011 CAR<=*** C1 00000002 MAR<=MBR[7..0],PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061 MBR<=memroy,CAR<=CAR+1 C3,C0 00000009 BR<=MBR,CAR<=CAR+1 C7,C0 00000081 ACC<=ACC-BR,CAR<=CAR+1 C21,C0 00200001 MAR<=PC,CAR<=0 C10,C2 00000404JMPGEZ XMBR<=memroy,CAR<=CAR+1 C3,C0 00000009 IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011 CAR<=*** C1 00000002 PC<=PC+1,CAR<=CAR+1 C6,C0 00000041 MAR<=PC,CAR<=0 C10,C2 00000404 Or PC<=MBR[7..0],CAR<=CAR+1; C11,C0 00000801 MAR<=PC,CAR<=0; C10,C2 00000404JMP XMBR<=memroy,CAR<=CAR+1 00000009 IR<=MBR[15..8],CAR<=CAR+1 00000011 CAR<=*** 00000002 PC<=MBR[7..0],CAR<=CAR+1 00000801 MAR<=PC,CAR<=0 00000404HALTMBR<=memroy,CAR<=CAR+1 00000009 IR<=MBR[15..8],CAR<=CAR+1 00000011 CAR<=*** 00000002 PC<=PC+1,CAR<=CAR+1 C6,C0 00000041 CAR<=CAR+1 C0 00000001 CAR<=CAR+1 C0 00000001 MAR<=PC,CAR<=0; C10,C2 00000404MPY XMBR<=memroy,CAR<=CAR+1 C3,C0 00000009 IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011 CAR<=*** C1 00000002 MAR<=MBR[7..0],PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061 MBR<=memory,CAR<=CAR+1 C3,C0 00000009 BR<=MBR,CAR<=CAR+1 C7,C0 00000081 ACC<=ACC*BR,CAR<=CAR+1 C27,C0 08000001 MAR<=PC,CAR<=0 C10,C2 00000404AND XMBR<=memroy,CAR<=CAR+1 C3,C0 00000009 IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011 CAR<=*** C1 00000002 MAR<=MBR[7..0],PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061 MBR<=memory,CAR<=CAR+1 C3,C0 00000009 BR<=MBR,CAR<=CAR+1 C7,C0 00000081 ACC<=ACC and BR,CAR<=CAR+1 C24,C0 01000001 MAR<=PC,CAR<=0 C10,C2 00000404OR XMBR<=memroy,CAR<=CAR+1 C3,C0 00000009 IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011CAR<=*** C1 00000002 MAR<=MBR[7..0],PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061 MBR<=memory,CAR<=CAR+1 C3,C0 00000009 BR<=MBR,CAR<=CAR+1 C7,C0 00000081 ACC<=ACC or BR,CAR<=CAR+1 C25,C0 02000001 MAR<=PC,CAR<=0 C10,C2 00000404NOT XMBR<=memroy,CAR<=CAR+1 C3,C0 00000009 IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011 CAR<=*** C1 00000002 MAR<=MBR[7..0],PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061 MBR<=memory,CAR<=CAR+1 C3,C0 00000009 BR<=MBR,ACC<=0,CAR<=CAR+1 C7,C8,,C0 00000181 ACC<=not BR,CAR<=CAR+1 C26,C0 04000001 MAR<=PC,CAR<=0 C10,C2 00000404SHIFTLMBR<=memroy,CAR<=CAR+1 C3,C0 00000009 IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011 CAR<=*** C1 00000002 MAR<=MBR[7..0],PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061 MBR<=memory,CAR<=CAR+1 C3,C0 00000009 BR<=MBR,ACC<=0,CAR<=CAR+1 C7,C8,,C0 00000181 ACC<=SRL BR,CAR<=CAR+1 C22,C0 00400001 MAR<=PC,CAR<=0 C10,C2 00000404SHIFTRMBR<=memroy,CAR<=CAR+1 C3,C0 00000009 IR<=MBR[15..8],CAR<=CAR+1 C4,C0 00000011 CAR<=*** C1 00000002 MAR<=MBR[7..0],PC<=PC+1,CAR<=CAR+1 C5,C6,C0 00000061 MBR<=memory,CAR<=CAR+1 C3,C0 00000009 BR<=MBR,ACC<=0,CAR<=CAR+1 C7,C8,,C0 00000181 ACC<=SRR BR,CAR<=CAR+1 C23,C0 00800001 MAR<=PC,CAR<=0 C10,C2 000004044.contents of RAM(instructions to run)When we want to execute some instructions, we just need to write instructions in RAM. A program is given as an example:Calculate the result of (1+2+3+...+100)=5050.1. programming with C language:sum=0;temp=100;loop :sum=sum+temp;temp=temp-1;if temp>=0 goto loop;end2. Assume in the memory:sum is stored at location A4,temp is stored at location A3,the contents of location A0 is 0,8the contents of location A1 is 1,the contents of location A2 is 10010=6416.We can translate the above C language program with the instructions listed in Table 1into the instruction program as shown in Table.Table Example of a programProgram with C language Program withinstructions contents of memory(RAM) in HEX Address Contentssum=0; LOAD A0 00 02A0STORE A4 01 01A4 temp=100;LOAD A2 02 02A2STORE A3 03 01A3loop :sum=sum+temp; LOOP:LOAD A4 04 02A4 ADD A3 05 03A3 STORE A4 06 01A4temp=temp-1; LOAD A3 07 02A3 SUB A1 08 04A1 STORE A3 09 01A3if temp>=0 goto loop; JMPGEZ LOOP 0A 0504 endHALT 0B 0700Sum1=a8 LOAD A8 0C 02A8 Sum1=a8*a9 MPY A9 0D 08A9 Sum2=aa LOAD AA 0E 02AA Sum2=aa*a9 MPY A9 0F 08A9 Sum3=aa LOAD AA 10 02AA Sum3=aa*ab MPY AB 11 08ABSimulation of the CPU1. The overview of top-level entity2. The waveform of the simulation of the CPU(1)The simulation waveform of calculating the the sum of all integers from 1 to 100. & 4*8 ;4*(-7);(-7)*(-8)(including STORE, LOAD, ADD, SUB, JMPGEZ, HALT,MPY. ) Content of the ram:The waveform of the result of (1+2+3+4+5+….+100=5050):2-1=15049+1=5050 The simulation waveform of MPY.8*4=32 (-7)*4=32 (-8)*(-7)=56Appendix(CPU design in VHDL language)BR:library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity br isport(clk:in std_logic;load_mbr:in std_logic; --c[11]data_mbr:in std_logic_vector(15 downto 0);out_br:out std_logic_vector(15 downto 0)); end br;architecture arc_br of br isbeginprocess(clk)variable data_br:std_logic_vector(15 downto 0); beginif(clk'event and clk='1')thenif(load_mbr='1')then --load mbr to brdata_br:=data_mbr;end if;else null;end if;out_br<=data_br;end process;end arc_br;MARlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity mar isport(clk:in std_logic;reset:in std_logic;load_pc:in std_logic;load_mbr:in std_logic;data_pc:in std_logic_vector(7 downto 0);data_mbrl:in std_logic_vector(7 downto 0);out_mar:out std_logic_vector(7 downto 0));end mar;architecture arc_mar of mar isprocess(clk,reset)variable data_mar:std_logic_vector(7 downto 0); beginif(clk'event and clk='1')thenif(reset='1') then data_mar:="00000000";elsif(load_pc='1')thendata_mar:=data_pc;elsif(load_mbr='1')thendata_mar:=data_mbrl;else null;end if;end if;out_mar<=data_mar;end process;end arc_mar;MBRlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity mbr isport(clk:in std_logic;reset:in std_logic;load_acc:in std_logic;load_ram:in std_logic;load_pc:in std_logic;data_pc:in std_logic_vector(15 downto 0);data_acc:in std_logic_vector(15 downto 0);data_ram:in std_logic_vector(15 downto 0);out_mbr_other:out std_logic_vector(15 downto 0);out_mbr_mar:out std_logic_vector(7 downto 0));end mbr;architecture arc_mbr of mbr isprocess(clk,reset)variable data_mbr:std_logic_vector(15 downto 0); beginif(clk'event and clk='1')thenif(reset='1') then data_mbr:="0000000000000000";elsif(load_ram='1')thendata_mbr:=data_ram;elsif(load_pc='1')thendata_mbr:=data_pc;elsif(load_acc='1')thendata_mbr:=data_acc;else null;end if;end if;out_mbr_other<=data_mbr;out_mbr_mar<=data_mbr(7 downto 0);end process;end arc_mbr;IRlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity ir isport(clk:in std_logic;reset:in std_logic;load_mbr:in std_logic;data_mbr:in std_logic_vector(15 downto 0);out_ir:out std_logic_vector(7 downto 0));end ir;architecture arc_ir of ir isbeginprocess(clk,reset)variable data_ir:std_logic_vector(7 downto 0);beginif(clk'event and clk='1')thenif(reset='1') then data_ir:="00000000";elsif(load_mbr='1')thendata_ir:=data_mbr(15 downto 8);else null;end if;end if;out_ir<=data_ir;end process;end arc_ir;PClibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity pc isport(clk:in std_logic;load_mbr:in std_logic;inc:in std_logic;reset:in std_logic;mbr_to_pc:in std_logic_vector(15 downto 0);out_pc_mar:out std_logic_vector(7 downto 0);out_pc_mbr:out std_logic_vector(15 downto 0) );end pc;architecture arc_pc of pc isbeginprocess(clk)variable data_pc:std_logic_vector(7 downto 0);beginif(clk'event and clk='1')thenif(reset='1') then data_pc:="00000000"; --reset elsif(inc='1')then --pc<=pc+1data_pc:=data_pc+1;elsif(load_mbr='1')then --load mbr to pc data_pc:=mbr_to_pc(7 downto 0);else null;end if;end if;out_pc_mar<=data_pc;out_pc_mbr(7 downto 0)<=data_pc;out_pc_mbr(15 downto 8)<="00000000";end process;end arc_pc;ALUlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity alu isport(acc_clr:in std_logic;clk:in std_logic;cs:in std_logic_vector(7 downto 0);br:in std_logic_vector(15 downto 0);acc_flag:out std_logic;accl:buffer std_logic_vector(15 downto 0);acch:out std_logic_vector(15 downto 0) );end alu;architecture arc_alu of alu isbeginp0:process(clk)variable data_acc:std_logic_vector(31 downto 0); variable data_acc2:std_logic_vector(15 downto 0); beginif(clk'event and clk='1') thenif acc_clr='1' then data_acc2:=x"0000";elsecase cs iswhen "00000001" => data_acc2:=data_acc2+br; --addwhen "00000010" => data_acc2:=data_acc2-br; --subwhen "00000100" => data_acc2:=data_acc2(14 downto 0)&'0'; --shift to leftwhen "00001000" => data_acc2:='0'& data_acc2(15 downto 1); --shift to rightwhen "00010000" => data_acc2:=data_acc2 and br; --andwhen "00100000" => data_acc2:=data_acc2 or br; --orwhen "01000000" => data_acc2:=not br; --notwhen "10000000" => data_acc:=data_acc2*br; --mpydata_acc2:=data_acc(15 downto 0);when others => null;end case;end if;end if;accl<=data_acc2; --flagacch<=data_acc(31 downto 16);acc_flag<=data_acc2(15);end process p0;end arc_alu;CU1library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cu1 isport(clk:in std_logic;reset:in std_logic;flag:in std_logic;cu1_inc:in std_logic; --c0ir_cu1:in std_logic; --c1cu1_clear:in std_logic; --c2ir_to_cu1:in std_logic_vector(7 downto 0);cu1_to_cm:out std_logic_vector(7 downto 0));end cu1;architecture behave of cu1 issignal reg:std_logic_vector(7 downto 0);beginp0:process(clk,reset)beginif(clk'event and clk='1') thenif (reset='1' or cu1_clear='1')thenreg<="00000000";elsif(cu1_inc='1') then reg<=reg+1;elsif(ir_cu1='1')thencase ir_to_cu1 iswhen "00000001"=> --01 stroereg<=x"08";when "00000010"=> --02 loadreg<=x"10";when "00000011"=> --03 addreg<=x"18";when "00000100"=> --04 subreg<=x"20";when "00000101"=> --05 jmpgzeif(flag='1') thenreg<=x"28";else reg<=x"30";end if;when "00000110"=> --06 jmpreg<=x"30";when "00000111"=> --07 haltreg<=x"38";when "00001000"=> --08 mpyreg<=x"40";when "00001001"=> --09 divreg<=x"48";when "00001010"=> --0a andreg<=x"50";when "00001011"=> --0b orreg<=x"58";when "00001100"=> --0c notreg<=x"60";when "00001101"=> --0d srrreg<=x"68";when "00001110"=> --0e srlreg<=x"70";when others=>end case;end if;end if;cu1_to_cm<=reg;end process p0;end behave;CU2library ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity cu2 isport(cm_cu2:in std_logic_vector(31 downto 0);c0,c1,c2,c3,c4,c5,c6,c7,c8,c9,c10,c11,c12,c13,c14,c15:out std_logic;C27_20:out std_logic_vector(7 downto 0));end cu2;architecture behave of cu2 isbeginC0<=cm_cu2(0);C1<=cm_cu2(1);C2<=cm_cu2(2);C3<=cm_cu2(3);C4<=cm_cu2(4);C5<=cm_cu2(5);C6<=cm_cu2(6);C7<=cm_cu2(7);C8<=cm_cu2(8);C9<=cm_cu2(9);C10<=cm_cu2(10);C11<=cm_cu2(11);C12<=cm_cu2(12);C13<=cm_cu2(13);C14<=cm_cu2(14);C15<=cm_cu2(15);C27_20<=cm_cu2(27 downto 20);end behave;CLK_DIFlibrary ieee;use ieee.std_logic_1164.all;use ieee.std_logic_unsigned.all;entity clk_dif isport(clk_in:in std_logic;clk_out:out std_logic);end CLK_dif;architecture behave of clk_dif isbeginp0:process(clk_in)variable counter:std_logic_vector(2 downto 0):="000"; beginif (clk_in'event and clk_in='0') thenif(counter="100") thenclk_out<='1';counter:="000";elseclk_out<='0';counter:=counter+'1';end if;end if;end process p0;end behave;。

接口实验 VHDL编程 实验报告

接口实验 VHDL编程 实验报告

短学期接口实验VHDL编程实验任务:用VHDL编程实现十六进制的计数显示。

并通过仿真或观察波形验证设计电路的正确性。

最后在SE-5M型EDA实验开发系统上执行验证结果。

实验设备:SE-5M 型EDA实验开发系统,Maxplus 9.23 。

实验原理:首先用MAxplus编写程序,然后进行编译,进行管叫设定,最后将程序下再到实验版的下载板上验证程序。

实验用到了以下管角:时钟信号CP1(CP2): 进行时钟信号设定。

总共有12个信号源,根据所需的时钟频率,跳线设置。

键盘扫描相应管角:Se-5M中有一个4X4的矩阵键盘,其连接图如下,键盘矩阵是与89C51和管理芯片(F7128)直接相连,而通过管理芯片键盘阵列实现了与CPLD间接相连,他是通过KEY来实现的。

当CZ1的KEY置ON时,CPLD可与89C51的P1口相连或者键盘阵列相连,当CZ1D的KEY置OFF时,89C51的P1口及键盘阵列与CPLD断开。

当CPLD和小键盘相连时H1-H4用于发出扫描信号,V1-V4为接收扫描信号,即H1-H4为输出管角,V1-V4为输入管角。

在具体在操作中,一个作为行扫描,一个作为列扫描,从而最终确定用户所按的键。

静态显示数码管M1-M2:用来选择最终的显示结果在哪一数码管上进行显示,例,要在最左边的那个数码管上显示结果,相应的值应该是“10000000”,如果要所有的数码管都显示,相应的值就是“11111111”。

动态显示数码管M3-M4: 用来将最终的结果显示在数码管上,由于要把每个数字或字母分成7段来显示,所以采用了动态扫描电路方式,将静态现实中的数码管M3,M4对应的8个I/O口用于动态显示的数码管的8个管,由于此处没用到小数点位dp,故总设它为0。

关于7段的分发和具体对应的数字和字符,祥见下图和下表:编程思想:首先要对输入输出数据进行定义,有两个4位的数组COL,ROW 分别相对应输入的行和输出的列,从而最终可以确定用户所按得键。

vhdl实验报告

vhdl实验报告

vhdl实验报告VHDL实验报告引言:VHDL(Very High Speed Integrated Circuit Hardware Description Language)是一种硬件描述语言,广泛应用于数字电路设计和仿真。

本篇实验报告将介绍我在VHDL实验中的学习和实践经验,包括实验目的、实验过程、实验结果以及对VHDL的理解和展望。

一、实验目的VHDL实验的主要目的是让我们掌握VHDL语言的基本语法和使用方法,能够利用VHDL描述数字电路,并通过仿真和综合工具进行验证和实现。

通过这些实验,我们可以深入了解数字电路的原理和设计方法,提高我们的逻辑设计能力和工程实践能力。

二、实验过程在实验过程中,我们首先学习了VHDL的基本语法,包括实体声明、端口声明、信号声明等。

然后,我们通过实例学习了VHDL的建模方法,包括组合逻辑电路的建模和时序逻辑电路的建模。

在组合逻辑电路的建模中,我们学习了使用逻辑运算符和条件语句描述电路的功能;在时序逻辑电路的建模中,我们学习了使用过程语句和时钟信号描述电路的状态转换。

在学习了VHDL的基础知识后,我们开始进行实验设计。

我们选择了一个简单的数字电路,如4位加法器,来进行实验验证。

首先,我们通过VHDL语言描述了加法器的功能和结构,包括输入端口、输出端口和中间信号。

然后,我们使用仿真工具进行了功能仿真,验证了加法器的正确性。

接着,我们使用综合工具将VHDL代码综合成门级电路,并进行了时序仿真和时序优化,验证了加法器的时序正确性和性能。

三、实验结果通过实验,我们成功地实现了4位加法器的功能,并验证了其正确性和性能。

在功能仿真中,我们输入了不同的测试数据,观察了输出结果,发现加法器能够正确地进行加法运算,并得到了正确的结果。

在时序仿真中,我们观察了电路的时序行为,包括输入信号的变化、输出信号的响应和中间信号的传播延迟等,发现加法器能够在时序上满足要求,并且具有较好的性能。

vhdl设计实验报告

vhdl设计实验报告

vhdl设计实验报告VHDL设计实验报告引言VHDL(Very High Speed Integrated Circuit Hardware Description Language)是一种硬件描述语言,广泛应用于数字电路设计和验证。

本实验旨在通过设计一个简单的电路来熟悉VHDL语言的基本语法和设计流程。

一、实验背景数字电路是现代电子系统的基础,而VHDL则是描述和设计数字电路的重要工具。

VHDL可以帮助工程师们以一种形式化的语言来描述电路的功能和结构,从而实现电路的模拟和验证。

二、实验目的本实验的目的是通过使用VHDL语言设计一个简单的电路,加深对VHDL语言的理解,并掌握基本的电路设计流程。

三、实验步骤1. 确定电路功能在设计电路之前,首先需要明确电路的功能。

本实验中,我们选择设计一个4位加法器电路。

2. 设计电路结构根据电路功能的要求,设计电路的结构。

在本实验中,我们需要设计一个4位加法器,因此需要使用4个输入端口和一个输出端口。

3. 编写VHDL代码使用VHDL语言编写电路的描述代码。

在代码中,需要定义输入和输出端口的类型和位宽,并实现电路的功能。

4. 进行仿真使用仿真工具对设计的电路进行仿真,以验证电路的功能是否符合预期。

通过输入不同的测试数据,观察输出是否正确。

5. 下载到FPGA开发板将设计好的电路代码下载到FPGA开发板上进行验证。

通过连接输入信号和观察输出信号,验证电路在实际硬件上的运行情况。

四、实验结果与分析经过仿真和实际验证,我们设计的4位加法器电路在功能上符合预期。

输入不同的数据进行加法运算时,输出结果都正确。

五、实验总结通过本次实验,我们深入了解了VHDL语言的基本语法和设计流程。

通过设计一个简单的电路,我们掌握了VHDL的应用方法,并通过仿真和实际验证,加深了对电路设计的理解。

六、实验心得本实验让我对VHDL语言有了更深入的认识。

通过实际操作,我更加熟悉了VHDL的编写和仿真流程。

VHDL与数字电路设计实验报告

VHDL与数字电路设计实验报告

VHDL与数字电路设计实验报告引言本实验旨在通过使用VHDL编程语言和数字电路设计技术,实现特定功能的电路设计。

本文档将对实验的步骤、设计原理和结果进行详细描述。

实验步骤1. 步骤一:熟悉VHDL编程语言在实验开始之前,团队成员对VHDL编程语言进行了研究和熟悉。

我们了解了VHDL的基本语法、数据类型和结构,并获得了对VHDL设计原理的初步理解。

2. 步骤二:设计功能电路在本实验中,我们选择了一个特定的功能电路进行设计。

我们首先进行了功能需求分析,并根据需求确定了电路的输入输出信号以及主要的逻辑运算。

然后,我们使用VHDL编程语言将电路的逻辑运算实现为代码,并进行了仿真和测试。

3. 步骤三:电路仿真和验证为了验证我们设计的电路功能的正确性,我们使用了VHDL仿真工具进行了电路的仿真和验证。

我们根据输入信号的不同组合,观察输出信号的变化,并与我们预期的结果进行比较。

通过这一步骤,我们确认了我们设计的电路能够按照预期工作。

4. 步骤四:电路实现和测试在确认电路的设计和仿真结果无误之后,我们进一步将电路实现到实际的数字电路平台上,并进行了硬件测试。

我们使用实际的输入信号来测试电路的性能和稳定性,并对输出信号进行观察和分析。

通过这一步骤,我们验证了电路在实际环境中的可行性。

设计原理我们设计的电路基于特定的功能需求,采用了经典的数字电路设计原理。

通过使用VHDL编程语言,我们将电路的逻辑运算实现为逻辑门和触发器的组合。

通过将输入信号连接到适当的逻辑门和触发器,我们实现了所需的功能。

结果与分析经过实验步骤的完成,我们成功地设计和实现了一个具有特定功能的数字电路。

在仿真测试和实际测试中,电路都表现出了良好的性能和稳定性。

根据结果的分析,我们验证了电路的设计原理和逻辑的正确性。

结论本实验通过使用VHDL编程语言和数字电路设计技术,成功地实现了一个具有特定功能的电路设计。

我们的实验结果表明,VHDL和数字电路设计技术在电路设计领域具有重要的应用价值。

VHDL实验报告(1)

VHDL实验报告(1)

VHDL 实验报告******班级:电子0701学号:************实验一组合逻辑电路设计一实验目的:1. 熟悉mux+pluxII软件,可以进行新文件的编辑和文件的修改。

2. 掌握门电路VHDL语言程序设计方法。

3. 掌握选择器VHDL语言程序设计方法。

4. 掌握加法器VHDL语言程序设计方法。

5. 熟悉VHDL编程的基本方法。

二实验设备:1.计算机2.Max+PlusII软件三实验原理及内容:1 二输入与门(1)实验原理二输入与门是我们数字电路中的一个基础逻辑门电路,是最基本的逻辑门电路之一,也是最简单的逻辑门之一。

它能实现两个输入端的相与,一般有三个端口。

二输入与门的表达式是:Y=ab二输入与门的逻辑符号如图(1)所示,真值表如表(1)所示。

图(1)与门逻辑符号表(1)与门真值表(2)实验内容a.在mux+pluxII文本编辑环境下,打开新文本,编写两输入与门VHDL语言源程序,程序设计如下:LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY and2 ISPORT(a,b: IN STD_LOGIC;Y: OUT STD_LOGIC);END and2;ARCHITECTURE behave OF and2 ISBEGINY <= a and b;END behave;b.对源程序进行编译,按照提示进行修改,直至编译通过。

c.对编译程序进行仿真,分析并记录仿真波形,其仿真波形图如图(2)所示。

图(2)二输入与门仿真图d.在自己的目录下保存相应的源文件、波形文件。

2 四选一选择器(1)实验原理四选一选择器如图(3)所示,真值表如表(2)所示。

图(3)mux4管脚图表(2)mux4真值表(2)实验内容a.在mux+plusII文本编辑环境下,打开新文件,编辑四选一VHDL源程序文件,其程序设计如下:LIBRARY IEEEUSE IEEE.STD_LOGIC_1164.ALL;ENTITY mux4 ISPORT(A: IN STD_LOGIC_VECTOR (1 DOWNTO 0);D0,D1,D2,D3:IN STD_LOGIC;G:IN STD_LOGIC;Y: OUT STD_LOGIC);END mux4;ARCHITECTURE dataflow OF mux4 ISBEGINPROCESS (A,D0,D1,D2,D3,G)BEGINIF (G ='0') THENIF (A="00")THEN Y <= D0;ELSIF(A="01")THEN Y <= D1;ELSIF(A="10")THEN Y <= D2;ELSE Y <= D3;END IF;ELSE Y <='0';END IF;END PROCESS;END dataflow;b.对源程序进行编译,按照提示进行修改,直到编译通过。

VHDL实验报告

VHDL实验报告

年月日VHDL实验报告学院专业学号姓名实验1 译码器设计一、实验原理1、译码器是数字系统中常用的组合逻辑电路,常用于地址译码。

74LS138是最常用的一种小规模集成电路,它有3个二进制输入端和8个译码输出端。

表1.1是它的真值表。

表1.1 3-8 译码器真值表2、普通的LED数码管由7段和一个点组成,使用它进行显示,需要译码驱动。

本实验实现一个七段LED显示译码电路。

为了实验方便,在译码之前加入一个4位二进制加法计数器,当低频率的脉冲信号输入计数器后,由7段译码器将计数值译为对应的十进制码,并由数码管显示出来。

图1.1为此电路的原理图。

图1.1 7段LED译码显示电路二、实验内容1、设计一个4-16译码器。

2、设计轮流显示表1.2所示字符的程序。

表1.2 字母显示真值表3、通过仿真,观察设计的正确性。

4、下载、验证设计的正确性。

三、源程序1、4-16译码器。

LIBRARY IEEE;USE IEEE.STD_LOGIC_1164.ALL;ENTITY decode ISPORT( d0, d1, d2,d3, s1 ,s2 ,s3:IN STD_LOGIC;Y : OUT STD_LOGIC_VECTOR ( 15 DOWNTO 0 ) );END decode;ARCHITECTURE rtl OF decode ISSIGNAL indata : STD_LOGIC_VECTOR ( 3 DOWNTO 0 );BEGINIndata <= d3 & d2 & d1 & d0 ;PROCESS ( indata, s1, s2, s3 )BEGINIF (s1 ='1' AND s2='0' AND s3 = '0' ) THENCASE indata ISWHEN "0000" => Y <= "1111111111111110" ;WHEN "0001" => Y <= "1111111111111101" ;WHEN "0010" => Y <= "1111111111111011" ; WHEN "0011" => Y <= "1111111111110111" ;WHEN "0100" => Y <= "1111111111101111" ;WHEN "0101" => Y <= "1111111111011111" ;WHEN "0110" => Y <= "1111111110111111" ;WHEN "0111" => Y <= "1111111101111111" ;WHEN "1000" => Y <= "1111111011111111" ;WHEN "1001" => Y <= "1111110111111111" ;WHEN "1010" => Y <= "1111101111111111" ; WHEN "1011" => Y <= "1111011111111111" ;WHEN "1100" => Y <= "1110111111111111" ;WHEN "1101" => Y <= "1101111111111111" ;WHEN "1110" => Y <= "1011111111111111" ;WHEN "1111" => Y <= "0111111111111111" ;WHEN OTHERS=> NULL;END CASE;ELSEY <= "1111111111111111" ;END IF;END PROCESS;END rtl;2、轮流显示表1.2所示字符的程序。

数字电路设计实验vhdl语言实验报告

数字电路设计实验vhdl语言实验报告

实验一秒表计数器的设计实验目的:本实验通过设计四种频率可选的数字时钟系统, 以达到熟悉VHDL 语言编程语法、设计思路和熟练掌握Quartus II 开发软件的目的。

二、实验内容:该数字时钟的显示格式如下所示: HH: MM: SS, 其中HH表示时计数的两位, MM表示分计数的两位, SS表示秒计数的两位。

本系统输入信号分别为复位信号rst(高有效)、sel(两位信号, 分别可以选择2分频、4分频8分频和16分频)、clk_in(时钟信号)、8位时输出、8位分输出、8位秒输出(其中高4为表示对应的高半字节、低4位表示的低半字节, 譬如当时间为08:59:30时, 时输出为”0000_1000”,分输出为”0101_1001”,秒输出为”0011_0000”)。

该时钟系统可以通过Sel信号时钟运行的快慢。

三、实验流程:通过对实验内容的分析: 可以考虑时钟系统的可由三部分组成: 1.分频器:分频器为时序电路并且通过《数字电路》理论课程的学习可知由计数器来实现, 同学可以回想一下实验1中是如何实现计数器电路的设计), 该模块主要产生2.4.8、16分频的时钟信号;2.多路选择器:在VHDL中多路选择器为组合逻辑, 可以有多种实现方法, 在这里主要选用了case语句来实现。

该模块的作用是从分频器中根据Sel信号选择适当的时钟信号;3.时钟控制器:该模块比较复杂, 主要实现功能是实现一个24小时的计时。

当时间为00:00:59的时候下一个时钟到来时状态的跳变为00:01:00, 计时中多数计数为加1操作, 有几个特殊状态需要重点考虑:当时间产生分进数时, 譬如上例。

当时间产生时进数时, 譬如00:01:59时刻的下一个状态为00:02:00;当时间产生时进数时, 譬如00:59:59是个的下一个状态为01:00:00。

当时间产生天进数时, 譬如23:59:59的下一个状态为00:00:00。

四、仿真要求:1、本次试验的结果全部采用功能仿真分析:在结果图中能够看到让复位信号rst为有效的情况下, 所有的输出为00:00:00;2.当频率选择输出分别为”00”、”01”、”10”、”11”时秒为的进数分别包含2.4.8、16倍clk_in的时钟周期;3.可以看到完整的计时周期00:00:00->23:59:59->00:00:00。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

计算机硬件课程设计设计报告学号:姓名:成绩:学号:姓名:成绩:东南大学计算机科学与工程系二0 10 年12 月目录1.实验名称 (2)2.实验目的 (2)3.实验任务……………………………………………………………………… 2.4.主要特色 (2)5. 设计方案 (3)5.1 数据格式和指令系统 (3)5.2本设计的体系结构 (5)5.测试结果与性能分析 (20)6.课程设计总结 (22)1.实验名称微程序控制的模型计算机的设计与调试2.实验目的1.综合运用“计算机组成原理”和“数字电路”等课程的知识,通过对模型机的设计和调试,加深对计算机各部件工作原理的认识。

2.进一步掌握运用EDA技术进行设计和调试的工作方法。

3.掌握计算机硬件设计的思想,方法及工作过程,进一步培养工程设计的能力。

3.实验任务1.自行规定数据格式和指令格式,在所提供的条件范围内设计一台由微程序控制(也可以用其他方式如组合逻辑等)的模型计算机。

2.根据设计方案,将模型机调试成功。

3.整理出相关文件。

(1)数据格式和指令系统。

(2)总框图。

(3)详细电路图或有关电路的VHDL语言源程序。

(4)微指令格式和微程序。

(5)调试过程和测试结果(包括测试程序)。

4.主要特色1.增加了ROM的宽度,改为24位,使得可以在一个时钟内读出24位的微指令。

2.对电路进行了合理的修改,具体增加了SRC. DEST结合IR0,IR2,IR1,IR3到RA,RB的译码电路。

3.SRC. DEST结合IR0,IR2,IR1,IR3到WA,WB的译码电路,实现了对于源操作数的写入。

4.由微指令到8CPU中对应的端口译码。

5.重新构造了ROM,RAM,修改了时序电路,调整了M1,M2,M3,M4的时序。

6.除了书上要求的指令微程序以外,还对微程序进行了扩充,加了逻辑左移指令:SAL(每次执行左移一位),以及乘法指令:MUL(8位与8位数据相乘,得到16位数据高8位写回源操作数,低8位写回目的操作数)7.修改了M1,M2,M3,M4的连接电路。

8.通过用软件模拟的方法,成功的构造了一个简单的CPU,更加熟练的学会使用EDA技术。

试验中结合了数字实验和组成原理部分内容。

9.用简单易读的方式排列24位控制信号,使得操作更加简便,如图所示5.设计方案5.1数据格式和指令系统(参考教材)采用8位数据通路,数据采用8位二进制定点表示。

7 6 5 4 3 2 1 0.设置7条机器指令和两条面板操作指令(1)面板操作指令(因为没有一BIOS 及操作系统,所以用面板指令进行初始化,启动机器)a.输入地址为PC置初始值,即输入程序的起始地址,当K1开关置“1”,K2开关置“0”时执行此操作。

b.输入程序将程序输入到内存的指定区域,当K1,K2开关均置“1”时,由面板输入开关输入程序c.本模型机设置K3开关,K3置1表示执行单步操作。

d.START表示启动开关。

(2)指令系统a.指令格式操作码寻址方式7 6 5 4 3 2 1 0有二种寻址方式寄存器寻址操作码R目R源7 6 5 4 3 2 1 0直接地址寻址由于地址要占用一个字节,所以此类指令为双字节指令。

操作码R目R源内存地址b.9条机器指令IN R;从开关输入数据送入到指定的寄存器R。

格式:0 0 0 1 R目0 0OUT R;从指定的寄存器R中取出数据送入到输出缓冲器,显示灯亮。

格式:0 0 1 0 0 0 R源LD R , address ;从内存指定单元取出数据,送入指定的寄存器R。

格式:0 0 1 1 R目0 0内存地址ST address, R; 从指定的寄存器R中取出数据,存入内存指定单元。

格式:0 1 0 0 0 0 R源内存地址ADD R1,R2;将两个寄存器中的数据相加,结果送到R1。

格式:0 1 0 1 R目R源JMP address; 无条件转移,即address PC。

格式:0 1 1 0 0 0 0 0内存地址HALT ;停机指令。

MUL R1,R2;将两个寄存器中的数据相乘,结果高8位送到R1,低8位送到R2。

格式:1 0 1 0 R目R源SAL R;将R中的数据左移一位,结果送到R1。

格式:1 0 0 1 R目5.2本设计的体系结构为了简单方便起见,我们采用单总线结构,总体机构和CPU内部结构设计如图所示总体结构图CPU内部结构1.数据通路设计(1)采用Quartus—II软件工具,先设计出运算器部分,如图所示.ALU.bdf,经时序仿真正确后,进行符号封装。

(2)采用Quartus—II软件工具,先设计出运算器部分,如图所示MUL.bdf,经时序仿真正确后,进行符号封装。

介绍数据通路时打开8CPU.bdf(2)根据指令系统,数据通路中应包括寄存器组,存储器等,采用单总线结构,截图一分为二(1)(2)其中为了做乘法,我们对8cpu加了6个控制信号,如图所示2.控制器设计(1)控制器总框图.控制信号(2)微指令格式和微命令首先对数据通路进行分析,需要22个控制信号。

此外还要2个信号:UPC (表示一段微程序结束),HALT(停机),共需要24个控制信号。

采用水平型格式表示。

控制数据通路的16个信号说明如下:G1,G2,G3,G4ramormul,cmul 分别控制6个多路开关A,B,C,D,EO,P,Q 分别控制对应的寄存器输入F 控制计数器PC的输入和计数I 控制指令寄存器的输入DEST 目的寄存器的读出控制信号SRC 源寄存器的读出控制信号WE 对RAM的写入信号GWN 通用寄存器组的写入信号LDN PC置初值的控制信号SRCWE 源或目的寄存器的写入信号(3)控存的安排和时序信号本方案采用的时序控制信号是由74393b产生的。

对于时序,本来是有六个时钟周期的,我们将其缩短在了四个,有效的提高了运行效率。

修改后的时序电路图时序脉冲(4)微地址入口电路的设计为简单起见,微地址采用8位,其高4位由指令操作码控制,低4位由一个4位的计数器控制。

将ROM的高段地址区用于存放面板指令的微程序,低段地址存储区存放一般指令的微程序,控制电路可参考图6。

图3-6 微地址入口电路(5)微命令译码电路a.本方案中寄存器组采用的是74670芯片,每次写入可以为源寄存器,也可以为目的寄存器,所以Wa,Wb要经过译码与IR2,IR3连接,读出时目的和源寄存器均可读出,所以依然要用译码电路。

电路设计如下:写寄存器译码电路读寄存器译码电路b.停机电路以下几种情况需停机:(a)总清. (b) 执行单指令操作,且一条指令执行完。

(c) 执行停机指令。

根据这三种情况可以设计出停机电路。

c.UPC微命令表示一段微程序结束,因此该命令要做的工作是:(a)置“0”微程序计数器(74161)。

(b)置“0”指令寄存器。

3.微程序和总电路图微程序定义如下:8cpu中的端口译码电路如下:Rom修改为24位,修改电路如下:24位重新排列微指令顺序8CPU重新封装效果图CPU总的电路图:(截成四部分)时序及upc产生部分8cpu及寄存器读写译码部分控制信号译码部分Rom及取微指令部分、6.测试结果与性能分析(测试程序、时序图、编译报告中资源使用情况)仿真:微程序和电路设计完成后,进行编译,并通过仿真来检验cup的各项功能。

仿真时,先用面板指令输入程序的起始地址和一段小程序。

我们输入的程序为:初始地址为00H,即Ram中程序如下:进行仿真,首先开关K1置1,K2置0,kdata为00H,为PC置初始值00即程序口地址,接着将K1置0,执行程序。

此时,我们置kdata始终为02H,通过IN指令输入到R0和R1中,然后继续执行程序!建立vwf文件如下:仿真结果如下:7.课程设计总结本实验是设计一个小型CPU,主要工作是在给定的CUP主体结构上完善电路,修正已有电路错误以及设计微程序。

本实验有相当的综合性:在实践过程中,我们充分使用了组成原理、微机接口、数字电路等相关知识。

通过本次实验,我们对CPU的结构和工作原理有了切实的认识。

尤其在总线,时序,微指令等方面,投入的时间不少,体会很深。

我们深刻理解了总线作为指令和数据传输的道路和桥梁,在CUP的工作过程中扮演的重要角色;弄懂了通过时序的调节解决总线的冲突的方法;在全面细致地分析了CUP结构和工作原理的基础上,我们掌握了编写微指令的方法与技巧。

通过组内讨论和求教于老师、同学,我们顺利的完成了基本的实验目标,并做了进一步研究。

利用加法指令,我们增加了SAL(左移一位)指令。

采用控制RA、RB读信号的控制思路,我们使得源、目的寄存器均可写入。

在此基础上,我们引入了8位乘法器,将结果——16位二进制数,成功写入源、目的寄存器。

对现有的24位控制信号,我们充分利用了每一位。

同时,我们注意到实验中还有很多可以改进的地方。

由于时间和给定CPU规格的限定,很多想法未能实施。

比如,编写微指令时,我们注意到:一条指令中的某条指令在M3时已经完成,空等一个M4,才取下一条。

这样的情况并不少见。

如果将执行微指令、取微指令等改为下降沿也能触发,就可以把下一条提到M4做,这就省了一个整个指令周期。

宏观的时间节省量自然也十分可观。

再如,实验提供的ROM为24位,这使得控制信号剩余不多,一旦想多加其它组件,就会为之苦恼。

我们想到自取名为“多面手控制信号”的解决方案:对于互斥的两条指令A和B(如ADD和MUL(肯定不会同时做)),可以根据需要,让A的控制型号同时控制B,所需做的额外工作是修改ROM中的微指令即可。

比起想法设法地扩展ROM,这种方法既快速,又充分利用资源。

实验提供的CPU中有不少这样的控制信号,值得好好利用。

当然,缺点也显而易见,由于控制信号一对多,修改、删除时得慎之再慎,增加了CUP维护的难度。

总之,通过本次实验,我们体会了学以致用的快乐,为进一步的深入的学习增添了几分信心。

相关文档
最新文档