Giter Site home page Giter Site logo

javacpu's Introduction

This is a project I and @AzureAqua made during Year 11 (2022) for GCSE Computer Science. I have made some small changes before publishing this to make the code a bit more readable and to fix a couple minor bugs.

It contains:

  • a Java-based representation of a CPU, its key components, and the fetch-decode-execute cycle
  • an instruction set based on that of the little man computer.
  • an assembler for that instruction set

Everything is designed within the scope of GCSE Computer Science; don't expect anything too advanced!

The CPU represents a 64-bit computer. It has:

  • a RAM with configurable size (theoretically up to 2.15GB but only 256 addresses can be fetched)
    • the ability to read machine-code programs (from text files) into memory
      • ignores any characters other than 0 or 1, meaning you can include comments in the machine code
  • a CPU with configurable max clock speed (theoretically up to 1GHz, but there are multiple bottlenecks)
    • a control unit handling I/O
      • a decode unit to decode 16-bit instructions from 64-bit data
        • an instruction set with up to 256x 8-bit opcodes (listed in InstructionSet)
    • an ALU capable of addition, subtraction, multiplication, division, modulo and equality
    • the following registers:
      • an accumulator (stores 64-bit values)
      • a program counter (stored 8-bit address for the next instruction to execute)
      • a memory address register (stores 8-bit address currently being fetched from or stored to)
      • a memory data register (stored 64-bit data fetched from RAM)
      • a current instruction register (stored 8-bit opcode of current instruction)
  • a motherboard handling communication between the CPU and RAM
    • three buses connecting the RAM and CPU (address bus, data bus and control bus)
      • 16x 4-bit control signals. The First bit indicates read (0) or write (1) and the remaining bits indicate byte size

The assembly language supports the following features:

  • comments (started using a #)
  • variables (created and referenced using $name)
    • Optional initial variable values, placed after the variable name
  • address references (created and referenced using -name)
  • %end to reference the last address (used to produce arrays)

Currently, the only optimization the assembler makes is that it strips away any 0s from the end of the machine code

javacpu's People

Contributors

hopperelec avatar

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.