Some bugs are fixed, still not running.
This commit is contained in:
@@ -43,7 +43,7 @@ void BankMachine::startBankMachine(sc_time minDelay)
|
||||
if (currentState == BmState::Precharged)
|
||||
{
|
||||
sc_time delay = max(minDelay, checker->delayToSatisfyConstraints(Command::ACT, bank));
|
||||
controller->triggerEventAfterDelay(delay);
|
||||
controller->triggerEventAfterDelay(delay, "startBankMachine 1");
|
||||
nextCommand = Command::ACT;
|
||||
timeToSchedule = sc_time_stamp() + delay;
|
||||
}
|
||||
@@ -55,14 +55,14 @@ void BankMachine::startBankMachine(sc_time minDelay)
|
||||
if (currentPayload->get_command() == TLM_READ_COMMAND)
|
||||
{
|
||||
sc_time delay = max(minDelay, checker->delayToSatisfyConstraints(Command::RD, bank));
|
||||
controller->triggerEventAfterDelay(delay);
|
||||
controller->triggerEventAfterDelay(delay, "startBankMachine 2");
|
||||
nextCommand = Command::RD;
|
||||
timeToSchedule = sc_time_stamp() + delay;
|
||||
}
|
||||
else if (currentPayload->get_command() == TLM_WRITE_COMMAND)
|
||||
{
|
||||
sc_time delay = max(minDelay, checker->delayToSatisfyConstraints(Command::WR, bank));
|
||||
controller->triggerEventAfterDelay(delay);
|
||||
controller->triggerEventAfterDelay(delay, "startBankMachine 3");
|
||||
nextCommand = Command::WR;
|
||||
timeToSchedule = sc_time_stamp() + delay;
|
||||
}
|
||||
@@ -72,7 +72,7 @@ void BankMachine::startBankMachine(sc_time minDelay)
|
||||
else
|
||||
{
|
||||
sc_time delay = max(minDelay, checker->delayToSatisfyConstraints(Command::PRE, bank));
|
||||
controller->triggerEventAfterDelay(delay);
|
||||
controller->triggerEventAfterDelay(delay, "startBankMachine 4");
|
||||
nextCommand = Command::PRE;
|
||||
timeToSchedule = sc_time_stamp() + delay;
|
||||
}
|
||||
@@ -86,3 +86,18 @@ std::pair<Command, tlm_generic_payload *> BankMachine::getNextCommand()
|
||||
else
|
||||
return std::pair<Command, tlm_generic_payload *>(Command::NOP, nullptr);
|
||||
}
|
||||
|
||||
void BankMachine::updateState(Command command)
|
||||
{
|
||||
if (command == Command::ACT)
|
||||
currentState = BmState::Activating;
|
||||
else if (command == Command::PRE)
|
||||
currentState = BmState::Precharging;
|
||||
else if (command == Command::RD)
|
||||
currentState = BmState::Reading;
|
||||
else if (command == Command::WR)
|
||||
currentState = BmState::Writing;
|
||||
else
|
||||
SC_REPORT_FATAL("BankMachine", "Unknown phase");
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
tlm_generic_payload *getNextStateAndResult();
|
||||
void startBankMachine(sc_time minDelay);
|
||||
std::pair<Command, tlm_generic_payload *> getNextCommand();
|
||||
void updateState(Command);
|
||||
private:
|
||||
tlm_generic_payload *currentPayload = nullptr;
|
||||
BmState currentState = BmState::Precharged;
|
||||
|
||||
@@ -38,6 +38,7 @@ ControllerNew::~ControllerNew()
|
||||
tlm_sync_enum ControllerNew::nb_transport_fw(tlm_generic_payload &trans,
|
||||
tlm_phase &phase, sc_time &delay)
|
||||
{
|
||||
std::cout << "Controller: " << sc_time_stamp() << std::endl;
|
||||
recordPhase(trans, phase, delay);
|
||||
sc_time notDelay = delay;
|
||||
|
||||
@@ -61,7 +62,7 @@ tlm_sync_enum ControllerNew::nb_transport_fw(tlm_generic_payload &trans,
|
||||
|
||||
printDebugMessage("[fw] " + phaseNameToString(phase) + " notification in " +
|
||||
notDelay.to_string());
|
||||
triggerEventQueue.notify(notDelay);
|
||||
triggerEventQueueAfterDelay(notDelay, "nb_transport_fw");
|
||||
|
||||
return TLM_ACCEPTED;
|
||||
}
|
||||
@@ -80,7 +81,7 @@ tlm_sync_enum ControllerNew::nb_transport_bw(tlm_generic_payload &trans,
|
||||
delay.to_string());
|
||||
Bank bank = DramExtension::getExtension(trans).getBank();
|
||||
bankMachines[bank]->setCommandFinishedTime(sc_time_stamp() + delay);
|
||||
triggerEventQueue.notify(delay);
|
||||
triggerEventQueueAfterDelay(delay, "nb_transport_bw");
|
||||
return TLM_ACCEPTED;
|
||||
}
|
||||
|
||||
@@ -108,19 +109,23 @@ void ControllerNew::recordPhase(tlm_generic_payload &trans, tlm_phase phase, sc_
|
||||
tlmRecorder->recordPhase(trans, phase, recTime);
|
||||
}
|
||||
|
||||
void ControllerNew::triggerEventAfterDelay(sc_time delay)
|
||||
void ControllerNew::triggerEventAfterDelay(sc_time delay, string sender)
|
||||
{
|
||||
triggerEvent.notify(delay);
|
||||
std::cout << "Delay: " << delay << " by " + sender << std::endl;
|
||||
if (delay != SC_ZERO_TIME)
|
||||
triggerEvent.notify(delay);
|
||||
}
|
||||
|
||||
void ControllerNew::triggerEventQueueAfterDelay(sc_time delay)
|
||||
void ControllerNew::triggerEventQueueAfterDelay(sc_time delay, string sender)
|
||||
{
|
||||
triggerEventQueue.notify(delay);
|
||||
std::cout << "Delayqueue: " << delay << " by " + sender << std::endl;
|
||||
if (delay != SC_ZERO_TIME)
|
||||
triggerEventQueue.notify(delay);
|
||||
}
|
||||
|
||||
void ControllerNew::controllerMethod()
|
||||
{
|
||||
std::cout << sc_time_stamp() << std::endl;
|
||||
std::cout << "ControllerMethod triggered at " << sc_time_stamp() << std::endl;
|
||||
releasePayload();
|
||||
acquirePayload();
|
||||
getNextBmStates();
|
||||
@@ -132,7 +137,7 @@ void ControllerNew::controllerMethod()
|
||||
|
||||
void ControllerNew::releasePayload()
|
||||
{
|
||||
if (sc_time_stamp() == timeToRelease /*&& payloadToRelease != nullptr*/)
|
||||
if (sc_time_stamp() == timeToRelease && payloadToRelease != nullptr)
|
||||
{
|
||||
responseQueue.pop();
|
||||
payloadToRelease->release();
|
||||
@@ -152,15 +157,15 @@ void ControllerNew::acquirePayload()
|
||||
payloadToAcquire->acquire();
|
||||
scheduler->storeRequest(payloadToAcquire);
|
||||
commandMux->insertPayload(payloadToAcquire);
|
||||
payloadToAcquire = nullptr;
|
||||
numberOfPayloads++;
|
||||
// TODO: insert payload ID
|
||||
printDebugMessage("Payload ID entered system.");
|
||||
payloadToAcquire->set_response_status(TLM_OK_RESPONSE);
|
||||
payloadToAcquire->set_response_status(tlm::TLM_OK_RESPONSE);
|
||||
tlm_phase tPhase = END_REQ;
|
||||
sc_time tDelay = SC_ZERO_TIME;
|
||||
recordPhase(*payloadToAcquire, tPhase, tDelay);
|
||||
tSocket->nb_transport_bw(*payloadToAcquire, tPhase, tDelay);
|
||||
payloadToAcquire = nullptr;
|
||||
}
|
||||
else
|
||||
printDebugMessage("Total number of payloads exceeded, backpressure!");
|
||||
@@ -213,6 +218,9 @@ void ControllerNew::sendToDram(Command command, tlm_generic_payload *payload)
|
||||
ScheduledCommand scheduledCommand(command, sc_time_stamp(), execTime, *payload);
|
||||
state->cleanUp(sc_time_stamp());
|
||||
state->change(scheduledCommand);
|
||||
Bank bank = scheduledCommand.getBank();
|
||||
bankMachines[bank]->updateState(command);
|
||||
std::cout << sc_time_stamp() << ": Sending command " << commandToString(command) << " on bank " << bank.toString() << std::endl;
|
||||
|
||||
sc_time delay = SC_ZERO_TIME;
|
||||
tlm_phase phase;
|
||||
@@ -226,6 +234,7 @@ void ControllerNew::sendToDram(Command command, tlm_generic_payload *payload)
|
||||
phase = BEGIN_WR;
|
||||
else
|
||||
SC_REPORT_FATAL("ControllerNew", "Unknown phase");
|
||||
|
||||
iSocket->nb_transport_fw(*payload, phase, delay);
|
||||
}
|
||||
|
||||
|
||||
@@ -33,8 +33,8 @@ public:
|
||||
tlm_utils::simple_target_socket<ControllerNew> tSocket;
|
||||
tlm_utils::simple_initiator_socket<ControllerNew> iSocket;
|
||||
|
||||
void triggerEventAfterDelay(sc_time);
|
||||
void triggerEventQueueAfterDelay(sc_time);
|
||||
void triggerEventAfterDelay(sc_time, string);
|
||||
void triggerEventQueueAfterDelay(sc_time, string);
|
||||
|
||||
ControllerState *state;
|
||||
std::map<Bank, BankMachine *> bankMachines;
|
||||
|
||||
Reference in New Issue
Block a user