Skip to content

JohnMachado11/CS104-Computer-Architecture

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 

Repository files navigation

CS104-Computer-Architecture

https://www.codecademy.com/learn/paths/computer-science

The code for this project is largely designed by Codecademy authors, I do not take full credit for it. I did however add a couple of methods of my own to the UltraSuperCalculator class as well as error catching in some areas of the code. I also added a "Binary Template" at the bottom of main.py to aid the user in sending instructions to the program.

Overall this was just a really cool project to build.

As a result I ended up learning a lot about how ISA's (Instruction Set Architecture) function such as:

  • CISC (Complex Instruction Set Computer)
  • RISC (Reduced Instruction Set Computer)
  • MIPS (Microprocessor without Interlocked Pipelined Stages)
 USCC (Ultra Super Calculation Computer) Headquarter's Instruction Set Architecture

  System Design:
   - Four function calculator
   - Can only operate on numbers stored in registers
   - Processor receives binary data as 32-bit strings
   - Returns results to the terminal
   - Can operate on 10-bit numbers (0 thru 1023)
   - Results can be negative (5 - 10 = -5)
  Instruction format:
   - 32 bit's in length
   - Binary data will come to the CPU as a string
   - Registers (32 total on CPU, 0-indexed)
      - 0 thru 21:  Available for number storage
        - 0: Constant 0
      - 22 thru 31: Available for history storage
 +=======+=======+=======+=======+=======+=======+=======+=======+
 | 0: 0  | 1:    | 2:    | 3:    | 4:    | 5:    | 6:    | 7:    |
 +-------+-------+-------+-------+-------+-------+-------+-------+
 | 8:    | 9:    |10:    |11:    |12:    |13:    |14:    |15:    |
 +-------+-------+-------+-------+-------+-------+-------+-------+
 |16:    |17:    |18:    |19:    |20:    |21:    |22: H0 |23: H1 |
 +-------+-------+-------+-------+-------+-------+-------+-------+
 |24: H2 |25: H3 |26: H4 |27: H5 |28: H6 |29: H7 |30: H8 |31: H9 |
 +=======+=======+=======+=======+=======+=======+=======+=======+
   - Bits 0-5 are OPCODEs
     - use variable 'opcode' in program
   - Bits 6-10 & 11-15 are source register locations
     - use variables 'source_one' and 'source_two' in program
   - Bits 16-25 are reserved for adding a new value to the registers
     - use variable 'store' in program
   - Bits 26-31 are functions
     - use variable 'function_code' in program
 +--------+----------+-------------------------------------+
 | OPCODE | FUNCTION | Definition                          |
 | 000000 |  100000  | Add two numbers from registers      |
 | 000000 |  100010  | Subtract two numbers from registers |
 | 000000 |  011000  | Multiply two numbers from registers |
 | 000000 |  011010  | Divide two numbers from registers   |
 | 000001 |  000000  | Store value to next register        |
 | 100001 |  000000  | Return previous calculation         |
 +--------+----------+-------------------------------------+

Image credit: Codecademy Imgur Image

About

Python implementation of a 32-bit processor with its own ISA (Instruction Set Architecture)

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages