Changeset 2689 for proto/Compiler


Ignore:
Timestamp:
Nov 24, 2012, 6:27:28 PM (7 years ago)
Author:
cameron
Message:

Base CCGO class, usable as null class

File:
1 edited

Legend:

Unmodified
Added
Removed
  • proto/Compiler/pablo.py

    r2688 r2689  
    499499    return self.adv_n_count
    500500
    501 
    502 class testCCGO():
     501#
     502# Base CCGO Class is also the null class, suitable for stream
     503# functions that have no carry-generating operations.
     504#
     505class CCGO:
     506    def __init__(self): pass
     507    def GenerateCarryDecls(self): return ""
     508    def GenerateInitializations(self): return ""
     509    def GenerateStreamFunctionDecls(self):  return ""
     510    def GenerateCarryInAccess(self, operation_no): return None
     511    def GenerateCarryOutStore(self, operation_no, carry_out_expr): return []
     512    def GenerateCarryIfTest(self, block_no, ifTest): return ifTest
     513    def GenerateCarryElseFinalization(self, block_no): return []
     514    def GenerateLocalDeclare(self, block_no): return []
     515    def GenerateCarryWhileTest(self, block_no, testExpr): return testExpr
     516    def EnterLocalWhileBlock(self, operation_offset):  pass
     517    def ExitLocalWhileBlock(self):  pass
     518    def GenerateCarryWhileFinalization(self, block_no): return []
     519    def GenerateStreamFunctionFinalization(self): return []
     520
     521class testCCGO(CCGO):
    503522    def __init__(self, carryInfoSet, carryGroupVarName='carryQ'):
    504523        self.carryInfoSet = carryInfoSet
     
    541560    def GenerateCarryOutStore(self, operation_no, carry_out_expr):
    542561        carry_index = self.carryIndex[operation_no - self.operation_offset]
    543         return ast.Assign([ast.Subscript(self.CarryGroupAtt('cq'), ast.Index(ast.Num(carry_index)), ast.Store())],
    544                           mkCall("bitblock::srli<127>", [carry_out_expr]))
     562        return [ast.Assign([ast.Subscript(self.CarryGroupAtt('cq'), ast.Index(ast.Num(carry_index)), ast.Store())],
     563                          mkCall("bitblock::srli<127>", [carry_out_expr]))]
    545564    def GenerateCarryIfTest(self, block_no, ifTest):
    546565        carry_count = self.carryInfoSet.block_op_count[block_no]
     
    555574    def GenerateLocalDeclare(self, block_no):
    556575        local_carryvar = ast.Name("sub" + self.carryGroupVar, ast.Load())
    557         return mkCallStmt('LocalCarryDeclare', [local_carryvar, ast.Num(self.carryInfoSet.block_op_count[block_no])])
     576        return [mkCallStmt('LocalCarryDeclare', [local_carryvar, ast.Num(self.carryInfoSet.block_op_count[block_no])])]
    558577    def GenerateCarryWhileTest(self, block_no, testExpr):
    559578        carry_count = self.carryInfoSet.block_op_count[block_no]
     
    571590        if carry_count == 0: return []
    572591        loopIndex = self.carryIndex[self.carryInfoSet.block_first_op[block_no]]       
    573         return mkCallStmt(self.CarryGroupAtt('CarryCombine'), [self.CarryGroupAtt('cq', "sub" + self.carryGroupVar), ast.Num(loopIndex), ast.Num(carry_count)])
     592        return [mkCallStmt(self.CarryGroupAtt('CarryCombine'), [self.CarryGroupAtt('cq', "sub" + self.carryGroupVar), ast.Num(loopIndex), ast.Num(carry_count)])]
    574593    def GenerateStreamFunctionFinalization(self):
    575594        carry_count = self.carryInfoSet.countBlockCarrysWithAdv1(0)
    576595        if carry_count == 0: return []
    577596        else: return [mkCallStmt(self.CarryGroupAtt('CarryQ_Adjust'), [ast.Num(carry_count)])]
     597
    578598
    579599def Strategic_CCGO_Factory(carryInfoSet):
     
    859879    local_carry_decl = self.ccgo.GenerateLocalDeclare(this_block)
    860880    #local_carry_decl = mkCallStmt('LocalCarryDeclare', [local_carryvar, ast.Num(carries)])
    861     inner_while.body.insert(0, local_carry_decl)
     881    inner_while.body = local_carry_decl + inner_while.body
    862882    #final_combine = mkCallStmt(ast.Attribute(self.carryvar, 'CarryCombine', ast.Load()), [ast.Attribute(local_carryvar, 'cq', ast.Load()),ast.Num(carry_base), ast.Num(carries)])
    863883    final_combine = self.ccgo.GenerateCarryWhileFinalization(this_block)
    864     inner_while.body.append(final_combine)
     884    inner_while.body += final_combine
    865885    #CARRYSET
    866886
Note: See TracChangeset for help on using the changeset viewer.