public Object execute(ExecutionEvent event) throws ExecutionException { DBSelection dbSel = new DBSelection(HandlerUtil.getCurrentSelection(event)); ElementDBNode sel = dbSel.getSel(); if (sel == null) { Logger.warn("nothing selected in the design browser, nothing to report"); return null; } String selName = (sel instanceof ModelDBNode) ? "/" : ((InstanceDBNode) sel).getInstPath(); MessageDialogWithToggle dialog = new MessageDialogWithToggle( HandlerUtil.getActiveShell(event), "Report type", null, "After clicking OK, the states of the current model are applied successively; " + "the currents found in each state are stored in a PowerPoint document ", MessageDialog.INFORMATION, new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0, "generate a power report instead", false); if (dialog.open() == Window.OK) { IScriptService interpreter = ScriptRegistry.instance.interpreter(SCRIPT_LANGAGE.TCL); try { interpreter.eval( "package require ms_report; ms_report::ppa_report " + selName + " " + (dialog.getToggleState() ? "power" : "current"), SCR_LOG_TYPE.PRINT_TRANSCRIPT); } catch (ScriptServiceException e) { ViewUtils.setErrorMessage("report generation failed", true); } } return null; }
private void readPinMapping() throws FileNotFoundException, IOException { CSVFileReader csvReader = new CSVFileReader(remapFileName, 'A'); pinRemapping = new HashMap<String, String>(); ignoredVCDPin = new HashSet<String>(); int linenum = 1; Vector<String> fields = csvReader.readFields(); while (fields != null) { if (fields.size() == 1) { ignoredVCDPin.add(fields.get(0).trim()); } else if (fields.size() == 2) { pinRemapping.put(fields.get(0).trim(), fields.get(1).trim()); } else { Logger.error("VCD", "remapping directive incorrect on line " + linenum); } linenum++; fields = csvReader.readFields(); } }
public boolean fillScenario(String vcdFile) { scenario.clearActivities(); // Read the mapping file if any -------------- // try { if (remapFileName != null && remapFileName.trim().length() > 0) readPinMapping(); } catch (FileNotFoundException e) { Logger.error("VCD", "cannot find file " + remapFileName); } catch (IOException e) { Logger.error("VCD", "file " + remapFileName + "incorrect"); } catch (Exception e) { Logger.error("VCD", "FATAL ERROR when reading the rempping file" + remapFileName); } // Convert the VCD ---------------------------- // try { reader = new VCDReader(vcdFile); } catch (Exception e) { Logger.error("VCD", "cannot open file " + vcdFile); return false; } Signal sig; String origPinName; String pinName; PortDBNode portNode; finalTime = -1; Object value; BoxSliceActivitySlice period = null; while ((sig = reader.getForceCommand()) != null) { if (finalTime != sig.time) { if (period != null) period.setActivityRatio(sig.time); period = scenario.addActivityPeriod( Float.toString(sig.time).replaceAll("\\.", "_"), sig.time, false, false); finalTime = sig.time; } if (sig == VCDReader.NO_SIGNAL) { if (sig.time > 0) break; else continue; } origPinName = sig.name.trim(); if (pinRemapping != null && pinRemapping.containsKey(origPinName)) pinName = pinRemapping.get(origPinName); else if (ignoredVCDPin != null && ignoredVCDPin.contains(origPinName)) continue; // ignore else pinName = origPinName; // //DEBUG // if (!pinName.contains("lclk_falcon_1")) // continue; if (pinNodeCache.containsKey(pinName)) { portNode = pinNodeCache.get(pinName); // the pin was already encountered and does not exist, skip the VCD line if (portNode == null) continue; } else { portNode = DBNodeTools.getPortDBNode(scenario.getModel(), pinName); pinNodeCache.put(pinName, portNode); if (portNode == null) { Logger.error("VCD", "the pin " + origPinName + " or its remapping does not exist"); continue; } } ComputerTypes computerType = portNode.getPort().getComputerType(); value = computerType.getDefaultValue(); switch (sig.type) { case REAL: if (!computerType.getJavaType().equalsIgnoreCase("float")) value = ToolsDesignTypes.formatValueToType(computerType, (float) sig.value_real); else value = (float) sig.value_real; break; default: switch (computerType) { case STRING: value = new String(new java.math.BigInteger(sig.value_bus, 2).toByteArray()); break; default: value = ToolsDesignTypes.formatValueToType(computerType, sig.value_bus); break; } break; } period.getSlice().addActivity(new PinState(null, portNode, value, false), 1, true, 0); } // normalize the time of all period float current = 0; float t; for (BoxSliceActivity act : scenario.getActivities()) { t = act.getActivityRatio() / finalTime; act.setActivityRatio(t - current); current = t; } return true; }
public Object execute(List<String> argList) throws TclShellException { JSAPResult argv = parse(argList); if (argv == null) { return false; } if (argv.getBoolean(SmOptionPM.LIST_ATTR_OPTION)) { for (PWR_SRC_ATTR e : PWR_SRC_ATTR.values()) System.out.println( " => " + e.arg + " :\n " + e.help + (e.allowed == null ? "" : " = " + StringUtilities.join(", ", e.allowed) + ")")); return true; } String modelID = argv.getString(SmOption.MODEL_OPTION); ModelDB model = (modelID != null) ? ToolsDesign.getModel(modelID) : UnwCore.getDBProject().model(); if (model == null) { Logger.error(ErrorList.DB3.errorName(), ErrorList.DB3.getMessage(modelID)); throw new TclShellException(""); } PMConfig cfg = PMResourceManager.instance.getPmconfig(model, null); String pwrsrcName = argv.getString(SmOptionPM.PWRSRC_OPTION); PowerSourceInstance powerSource = PMFindVDomainTools.findPowerSource(cfg, pwrsrcName); if (powerSource == null) { Logger.error( ErrorListPM.PM22.errorName(), ErrorListPM.PM22.getMessage(pwrsrcName + "in model " + model.getModelName())); throw new TclShellException(""); } if (!argv.contains(SmOption.NAME_VALUE_OPTION)) { Logger.error("TCL", "no attribute specified"); throw new TclShellException(""); } String[] tokens = argv.getStringArray(SmOption.NAME_VALUE_OPTION); if (tokens.length % 2 != 0) { Logger.error(ErrorListPM.PM_TCL1.errorName(), ErrorListPM.PM_TCL1.getMessage()); throw new TclShellException(""); } String attrName; String attrValue; boolean error = false; for (int i = 0; i < tokens.length; i += 2) { attrName = tokens[i]; attrValue = tokens[i + 1]; PWR_SRC_ATTR id = PWR_SRC_ATTR.findAttr(attrName); if (id == null) { Logger.error(ErrorListPM.PM_TCL3.errorName(), ErrorListPM.PM_TCL3.getMessage(attrName)); throw new TclShellException(""); } else { CONNECT_DIRECTIVE direct = null; switch (id) { case CONNECT_IVOLT: try { direct = CONNECT_DIRECTIVE.valueOf(attrValue); powerSource.setConnectInputVoltage(direct); } catch (Exception e) { error = true; } break; case CONNECT_CTRL: try { direct = CONNECT_DIRECTIVE.valueOf(attrValue); powerSource.setConnectControl(direct); } catch (Exception e) { error = true; } break; case NAME: if (FormatValidation.isAlphaNumeric(attrValue, false)) { powerSource.setName(attrValue); } else error = true; default: break; } if (error) { Logger.error( ErrorListPM.PM_TCL2.errorName(), ErrorListPM.PM_TCL2.getMessage(attrValue + " for attribute " + attrName)); throw new TclShellException(""); } } } return true; }
public Object execute(List<String> argList) throws TclShellException { JSAPResult argv = parse(argList); if (argv == null) { return false; } InstanceDB inst; boolean hasError = false; String modelID = argv.getString(SmOption.MODEL_OPTION); ModelDB model = SmOption.getModel(modelID); if (model == null) throw new TclShellException(""); boolean createPort = argv.getBoolean(SmOption.CREATE_PORT_OPTION); /* * Set Parameters */ String[] instances = argv.getStringArray(SmOption.INSTANCE_OPTION); Collection<InstanceDB> instToConnect = new ArrayList<InstanceDB>(); if (instances == null || instances.length == 0) instToConnect = model.instances(); for (String instName : instances) { inst = model.instance(instName); if (inst == null) { Logger.error( ErrorList.DB15.errorName(), ErrorList.DB15.getMessage(instName + " in model " + model.getModelName())); hasError = true; continue; } instToConnect.add(inst); } DBJobParam param = new DBJobParam(); param.setSrcData( ConnectByNameDBJob.CONNECT_INSTANCES, instToConnect.toArray(new InstanceDB[instToConnect.size()])); param.setSrcData(ConnectByNameDBJob.CREATE_PORT, createPort); param.setSrcData(ConnectByNameDBJob.LEAKAGE_PORT, argv.getBoolean(SmOption.LEAKAGE_OPTION)); param.setSrcData( ConnectByNameDBJob.PROPAGATE_UP, SmOption.UP_OPTION.equals(argv.getString(SmOption.PROPAGATE_OPTION))); if (argv.contains(SmOption.DIRECTION_OPTION)) { String dir = argv.getString(SmOption.DIRECTION_OPTION); if ("in".equals(dir)) param.setSrcData(ConnectByNameDBJob.DIRECTION, PortInDB.class); else if ("out".equals(dir)) param.setSrcData(ConnectByNameDBJob.DIRECTION, PortOutDB.class); } if (argv.getBoolean(SmOption.HIER_OPTION)) param.setSrcData(ConnectByNameDBJob.HIER_OPTION, true); param.setSrcData(ConnectByNameDBJob.KEEPCONNECTION, !argv.getBoolean(SmOption.FORCE_OPTION)); DBJob job = new ConnectByNameDBJob(param); job.launch(); if (hasError || !job.isSuccessful()) throw new TclShellException("error with " + getCommandText()); return null; }