Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

1Learning Outcomes

As mentioned in the previous section, a CPU has two types of elements, reflecting the design of many digital logic systems.

In this section, we discuss the state elements needed in a RISC-V processor. We will discuss and introduce the combinational logic blocks as we build out the full datapath.

1.1Program Counter

The Program Counter is a 32-bit register in Figure 1 and holds the value of the current instruction, i.e., instruction to execute in the current clock cycle.

"TODO"

Figure 1:The Program Counter, PC, is a single 32-bit register in the CPU.

Behavior:

1.2Register File (Regfile)

The Register File (regfile, or Reg[]) has 32 registers: register numbers x0 to x31.

"TODO"

Figure 2:The RegFile is symbolically written as Reg[] and is composed of registers x0 to x31.

Behavior:

1.3DMEM: Data Memory

For this class, memory is “magic.” Assume a 32-bit byte-addressed memory space, and memory access occurs with 32-bit words. We go into more detail with our course projects.

For our single-cycle datapath, we must access memory twice: once during IF (Instruction Fetch) to read the instruction from memory, and once during MEM (Memory Access) if we load/store data from/to memory. We therefore need two memory blocks: IMEM and DMEM for instruction memory and data memory, respectively.[1]

The Data Memory block DMEM has edge-triggered writes, just like Reg[].

"TODO"

Figure 3:The Data Memory block DMEM. Read operations behave like combinational logic, whereas write operations occur on the rising clock edge.

Behavior: DMEM read/writes behave similarly to Regfile, though now we provide memory addresses as input, not register numbers.

1.4IMEM: Instruction Memory

The Instruction Memory block IMEM is a read-only memory that fetches instructions.[2]

"TODO"

Figure 4:In our CPU, the Instruction Memory block IMEM is read-only and behaves like combinational logic.

Behavior:

Footnotes
  1. Under the hood, IMEM and DMEM are placeholders for L1 caches: L1i, L1d.

  2. We will need to write the instruction memory when we load the program, which we ignore for simplicity.