Code Monkey home page Code Monkey logo

instruction-set-executant's Introduction

License Language Version

C++ Instruction Set Executant

This code is a C++ class called instruction_set that defines a set of methods and member variables for executing instructions. The code is implemented as a part of an instruction execution (sample) system like a compiler where instructions are loaded, executed, and operands are manipulated based on the given type.

  • The class instruction_set is defined with private member variables, including arrays stack, main_memory, p, r, and code, as well as scalar variables ip, flags, sp, and codesize.
  • The public section of the class contains several method declarations, including jump, compare, input, output, move, logic_and, logic_not, logic_xor, logic_or and etc. These methods perform various operations on operands and modify the state of the instruction execution.

RV32IM Instruction Set Executant

This repository also contains an implementation of a simple RISC-V Instruction Set Executant class in C++. The processor executes instructions from the RV32IM instruction set architecture. The src/RV32IM_instruction_set.h includes functions for reading and writing control and status registers (CSRs), as well as executing various instructions such as arithmetic operations, memory operations, branches, jumps, and system instructions.

The main components of the code are:

  • Declaration and initialization of registers: The code declares an array of 32 general-purpose registers and an unordered map for CSR registers.
  • Instruction execution: The execute_instruction function takes an instruction as input and performs the necessary operations based on the opcode and other fields of the instruction. It supports instructions for arithmetic operations, load/store operations, branches, jumps, and system instructions.
  • CSR operations: The code includes functions for reading and writing CSR registers. These functions handle different types of CSR instructions, such as CSRRW (read/write), CSRRS (read/set), CSRRC (read/clear), CSRRWI (read/write immediate), CSRRSI (read/set immediate), and CSRRCI (read/clear immediate).
  • Immediate value generation: The code includes logic for generating immediate values for different instruction types (I, S, B, U, J). The immediate values are used for operand calculations in instructions.

Overall, this code provides a basic implementation of a RISC-V processor that can execute a subset of the RV32IM instruction set.

[!Note]
Please be aware that the codes provided in this repository is designed for educational purpose and should not be considered suitable for professional applications. It is only offering examples and demonstrations of fundamental concepts. It is crucial to understand that this code may not meet the particular standards expected in a professional setting. Therefore, it is strongly advised to modify and enhance the code appropriately before utilizing it in any production or professional environment.

This repository contains open-source codes under the MIT license and is free to use.

  • Created By : Arvin Delavari - [email protected]
  • Iran University of Science and Technology, Electronics Research Center - October 2023
  • Digital Design Research Lab, Super-Computing and Networking (SCaN) Research Lab

instruction-set-executant's People

Contributors

arvindelavari avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

gmh5225

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.