diff options
Diffstat (limited to 'src/mem/slicc')
-rw-r--r-- | src/mem/slicc/symbols/StateMachine.py | 167 | ||||
-rw-r--r-- | src/mem/slicc/symbols/Type.py | 6 |
2 files changed, 57 insertions, 116 deletions
diff --git a/src/mem/slicc/symbols/StateMachine.py b/src/mem/slicc/symbols/StateMachine.py index 008438869..af9850896 100644 --- a/src/mem/slicc/symbols/StateMachine.py +++ b/src/mem/slicc/symbols/StateMachine.py @@ -186,8 +186,8 @@ public: void printConfig(ostream& out) const; void wakeup(); void set_atomic(Address addr); - void started_writes(); - void clear_atomic(); + void clear_atomic(Address addr); + void reset_atomics(); void printStats(ostream& out) const { s_profiler.dumpStats(out); } void clearStats() { s_profiler.clearStats(); } private: @@ -201,7 +201,6 @@ private: if self.ident == "L1Cache": code(''' int servicing_atomic; -bool started_receiving_writes; Address locked_read_request1; Address locked_read_request2; Address locked_read_request3; @@ -301,7 +300,6 @@ $c_ident::$c_ident(const string &name) 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); @@ -600,93 +598,6 @@ void ${ident}_Controller::wakeup() 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: @@ -695,17 +606,14 @@ else { continue if ident == "L1Cache": - if str(port).find("forwardRequestNetwork_in") >= 0: + if (str(port).find("forwardRequestNetwork_in") >= 0 or str(port).find("requestNetwork_in") >= 0 or str(port).find("requestIntraChipL1Network_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 ((((servicing_atomic > 0) && (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) { @@ -716,7 +624,7 @@ if (!postpone) { code.dedent() if ident == "L1Cache": - if str(port).find("forwardRequestNetwork_in") >= 0: + if (str(port).find("forwardRequestNetwork_in") >= 0 or str(port).find("requestNetwork_in") >= 0 or str(port).find("requestIntraChipL1Network_in") >= 0): code.dedent() code('}') code.indent() @@ -735,31 +643,62 @@ if (!postpone) { void ${ident}_Controller::set_atomic(Address addr) { servicing_atomic++; + switch (servicing_atomic) { + case(1): + assert(locked_read_request1 == Address(-1)); + locked_read_request1 = addr; + break; + case(2): + assert(locked_read_request2 == Address(-1)); + locked_read_request2 = addr; + break; + case(3): + assert(locked_read_request3 == Address(-1)); + locked_read_request3 = addr; + break; + case(4): + assert(locked_read_request4 == Address(-1)); + locked_read_request4 = addr; + break; + default: + assert(0); + + } } -void ${ident}_Controller::started_writes() +void ${ident}_Controller::clear_atomic(Address addr) { - started_receiving_writes = true; + + assert(servicing_atomic > 0); + if (addr == locked_read_request1) + locked_read_request1 = Address(-1); + else if (addr == locked_read_request2) + locked_read_request2 = Address(-1); + else if (addr == locked_read_request3) + locked_read_request3 = Address(-1); + else if (addr == locked_read_request4) + locked_read_request4 = Address(-1); + else + assert(0); + servicing_atomic--; + } -void ${ident}_Controller::clear_atomic() +void ${ident}_Controller::reset_atomics() { - 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); - } + + servicing_atomic = 0; + 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() +void ${ident}_Controller::reset_atomics() { assert(0); } @@ -769,7 +708,7 @@ void ${ident}_Controller::set_atomic(Address addr) assert(0); } -void ${ident}_Controller::clear_atomic() +void ${ident}_Controller::clear_atomic(Address addr) { assert(0); } diff --git a/src/mem/slicc/symbols/Type.py b/src/mem/slicc/symbols/Type.py index 2541296dc..bafc6ea9e 100644 --- a/src/mem/slicc/symbols/Type.py +++ b/src/mem/slicc/symbols/Type.py @@ -430,8 +430,10 @@ enum ${{self.c_ident}} { # For each field for i,(ident,enum) in enumerate(self.enums.iteritems()): desc = enum.get("desc", "No description avaliable") - init = ' = %s_FIRST' % self.c_ident if i == 0 else '' - + if i == 0: + init = ' = %s_FIRST' % self.c_ident + else: + init = '' code('${{self.c_ident}}_${{enum.ident}}$init, /**< $desc */') code.dedent() code(''' |