Docsity

Pipelining Assignment 4 - Computer Architecture I, Assignments of Computer Architecture and Organization

Toggle sidebar
bg1
CSE420/598 Computer Architecture I (FALL 2008)
Programming Assignment 4 (100 + 50 points)
Pipelining Simulator
(Due 12/03/2008 at the start of the class)
In this assignment, you will implement a pipelining simulator using C, C++, C# or
JAVA.
Task 1 (100 points): Mandatory for CSE420/598
Implement the pipelining simulator of Figure A.24 on page A-38. There are five stages:
Instruction Fetch (IF), Instruction Decode (ID), Execution (EX), Memory access (MEM),
and Write-back (WB). Assume that that the second half of the decode stage performs a
read of source registers, and that the first half of the write-back stage writes to the register
file.
We assume there are four classes of instructions. We assume each instruction is 4 bytes
and all registers are 4 bytes. Assume a byte-addressable computer.
Arithmetic – Consider two arithmetic operations: add (ADD) and integer add
(ADDI). The first register is the destination and the others are the source. For
example,
Instruction Meaning
ADD R1, R2, R3 R1 = R2 + R3
pf3
pf4
pf5

Partial preview of the text

Download Pipelining Assignment 4 - Computer Architecture I and more Assignments Computer Architecture and Organization in PDF only on Docsity!

CSE420/598 Computer Architecture I (FALL 2008)

Programming Assignment 4 (100 + 50 points)

Pipelining Simulator

(Due 12/03/2008 at the start of the class) In this assignment, you will implement a pipelining simulator using C, C++, C# or JAVA. Task 1 (100 points): Mandatory for CSE420/ Implement the pipelining simulator of Figure A.24 on page A-38. There are five stages: Instruction Fetch (IF), Instruction Decode (ID), Execution (EX), Memory access (MEM), and Write-back (WB). Assume that that the second half of the decode stage performs a read of source registers, and that the first half of the write-back stage writes to the register file. We assume there are four classes of instructions. We assume each instruction is 4 bytes and all registers are 4 bytes. Assume a byte-addressable computer.  Arithmetic – Consider two arithmetic operations: add (ADD) and integer add (ADDI). The first register is the destination and the others are the source. For example, Instruction Meaning ADD R1, R2, R3 R1 = R2 + R

ADDI R1, R2, 100 R1= R2 + 100

 Data Transfer – These instructions take a base register and offset. The effective address is the sum of the content of the base register and offset. Load (LD) and Store (SD) instructions move 4-byte data from memory to the register and from the register to memory. Move (MV) instruction copies an integer value to a register. Here, Regs[R] is the content of register R. A subscript is used to indicate selection of a bit from a field. Bits are labeled from the most-significant bit starting at 0. The variable Mem is indicate main memory and is indexed by a byte address. Since we assume 4-byte data transfer between a register and the main memory, Mem[x] brings 4-byte data starting address x to x+3 from the main memory. The data is stored big-endian. The symbol ## is used to concatenate fields. For example, Instruction Meaning LD R1, 100(R2) R1 = Mem(Regs[R2]+100) ## Mem(Regs[R2]+101) ## Mem(Regs[R2]+102) ## Mem(Regs[R2]+103) or R10..7 = Mem(Regs[R2]+ 10 0) R18..15 = Mem(Regs[R2]+ 10 1) R116..23 = Mem(Regs[R2]+ 10 2) R124..31 = Mem(Regs[R2]+ 10 3) SD R1, 100(R2) Mem(Regs[R2]+ 100) ## Mem(Regs[R2]+ 101) ## Mem(Regs[R2]+ 102) ## Mem(Regs[R2]+ 103) = R1 or Mem(Regs[R2]+ 10 0) = R10.. Mem(Regs[R2]+ 10 1) = R18.. Mem(Regs[R2]+ 10 2) = R116.. Mem(Regs[R2]+ 10 3) = R124.. MV R1, 0 R1 = 0  Branches – We consider one comparison instruction called set on less than (SLT). This instruction compares two registers and set a first register to 1 if the second is less than the third. Otherwise, it is set to 0. There are three branch instructions, BEZ, BNEZ and JUMP. For example, Instruction Meaning SLT R1, R2, R3 if R2 < R3, R1 = 1 BEZ R1, 10 if R1 = 0, PC = NPC + 10* BNEZ R1, 10 if R1 ≠ 0, PC = NPC + 10* JUMP 10 Unconditional jump, PC = NPC + 10*  Meta Instructions – These instructions execute nothing, but are used for debugging. All instructions reference data at the start of the current clock cycle when the instruction is encountered. These instructions do not take the clock

103 10 (R2 = 10)

107 20 (R3 = 20)

Run the input program using your simulator. You should update the input file (the data of memory) as the execution of the program. For example, after execution, the data will be updated to 108 0 109 0 110 0 111 30 (R2 + R3) You should display the total number of cycles to complete a program and submit the updated input files. For this assignment, there are 10 registers (Z, T0 – T4 and S0 – S3) and the range of main memory is 0 – 255 (2^8). The register Z holds zero. Task 2 (50 points): Mandatory for CSE598/ Extra credit for CSE Repeat with the above exercise using “forwarding” and “predicted-untaken” to avoid data and control hazards. The program takes the input file names as arguments. The command line should be Pipelining2 “ input_file ” where Pipelining2 is the execution file name and “ input_file ” is the input file name. Report: Your report should have the detailed explanation of the implementation, events on every pipe stage (refer Figure A.19 and 39), results for input files, discussion on your results, and things you learned. The length of report should be 2 – 3 pages. The font size should not be greater than 12. README file:

In a README file, you should include 1) the programming environment you used (e.g. MAC/Windows, the version of complier, etc), and 2) tips to compile and run your program. Deliverables:

  • A Zip file including source codes, a README file, updated input files and a report. Please name your zip file as LastName_HW3.zip (e.g. Kim_HW3.zip). Send the zipped file to the TA ([email protected]) with your full name and ASU ID.