text: import ila
  import ptxSim
  #import ptxILA
  import ptxILANoBar
  import pickle
  reg_map_file = 'reg_map'
  
  def synthesize():
      #ptxModel = ptxILA.ptxGPUModel()
      ptxModel = ptxILANoBar.ptxGPUModel()
      ptxSimulator = ptxSim.ptx_sim()
      ptxModel.model.set_next('pc', ptxModel.pc_nxt())
      ptxModel.model.set_next('mem', ptxModel.mem_nxt())
      reg_map_obj = open(reg_map_file, 'r')
      reg_map = pickle.load(reg_map_obj)
      reg_book = reg_map.keys()
      reg_book.remove('bar_state')
      reg_book.remove('bar_counter_enter')
      reg_book.remove('bar_counter_exit')
      for reg_name in reg_book:
          ptxModel.model.set_next(reg_name, ptxModel.sreg_nxt(reg_map[reg_name]))
      '''
      #synthesize bar
      for reg_name in reg_map.keys():
          if reg_name == 'bar_state':
              continue
          if reg_name == 'bar_counter_enter':
              continue
          if reg_name == 'bar_counter_exit':
              continue
          ptxModel.model.set_next(reg_name, ptxModel.sreg_nxt(reg_map[reg_name]))
      
      #test_reg = 'pc'
      #print 'start'
      synthesize_regs = ['pc', 'bar_state', 'bar_counter_enter', 'bar_counter_exit']
      '''
      synthesize_regs = reg_book + ['pc']
      for synthesize_reg in synthesize_regs:
          ptxModel.model.synthesize(synthesize_reg, lambda s:ptxSimulator.state_parser(s))
          ast = ptxModel.model.get_next(synthesize_reg)
          ptxModel.model.exportOne(ast, 'ast' + synthesize_reg)
      
      #ptxModel.model.synthesize(test_reg, lambda s:ptxSimulator.state_parser(s))
      #ast = ptxModel.model.get_next(test_reg)
      print ast
      #ptxModel.model.exportOne(ast, 'ast%r4')
      #ptxModel.compare()
  
  
  
  
  if __name__ == '__main__':
      synthesize()
  