Ignore:
Timestamp:
Dec 27, 2012, 7:07:56 AM (6 years ago)
Author:
cameron
Message:

Separate allocation from init, add BLOCK_SIZE parameter, tidy

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/CCGO.py

    r2786 r2799  
    2323class CCGO:
    2424    def __init__(self): pass
     25    def allocate_all(self): pass
    2526    def GenerateCarryDecls(self): return ""
    2627    def GenerateInitializations(self): return ""
     
    5859#
    5960class testCCGO(CCGO):
    60     def __init__(self, carryInfoSet, carryGroupVarName='carryQ'):
     61    def __init__(self, BLOCK_SIZE, carryInfoSet, carryGroupVarName='carryQ'):
     62        self.BLOCK_SIZE = BLOCK_SIZE
    6163        self.carryInfoSet = carryInfoSet
    6264        self.carryGroupVar = carryGroupVarName
     65
     66    def allocate_all(self):
    6367        self.carryIndex = {}
    6468        self.advIndex = {}
     
    6670        carry_counter = 0
    6771        adv_counter = 0
    68         for op_no in range(carryInfoSet.operation_count):
     72        for op_no in range(self.carryInfoSet.operation_count):
    6973          self.carryIndex[op_no] = carry_counter
    70           if not op_no in carryInfoSet.advance_amount.keys(): carry_counter += 1
    71           elif carryInfoSet.advance_amount[op_no] == 1: carry_counter += 1
     74          if not op_no in self.carryInfoSet.advance_amount.keys(): carry_counter += 1
     75          elif self.carryInfoSet.advance_amount[op_no] == 1: carry_counter += 1
    7276          else: 
    7377            self.advIndex[op_no] = adv_counter
    7478            adv_counter += 1
    7579        # Add a dummy entry for any possible final block that is empty.
    76         self.carryIndex[carryInfoSet.operation_count] = carry_counter
    77         self.advIndex[carryInfoSet.operation_count] = adv_counter
     80        self.carryIndex[self.carryInfoSet.operation_count] = carry_counter
     81        self.advIndex[self.carryInfoSet.operation_count] = adv_counter
    7882        self.carry_count = carry_counter
     83
    7984    # Helper
    8085    def CarryGroupAtt(self, attname, CarryGroupVarName=""):
     
    106111        carry_index = self.carryIndex[operation_no - self.operation_offset]
    107112        return [ast.Assign([ast.Subscript(self.CarryGroupAtt('cq'), ast.Index(ast.Num(carry_index)), ast.Store())],
    108                           mkCall("bitblock::srli<127>", [carry_out_expr]))]
     113                          mkCall("bitblock::srli<%i>" % (self.BLOCK_SIZE - 1), [carry_out_expr]))]
    109114    def GenerateAdvanceInAccess(self, operation_no):
    110115        adv_index = self.advIndex[operation_no - self.operation_offset]
Note: See TracChangeset for help on using the changeset viewer.