Minor simulator updates
Signed-off-by: Caleb Palmer <cnpalmer@us.ibm.com>
Change-Id: I351e5a9b8435c7aa3cfdec275ab183b50aa5e3d1
diff --git a/test/simulator/simulator.cpp b/test/simulator/simulator.cpp
index b68ec80..572809e 100644
--- a/test/simulator/simulator.cpp
+++ b/test/simulator/simulator.cpp
@@ -22,7 +22,7 @@
//------------------------------------------------------------------------------
-void SimulatorData::addChip(const Chip& i_chip)
+void SimulatorData::addChip(const Chip& i_chip, const char* i_chipPath)
{
// First check if this entry already exists.
auto chip_itr = std::find(iv_chipList.begin(), iv_chipList.end(), i_chip);
@@ -42,10 +42,20 @@
// Add the new entry.
iv_typeList.push_back(chipType);
- // Look for the file path
- auto itr2 = cv_chipPath.find(static_cast<SimChipType>(chipType));
- ASSERT_NE(cv_chipPath.end(), itr2);
- const char* path = itr2->second;
+ // Look for the file path, if a path was provided use that instead of one
+ // of the hardcoded values in the map.
+ ASSERT_TRUE(nullptr != i_chipPath);
+ const char* path = "";
+ if (0 != strcmp(i_chipPath, ""))
+ {
+ path = i_chipPath;
+ }
+ else
+ {
+ auto itr2 = cv_chipPath.find(static_cast<SimChipType>(chipType));
+ ASSERT_NE(cv_chipPath.end(), itr2);
+ path = itr2->second;
+ }
// Open the Chip Data File
std::ifstream cdf{path, std::ifstream::binary};
@@ -103,11 +113,11 @@
//------------------------------------------------------------------------------
-void SimulatorData::endIteration()
+void SimulatorData::simIsolate(IsolationData& o_isoData)
{
// Start by calling libhei::isolate().
IsolationData isoData{};
- isolate(iv_chipList, isoData);
+ isolate(iv_chipList, o_isoData);
/* TODO: Currently used for debug. Eventually, we want this written to file.
for (const auto& e : isoData.getRegisterDump())
@@ -123,7 +133,7 @@
*/
// Get the list of signatures found in isolation.
- std::vector<Signature> givenSigList = isoData.getSignatureList();
+ std::vector<Signature> givenSigList = o_isoData.getSignatureList();
// Print out the expected signature list and verify matches with given list.
HEI_INF("Signature summary:")
@@ -163,6 +173,15 @@
// Final check for mismatches.
ASSERT_FALSE(mismatch);
+}
+
+//------------------------------------------------------------------------------
+
+void SimulatorData::endIteration()
+{
+ // First call simIsolate to isolate and check the expected signatures.
+ IsolationData isoData{};
+ simIsolate(isoData);
// The iteration is complete so we can flush the data.
flushIterationData();
diff --git a/test/simulator/simulator.hpp b/test/simulator/simulator.hpp
index e3b6bef..b1079d8 100644
--- a/test/simulator/simulator.hpp
+++ b/test/simulator/simulator.hpp
@@ -78,7 +78,7 @@
* initialize() API which will initialize the isolator with the Chip
* Data File associated with this chip.
*/
- void addChip(const Chip& i_chip);
+ void addChip(const Chip& i_chip, const char* i_chipPath = "");
/** @brief Retrieve ScomReg from map and return its value */
uint64_t getScomReg(const Chip& i_chip, uint32_t i_address)
@@ -154,9 +154,15 @@
}
/**
+ * @brief Runs the simulation for isolation and verifies the expected
+ * signatures.
+ */
+ void simIsolate(IsolationData& o_isoData);
+
+ /**
* @brief After an iteration is set up with registers and expected
* signatures, this is called to run the simulation and verify the
- * expected signatures.
+ * expected signatures and will then flush the iteration data.
*/
void endIteration();
};