Sam Mussmann avatar Sam Mussmann committed c6e766f

Stop tracking instruction by index in reorder buffer and .issue_next()

Comments (0)

Files changed (1)

   instructions are all done executing.
   """
   done = False
-  _next_instruction = 0
 
   class _Instruction:
     """ Internal representation of an instruction.
         'messages': '; '.join(format_msg(m) for m in self.messages)}
 
   def __init__(self, instructions):
-    self.instructions = [_InstructionTracker._Instruction(instr, i, self) for
+    self.instructions = [_InstructionTracker._Instruction(instr, i) for
                          i, instr in enumerate(instructions)]
 
   def issue_next(self, reorder_buffer):
-    if (self._next_instruction < len(self.instructions) and
-        not reorder_buffer.is_full()):
-      reorder_buffer.add(self._next_instruction)
-      instruction = self.instructions[self._next_instruction]
-      instruction.issue()
-      self._next_instruction += 1
+    unissued = filter(lambda i: i.cur_state == "unissued", self.instructions)
+    if unissued and not reorder_buffer.is_full():
+      reorder_buffer.add(unissued[0])
+      unissued[0].issue()
 
   def update(self, new_cycle):
     for instruction in self.instructions:
     self.storage = list()
     self.length = length  # Default arg is basically infinity
 
-  def add(self, instruction_number):
+  def add(self, instruction):
     if self.is_full():
       raise Exception("Reorder buffer just got too full!! Oops!")
-    self.storage.append(instruction_number)
+    self.storage.append(instruction)
 
   def is_full(self):
     return len(self.storage) >= self.length
 
-  def commit(self, instruction_tracker):
+  def commit(self):
     if len(self.storage) == 0:
       return
     head = self.storage[0]
-    if instruction_tracker.instructions[head].ready_to_commit():
-      instruction_tracker.instructions[head].commit()
+    if head.ready_to_commit():
+      head.commit()
       self.storage.pop(0)
 
   def IS_instruction_iterator(self, instruction_tracker):
-    return itertools.ifilter(lambda i: i.cur_state == "IS",
-        itertools.imap(lambda i: instruction_tracker.instructions[i],
-          self.storage))
-
-  def WB_instruction_iterator(self, instruction_tracker):
-    return itertools.ifilter(lambda i: i.cur_state == "WB",
-        itertools.imap(lambda i: instruction_tracker.instructions[i],
-          self.storage))
+    return itertools.ifilter(lambda i: i.cur_state == "IS", self.storage)
 
 class _FunctionalUnits:
   class FunctionalUnit:
           functional_units.enqueue(instr)
       del reservation_station[instruction.index] 
     # Deal with CM stage
-    reorder_buffer.commit(instruction_tracker)
+    reorder_buffer.commit()
 
     cycle += 1
     instruction_tracker.update(cycle)
 # This is debug stuff to dump the state of various hardware pieces.  I'm
 # leaving it here should you need it to debug stuff.
 #
-#  for instruction in (instruction_tracker.instructions[i] for i in reorder_buffer.storage):
+#  for instruction in reorder_buffer.storage:
 #    print instruction
 #  print("reservation_station_state",
 #    ['{0!s}: {1}'.format(k, ', '.join(map(lambda x: str(x), v))) for k, v in
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.