Go to the documentation of this file.
63 using namespace ArmISA;
68 const int TarmacParserRecord::MaxLineLength;
69 int8_t TarmacParserRecord::maxVectorLength = 0;
71 TarmacParserRecord::ParserInstEntry TarmacParserRecord::instRecord;
72 TarmacParserRecord::ParserRegEntry TarmacParserRecord::regRecord;
73 TarmacParserRecord::ParserMemEntry TarmacParserRecord::memRecord;
74 TarmacBaseRecord::TarmacRecordType TarmacParserRecord::currRecordType;
77 TarmacParserRecord::destRegRecords;
78 char TarmacParserRecord::buf[TarmacParserRecord::MaxLineLength];
79 TarmacParserRecord::MiscRegMap TarmacParserRecord::miscRegMap = {
744 TarmacParserRecord::TarmacParserRecordEvent::process()
749 end = destRegRecords.end();
753 for (; it != end; ++it) {
758 values.push_back(thread->readIntReg(it->index));
761 if (instRecord.isetstate == ISET_A64) {
764 auto vv = vc.
as<uint32_t>();
765 values.push_back(vv[0]);
767 const VecElem elem = thread->readVecElem(
771 values.push_back(elem);
775 if (instRecord.isetstate == ISET_A64) {
778 auto vv = vc.
as<uint64_t>();
779 values.push_back(vv[0]);
781 const VecElem w0 = thread->readVecElem(
785 const VecElem w1 = thread->readVecElem(
790 values.push_back((uint64_t)(w1) << 32 | w0);
797 auto pv =
pc.as<uint8_t>();
799 for (
int i = maxVectorLength * 8;
i > 0; ) {
800 p = (
p << 1) | pv[--
i];
806 if (instRecord.isetstate == ISET_A64) {
809 auto vv = vc.
as<uint64_t>();
810 values.push_back(vv[0]);
811 values.push_back(vv[1]);
813 const VecElem w0 = thread->readVecElem(
817 const VecElem w1 = thread->readVecElem(
821 const VecElem w2 = thread->readVecElem(
825 const VecElem w3 = thread->readVecElem(
830 values.push_back((uint64_t)(w1) << 32 | w0);
831 values.push_back((uint64_t)(w3) << 32 | w2);
836 int8_t
i = maxVectorLength;
839 auto vv = vc.
as<uint64_t>();
841 values.push_back(vv[--
i]);
848 CPSR cpsr = thread->readMiscRegNoEffect(it->index);
849 cpsr.nz = thread->readCCReg(
CCREG_NZ);
850 cpsr.c = thread->readCCReg(
CCREG_C);
851 cpsr.v = thread->readCCReg(
CCREG_V);
852 cpsr.ge = thread->readCCReg(
CCREG_GE);
853 values.push_back(cpsr);
856 cpsr.nz = thread->readCCReg(
CCREG_NZ);
857 cpsr.c = thread->readCCReg(
CCREG_C);
858 cpsr.v = thread->readCCReg(
CCREG_V);
859 values.push_back(cpsr);
863 const uint32_t ones = (uint32_t)(-1);
872 fpcrMask.stride = ones;
873 fpcrMask.rMode = ones;
877 values.push_back(fpscr & fpcrMask);
881 const uint32_t ones = (uint32_t)(-1);
894 values.push_back(fpscr & fpsrMask);
896 values.push_back(thread->readMiscRegNoEffect(it->index));
900 panic(
"Unknown TARMAC trace record type!");
904 if (values.size() != it->values.size()) same =
false;
906 uint32_t size = values.size();
907 if (size > it->values.size())
908 size = it->values.size();
911 for (
int i = 0;
i < size; ++
i) {
912 if (values[
i] != it->values[
i]) {
921 TarmacParserRecord::printMismatchHeader(inst, *
pc);
924 outs <<
"diff> [" << it->repr <<
"] gem5: 0x" << std::hex;
925 for (
auto v : values)
926 outs << std::setw(16) << std::setfill(
'0') <<
v;
928 outs <<
", TARMAC: 0x" << std::hex;
929 for (
auto v : it->values)
930 outs << std::setw(16) << std::setfill(
'0') <<
v;
934 destRegRecords.clear();
936 if (mismatchOnPcOrOpcode && (parent.exitOnDiff ||
937 parent.exitOnInsnDiff))
938 exitSimLoop(
"a mismatch with the TARMAC trace has been detected "
939 "on PC or opcode", 1);
940 if (mismatch && parent.exitOnDiff)
941 exitSimLoop(
"a mismatch with the TARMAC trace has been detected "
946 TarmacParserRecord::TarmacParserRecordEvent::description()
const
948 return "TARMAC parser record event";
957 outs <<
"\nMismatch between gem5 and TARMAC trace @ " << std::dec
959 <<
"[seq_num: " << std::dec << instRecord.seq_num
960 <<
", opcode: 0x" << std::hex << (staticInst->
getEMI() & 0xffffffff)
961 <<
", PC: 0x" <<
pc.instAddr()
962 <<
", disasm: " << staticInst->
disassemble(
pc.instAddr()) <<
"]"
972 _pc, _macroStaticInst),
973 parsingStarted(false), mismatch(false),
974 mismatchOnPcOrOpcode(false), parent(_parent)
976 memReq = std::make_shared<Request>();
987 uint64_t written_data = 0;
1014 outs <<
"diff> [PC] gem5: 0x" << std::hex <<
pc->instAddr()
1023 outs <<
"diff> [opcode] gem5: 0x" << std::hex
1024 << arm_inst->encoding()
1037 outs <<
"diff> [iset_state] gem5: "
1058 outs <<
"diff> [mem(0x" << std::hex <<
memRecord.addr
1059 <<
")] gem5: 0x" << written_data
1069 panic(
"Unknown TARMAC trace record type!");
1081 exitSimLoop(
"a mismatch with the TARMAC trace has been detected "
1082 "on PC or opcode", 1);
1095 if (
buf[0] !=
'I') {
1101 assert((
buf[0] ==
'c') && (
buf[1] ==
'p') && (
buf[2] ==
'u'));
1109 if (
buf[0] ==
'I') {
1118 char c = trace.peek();
1136 warn(
"Invalid TARMAC trace record (seq_num: %lld)",
1144 }
else if (
buf[0] ==
'R') {
1150 if (std::tolower(
buf[0]) ==
'r' && isdigit(
buf[1])) {
1153 int base_index = atoi(&
buf[1]);
1154 char* pch = strchr(
buf,
'_');
1159 if (strncmp(pch,
"usr", 3) == 0)
1161 else if (strncmp(pch,
"fiq", 3) == 0)
1163 else if (strncmp(pch,
"irq", 3) == 0)
1165 else if (strncmp(pch,
"svc", 3) == 0)
1167 else if (strncmp(pch,
"mon", 3) == 0)
1169 else if (strncmp(pch,
"abt", 3) == 0)
1171 else if (strncmp(pch,
"und", 3) == 0)
1173 else if (strncmp(pch,
"hyp", 3) == 0)
1176 }
else if (std::tolower(
buf[0]) ==
'x' && isdigit(
buf[1])) {
1180 }
else if (std::tolower(
buf[0]) ==
's' && isdigit(
buf[1])) {
1184 }
else if (std::tolower(
buf[0]) ==
'd' && isdigit(
buf[1])) {
1188 }
else if (std::tolower(
buf[0]) ==
'q' && isdigit(
buf[1])) {
1192 }
else if (std::tolower(
buf[0]) ==
'z' && isdigit(
buf[1])) {
1196 }
else if (std::tolower(
buf[0]) ==
'p' && isdigit(
buf[1])) {
1200 }
else if (strncmp(
buf,
"SP_EL", 5) == 0) {
1210 std::string reg_name =
buf;
1211 std::transform(reg_name.begin(), reg_name.end(), reg_name.begin(),
1217 warn(
"Unknown register in TARMAC trace (%s).\n",
buf);
1227 uint64_t hi = strtoull(
buf, NULL, 16);
1229 uint64_t
lo = strtoull(
buf, NULL, 16);
1243 v = (
v << 32) | lsw;
1251 char c = trace.peek();
1252 if ((
c ==
':') || (
c ==
'_')) {
1256 v = (
v << 32) | lsw;
1266 char c = trace.peek();
1312 if (req->isLLSC() || req->isLocalAccess())
1340 saved_offset =
trace.tellg();
1341 trace >> buf >> buf >> buf;
1344 if (buf[0] ==
'I') {
1348 trace.seekg(saved_offset, std::ios::beg);
1357 panic(
"End of TARMAC trace reached before start PC\n");
1364 switch (isetstate) {
1368 return "Thumb (A32)";
1372 return "UNSUPPORTED";
Tick curTick()
The universal simulation clock.
bool mismatch
True if a mismatch has been detected for this instruction.
Addr instAddr() const
Returns the memory address of the instruction this PC points to.
static char buf[MaxLineLength]
Buffer used for trace file parsing.
bool memWrCheck
If true, memory write accesses are checked.
static IntRegIndex INTREG_FIQ(unsigned index)
static IntRegIndex INTREG_MON(unsigned index)
constexpr decltype(nullptr) NoFault
@ MISCREG_TLBI_VAAE1IS_Xt
constexpr unsigned NumVecElemPerNeonVecReg
VecPredReg::Container VecPredRegContainer
static std::list< ParserRegEntry > destRegRecords
List of records of destination registers.
@ VecElemClass
Vector Register Native Elem lane.
static int8_t maxVectorLength
Max.
@ MISCREG_TLBI_IPAS2E1IS_Xt
std::vector< EventQueue * > mainEventQueue
Array for main event queues.
static IntRegIndex INTREG_SVC(unsigned index)
static IntRegIndex INTREG_UND(unsigned index)
bool contains(const Addr &a) const
Determine if the range contains an address.
virtual BaseMMU * getMMUPtr()=0
virtual const PCStateBase & pcState() const =0
static IntRegIndex INTREG_USR(unsigned index)
@ MISCREG_TLBI_IPAS2LE1IS_Xt
@ MISCREG_TLBI_VMALLS12E1IS
@ MISCREG_TLBI_VALE2IS_Xt
static IntRegIndex INTREG_HYP(unsigned index)
@ MISCREG_TLBI_VALE1IS_Xt
@ MISCREG_ID_AA64AFR1_EL1
@ MISCREG_ID_AA64MMFR0_EL1
std::ifstream trace
TARMAC trace file.
T * get() const
Directly access the pointer itself without taking a reference.
@ MISCREG_ID_AA64DFR1_EL1
@ MISCREG_TLBI_VALE3IS_Xt
@ MISCREG_TLBI_VMALLS12E1
bool cpuId
If true, the trace format includes the CPU id.
@ funcRequestorId
This requestor id is used for functional requests that don't come from a particular device.
void exitSimLoop(const std::string &message, int exit_code, Tick when, Tick repeat, bool serialize)
Schedule an event to exit the simulation loop (returning to Python) at the end of the current cycle (...
@ MISCREG_DBGCLAIMCLR_EL1
AddrRange ignoredAddrRange
Ignored addresses (ignored if empty).
This proxy attempts to translate virtual addresses using the TLBs.
bool macroopInProgress
True if a macroop is currently in progress.
const char * iSetStateToStr(ISetState isetstate) const
Returns the string representation of an instruction set state.
Event triggered to check the value of the destination registers.
@ MISCREG_DBGAUTHSTATUS_EL1
static ParserInstEntry instRecord
Buffer for instruction trace records.
bool mismatchOnPcOrOpcode
True if a mismatch has been detected for this instruction on PC or opcode.
std::vector< uint64_t > values
union gem5::Trace::InstRecord::@119 data
@ MISCREG_DBGCLAIMSET_EL1
Vector Register Abstraction This generic class is the model in a particularization of MVC,...
ISetState
ARM instruction set state.
static ParserMemEntry memRecord
Buffer for memory access trace records (stores only).
@ MISCREG_ID_AA64PFR1_EL1
ThreadContext is the external interface to all thread state for anything outside of the CPU.
@ MISCREG_ID_AA64MMFR2_EL1
std::shared_ptr< FaultBase > Fault
VecElem * as()
View interposers.
static const int MaxLineLength
@ MISCREG_ID_AA64AFR0_EL1
uint64_t Tick
Tick count type.
std::shared_ptr< Request > RequestPtr
@ NO_ACCESS
The request should not cause a memory access.
static ParserRegEntry regRecord
Buffer for register trace records.
bool exitOnDiff
If true, the simulation is stopped as the first mismatch is detected.
Fault translateAtomic(const RequestPtr &req, ThreadContext *tc, Mode mode) override
@ MISCREG_TLBI_ASIDE1IS_Xt
std::ostream & output()
Get the ostream from the current global logger.
@ MISCREG_ID_AA64DFR0_EL1
@ MISCREG_ID_AA64MMFR1_EL1
uint64_t Addr
Address type This will probably be moved somewhere else in the near future.
bool isLastMicroop() const
RequestPtr memReq
Request for memory write checks.
@ MISCREG_ID_AA64ISAR1_EL1
@ MISCREG_TLBI_IPAS2LE1_Xt
std::unique_ptr< PCStateBase > pc
@ MISCREG_TLBI_VAALE1IS_Xt
bool FullSystem
The FullSystem variable can be used to determine the current mode of simulation.
bool readMemNoEffect(Addr addr, uint8_t *data, unsigned size, unsigned flags)
Performs a memory access to read the value written by a previous write.
Tarmac Parser: this tracer parses an existing Tarmac trace and it diffs it with gem5 simulation statu...
virtual uint64_t getEMI() const
Addr size
The size of the memory request.
static IntRegIndex INTREG_IRQ(unsigned index)
virtual const std::string & disassemble(Addr pc, const loader::SymbolTable *symtab=nullptr) const
Return string representation of disassembled instruction.
static IntRegIndex INTREG_ABT(unsigned index)
static MiscRegMap miscRegMap
static ISetState pcToISetState(const PCStateBase &pc)
Returns the Instruction Set State according to the current PCState.
bool parsingStarted
True if a TARMAC instruction record has already been parsed for this instruction.
Addr addr
The address that was accessed.
Addr startPc
Tracing starts when the PC gets this value for the first time (ignored if 0x0).
void advanceTraceToStartPc()
Helper function to advance the trace up to startPc.
@ VecRegClass
Vector Register.
bool exitOnInsnDiff
If true, the simulation is stopped as the first mismatch is detected on PC or opcode.
Reference material can be found at the JEDEC website: UFS standard http://www.jedec....
@ MISCREG_ID_AA64PFR0_EL1
bool advanceTrace()
Advances the TARMAC trace up to the next instruction, register, or memory access record.
@ MISCREG_TLBI_IPAS2E1_Xt
static TarmacRecordType currRecordType
Type of last parsed record.
unsigned flags
The flags that were assigned to the request.
@ MISCREG_ID_AA64ISAR0_EL1
Register ID: describe an architectural register with its class and index.
#define panic(...)
This implements a cprintf based panic() function.
static void printMismatchHeader(const StaticInstPtr inst, const PCStateBase &pc)
Print a mismatch header containing the instruction fields as reported by gem5.
Generated on Tue Dec 21 2021 11:34:22 for gem5 by doxygen 1.8.17