def init_parameters(self, dut_params={}, verbose=True): '''| | Assign values to parameters. The values are provided from unit tests. | If a value for a parameter is not provided, then the default value is used. | Default value is always given when creating a Parameter object) |________''' for def_param in self.get_parameters(): if def_param.inst_name in dut_params.keys(): def_param.value = dut_params[def_param.inst_name] elif verbose: mylog.warn("No initial value provided for parameter '%s'. The default value (%s = %s) will be used." % (def_param, def_param, def_param.value))
def get_all_parameters(self, overwrite_params={}, verbose=False): '''| | Returns OrderedDict of all parameters (unique). Overwrites the parameters given in overwrite_params |________''' params = OrderedDict([(parameter.inst_name, parameter.value) for parameter in self.get_parameters()]) for x in params.keys(): if x in overwrite_params: params[x] = overwrite_params[x] elif verbose: mylog.warn("No initial value provided for parameter '%s'. The default value (%s = %s) will be used." % (x, x, params[x])) return params
def check_config(self, cname): '''| | Check test configuration | Determine the end-of-simulation conditions: len of stim_ and ref_ lists |________''' mylog.info(cname + ": " + self.impl2string(self.models)) conf_str = self.dict2string(self.tb_config) if conf_str != '': mylog.info("Configuration: " + conf_str) if self.dut_params != {}: mylog.info("DUT parameters: " + self.params2string(self.dut_params)) mty_stim_list = True stim_not_present = True for key,val in self.tst_data.iteritems(): if "stim" in key: stim_not_present = False if val != [] and "file" in val[0]: num_payloads = sum(1 for line in open(val[0]["file"])) self.cond_sim_end[key[5:]] = num_payloads else: self.cond_sim_end[key[5:]] = len(val) if self.cond_sim_end[key[5:]] > 0: mty_stim_list = False if stim_not_present or mty_stim_list: mylog.info("No stimuli provided") no_ref_data = True for key,val in self.ref_data.iteritems(): if val[0] != [] and "file" in val[0][0]: num_payloads = sum(1 for line in open(val[0][0]["file"])) self.cond_sim_end[key] = num_payloads else: self.cond_sim_end[key] = len(val[0]) if self.cond_sim_end[key] > 0: no_ref_data = False # To avoid endless simulation if self.tb_config["simulation_time"] == "auto" and (stim_not_present or mty_stim_list) and no_ref_data: self.tb_config["simulation_time"] = 5 mylog.warn("Simulation time ca not be determined! Selecting a constant simulation time.")