ETISS 0.8.0
Extendable Translating Instruction Set Simulator (version 0.8.0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RV32IMACFD_ZifenceiInstr.cpp
Go to the documentation of this file.
1
8#include "RV32IMACFDArch.h"
9#include "RV32IMACFDFuncs.h"
10
11using namespace etiss;
12using namespace etiss::instr;
13
14
15// FENCE_I ---------------------------------------------------------------------
18 "fence_i",
19 (uint32_t) 0x00100f,
20 (uint32_t) 0x00707f,
22 {
23
24// -----------------------------------------------------------------------------
25
26// -----------------------------------------------------------------------------
27
28// -----------------------------------------------------------------------------
29etiss_uint8 rd = 0;
30static BitArrayRange R_rd_0(11, 7);
31rd += R_rd_0.read(ba) << 0;
32etiss_uint8 rs1 = 0;
33static BitArrayRange R_rs1_0(19, 15);
34rs1 += R_rs1_0.read(ba) << 0;
35etiss_uint16 imm = 0;
36static BitArrayRange R_imm_0(31, 20);
37imm += R_imm_0.read(ba) << 0;
38
39// -----------------------------------------------------------------------------
40
41 {
43
44 cp.code() = std::string("//FENCE_I\n");
45
46// -----------------------------------------------------------------------------
47cp.code() += "cpu->exception = ETISS_RETURNCODE_RELOADBLOCKS;\n";
48cp.code() += "etiss_coverage_count(1, 148);\n";
49{ // block
50cp.code() += "etiss_coverage_count(1, 1169);\n";
51cp.code() += "{ // block\n";
52cp.code() += "cpu->nextPc = " + std::to_string(ic.current_address_ + 4) + "ULL;\n";
53cp.code() += "etiss_coverage_count(5, 1168, 1164, 1167, 1165, 1166);\n";
54cp.code() += "} // block\n";
55} // block
56cp.code() += "((RV32IMACFD*)cpu)->FENCE[1ULL] = " + std::to_string(imm) + "ULL;\n";
57cp.code() += "etiss_coverage_count(3, 6360, 6358, 6359);\n";
58cp.code() += "instr_exit_" + std::to_string(ic.current_address_) + ":\n";
59cp.code() += "cpu->instructionPointer = cpu->nextPc;\n";
60// -----------------------------------------------------------------------------
61 cp.getAffectedRegisters().add("instructionPointer", 32);
62 }
63 {
65
66 cp.code() = std::string("//FENCE_I\n");
67
68// -----------------------------------------------------------------------------
69cp.code() += "return cpu->exception;\n";
70// -----------------------------------------------------------------------------
71 }
72
73 return true;
74 },
75 0,
76 [] (BitArray & ba, Instruction & instr)
77 {
78// -----------------------------------------------------------------------------
79etiss_uint8 rd = 0;
80static BitArrayRange R_rd_0(11, 7);
81rd += R_rd_0.read(ba) << 0;
82etiss_uint8 rs1 = 0;
83static BitArrayRange R_rs1_0(19, 15);
84rs1 += R_rs1_0.read(ba) << 0;
85etiss_uint16 imm = 0;
86static BitArrayRange R_imm_0(31, 20);
87imm += R_imm_0.read(ba) << 0;
88
89// -----------------------------------------------------------------------------
90
91 std::stringstream ss;
92// -----------------------------------------------------------------------------
93ss << "fence_i" << " # " << ba << (" [rd=" + std::to_string(rd) + " | rs1=" + std::to_string(rs1) + " | imm=" + std::to_string(imm) + "]");
94// -----------------------------------------------------------------------------
95 return ss.str();
96 }
97);
etiss::instr::InstructionGroup ISA32_RV32IMACFD("ISA32_RV32IMACFD", 32)
static InstructionDefinition fence_i_rd_rs1_imm(ISA32_RV32IMACFD, "fence_i",(uint32_t) 0x00100f,(uint32_t) 0x00707f, [](BitArray &ba, etiss::CodeSet &cs, InstructionContext &ic) { etiss_uint8 rd=0;static BitArrayRange R_rd_0(11, 7);rd+=R_rd_0.read(ba)<< 0;etiss_uint8 rs1=0;static BitArrayRange R_rs1_0(19, 15);rs1+=R_rs1_0.read(ba)<< 0;etiss_uint16 imm=0;static BitArrayRange R_imm_0(31, 20);imm+=R_imm_0.read(ba)<< 0;{ CodePart &cp=cs.append(CodePart::INITIALREQUIRED);cp.code()=std::string("//FENCE_I\n");cp.code()+="cpu->exception = ETISS_RETURNCODE_RELOADBLOCKS;\n";cp.code()+="etiss_coverage_count(1, 148);\n";{ cp.code()+="etiss_coverage_count(1, 1169);\n";cp.code()+="{ // block\n";cp.code()+="cpu->nextPc = "+std::to_string(ic.current_address_+4)+"ULL;\n";cp.code()+="etiss_coverage_count(5, 1168, 1164, 1167, 1165, 1166);\n";cp.code()+="} // block\n";} cp.code()+="((RV32IMACFD*)cpu)->FENCE[1ULL] = "+std::to_string(imm)+"ULL;\n";cp.code()+="etiss_coverage_count(3, 6360, 6358, 6359);\n";cp.code()+="instr_exit_"+std::to_string(ic.current_address_)+":\n";cp.code()+="cpu->instructionPointer = cpu->nextPc;\n";cp.getAffectedRegisters().add("instructionPointer", 32);} { CodePart &cp=cs.append(CodePart::APPENDEDRETURNINGREQUIRED);cp.code()=std::string("//FENCE_I\n");cp.code()+="return cpu->exception;\n";} return true;}, 0, [](BitArray &ba, Instruction &instr) { etiss_uint8 rd=0;static BitArrayRange R_rd_0(11, 7);rd+=R_rd_0.read(ba)<< 0;etiss_uint8 rs1=0;static BitArrayRange R_rs1_0(19, 15);rs1+=R_rs1_0.read(ba)<< 0;etiss_uint16 imm=0;static BitArrayRange R_imm_0(31, 20);imm+=R_imm_0.read(ba)<< 0;std::stringstream ss;ss<< "fence_i"<< " # "<< ba<<(" [rd="+std::to_string(rd)+" | rs1="+std::to_string(rs1)+" | imm="+std::to_string(imm)+"]");return ss.str();})
uint8_t etiss_uint8
Definition types.h:87
uint16_t etiss_uint16
Definition types.h:90
Contains a small code snipped.
Definition CodePart.h:386
@ APPENDEDRETURNINGREQUIRED
Definition CodePart.h:402
std::string & code()
Definition CodePart.h:416
RegisterSet & getAffectedRegisters()
Definition CodePart.h:414
A set of CodeParts.
Definition CodePart.h:437
void append(const CodePart &part, CodePart::TYPE type)
Definition CodePart.h:450
void add(const RegisterPart &rp)
add a registerPart to the set or just its relevant bits if a register with the same name is already p...
Definition CodePart.h:222
Reading through it will only return bits within the range.
I read(const BitArray &ba)
reads bits from the range to the return value starting at the lsb.
stores a bit vector
this class contains parameters that persist in between instruction lookpus/translation within a trans...
uint64_t current_address_
start address of current instruction
holds information and translation callbacks for an instruction.
Page Table Entry (PTE) defines the composition of Page Frame Number (PFN) and relavant flags.
Definition Benchmark.h:53