Skip to content

Commit

Permalink
Simple interface of Interpreter (#7)
Browse files Browse the repository at this point in the history
Co-authored-by: c71n93 <korostinskii.r@phystech.edu>
Co-authored-by: levBagryansky <28lev11@gmail.com>
  • Loading branch information
3 people authored Oct 6, 2023
1 parent b01fa47 commit 2dc4e93
Show file tree
Hide file tree
Showing 8 changed files with 78 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ cmake_minimum_required(VERSION 3.26)
project(ChaiVM)
set(CMAKE_CXX_STANDARD 17)

set(SOURCE_FILES src/main.cpp)
set(SOURCE_FILES src/main.cpp include/ChaiVM/interpreter/instruction.hpp include/ChaiVM/types.hpp include/ChaiVM/interpreter/executor.hpp include/ChaiVM/utils/non-copyable.hpp include/ChaiVM/interpreter/reg-file.hpp)

add_subdirectory(third_party)
add_subdirectory(test)
add_executable(${PROJECT_NAME} ${SOURCE_FILES})

include_directories(include)
14 changes: 14 additions & 0 deletions include/ChaiVM/interpreter/decoder.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#ifndef CHAIVM_DECODER_HPP
#define CHAIVM_DECODER_HPP

#include "instruction.hpp"

using namespace chai::interpreter;

class Decoder {

public:
Instruction parse(uint32_t word) ;
};

#endif //CHAIVM_DECODER_HPP
8 changes: 8 additions & 0 deletions include/ChaiVM/interpreter/executor.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CHAIVM_EXECUTOR_HPP
#define CHAIVM_EXECUTOR_HPP

class Executor {

};

#endif //CHAIVM_EXECUTOR_HPP
27 changes: 27 additions & 0 deletions include/ChaiVM/interpreter/instruction.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef CHAIVM_INSTRUCTION_HPP
#define CHAIVM_INSTRUCTION_HPP

#include <cstdint>

namespace chai::interpreter {


using Opcode = uint8_t;
using Register = uint8_t;
using Immediate = uint32_t;

enum Operation {
Inv,
};

struct Instruction {
Operation operation;
Immediate immediate;
Register src;
Register dst;
};


}

#endif //CHAIVM_INSTRUCTION_HPP
8 changes: 8 additions & 0 deletions include/ChaiVM/interpreter/reg-file.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#ifndef CHAIVM_REG_FILE_HPP
#define CHAIVM_REG_FILE_HPP

class RegisterFIle {

};

#endif //CHAIVM_REG_FILE_HPP
6 changes: 6 additions & 0 deletions include/ChaiVM/types.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#ifndef CHAIVM_TYPES_HPP
#define CHAIVM_TYPES_HPP

#include <cstdint>

#endif //CHAIVM_TYPES_HPP
11 changes: 11 additions & 0 deletions include/ChaiVM/utils/non-copyable.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#ifndef CHAIVM_NON_COPYABLE_HPP
#define CHAIVM_NON_COPYABLE_HPP

class INonCopyable {
public:
INonCopyable(const INonCopyable &rhs) = delete;
INonCopyable& operator=(const INonCopyable &rhs) = delete;
virtual ~INonCopyable() = 0;
};

#endif //CHAIVM_NON_COPYABLE_HPP
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#include <iostream>
#include "ChaiVM/interpreter/decoder.hpp"

int main() { std::cout << "Hello world" << std::endl; }

0 comments on commit 2dc4e93

Please sign in to comment.