Prog - Assignment 3
Prog - Assignment 3
Introduction
Now, we will build an enhanced MIPS emulator with 5 pipeline stages. Pipeline has been a big change in designing
microarchitecture of modern microprocessors. Pipelining makes users best utilize the given hardware by
concurrently executing multiple instructions at the same time. In five stage pipeline, instruction is processed in
five distinct stages (or pipeline stages): IF, ID, EX, MEM, WB.
In a pipelined processor, an instruction is processed with multiple cpu clock cycles. For example, our five-stage
pipeline MIPS, one instruction execution is completed in five cycles. At the first cpu clock, an instruction is
fetched into CPU from memory. In the next cycle, the fetched instruction is decoded, and register values are read.
Then, the decoded instruction is executed by ALU in the execution stage, which is the third cycle. Next, the
execution accesses memory if needed in the fourth cycle. Finally, the register update and write back is performed
in the fifth cycle.
In addition to multi-cycle execution, in a pipeline processor, the execution of different instructions are overlapped.
Namely, five different instructions can be executed at the same time, each of which instructions utilizes different
hardware unit. Thus, it increases performance in terms of throughput. Now, the clock cycle time does not have to
rely upon the slowest instruction execution, and we can maximize hardware utilization by concurrent execution.
One concern about pipeline execution is hazard/or pipeline stall. Hazard represents the state at which pipeline is
not full because an instruction in the pipeline is dependent upon another instruction, hindering the concurrent
execution. Modern microprocessors address pipeline hazard with various techniques, including register
forwarding, loop unrolling, instruction scheduling, branch prediction, speculative execution, etc.
In this programming assignment, you will emulate simple pipeline processor, fully in software. We consider the
MIPS processor with five pipeline stages. You should resolve pipeline hazards, or dependency to fill in the pipeline
as much as possible.
This program assignment is critical in your evaluation, so please work hard to complete in your schedule. If you
need help, please ask for the help. (I am here for that specific purpose) I, of course, welcome for any questions on
the subject. We will have demo time for some of your work (good/bad). In demo, you are asked to explain your
software (structure/implementation). If you can, please think about the visualization of the emulator. Note for the
one strict rule that do not copy code from any others. Deep discussion on the subject is okay (and encouraged),
but same code (or semantics) will result in sad ending.
Extra implementation is highly encouraged, meaning that various branch prediction, data forwarding technique
implementation would differentiate your work. (Unique /creative approaches are more appreciated, even trial has
significant credit.)
Advice one: You may need some time to think about your software structure, and operation, and pipeline.
Therefore, think with note and pen, before rushing the code work.
Advice two: Make basic structure robust, and reliable. If you make code on suspicious base, you are easy to lose
the way. Make print logs, before you have gone too much. Make basic structure, at the first hand. Make some
checkpoints before you got failure.
Advice three: You can make things work from small pieces to a larger one. You may consider writing code in the
following sequences.
Last advice, but not least: Begin as early as possible. Ask for help as early as possible. Try as early as possible.
They are for your health-care.