def use_route_blocks(dev,used_route_blocks,conn_assign): path = conn_assign.path vadpstmts = [] if len(path) <= 2: return vadpstmts,list(path) new_path = list(path) for idx,(route_block,route_inst_pattern) in enumerate(path[1:-1]): blk = dev.get_block(route_block) assert(len(blk.modes) == 1) assert(len(blk.state) == 0) assert(len(blk.data) == 0) # get first compatible instance that has not been used yet try: inst = next(inst for inst in dev.layout.instances(route_block) \ if not devlib.Layout \ .intersection(inst,route_inst_pattern) is None and \ (route_block,inst) not in used_route_blocks ) new_path[1+idx]= (route_block,inst) used_route_blocks.append((route_block,inst)) target_port = vadplib.PortVar(blk,devlib.Location(inst)) stmt = vadplib.VADPConfig(target_port,blk.modes) stmt.target.ident = devlib.Location(inst) vadpstmts.append(stmt) except StopIteration as e: raise Exception("no instances for route block <%s>" % route_block) return vadpstmts,new_path
def generate_vadp_fragment_for_path(dev,route_block_instances,conn_assign): def get_route_input(blk): name = blk.inputs.field_names()[0] return blk.inputs[name] def get_route_output(blk): name = blk.outputs.field_names()[0] return blk.outputs[name] vadp_config_stmts, path = use_route_blocks(dev, \ route_block_instances, \ conn_assign) for stmt in vadp_config_stmts: yield stmt for idx in range(0,len(path)-1): src_tuple = path[idx] dest_tuple = path[idx+1] assert(not devlib.Layout.is_pattern(src_tuple[1])) assert(not devlib.Layout.is_pattern(dest_tuple[1])) srcblk = dev.get_block(src_tuple[0]) src = vadplib.PortVar(srcblk, \ devlib.Location(src_tuple[1]), \ srcblk.outputs[src_tuple[2]] \ if len(src_tuple) == 3 else \ get_route_output(srcblk) ) destblk = dev.get_block(dest_tuple[0]) dest = vadplib.PortVar(destblk, \ devlib.Location(dest_tuple[1]), \ destblk.inputs[dest_tuple[2]] \ if len(dest_tuple) == 3 else \ get_route_input(destblk) ) yield vadplib.VADPConn(src,dest)
def test_board(args): board = runtime_util.get_device(args.model_number, layout=True) for chip_id in range(0, 2): for tile_id in range(4): for slice_id in [0, 2]: for block in board.blocks: if not block.requires_calibration(): continue modes = list(block.modes) # limit the fanout modes to just positive copies if block.name == "fanout": modes = list( filter(lambda m: not "-" in str(m), block.modes)) loc = devlib.Location([chip_id, tile_id, slice_id, 0]) test_block(board,block,loc,modes, \ maximize_fit=args.maximize_fit, \ minimize_error=args.minimize_error, \ model_based=args.model_based) finalize_test(board, \ maximize_fit=args.maximize_fit, \ minimize_error=args.minimize_error, \ model_based=args.model_based)
def resources(self): if len(self.path) <= 2: return for route_block,route_loc in self.path[1:-1]: yield BlockInstanceResource(self.dev, \ self.dev.get_block(route_block), devlib.Location(route_loc)) '''
def from_block_loc_t(dev,dict_): chip = dict_['chip'] tile = dict_['tile'] slice_ = dict_['slice'] idx = dict_['idx'] block_type = llenums.BlockType.by_name(str(dict_['block'])) blk = dev.get_block(block_type.value) addr = [int(dict_['chip']), \ int(dict_['tile']), \ int(dict_['slice']), \ int(dict_['idx'])] return blk,devlib.Location(addr)
def get_device(model_number, layout=False, model_subdir=""): hcdcv2 = devlib.Device('hcdcv2', model_number=model_number, model_subdir=model_subdir) hcdcv2.add_block(hwlib.hcdc.fanout.fan) hcdcv2.add_block(hwlib.hcdc.mult.mult) hcdcv2.add_block(hwlib.hcdc.integ.integ) hcdcv2.add_block(hwlib.hcdc.ext_out.ext_out) hcdcv2.add_block(hwlib.hcdc.dac.dac) hcdcv2.add_block(hwlib.hcdc.adc.adc) hcdcv2.add_block(hwlib.hcdc.lut.lut) hcdcv2.add_block(hwlib.hcdc.routeblocks.tin) hcdcv2.add_block(hwlib.hcdc.routeblocks.tout) hcdcv2.add_block(hwlib.hcdc.routeblocks.cin) hcdcv2.add_block(hwlib.hcdc.routeblocks.cout) hcdcv2.add_block(hwlib.hcdc.ext_in.ext_in) # hwtime/wall clock time hcdcv2.time_constant = 1.0 / 126000 # profiling operations hcdcv2.profile_status_type = llenums.ProfileStatus hcdcv2.profile_op_type = llenums.ProfileOpType if layout: hcdc_layout.make(hcdcv2) hcdcv2.set_external_pin(llenums.ExternalPins.OUT0, \ hwlib.hcdc.ext_out.ext_out, \ devlib.Location([0,3,2,0]), \ 'z', \ llenums.Channels.POS) hcdcv2.set_external_pin(llenums.ExternalPins.OUT1, \ hwlib.hcdc.ext_out.ext_out, \ devlib.Location([0,3,2,0]), \ 'z', \ llenums.Channels.NEG) return hcdcv2
def characterize_adp(args): board = runtime_util.get_device(args.model_number, layout=True) runtime = GrendelRunner() runtime.initialize() if not args.adp is None: adp = runtime_util.get_adp(board, args.adp, widen=args.widen) if args.adp_locs: args.num_locs = 1 for cfg in adp.configs: blk = board.get_block(cfg.inst.block) cfg_modes = cfg.modes for mode in cfg_modes: cfg.modes = [mode] characterize_configured_block(runtime,board,blk,cfg, \ grid_size=args.grid_size, \ num_locs=args.num_locs,\ num_hidden_codes=args.num_hidden_codes, \ adp_locs=args.adp_locs) else: if args.adp_locs or args.widen: raise Exception( "full board characterization doesn't accept adp-locs or widen parameters" ) for block in board.blocks: if not block.requires_calibration(): continue continue for mode in block.modes: loc = devlib.Location( list(board.layout.instances(block.name))[0]) cfg = BlockConfig.make(block, loc) cfg.modes = [mode] characterize_configured_block(runtime,board,block,cfg, \ grid_size=args.grid_size, \ num_locs=args.num_locs,\ num_hidden_codes=args.num_hidden_codes, \ adp_locs=False)
def add_virtual_instance(self,block,identifier): instances = set(map(lambda full_loc: \ devlib.Location(self.dev.layout.prefix(full_loc,self.view)),\ self.dev.layout.instances(block.name))) if len(instances) == 0: self.fail(" no locations for block <%s> with identifier <%d>" \ % (block.name,identifier)) for loc in instances: if not self.is_valid_instance_assignment(block,identifier,loc): continue assign = BlockIdentifierAssignVar(self.dev, \ block, \ identifier, \ loc) self.identifier_assigns \ .append(assign) for res in assign.resources(): if not res in self.resources: self.resources.append(res)
def random_locs(board,block,num_locs): insts = list(board.layout.instances(block.name)) for addr in random.sample(insts,min(len(insts),num_locs)): yield devlib.Location(addr)