Lab 6

Computer Architecture I @ ShanghaiTech University

Getting started:

Download the files for Lab 6 first.

Part I: FSM

Exercise 1: FSMs to Digital Logic

In this exercise, you need to translate a FSM into a digital logic circuit. FSM's keep track of inputs given, moves between states based on these inputs, and outputs something everytime something is input. We use a register to store the state of the FSM we're currently in, and combinational logic to map FSM input & current register state to FSM output & next register state.

ACTION ITEM:

Load the given starter file ex1.circ into Logisim. Modify this circuit's subcircuits StateBitZero and StateBitOne to implement this Moore FSM: Detecting 010 pattern in a bit sequence(use overlapping). Show this completed circuit to your TA (remember to save!)

  1. Note that the FSM is implemented by the following diagram (the four state names 00, 01, 10, 11 are just names written in binary - they have no direct relationship with the actual zeros and ones of the FSM input/output). Take some time to understand how this diagram implements the FSM:

  2. Observe that the following is a truth table for the FSM (convince yourself of this):

    st1 st0 input next st1 next st0 output
    0 0 0 0 1 0
    0 0 1 0 0 0
    0 1 0 0 1 0
    0 1 1 1 0 0
    1 0 0 1 1 0
    1 0 1 0 0 0
    1 1 0 0 1 1
    1 1 1 1 0 1
  3. We've provided you with a starter Logisim circuit to start out in ex1.circ.

  4. Note that the top level of the circuit looks almost exactly the same as our previous adder circuit, but now there's a FSMLogic block instead of an adder block. FSMLogic is the combinational logic block for this FSM. We have handled the output bit for you. You should complete the circuit by completing the StateBitOne and StateBitZero subcircuits, which produces the next state bits.

Check-off

Show your StateBitZero circuit & StateBitOne circuit to your TA and demonstrate that they behave correctly.

Part II: Introduction to RV32 CPU

Exeicise 2: Program Counter

In the RV32I CPU, the Program Counter (PC) is a core component responsible for tracking the address of instructions. Below is a detailed description of the PC's functionality, input, and output ports:

Functionality:

Input Ports:

Output Ports:

ACTION ITEM:

Load the given starter file ex2.circ into Logisim and implement a PC circuit. Show this completed circuit to your TA (remember to save!)

Details:

In this lab, All instructions are a fixed 32 bits in length, meaning that instructions must be aligned on a 4-byte boundary in memory. But sometimes, An instruction-address-misaligned exception is generated on a taken branch or unconditional jump if the target address is not 4-byte aligned. In this case, it needs to be automatically rounded down to 4-byte alignment. For example, if the target address is 0x000000A3, you need to align it to 0x000000A0.

Check-off

Show ex2.circ to your TA, and explain: