目录 ← 首页
CS61C

Control Logic Design

Learning Outcomes

  • Given an instruction, identify control signals.
  • Explain how a ROM can be used in control logic to translate instruction bits (“address input”) into control signals (“word output”).
  • Implement control logic with ROM and combinational logic blocks.

In this section we discuss how to implement the controller, i.e., the control logic block. Here is #fig-five-step-single-cycle-control from our chapter introduction to jog your memory.

Same five-step datapath annotated with control influence, highlighting how control signals select active data paths for each instruction.

As the datapath computes values, the control logic selects the necessary values needed to execute the instruction.

Review Control Signals

Before continuing, review the following video, which practices identifying and setting the control signals that set the datapath operation for two different instructions: sw and beq.

Then, confirm the control signals for the subset of instructions shown in #tab-control-truth-table.

Remember that branches conditionally update PC based on the output of the branch comparator block. The block’s output signals BrEq and BrLT are fed into the control logic, which then sets PCSel selector that wires into the PCSel mux. See the partial truth table below (@tab-branch-truth-table).

Control Logic / Controller

The control logic subcircuit (i.e., the controller) takes the instruction bits (and BrEq, BrLT) and outputs all the control signals needed to execute that instruction. The control signals are listed in #tab-controller-signals.

In general, there are two approaches to implementing control logic:

  1. Read-Only Memory (ROM): A ROM reads out words at a given input address. Because the ROM is read-only, it is populated with the needed ones and zeros at design time.

    The regular structure of a ROM means it can easily designed and reprogrammed to fix errors (e.g., during prototyping) or when adding instructions (like extensions for compressed instructions). ROMs are also popular when designing control logic manually, like in this course.

  2. Combinational Logic using AND, OR, and NOT gates. In real chip design, control is typically designed with logic gates because it is more compact and much faster than ROM alternatives. Today, chip designers use logic synthesis tools to convert truth tables to networks of gates. See this approach below.

ROM Approach

In this course, we implement the controller design in #fig-control-design, which has two subcircuits:

  1. Read-Only Memory (ROM): The ROM takes in a 9-bit address constructed from the instruction bits, then outputs a 14-bit “word” that can be decoded into the needed control signals.

  2. The Take branch? combinational logic block takes in the Branch Comparator outputs and outputs the PCSel control signal.

Controller design with ROM block and decoder symbol generating most control signals from instruction bits and a take-branch logic block generating PCSel from BrEq and BrLT.

Suggested control design has two parts.

Combinational Logic Approach

Because the ROM effectively performs a lookup on a giant truth table, we can alternatively implement our control logic subcircuit entirely using AND, OR, and NOT gates. We can use our trusty Sum of Products approach to write the canonical form, then reduce the expression using Boolean Algebra Laws.

Example 1: Suppose we wanted to implement a signal that is high if we have an R-Type instruction. The opcode for all R-Type instructions is 0110011 (instruction bits inst[7:0]), so our corresponding boolean expression is:

R-Type=(inst[6]inst[5]inst[4]inst[3]inst[2])\text{R-Type} = (\overline{\texttt{inst}[6]} \cdot \texttt{inst}[5] \cdot \texttt{inst}[4] \cdot \overline{\texttt{inst}[3]} \cdot \overline{\texttt{inst}[2]})

Example 2: Suppose we wanted to implement the BrUn signal. The BrUn signal is high if we have a B-Type instruction AND if that instruction’s funct3 indicates an unsigned compare.

Considering the fields of the relevant instructions above, we can write an expression for BrUn:

BrUn=(B-Type)(Unsigned Compare)=(inst[6]inst[5]inst[4]inst[3]inst[2])(inst[13])\begin{aligned} \texttt{BrUn} &= (\text{B-Type}) \cdot (\text{Unsigned Compare}) \\ &= (\texttt{inst}[6] \cdot \texttt{inst}[5] \cdot \overline{\texttt{inst}[4]} \cdot \overline{\texttt{inst}[3]} \cdot \overline{\texttt{inst}[2]}) \cdot (\texttt{inst}[13]) \end{aligned}