Skip to content

Commit

Permalink
cpu-o3: Split operations in the ldst pipeline
Browse files Browse the repository at this point in the history
Now initiateAcc only does tlb access and is located at s0 of the load/store pipeline.

Load makes cache access and query violations at s1, receives the cache response at s2, and writes back at s3.
Store updates sq and query violations at s1, and writes back at s4.

AMO operations are now executed using `executeAmo`.

Change-Id: Iac678b7de3a690329f279c70fdcd22be4ed22715
  • Loading branch information
happy-lx committed Dec 9, 2024
1 parent 08a32d3 commit fb23649
Show file tree
Hide file tree
Showing 5 changed files with 481 additions and 199 deletions.
2 changes: 1 addition & 1 deletion src/cpu/o3/iew.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1468,7 +1468,7 @@ IEW::executeInsts()
// Tell the LDSTQ to execute this instruction (if it is a load).
if (inst->isAtomic()) {
// AMOs are treated like store requests
fault = ldstQueue.executeStore(inst);
fault = ldstQueue.executeAmo(inst);

if (inst->isTranslationDelayed() &&
fault == NoFault) {
Expand Down
32 changes: 19 additions & 13 deletions src/cpu/o3/lsq.cc
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@

#include <algorithm>
#include <csignal>
#include <cstdint>
#include <list>
#include <string>

Expand All @@ -51,6 +52,7 @@
#include "base/trace.hh"
#include "cpu/o3/cpu.hh"
#include "cpu/o3/dyn_inst.hh"
#include "cpu/o3/dyn_inst_ptr.hh"
#include "cpu/o3/iew.hh"
#include "cpu/o3/limits.hh"
#include "debug/Drain.hh"
Expand Down Expand Up @@ -319,19 +321,11 @@ LSQ::executePipeSx()
}

Fault
LSQ::executeLoad(const DynInstPtr &inst)
LSQ::executeAmo(const DynInstPtr &inst)
{
ThreadID tid = inst->threadNumber;

return thread[tid].executeLoad(inst);
}

Fault
LSQ::executeStore(const DynInstPtr &inst)
{
ThreadID tid = inst->threadNumber;

return thread[tid].executeStore(inst);
return thread[tid].executeAmo(inst);
}

void
Expand Down Expand Up @@ -561,8 +555,12 @@ LSQ::recvFunctionalCustomSignal(PacketPtr pkt, int sig)
LSQRequest *request = dynamic_cast<LSQRequest*>(pkt->getPrimarySenderState());
panic_if(!request, "Got packet back with unknown sender state\n");
if (sig == DcacheRespType::Miss) {
// notify cache miss
iewStage->loadCancel(request->instruction());
if (request->instruction()->isLoad()) {
// notify cache miss
iewStage->loadCancel(request->instruction());
// set cache miss flag in pipeline
thread[request->_port.lsqID].setFlagInPipeLine(request->instruction(), LdStFlags::CacheMiss);
}
} else {
panic("unsupported sig %d in recvFunctionalCustomSignal\n", sig);
}
Expand Down Expand Up @@ -954,6 +952,14 @@ LSQ::pushRequest(const DynInstPtr& inst, bool isLoad, uint8_t *data,
request->initiateTranslation();
}

if (!isLoad && !isAtomic) {
// store inst temporally saves its data in memData
inst->memData = new uint8_t[size];
memcpy(inst->memData, data, size);
}

inst->effSize = size;

if (!isLoad && !inst->isVector() && size > 1 && addr % size != 0) {
warn( "Store misaligned: size: %u, Addr: %#lx, code: %d\n", size,
addr, RiscvISA::ExceptionCode::STORE_ADDR_MISALIGNED);
Expand All @@ -963,7 +969,7 @@ LSQ::pushRequest(const DynInstPtr& inst, bool isLoad, uint8_t *data,
}

/* This is the place were instructions get the effAddr. */
if (request->isTranslationComplete()) {
if (inst->isAtomic() && request->isTranslationComplete()) {
if (request->isMemAccessRequired()) {
inst->effAddr = request->getVaddr();
inst->effSize = size;
Expand Down
19 changes: 14 additions & 5 deletions src/cpu/o3/lsq.hh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ class IEW;
class LSQUnit;
class StoreBufferEntry;

/** The Flag of Load/Store inst in Pipeline. */
enum LdStFlags
{
Valid = 0,
Replayed,
CacheMiss,
Squashed,
Num_Flags
};

constexpr uint64_t LdStFlagNum = LdStFlags::Num_Flags;

class LSQ
{
public:
Expand Down Expand Up @@ -741,11 +753,8 @@ class LSQ
/** Inserts a store into the LSQ. */
void insertStore(const DynInstPtr &store_inst);

/** Executes a load. */
Fault executeLoad(const DynInstPtr &inst);

/** Executes a store. */
Fault executeStore(const DynInstPtr &inst);
/** Executes an amo inst. */
Fault executeAmo(const DynInstPtr &inst);

/** Iq issues a load to load pipeline. */
void issueToLoadPipe(const DynInstPtr &inst);
Expand Down
Loading

0 comments on commit fb23649

Please sign in to comment.