Project 1, Part 2: The Datapath
The previous article established the instruction set architecture. This article connects the physical datapath components that store, manipulate, and transfer 8-bit data words. The processor datapath integrates an arithmetic logic unit, a multi-port register file, program counters, and multiplexers.
Datapath Building Blocks
The datapath incorporates three core functional blocks:
-
Arithmetic Logic Unit (ALU): Reuses the parameterized ALU from Section 7.1. It executes addition, subtraction, bitwise AND, and bitwise OR operations.
-
Register File: Implements a 4-entry, 8-bit dual-read register bank as introduced in Section 3.6:
module reg_file (
input logic clk,
input logic [1:0] rd_addr_a, rd_addr_b, wr_addr,
input logic [7:0] wr_data,
input logic wr_en,
output logic [7:0] rd_data_a, rd_data_b
);
logic [7:0] regs [0:3];
assign rd_data_a = regs[rd_addr_a]; // Asynchronous combinational read
assign rd_data_b = regs[rd_addr_b];
always_ff @(posedge clk) begin
if (wr_en) regs[wr_addr] <= wr_data;
end
endmodule
- Memory Arrays: Instantiates two single-port RAM blocks from Section 7.1: one for instruction storage and one for data memory.
Interconnect and Multiplexer Architecture
The datapath routes operands between registers, execution units, and storage buses:
Two multiplexers control operational data routing:
- ALU Operand-B Multiplexer:
Selects between register source operand
Rs(for R-type instructions) and immediate constant values. This hardware sharing allows a single ALU to serve multiple instruction classes. - Write-Back Multiplexer:
Selects the data source written into destination register
Rd. Data originates from the ALU result (arithmetic), data memory (load), or the immediate field (load immediate).
Control Signal Requirements
The datapath executes operations under the direction of an external control unit. The control unit must provide the following control lines:
alu_src_b: Selects registerRsdata or zero-extended immediate data.wb_sel: Directs the write-back multiplexer to select the ALU result, memory data, or immediate value.reg_wr_en: Enables synchronous writes into the register file.mem_wr_en: Enables synchronous write transactions to data memory.pc_load: Controls Program Counter branch updates when conditional tests succeed.
Practice Exercise
Trace the active datapath signals when the processor executes LDI R2, 6.
Identify which functional blocks are active and which remain idle.
Solution
During execution of LDI R2, 6:
- The ALU and data memory remain idle.
- The write-back multiplexer selects the zero-extended 3-bit immediate field (value 6).
wr_addrreceives the destination register code for R2 (2'b10).reg_wr_enasserts for one clock cycle to capture the immediate value into register R2.- The Program Counter increments to fetch the next instruction byte.
The datapath integrates the register file, ALU, multiplexers, and memory interfaces. Routing multiplexers share physical execution units across different instruction formats. The next article designs the finite state machine and control logic that sequence these datapath lines.