summaryrefslogtreecommitdiff
path: root/src/mem/slicc/symbols/StateMachine.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/mem/slicc/symbols/StateMachine.py')
-rw-r--r--src/mem/slicc/symbols/StateMachine.py217
1 files changed, 15 insertions, 202 deletions
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py
index 008438869..73c3fe720 100644
--- a/src/mem/slicc/symbols/StateMachine.py
+++ b/src/mem/slicc/symbols/StateMachine.py
@@ -185,11 +185,10 @@ public:
void print(ostream& out) const;
void printConfig(ostream& out) const;
void wakeup();
- void set_atomic(Address addr);
- void started_writes();
- void clear_atomic();
void printStats(ostream& out) const { s_profiler.dumpStats(out); }
void clearStats() { s_profiler.clearStats(); }
+ void blockOnQueue(Address addr, MessageBuffer* port);
+ void unblock(Address addr);
private:
''')
@@ -198,17 +197,6 @@ private:
for param in self.config_parameters:
code('int m_${{param.ident}};')
- if self.ident == "L1Cache":
- code('''
-int servicing_atomic;
-bool started_receiving_writes;
-Address locked_read_request1;
-Address locked_read_request2;
-Address locked_read_request3;
-Address locked_read_request4;
-int read_counter;
-''')
-
code('''
int m_number_of_TBEs;
@@ -222,6 +210,8 @@ map< string, string > m_cfg;
NodeID m_version;
Network* m_net_ptr;
MachineID m_machineID;
+bool m_is_blocking;
+map< Address, MessageBuffer* > m_block_map;
${ident}_Profiler s_profiler;
static int m_num_controllers;
// Internal functions
@@ -298,16 +288,6 @@ $c_ident::$c_ident(const string &name)
{
''')
code.indent()
- if self.ident == "L1Cache":
- code('''
-servicing_atomic = 0;
-started_receiving_writes = false;
-locked_read_request1 = Address(-1);
-locked_read_request2 = Address(-1);
-locked_read_request3 = Address(-1);
-locked_read_request4 = Address(-1);
-read_counter = 0;
-''')
code('m_num_controllers++;')
for var in self.objects:
@@ -517,6 +497,17 @@ const MachineType $c_ident::getMachineType() const{
return MachineType_${ident};
}
+void $c_ident::blockOnQueue(Address addr, MessageBuffer* port) {
+ m_is_blocking = true;
+ m_block_map[addr] = port;
+}
+void $c_ident::unblock(Address addr) {
+ m_block_map.erase(addr);
+ if (m_block_map.size() == 0) {
+ m_is_blocking = false;
+ }
+}
+
void $c_ident::print(ostream& out) const { out << "[$c_ident " << m_version << "]"; }
void $c_ident::printConfig(ostream& out) const {
@@ -582,144 +573,12 @@ void ${ident}_Controller::wakeup()
# InPorts
#
- # Find the position of the mandatory queue in the vector so
- # that we can print it out first
-
- mandatory_q = None
- if self.ident == "L1Cache":
- for i,port in enumerate(self.in_ports):
- assert "c_code_in_port" in port
- if str(port).find("mandatoryQueue_in") >= 0:
- assert mandatory_q is None
- mandatory_q = port
-
- assert mandatory_q is not None
-
- # print out the mandatory queue here
- port = mandatory_q
- code('// ${ident}InPort $port')
- output = port["c_code_in_port"]
-
- pos = output.find("TransitionResult result = doTransition((L1Cache_mandatory_request_type_to_event(((*in_msg_ptr)).m_Type)), L1Cache_getState(addr), addr);")
- assert pos >= 0
- atomics_string = '''
-if ((((*in_msg_ptr)).m_Type) == CacheRequestType_ATOMIC) {
- if (servicing_atomic == 0) {
- if (locked_read_request1 == Address(-1)) {
- assert(read_counter == 0);
- locked_read_request1 = addr;
- assert(read_counter == 0);
- read_counter++;
- }
- else if (addr == locked_read_request1) {
- ; // do nothing
- }
- else {
- assert(0); // should never be here if servicing one request at a time
- }
- }
- else if (!started_receiving_writes) {
- if (servicing_atomic == 1) {
- if (locked_read_request2 == Address(-1)) {
- assert(locked_read_request1 != Address(-1));
- assert(read_counter == 1);
- locked_read_request2 = addr;
- assert(read_counter == 1);
- read_counter++;
- }
- else if (addr == locked_read_request2) {
- ; // do nothing
- }
- else {
- assert(0); // should never be here if servicing one request at a time
- }
- }
- else if (servicing_atomic == 2) {
- if (locked_read_request3 == Address(-1)) {
- assert(locked_read_request1 != Address(-1));
- assert(locked_read_request2 != Address(-1));
- assert(read_counter == 1);
- locked_read_request3 = addr;
- assert(read_counter == 2);
- read_counter++;
- }
- else if (addr == locked_read_request3) {
- ; // do nothing
- }
- else {
- assert(0); // should never be here if servicing one request at a time
- }
- }
- else if (servicing_atomic == 3) {
- if (locked_read_request4 == Address(-1)) {
- assert(locked_read_request1 != Address(-1));
- assert(locked_read_request2 != Address(-1));
- assert(locked_read_request3 != Address(-1));
- assert(read_counter == 1);
- locked_read_request4 = addr;
- assert(read_counter == 3);
- read_counter++;
- }
- else if (addr == locked_read_request4) {
- ; // do nothing
- }
- else {
- assert(0); // should never be here if servicing one request at a time
- }
- }
- else {
- assert(0);
- }
- }
-}
-else {
- if (servicing_atomic > 0) {
- // reset
- servicing_atomic = 0;
- read_counter = 0;
- started_receiving_writes = false;
- locked_read_request1 = Address(-1);
- locked_read_request2 = Address(-1);
- locked_read_request3 = Address(-1);
- locked_read_request4 = Address(-1);
- }
-}
-'''
-
- output = output[:pos] + atomics_string + output[pos:]
- code('$output')
-
for port in self.in_ports:
- # don't print out mandatory queue twice
- if port == mandatory_q:
- continue
-
- if ident == "L1Cache":
- if str(port).find("forwardRequestNetwork_in") >= 0:
- code('''
-bool postpone = false;
-if ((((*m_L1Cache_forwardToCache_ptr)).isReady())) {
- const RequestMsg* in_msg_ptr;
- in_msg_ptr = dynamic_cast<const RequestMsg*>(((*m_L1Cache_forwardToCache_ptr)).peek());
- if ((((servicing_atomic == 1) && (locked_read_request1 == ((*in_msg_ptr)).m_Address)) ||
- ((servicing_atomic == 2) && (locked_read_request1 == ((*in_msg_ptr)).m_Address || locked_read_request2 == ((*in_msg_ptr)).m_Address)) ||
- ((servicing_atomic == 3) && (locked_read_request1 == ((*in_msg_ptr)).m_Address || locked_read_request2 == ((*in_msg_ptr)).m_Address || locked_read_request3 == ((*in_msg_ptr)).m_Address)) ||
- ((servicing_atomic == 4) && (locked_read_request1 == ((*in_msg_ptr)).m_Address || locked_read_request2 == ((*in_msg_ptr)).m_Address || locked_read_request3 == ((*in_msg_ptr)).m_Address || locked_read_request1 == ((*in_msg_ptr)).m_Address)))) {
- postpone = true;
- }
-}
-if (!postpone) {
-''')
code.indent()
code('// ${ident}InPort $port')
code('${{port["c_code_in_port"]}}')
code.dedent()
- if ident == "L1Cache":
- if str(port).find("forwardRequestNetwork_in") >= 0:
- code.dedent()
- code('}')
- code.indent()
code('')
code.dedent()
@@ -730,52 +589,6 @@ if (!postpone) {
}
''')
- if self.ident == "L1Cache":
- code('''
-void ${ident}_Controller::set_atomic(Address addr)
-{
- servicing_atomic++;
-}
-
-void ${ident}_Controller::started_writes()
-{
- started_receiving_writes = true;
-}
-
-void ${ident}_Controller::clear_atomic()
-{
- assert(servicing_atomic > 0);
- read_counter--;
- servicing_atomic--;
- if (read_counter == 0) {
- servicing_atomic = 0;
- started_receiving_writes = false;
- locked_read_request1 = Address(-1);
- locked_read_request2 = Address(-1);
- locked_read_request3 = Address(-1);
- locked_read_request4 = Address(-1);
- }
-}
-''')
- else:
- code('''
-void ${ident}_Controller::started_writes()
-{
- assert(0);
-}
-
-void ${ident}_Controller::set_atomic(Address addr)
-{
- assert(0);
-}
-
-void ${ident}_Controller::clear_atomic()
-{
- assert(0);
-}
-''')
-
-
code.write(path, "%s_Wakeup.cc" % self.ident)
def printCSwitch(self, path):