Processor System Design Report
Table of Contents
- Introduction
- Design Overview
- ALU File
- Register File
- Control Signal
- Conclusion
- Appendix
Introduction
The objective of this project is to design and implement a simplified processor system capable of executing R-type instructions using Logisim, a digital logic simulator. This processor system integrates three primary components: a 32-bit Arithmetic Logic Unit (ALU), a 32-register register file, and a controller module. The system is synchronized using a clock signal to ensure coordinated operations. This report details the design, integration, and verification of these components to achieve the desired functionality.
Design Overview
The processor system is structured into four main modules:
- Register File (32 Registers): Manages data storage and retrieval, facilitating operand sourcing and result storage.
- 32-bit ALU: Performs arithmetic and logical operations on data retrieved from the register file.
- Controller Module: Generates control signals based on R-type instruction decoding to orchestrate the ALU and Register File operations.
- Clock: Synchronizes write operations and ensures orderly data flow within the system.
The integration of these components allows the processor to perform typical R-type instructions (e.g., add, subtract, AND, OR) by fetching operands from the register file, processing them through the ALU, and storing the results back into the register file. The controller module ensures that the appropriate operations are executed by interpreting the instruction codes and generating the necessary control signals.
System Architecture
[image: System Architecture]
Figure 1: High-level Architecture of the Processor System
The architecture diagram illustrates the interconnections between the Register File, ALU, Controller, and Clock modules. Data flows from the register file to the ALU, and upon operation completion, the results are written back to the register file under control of the Controller module, all synchronized by the clock.
ALU File
Overview
The 32-bit Arithmetic Logic Unit (ALU) is the computational heart of the processor, responsible for performing arithmetic and logic operations essential for executing R-type instructions.
Inputs
- Read Data 1 (32-bit): Data from the first source register (
rs) retrieved from the Register File.
- Read Data 2 (32-bit): Data from the second source register (
rt) retrieved from the Register File.
- ALU Control Signals (5-bit): Determines the specific operation to be performed (e.g., add, subtract, AND, OR).
Outputs
- ALU Result (32-bit): The outcome of the performed operation, which is written back to the Register File.
- Flags:
- Zero: Indicates if the ALU result is zero.
- Overflow: Indicates if an arithmetic overflow has occurred.
- Underflow: Indicates if an arithmetic underflow has occurred.
Supported Operations
The ALU is designed to support the following R-type operations:
- Addition (ADD)
- Subtraction (SUB)
- Bitwise AND (AND)
- Bitwise OR (OR)
- Set on Less Than (SLT)
Design Implementation
Using Logisim, the ALU is constructed using a combination of basic gates and pre-built arithmetic components. A 2⁵-bit control signal is mapped to the specific operation through a multiplexer that selects the appropriate operation circuitry based on the control inputs.
Integration with Register File
The ALU receives two 32-bit inputs from the Register File's output ports (Read Data 1 and Read Data 2). After performing the designated operation, the ALU's 32-bit result is fed back into the Register File as Write Data when the RegWrite signal is enabled.
Flag Management
The Zero flag is derived by OR-ing all bits of the ALU result to detect if the result is zero. The Overflow and Underflow flags are calculated based on the sign bits and the arithmetic results to detect anomalous computations.
Register File
Overview
The Register File serves as a small, fast-access storage area within the processor, holding 32 registers each 32 bits wide. It facilitates rapid reading and writing of operands and results essential for instruction execution.
Inputs
- Address Inputs:
- rs (5-bit): Address of the first source register.
- rt (5-bit): Address of the second source register.
- rd (5-bit): Address of the destination register.
- Write Data (32-bit): Data to be written into the destination register, typically the ALU result.
- RegWrite (Control Signal): Enables writing to the destination register.
- Clock: Synchronizes write operations to ensure data integrity.
Outputs
- Read Data 1 (32-bit): Data read from the
rs register.
- Read Data 2 (32-bit): Data read from the
rt register.
Design Implementation
The Register File is implemented using a collection of 32 registers, each capable of storing 32-bit data. Logisim's register components are utilized to build the storage, with multiplexers handling the selection of specific registers based on the address inputs. The RegWrite signal, governed by the Controller module, determines if a write operation should occur during a clock pulse.
Operational Flow
-
Read Phase:
- The
rs and rt addresses are decoded to select the corresponding registers.
- The data from these registers is output as
Read Data 1 and Read Data 2.
-
Write Phase:
- If
RegWrite is asserted, on the rising edge of the clock, the Write Data is written into the register specified by rd.
Integration with ALU
The Register File supplies the ALU with the operands necessary for computations. Post-ALU operation, the result is written back into the Register File, enabling the next instructions to operate on updated data.
Control Signal
Overview
The Controller module is pivotal in orchestrating the operations of the ALU and Register File. It interprets the R-type instruction opcode and generates the necessary control signals to enable appropriate data flow and operations within the processor.
Outputs
- ALU Control Signals (5-bit): Direct the ALU to perform specific operations.
- RegWrite (1-bit): Enables writing the ALU result back to the Register File.
Instruction Decoding
Given that the system is designed solely for R-type instructions, the Controller decodes the opcode and function fields to determine the required ALU operation. The 9-bit control signal comprises the ALU operation control and the RegWrite signal.
Design Implementation
Using a finite state machine (FSM) within Logisim, the Controller processes the instruction opcode by mapping it to predefined control signal patterns. Each R-type instruction (e.g., ADD, SUB) has a unique ALU control code, ensuring the ALU performs the correct operation.
Control Signal Mapping
| Instruction | Function Code | ALU Control Signal | RegWrite |
|---|
| ADD | 100000 | 00000 | 1 |
| SUB | 100010 | 00001 | 1 |
| AND | 100100 | 00010 | 1 |
| OR | 100101 | 00011 | 1 |
| SLT | 101010 | 00100 | 1 |
Table 1: Example Control Signal Mapping for R-type Instructions
Integration with ALU and Register File
The Controller's ALU control signals are directly connected to the ALU's control inputs, ensuring synchronized operation. The RegWrite signal is fed to the Register File, enabling it to accept the ALU result as Write Data when appropriate.
Clock
Overview
The clock is a fundamental component that synchronizes all operations within the processor system. It ensures that events such as register writes occur in a predictable and orderly fashion, maintaining data consistency and system reliability.
Design Implementation
In Logisim, the clock is implemented using a clock component configured to a specific frequency suitable for simulation purposes. The clock signal is distributed to the Register File and other synchronous components to coordinate their operations.
Operational Synchronization
- Register File Writes: The
RegWrite signal is evaluated in conjunction with the rising edge of the clock to determine when to write data into the specified register.
- ALU Operations: Although the ALU operations are combinational, their integration with the clock ensures that the system processes instructions in discrete time steps, aligned with clock cycles.
Testing and Verification
Ensuring the correctness of the processor system involved rigorous testing using various R-type instructions. The verification process focused on the following aspects:
-
ALU Operation Accuracy:
- Test Cases: Executed instructions like
ADD, SUB, AND, OR, and SLT with known operands.
- Verification: Compared the ALU results against expected outcomes to ensure accurate computations.
- Example:
- Instruction:
ADD R1, R2, R3
- Operands: R2 = 10, R3 = 20
- Expected Result: R1 = 30
-
Flag Functionality:
- Zero Flag: Verified by performing operations that result in zero (e.g.,
SUB R1, R2, R2).
- Overflow/Underflow Flags: Tested with operations that exceed the 32-bit signed integer range.
- Example:
- Instruction:
ADD R1, R2, R3 where R2 = 2³¹ - 1, R3 = 1
- Expected Result: Overflow flag set.
-
Register File Operations:
- Read Operations: Ensured that
Read Data 1 and Read Data 2 correctly reflect the contents of rs and rt.
- Write Operations: Confirmed that only the
rd register is updated when RegWrite is enabled, and that the correct data is written.
- Example:
- Instruction:
AND R4, R5, R6
- Operands: R5 = 0xFF00FF00, R6 = 0x00FF00FF
- Expected Result: R4 = 0x00000000
-
Synchronized Operations:
- Verified that all write operations occur on the correct clock cycle and that data is stable across clock edges.
Simulation Results
Example Instruction Execution
-
Instruction: ADD R1, R2, R3
-
Initial Register Values:
-
Expected Outcome:
- R1 = 42
- Zero Flag = 0
- Overflow Flag = 0
- Underflow Flag = 0
-
Simulation Screenshot:
[image: ADD Instruction Execution]
Figure 2: Register File and ALU States during ADD Instruction Execution
Flag Verification
- Zero Flag Test:
-
Instruction: SUB R4, R5, R5
-
Operands: R5 = 100
-
Expected R4: 0
-
Expected Flags: Zero = 1, Overflow = 0, Underflow = 0
-
Simulation Screenshot:
[image: Zero Flag Test]
Figure 3: Zero Flag Activated after Subtraction Resulting in Zero
- Overflow Flag Test:
-
Instruction: ADD R6, R7, R8
-
Operands: R7 = 2³¹ - 1, R8 = 1
-
Expected R6: Overflow occurs
-
Expected Flags: Zero = 0, Overflow = 1, Underflow = 0
-
Simulation Screenshot:
[image: Overflow Flag Test]
Figure 4: Overflow Flag Activated after Addition Resulting in Overflow
Conclusion of Testing
All test cases confirmed the correct functionality of the ALU operations, flag settings, and register file updates. The synchronized write operations aligned with the clock cycles, demonstrating reliable system behavior under various instruction executions.
Conclusion
This project successfully designed and implemented a processor system in Logisim capable of executing R-type instructions using a 32-bit ALU, a 32-register register file, and a dedicated controller module. The integration of these components was meticulously orchestrated to ensure accurate data flow and operation execution, synchronized by a clock signal. Comprehensive testing verified the system's correctness in performing arithmetic and logical operations, managing control flags, and handling register read/write operations. The modular design facilitates future expansions, such as incorporating additional instruction types or enhancing ALU capabilities.
Appendix
Logisim Project Structure
- Main Circuit (
Processor.lms): Integrates Register File, ALU, Controller, and Clock modules.
- Register File Module (
RegisterFile.lms): Contains all 32 registers with read/write logic.
- ALU Module (
ALU32.lms): Implements the 32-bit ALU with operation selection.
- Controller Module (
Controller.lms): Decodes instructions and generates control signals.
- Clock Module (
Clock.lms): Generates synchronized clock pulses.
Screenshots
Figure 5: Register File Contents during Instruction Execution
-
Control Signals:
[image: Control Signals]
Figure 6: Control Signal Transitions during Operation
-
ALU Operation:
[image: ALU Operation]
Figure 7: ALU Processing Read Data Inputs and Generating Result
Brief Report on Integration
The successful integration of the Register File, ALU, and Controller relies on precise interconnections and signal coordination. The Register File provides the necessary operands to the ALU, while the ALU's output is routed back into the Register File based on control signals from the Controller. The Controller interprets instruction opcodes to generate specific control signals that dictate ALU operations and manage register writes. Synchronization via the clock ensures that write operations occur seamlessly within clock cycles, preventing data races and ensuring system stability. The modular design allows each component to operate independently yet cohesively within the system, facilitating debugging and future enhancements.