summaryrefslogtreecommitdiff
path: root/src/learning_gem5/part2/simple_object.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/learning_gem5/part2/simple_object.cc')
-rw-r--r--src/learning_gem5/part2/simple_object.cc26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/learning_gem5/part2/simple_object.cc b/src/learning_gem5/part2/simple_object.cc
index 76dadf9c8..66f1ca206 100644
--- a/src/learning_gem5/part2/simple_object.cc
+++ b/src/learning_gem5/part2/simple_object.cc
@@ -46,9 +46,18 @@ SimpleObject::SimpleObject(SimpleObjectParams *params) :
std::cout << "Hello World! From a SimObject!" << std::endl;
}
+bool SimpleObject::SimplePort::recvTimingResp(PacketPtr pkt)
+{
+ std::cout << "Receive packet, val = 0x" <<
+ std::hex << pkt->getLE<uint32_t>() <<
+ ". Tick = " << std::dec << curTick() << std::endl;
+ return true;
+}
+
void SimpleObject::processEvent()
{
- readAtomic();
+ // readAtomic();
+ readTiming();
}
void SimpleObject::readAtomic()
@@ -66,6 +75,21 @@ void SimpleObject::readAtomic()
std::cout << "read value 0x" << std::hex << val << std::endl;
}
+void SimpleObject::readTiming()
+{
+ RequestPtr req = std::make_shared<Request>(0x200000, 4, 0, masterId);
+ PacketPtr pkt = Packet::createRead(req);
+
+ // we cannot use a local stack variable in timing request
+ pkt->dataDynamic(new uint32_t);
+
+ bool res = memPort.sendTimingReq(pkt);
+ if (res) {
+ std::cout << "Successfully send timing request. Tick = " <<
+ curTick() << std::endl;
+ }
+}
+
void SimpleObject::writeAtomic()
{
RequestPtr req = std::make_shared<Request>(0x200000, 4, 0, masterId);