3

Build Your Own PC - Java-based Compiler and Assembler

A Java assignment simulating a basic computer system, featuring memory management, an ALU, and custom commands using a compiler and assembler. Built using Java in NetBeans IDE.

Build Your Own PC - Java-based Compiler and Assembler

Overview

Build Your Own PC is a Java project simulating a basic computer architecture, including memory, an Arithmetic Logic Unit (ALU), registers, and a compiler. Developed as an assignment, it focuses on using Java commands to assemble and compile code, providing low-level operation simulations and memory management.

Key Components

  • Memory Management: Simulates computer memory, allowing register manipulation and memory access.
  • Arithmetic Logic Unit (ALU): Executes logical and arithmetic operations as per the instructions.
  • Registers and Bit Operations: Implements registers and basic bit manipulation, supporting various computational commands.
  • Assembler and Compiler Integration: Uses Java commands to compile and assemble instructions, enabling the simulation of basic computer processes.

Unit Test Cases

The project includes a comprehensive suite of unit tests to ensure the correct functioning of each component. Here’s a breakdown of the test cases:

  1. Register Filling Test:
    • The filler() function fills registers with predefined values, ranging from 0 to 15, simulating data population in memory.
  2. ALU Tests:
    • Two separate tests (ALUtest and ALUtest1) to verify the functionality of arithmetic and logic operations.
    • Commands include loading and executing instructions with cpu.preload() and cpu.run().
  3. Move Operation Tests:
    • movetest and movetest1 simulate moving data between registers, ensuring correct data handling and transfer within memory.
  4. Halt Tests:
    • Two test cases, halttest and halttest1, are included to test the halt functionality, simulating the stopping of processes.

Sample Test Execution

Each test case simulates CPU operations using preloaded commands. Example output:

// Test: ALU Operations
System.out.println("-----------------CPU 0 [ALU test]---------------");
cpu.fillregister(filler());
cpu.preload(ALUtest);
cpu.run();

Tech Stack

  • Programming Language: Java
  • Frameworks/Libraries: Java core libraries
  • IDE: NetBeans
  • Features: Memory, ALU, Longword, Assembler, Bit manipulation

Development & Setup

This project is developed in Java and requires NetBeans IDE for testing and modification.

  1. Clone Repository:

    git clone https://github.com/yourusername/build-your-own-pc
    cd build-your-own-pc
    
  2. Run Tests:

    • Open Computer_test in NetBeans IDE and run the runtests() function to execute all test cases.

Access & Documentation

Since this is an offline project, all functionalities and tests can be run directly within NetBeans.


This project demonstrates a foundational understanding of computer architecture principles, including memory, ALU, and compiler simulation, implemented in Java.