1、东南大学计算结构CPU报告Computer Organization and ArchitectureCOURSE DESIGNNAME STUDENT NUMBER COURSEComputer Organization and Architecture Course DesignPROJECTA Central Processing Unit (CPU) Basing On Verilog HDLSOFTWARE PLATFORM ISE 14.1DATEAPR.15.20141. Purpose (1) The purpose of this project is to design a
2、 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
3、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.(2
4、) The use of ISE software for design and simulation.2. TasksSingle-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 add
5、ress 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 in
6、struction 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 1.Figure1. The instruction formatThe opcode of the relevant instructions are listed in Table 1.InstructionOPCODECommentsADD X00000001ACC+X-ACCSUB X00000010ACC-X-
7、ACCAND X00000011ACC and X-ACCOR X00000100ACC or X-ACCNOT X00000101NOT X-ACCSHIFTR00000110SHIFT ACC to Right 1bit,Logic ShiftSHIFTL00000111SHIFT ACC to Left 1bit,Logic ShiftMPY X00001000ACCX-ACCDIV X00001001ACCX-ACCJMPGEZ X00001010If ACC0 then X-PC else PC+1-PCJMP X00001011X-PCHALT00001100Halt a prog
8、ramSTORE X00001101ACC-XLOAD X00001110X-ACCTable1. List of instructions and relevant opcodes3. The overall connection expressed in the top module formFigure2. The overall connection expressed in the top module form4. Internal Registers and Memory4.1 Memory (Dist_mem_gen_v7_1)The Xilinx LogiCORE IP Di
9、stributed Memory Generator core uses Xilinx Synthesis Technology (XST) to create a variety of distributed memories. It generates read-only memories (ROMs), single, simple dual, and dual-port random access memories (RAMs), and SRL16-based memories; Supports data depths ranging from 1665,536 words; Su
10、pports data widths ranging from 11024 bits.This memory is a single port RAM generated by Dist_mem_gen_v7_1.4.2 MAR (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 memor
11、y, 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.4.3 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 sys
12、tem bus. In our design, MBR has 16 bits. The module has been horizontally inverted.4.4 PC (Program Counter)PC keeps track of the instructions to be used in the program. In our design, PC has 8 bits.4.5 IR (Instruction Register)IR contains the opcode part of an instruction. In our design, IR has 8 bi
13、ts.4.6 ACC (Accumulator)ACC holds one operand for ALU, and generally ACC holds the calculation result of ALU. In our design, ACC has 16 bits.BR is used as an input of ALU, it holds other operand for ALU. In our design, BR has 16 bits. The module has been horizontally inverted.4.7 ALU (Arithmetic Log
14、ic Unit)ALU is a calculation unit which accomplishes basic arithmetic and logic operations. In our design, some operations must be supported which are listed as follows:Table2. ALU Operations4.8 CU (Microprogrammed Control Unit)We have learnt the knowledge of Microprogrammed control unit. Here, we o
15、nly 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
16、 micro-operations which are executed at the same time.Figure 3 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 f
17、rom 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 sequ
18、encing unit that loads the control address register and issues a read command.Figure3. Control Unit Micro-architectureIn my design, I simplify the structure of MU. Figure 4 shows the Control Unit Micro-architecture in my design. CM is a Distributed ROM generated by Dist_mem_gen_v7_1. Its function is
19、 the same with the control memory plus the control buffer register in figure 3. Similarly, the SequencingLogics function is the same with sequencing logic plus control address register in figure 3.Figure4. Control Unit Micro-architecture in my designControl SignalsCM地址控制C0CAR=CAR+1C1CAR=*C2CAR=0系统总线
20、C3RWmemoryC5Wmemory数据通路C4memory=MBRC6MBR=memoryC7IR=MBR15.8C8MAR=MBR7.0C9BR=MBRC10PC=MBRC11MAR=PCC12PC=PC+1C13ALU=BRC14ALU=ACCC15ACC=ALUC16ACC=BRC17MBR=ACCALU控制ALU0ALU1ALU2ALU3Table3. Meanings of each bit of control signal运算ALU3:0ADD0001SUB X0010AND X0011OR X0100NOT X0101SHIFTR0110SHIFTL0111MPY X100
21、0DIV X1001Table4. Meanings of ALU3:0 signal Table5. CPU instruction set and relevant micro-operations and control signalsAs figure 4 and table 3 shows, there are 2 output bus from Control Unit. One is the control signal bus CS17:0, the other one is the ALUFlag signal bus ALUFlag3:0, which indicates
22、that which calculation is going to be executed in ALU. More specifically, table 4 shows meanings of ALU3:0 signal.Table 5 shows the CPU instruction set and accordingly micro-operations and control signals. This is the foundation of the whole design.5. Design description of the simulation input wavef
23、ormsTwo simulation input signals are needed in my design.(1) clk: clock signal of the whole system. The clock period is 10 us. All the registers are positive-edge-triggered.(2) reset: reset when reset = 1. All the reset signals for the registers are synchronized to the clock signal.6. Simulation res
24、ults(1) 1+2+3+100=5050Table6. Program of 1+2+3+100Figure5. Waveform of 1+2+3+100(2)123=36Table7. Program of 123Figure6. Waveform of 123(3)123=4Table8. Program of 123Figure7. Waveform of 1237. Conclusions and Discussions(1) It takes 46ms to finish the calculation 1+2+3+100=5050, in the condition of t
25、he clock period 10us.(2) The result of the multiplication calculation has been limited to 8bit since the MR register is not used.(3) The division calculation can only been called exact division, since the operator which is used in the code is “/ ”.(4)感想:CPU的设计相对比较复杂,在真正用ISE进行编程仿真之前需要把课本上CPU部分尤其是CU的工
26、作原理弄清楚,并用EXCEL工具设计自己的指令集和其对应的微操作。这中间很多地方容易出错,也容易使人迷糊,这时就要勤于动手在纸上规划自己的设计。当草稿纸上和EXCEL中的设计完成后,再用ISE进行编程仿真就会很快了,良好的设计会对后面的工作起到很大的促进作用。在这中间会对课本知识有更加透彻深入的理解。这个实验完全由我独立完成,其中前期设计所使用的时间占到了总花费时间的一半,后期编程调试仿真花费了总时间的另一半。Appendix-MAR-module MAR( input 15:0 MBRdata, input 7:0 PCdata, input 17:0 CS, output 7:0 MA )
27、; reg 7:0 MA; always(posedge CS8 or posedge CS11) begin if(CS8=1)begin MA=MBRdata7:0;end if(CS11=1)begin MA=PCdata;end end endmodule-MBR-module MBR( output 15:0 MBdata, input 17:0 CS, input 15:0 ACC, input 15:0 MEM ); reg 15:0 MBdata; always (posedge CS6 or posedge CS17) begin if(CS6=1)begin MBdata=
28、MEM;end if(CS17=1)begin MBdata=ACC;end endendmodule-PC-module PC( input reset, input 17:0 CS, input 15:0 MBRdata, input clk, output 7:0 PCdata ); reg 7:0 PCdata; always(posedge clk) begin if(reset=1) begin PCdata=8b00000000; end if(CS10=1)begin PCdata=MBRdata7:0; end if(CS12=1)begin PCdata=PCdata+1;
29、 end endendmodule-IR-module IR( input 17:0 CS, input 15:0 MBRdata, output 7:0 IRdata ); reg 7:0 IRdata; always(posedge CS7) begin if(CS7=1)begin IRdata=MBRdata15:8; end endendmodule-ACC-module ACC( input 17:0 CS, input 15:0 ALUdata, input 15:0 BRdata, input reset, input clk, output 15:0 ACCdata, out
30、put zflag ); reg 15:0 ACCdata; reg zflag; always(posedge clk) begin if(reset=1) begin ACCdata=16b0000000000000000; zflag=1; end else if(ACCdata15=0) begin if(CS15=1) begin ACCdata=ALUdata; zflag=1; end else if(CS16=1) begin ACCdata=BRdata; zflag=1; end else begin zflag=1;end end else begin if(CS15=1) begin ACCdata=ALUdata; z
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1