forked from PrincetonUniversity/ILAng
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'ilair' into coverity_check
- Loading branch information
Showing
803 changed files
with
52,311 additions
and
5,503 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
[submodule "examples/RISC-V/simulator"] | ||
path = examples/RISC-V/simulator | ||
url = https://github.com/zhanghongce/riscv-ila-sim.git | ||
[submodule "glog"] | ||
path = glog | ||
url = https://github.com/google/glog.git | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,9 @@ language: cpp | |
os: linux | ||
sudo: required | ||
dist: trusty | ||
compiler: | ||
- g++ | ||
#- clang++ | ||
|
||
branches: | ||
only: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
main | ||
*~ | ||
*.o | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
|
||
export ROOT_PATH = $(shell pwd) | ||
export ILA_LIB = $(ROOT_PATH)/../../build/lib | ||
export ILA_HEADER = $(ROOT_PATH)/../../include | ||
|
||
CXX=clang++ | ||
CXX_FLAGS=-std=c++11 -Wall -fPIC | ||
CXX_FLAGS+=-I$(ILA_HEADER) | ||
LD_FLAGS=-L$(ILA_LIB) -lilatoolsd | ||
|
||
HDR_DIR=include | ||
SRC_DIR=src | ||
OBJ_DIR=obj | ||
|
||
HDR_FILES := $(wildcard $(HDR_DIR)/*.hpp) | ||
SRC_FILES := $(wildcard $(SRC_DIR)/*.cc) | ||
OBJ_FILES := $(patsubst $(SRC_DIR)/%.cc,$(OBJ_DIR)/%.o,$(SRC_FILES)) | ||
|
||
main: $(OBJ_FILES) | ||
$(CXX) $(LD_FLAGS) -o $@ $^ | ||
|
||
$(OBJ_DIR)/%.o: $(SRC_DIR)/%.cc $(OBJ_DIR) $(HDR_FILES) | ||
$(CXX) $(CXX_FLAGS) -I$(ROOT_PATH)/$(HDR_DIR) -c -o $@ $< | ||
|
||
$(OBJ_DIR): | ||
mkdir $(OBJ_DIR) | ||
|
||
all: main.exe | ||
|
||
clean: | ||
rm -rf $(OBJ_DIR)/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
RISC-V ILA | ||
--------------- | ||
|
||
User Level ISA : RV32I | ||
|
||
* 8 branch/jump instructions | ||
* 5 load instructions | ||
* 3 store instructions | ||
* 10 ALU instructions | ||
* 9 ALU-immediate instructions | ||
* 2 immediate instructions | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
#!/bin/sh | ||
|
||
export LD_LIBRARY_PATH=$(pwd)/../../build/lib/:$LD_LIBRARY_PATH | ||
export LIBRARY_PATH=$(pwd)/../../build/lib/:$LIBRARY_PATH | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
/******************** | ||
RISC-V Encoding | ||
********************/ | ||
|
||
#ifndef __RISCV_ENCODING_HPP__ | ||
#define __RISCV_ENCODING_HPP__ | ||
|
||
#define XLEN 32 | ||
#define INSTR_SIZE XLEN | ||
#define MEM_WORD_ADDR_LEN (XLEN-2) | ||
#define MEM_WORD XLEN | ||
|
||
|
||
#define OP_LEN 7 | ||
#define OPIMM BvConst(0x13, OP_LEN) | ||
#define LUI BvConst(0x37, OP_LEN) | ||
#define AUIPC BvConst(0x17, OP_LEN) | ||
#define OP BvConst(0x33, OP_LEN) | ||
#define BRANCH BvConst(0x63, OP_LEN) | ||
#define JAL BvConst(0x6f, OP_LEN) | ||
#define JALR BvConst(0x67, OP_LEN) | ||
#define LOAD BvConst(0x03, OP_LEN) | ||
#define STORE BvConst(0x23, OP_LEN) | ||
|
||
// funct3 for OPIMM | ||
|
||
#define FUNCT3_LEN 3 | ||
#define ADDI BvConst(0x0, FUNCT3_LEN) | ||
#define SLTI BvConst(0x2, FUNCT3_LEN) | ||
#define SLTIU BvConst(0x3, FUNCT3_LEN) | ||
#define ANDI BvConst(0x7, FUNCT3_LEN) | ||
#define ORI BvConst(0x6, FUNCT3_LEN) | ||
#define XORI BvConst(0x4, FUNCT3_LEN) | ||
#define SLLI BvConst(0x1, FUNCT3_LEN) | ||
#define SRLI BvConst(0x5, FUNCT3_LEN) | ||
#define SRAI BvConst(0x5, FUNCT3_LEN) | ||
|
||
#define FUNCT7_LEN 7 | ||
#define SLLIfunct7 BvConst(0x00, FUNCT7_LEN) | ||
#define SRLIfunct7 BvConst(0x00, FUNCT7_LEN) | ||
#define SRAIfunct7 BvConst(0x20, FUNCT7_LEN) | ||
#define funct7_NM BvConst(0x00, FUNCT7_LEN) | ||
#define funct7_PM BvConst(0x20, FUNCT7_LEN) | ||
|
||
// funct3 for OP | ||
#define ADD BvConst(0x0 , FUNCT3_LEN) | ||
#define SLL BvConst(0x1 , FUNCT3_LEN) | ||
#define SLT BvConst(0x2 , FUNCT3_LEN) | ||
#define SLTU BvConst(0x3 , FUNCT3_LEN) | ||
#define XOR BvConst(0x4 , FUNCT3_LEN) | ||
#define SRL BvConst(0x5 , FUNCT3_LEN) | ||
#define OR BvConst(0x6 , FUNCT3_LEN) | ||
#define AND BvConst(0x7 , FUNCT3_LEN) | ||
#define SUB BvConst(0x0 , FUNCT3_LEN) | ||
#define SRA BvConst(0x5 , FUNCT3_LEN) | ||
|
||
// funct 3 for BRANCH | ||
#define BEQ BvConst(0x0, FUNCT3_LEN) | ||
#define BNE BvConst(0x1, FUNCT3_LEN) | ||
#define BLT BvConst(0x4, FUNCT3_LEN) | ||
#define BGE BvConst(0x5, FUNCT3_LEN) | ||
#define BLTU BvConst(0x6, FUNCT3_LEN) | ||
#define BGEU BvConst(0x7, FUNCT3_LEN) | ||
|
||
// funct 3 for L/S | ||
#define BYTE BvConst(0x0 , FUNCT3_LEN) | ||
#define HALF BvConst(0x1 , FUNCT3_LEN) | ||
#define WORD BvConst(0x2 , FUNCT3_LEN) | ||
#define DOUBLE BvConst(0x3 , FUNCT3_LEN) | ||
#define BU BvConst(0x4 , FUNCT3_LEN) | ||
#define HU BvConst(0x5 , FUNCT3_LEN) | ||
#define WU BvConst(0x6 , FUNCT3_LEN) | ||
|
||
|
||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/******************** | ||
ILA helpers | ||
********************/ | ||
|
||
|
||
#ifndef __ILA_HELPER_HPP__ | ||
#define __ILA_HELPER_HPP__ | ||
|
||
/* | ||
template<typename First, typename ... Rest> | ||
ExprRef mConcat(const First & arg, const Rest & ... rest ) { | ||
return Concat( arg , mConcat(rest...) ); | ||
} | ||
*/ | ||
|
||
#include <list> | ||
typedef std::list<ila::ExprRef> exp_list; | ||
ila::ExprRef lConcat(const exp_list & l); | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/******************** | ||
RISC-V ILA | ||
********************/ | ||
|
||
#ifndef __RISCV_ILA_HPP__ | ||
#define __RISCV_ILA_HPP__ | ||
|
||
#include <vector> | ||
|
||
#include "encoding.hpp" | ||
|
||
|
||
|
||
class riscvILA_user | ||
{ | ||
|
||
Ila model; | ||
|
||
ExprRef pc; | ||
ExprRef mem; | ||
std::vector<ExprRef> GPR; // R0-R31 | ||
|
||
std::set<std::string> Instrs; | ||
std::map<std::string, InstrRef> InstrMap; | ||
|
||
ExprRef inst; | ||
|
||
ExprRef opcode; | ||
ExprRef rd; | ||
ExprRef rs1; | ||
ExprRef rs2; | ||
ExprRef funct3; | ||
ExprRef funct7; | ||
ExprRef funct12; | ||
ExprRef immI; | ||
ExprRef immS; | ||
ExprRef immB; | ||
ExprRef immU; | ||
ExprRef immJ; | ||
ExprRef csr_index; | ||
|
||
protected: | ||
ExprRef indexIntoGPR(const ExprRef & idxBits); | ||
void UpdateGPR(InstrRef & inst, const ExprRef & idxBits, const ExprRef & val ); | ||
|
||
ExprRef bv(int val) { return BvConst(val, XLEN); } | ||
ExprRef zext(const ExprRef & v) {return ZExt( v, XLEN ); } | ||
ExprRef sext(const ExprRef & v) {return SExt( v, XLEN ); } | ||
|
||
ExprRef getSlice(const ExprRef & word,const ExprRef & lowBits, int width, bool unSigned); | ||
ExprRef CombineSlices(const ExprRef & word, const ExprRef & lowBits, int width, const ExprRef & old); | ||
|
||
|
||
// privileged model will overload these to insert their address translation | ||
virtual ExprRef FetchFromMem(const ExprRef &m, const ExprRef &addr) { return Load(m,addr); } | ||
virtual ExprRef LoadFromMem (const ExprRef &m, const ExprRef &addr) { return Load(m,addr); } | ||
virtual ExprRef StoreToMem (const ExprRef &m, const ExprRef &addr , const ExprRef &data) { return Store(m,addr,data); } | ||
|
||
public: | ||
riscvILA_user( int pc_init_val ); | ||
void addInstructions(); | ||
}; | ||
|
||
|
||
|
||
|
||
class riscvILA_machine : public riscvILA_user | ||
{ | ||
}; | ||
|
||
|
||
|
||
|
||
#endif |
Oops, something went wrong.