Git Product home page Git Product logo

r0-cpu's Introduction

R0-CPU

alt tag

Intro

R0 is a hard-wired 8-bit CPU, built on Von Neumann Architecture.
It was built as an application on the theory of Computer Organization.

Instruction Set

  • Half of the instructions in the instruction set fit into one byte.

  • These instructions are identified by a 0 in the most-significant bit in the instruction, i.e. op1 = 0X.

  • The 4 bits of opcode are split into op1 and op2.

  • Rd is the destination register, and Rs is the source register.

  • The other half of the instruction set are two-byte instructions. The first byte has the same format as above, and it is followed by an 8-bit constant or immediate value

  • These two-byte instructions are identified by a 1 in the most-significant bit in the instruction, i.e. op1 = 1X.

  • With 4 operation bits, there are 16 instructions.

op1 op2 Mnemonic Purpose
00 00 AND Rd, Rs Rd = Rd AND Rs
00 01 OR Rd, Rs Rd = Rd OR Rs
00 10 ADD Rd, Rs Rd = Rd + Rs
00 11 SUB Rd, Rs Rd = Rd - Rs
01 00 LW Rd, (Rs) Rd = Mem[Rs]
01 01 SW Rd, (Rs) Mem[Rs] = Rd
01 10 MOV Rd, Rs Rd = Rs
01 11 NOP Do nothing
10 00 JEQ Rd, immed PC = immed if Rd == 0
10 01 JNE Rd, immed PC = immed if Rd != 0
10 10 JGT Rd, immed PC = immed if Rd > 0
10 11 JLT Rd, immed PC = immed if Rd < 0
11 00 LW Rd, immed Rd = Mem[immed]
11 01 SW Rd, immed Mem[immed] = Rd
11 10 LI Rd, immed Rd = immed
11 11 JMP immed PC = immed

Architecture

  • The CPU has an 8-bit data bus and an 8-bit address bus, so it can only support 256 bytes of memory to hold both instructions and data.

  • Internally, there are four 8-bit registers, R0 to R3, plus an Instruction Register, the Program Counter, and an 8-bit register which holds immediate values.

  • The ALU is the same one that we designed last week. It performs the four operations AND, OR, ADD and SUB on two 8-bit values, and supports signed ADDs and SUBs.

  • The CPU is a load/store architecture: data has to be brought into registers for manipulation, as the ALU only reads from and writes back to the registers.

  • The ALU operations have two operands: one register is a source register, and the second register is both source and destination register, i.e. destination register = destination register OP source register.

  • All the jump operations perform absolute jumps; there are no PC-relative branches. There are conditional jumps based on the zeroness or negativity of the destination register, as well as a "jump always" instruction.

  • The dbus and sbus labels indicate the lines coming out from the register file which hold the value of the destination and source registers.

  • Note the data loop involving the registers and the ALU, whose output can only go back into a register.

  • The dataout bus is only connected to the dbus line, so the only value which can be written to memory is the destination register.

License

This Project is signed under MIT License.

r0-cpu's People

Contributors

mohammedrashad 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.