Skip to content

DarkHawk727/ARM-LEG-Simulator

Repository files navigation

█████╗ ██████╗ ███╗ ███╗ ██╗ ███████╗ ██████╗ ██╔══██╗██╔══██╗████╗ ████║ ██║ ██╔════╝██╔════╝ ███████║██████╔╝██╔████╔██║█████╗██║ █████╗ ██║ ███╗ ██╔══██║██╔══██╗██║╚██╔╝██║╚════╝██║ ██╔══╝ ██║ ██║ ██║ ██║██║ ██║██║ ╚═╝ ██║ ███████╗███████╗╚██████╔╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚══════╝╚══════╝ ╚═════╝

python pseudo-ARM program simulator

License: MIT

This is a Python program to "simulate" the subset of the subset of ARM we use in CS 251: Computer Organization and Design. The word simulate is used loosely as this program doesn't execute the instructions how a real CPU would, its behaviorally? equivalent to it.

Program Structure

.
├── arm_leg/
│   ├── components/
│   │   ├── cpu.py
│   │   ├── data_memory.py
│   │   └── register_file.py
│   ├── instructions/
│   │   ├── b_format.py
│   │   ├── cb_format.py
│   │   ├── d_format.py
│   │   ├── i_format.py
│   │   ├── instruction.py
│   │   ├── nop.py
│   │   ├── opcodes.py
│   │   └── r_format.py
│   ├── __init__.py
│   ├── main.py
│   └── utils.py
├── tests/
│   ├── test_arithmetic_operations.py
│   ├── test_branching.py
│   ├── test_load_store.py
│   └── test_parsing_instructions.py
├── .gitignore
├── conftest.py
├── instruction_documentation.md
├── LICENSE
├── readme.md
└── requirements.txt

Installation

⚠️ This program requires python >=3.10.

Clone the repository

git clone https://github.com/DarkHawk727/ARM-LEG-Simulator/

then install the dependencies

pip install -r requirements.txt

Usage

ℹ️ For information about how to write your pseudo-ARM programs, see the Instruction Documentation.

Using ARM-LEG in the Command Line

ARM-LEG -f "some/folder/example.txt" -p ["BOTH" | "MEM" | "REG"] -m 1000

(you can use --help to display this in the command line)

The print option will either display the contents of the memory, the registers, or both for each iteration of the pseudo-ARM program; this means that the outputs can get quite long. The -m option will set a max-iterations count so that in the case of an infinite loop, the program does terminate.

(you can redirect the outputs to a textfile using standard output redirection)

Current Limitations

  • Doesn't support X31 immutability.
  • Doesn't support X31 aliasing with XZR.
  • Doesn't support comments?
  • Need to add tests for all instructions
  • Programs must be at most 31 instructions long (Just 31 stores or smth) since they are stored in the registers (need to move them to memory)
  • Cannot parse XOR due to how tokenize() works.

Future Improvements

  • Pipelining? This model of computation isn’t strictly required but could be useful for simulation purposes
    • Stalls
    • Flushes
    • Branch Prediction
  • Code rearrangement?
  • Control unit with its signals
  • Having a diagram like in Markdeep to show the value of various components in the datapath.
  • Set-Associative and Direct-Mapped Caches?
  • Adding the binary number (highlighted by field) for each instruction

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request.

About

ARM/LEG Simulator in Python for CS 251

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages