This repository contains the Verilog implementation of a basic Process-in-Memory (PIM) system. The PIM system integrates memory, an Arithmetic Logic Unit (ALU), and a Control Unit (CU) to perform in-memory computations. The system supports basic memory read/write operations as well as arithmetic and logical operations on data stored in memory. A block diagram of the system is included in the repository.
- System Specifications
- Module Descriptions
- Instruction Format
- Operation Scenarios
- Testbench
- Simulation and Results
- Inputs:
clk: Clock signal for synchronization.rst: Reset signal to initialize the system.instruction: A 45-bit instruction for controlling operations.operation_enable: Signal to enable the execution of operations.
- Outputs:
data_out: 32-bit output data from memory or ALU.ready: Signal indicating the completion of an operation.
The ALU performs arithmetic and logical operations based on the opcode:
- Operations:
00: Addition (A + B)01: Subtraction (A - B)10: Bitwise AND (A & B)11: Bitwise OR (A | B)
The CU decodes the 45-bit instruction and generates control signals for memory, ALU, and registers. It handles:
- Memory read/write operations.
- ALU operation sequencing.
- Register file management.
A 1KB memory module with 32-bit words. Supports:
- Read operations: Outputs data at a specified address.
- Write operations: Stores data at a specified address.
Integrates the ALU and register file. It handles:
- Loading data into registers.
- Performing ALU operations.
- Outputting results.
A 2:1 multiplexer for selecting between:
- ALU output.
- Immediate data from the instruction.
A register file with two 32-bit registers for storing intermediate data during ALU operations.
The top-level module that integrates all components and manages the overall operation of the system.
The 45-bit instruction is divided into the following fields:
- Opcode (3 bits):
1xx: ALU operation (bits 1-0 specify the ALU operation).0xx: Memory operation (00for read, otherwise write).
- Operand A (10 bits): Address for memory read/write or the first ALU operand.
- Operand B (10 bits): Address for the second ALU operand.
- Operand C (10 bits): Address for storing the ALU result.
- Immediate Data (12 bits): Used for write operations (combined with Operands B and C to form a 32-bit value).
- Opcode:
001,010, or011. - Steps:
- Set
memory_writeto1. - Provide
memory_addressandimmediate_memory_data. - Wait for
readysignal to indicate completion.
- Set
- Opcode:
000. - Steps:
- Set
memory_readto1. - Provide
memory_address. - Wait for
readysignal and readdata_out.
- Set
- Opcode:
1xx. - Steps:
- Fetch the first operand from memory.
- Fetch the second operand from memory.
- Perform the ALU operation.
- Store the result in memory.
The testbench (tb) verifies the functionality of the PIM system. It includes tasks for:
- Writing to memory.
- Reading from memory.
- Performing ALU operations.
- Memory Initialization:
- Write edge-case values to memory (e.g., largest positive integer, smallest negative integer, zero).
- Verify writes by reading back the values.
- ALU Operations:
- Addition, subtraction, bitwise AND, and bitwise OR.
- Verify results by reading from memory.
Running the testbench file (tb.v) produces the following output:
- Arian Afzalzadeh
- Sina Imani
