Beispiel #1
0
  public static FunctionComponent instantiateGate(
      final Gate gate, final String instanceName, final Circuit circuit) {
    final FunctionComponent component = new FunctionComponent();
    component.setModule(gate.name);
    circuit.add(component);
    if (instanceName != null) {
      try {
        circuit.setName(component, instanceName);
      } catch (ArgumentException e) {
        LogUtils.logWarningLine(
            "Cannot set name '"
                + instanceName
                + "' for component '"
                + circuit.getName(component)
                + "'.");
      }
    }

    FunctionContact contact = new FunctionContact(IOType.OUTPUT);
    component.add(contact);
    circuit.setName(contact, gate.function.name);
    String setFunction = getSetFunction(gate);
    String resetFunction = getResetFunction(gate);
    if (CommonDebugSettings.getVerboseImport()) {
      LogUtils.logInfoLine(
          "Instantiating gate "
              + gate.name
              + " "
              + gate.function.name
              + "="
              + gate.function.formula);
      LogUtils.logInfoLine("  Set function: " + setFunction);
      LogUtils.logInfoLine("  Reset function: " + resetFunction);
    }
    try {
      BooleanFormula setFormula = CircuitUtils.parseContactFuncton(circuit, component, setFunction);
      contact.setSetFunctionQuiet(setFormula);
      BooleanFormula resetFormula =
          CircuitUtils.parseContactFuncton(circuit, component, resetFunction);
      contact.setResetFunctionQuiet(resetFormula);
    } catch (org.workcraft.formula.jj.ParseException e) {
      throw new RuntimeException(e);
    }
    return component;
  }
Beispiel #2
0
 private static List<String> processArg(String file) {
   Scanner sc = null;
   try {
     sc = new Scanner(new File(file));
   } catch (FileNotFoundException e) {
     LogUtils.logErrorLine(e.getMessage());
   }
   String targ = "";
   String larg = "";
   String sarg = "";
   while (sc.hasNextLine()) {
     Scanner line = new Scanner(sc.nextLine());
     Scanner nxt = new Scanner(line.next());
     String check = nxt.next();
     String str;
     if (check.startsWith("trace")) {
       nxt = new Scanner(line.next());
       targ = "-t";
       targ = targ + nxt.next();
     } else if (check.startsWith("level")) {
       nxt = new Scanner(line.next());
       larg = "-v";
       str = nxt.next();
       level = str;
       if (str.equals("normal")) {
         // System.out.println("Read v1");
         larg = "-v1";
       } else if (str.equals("advanced")) {
         // System.out.println("Read v2");
         larg = "-v2";
       }
     } else if (check.startsWith("display")) {
       nxt = new Scanner(line.next());
       str = nxt.next();
       // System.out.println("strrr=" + str);
       display = str;
     } else if (check.startsWith("highlight")) {
       nxt = new Scanner(line.next());
       str = nxt.next();
       // System.out.println("strrr=" + str);
       highlight = str;
     } else if (check.startsWith("soln")) {
       nxt = new Scanner(line.next());
       str = nxt.next();
       // System.out.println("solnnnnnnnnnnnnnnnnn=" + str);
       soln = str;
       sarg = "-s" + str;
     }
   }
   ArrayList<String> args = new ArrayList<>();
   if (!targ.isEmpty()) args.add(targ);
   if (!larg.isEmpty()) args.add(larg);
   if (!sarg.isEmpty()) args.add(sarg);
   return args;
 }
Beispiel #3
0
 private static String processEq(String file) {
   Scanner sc = null;
   try {
     sc = new Scanner(new File(file));
   } catch (FileNotFoundException e) {
     LogUtils.logErrorLine(e.getMessage());
   }
   String str = "";
   while (sc.hasNextLine()) {
     String line = sc.nextLine();
     // System.out.println(sc.next());
     str = str + line + '\n';
   }
   return str;
 }
Beispiel #4
0
 private static void processQsl(String file) {
   qslist.clear();
   Scanner sc = null;
   try {
     sc = new Scanner(new File(file));
   } catch (FileNotFoundException e) {
     LogUtils.logErrorLine(e.getMessage());
   }
   while (sc.hasNextLine()) {
     Scanner line = new Scanner(sc.nextLine());
     Scanner nxt = new Scanner(line.next());
     String check = nxt.next();
     nxt = new Scanner(line.next());
     String str = nxt.next();
     int num = Integer.parseInt(str);
     // System.out.println("qsl " + check + " " + str + " " + num);
     qslist.add(new Qslist(check, num));
   }
 }
  private void handleSynthesisResult(
      ExternalProcessResult mpsatResult, boolean sequentialAssign, RenderType renderType) {
    final String log = new String(mpsatResult.getOutput());
    if ((log != null) && !log.isEmpty()) {
      System.out.println(log);
      System.out.println();
    }
    byte[] eqnOutput = mpsatResult.getFileData(MpsatSynthesisTask.EQN_FILE_NAME);
    if (eqnOutput != null) {
      LogUtils.logInfoLine("MPSat synthesis result in EQN format:");
      System.out.println(new String(eqnOutput));
      System.out.println();
    }
    byte[] verilogOutput = mpsatResult.getFileData(MpsatSynthesisTask.VERILOG_FILE_NAME);
    if (verilogOutput != null) {
      LogUtils.logInfoLine("MPSat synthesis result in Verilog format:");
      System.out.println(new String(verilogOutput));
      System.out.println();
    }
    if (MpsatSynthesisUtilitySettings.getOpenSynthesisResult() && (verilogOutput != null)) {
      try {
        ByteArrayInputStream in = new ByteArrayInputStream(verilogOutput);
        VerilogImporter verilogImporter = new VerilogImporter(sequentialAssign);
        final Circuit circuit = verilogImporter.importCircuit(in);
        final WorkspaceEntry we = task.getWorkspaceEntry();
        Path<String> path = we.getWorkspacePath();
        final Path<String> directory = path.getParent();
        final String name = FileUtils.getFileNameWithoutExtension(new File(path.getNode()));
        final ModelEntry me = new ModelEntry(new CircuitDescriptor(), circuit);
        boolean openInEditor = me.isVisual() || CommonEditorSettings.getOpenNonvisual();

        final Framework framework = Framework.getInstance();
        final Workspace workspace = framework.getWorkspace();
        WorkspaceEntry newWorkspaceEntry = workspace.add(directory, name, me, true, openInEditor);
        VisualModel visualModel = newWorkspaceEntry.getModelEntry().getVisualModel();
        if (visualModel instanceof VisualCircuit) {
          VisualCircuit visualCircuit = (VisualCircuit) visualModel;
          for (VisualFunctionComponent component : visualCircuit.getVisualFunctionComponents()) {
            component.setRenderType(renderType);
          }
          String title = we.getModelEntry().getModel().getTitle();
          visualCircuit.setTitle(title);
          if (!we.getFile().exists()) {
            JOptionPane.showMessageDialog(
                null,
                "Error: Unsaved STG cannot be set as the circuit environment.",
                TITLE,
                JOptionPane.ERROR_MESSAGE);
          } else {
            visualCircuit.setEnvironmentFile(we.getFile());
            if (we.isChanged()) {
              JOptionPane.showMessageDialog(
                  null,
                  "Warning: The STG with unsaved changes is set as the circuit environment.",
                  TITLE,
                  JOptionPane.WARNING_MESSAGE);
            }
          }
          SwingUtilities.invokeLater(
              new Runnable() {
                @Override
                public void run() {
                  framework.getMainWindow().getCurrentEditor().updatePropertyView();
                }
              });
        }
      } catch (DeserialisationException e) {
        throw new RuntimeException(e);
      }
    }
  }