Exemple #1
0
  private String showComponent(Component comp) {
    String ret = comp.toString();
    for (Port port : comp.getPorts()) {
      String value = port.getValue() == null ? "null" : port.getValue().debug();
      if (port == comp.getGoPort() || port == comp.getClockPort() || port == comp.getResetPort()) ;
      else ret = ret + " p:" + value;
      /*
       * if (port == getGoPort()) ret = ret + " go:" + val; else if (port
       * == getClockPort()) ret = ret + " ck:" + val; else if (port ==
       * getResetPort()) ret = ret + " rs:" + val; else ret = ret + " p:"
       * + val;
       */
    }
    for (Exit exit : comp.getExits()) {
      for (Bus bus : exit.getBuses()) {
        String value = bus.getValue() == null ? "null" : bus.getValue().debug();
        if (bus == exit.getDoneBus())
          // ret = ret + " done:" + val;
          ;
        else ret = ret + " data:" + value;
      }
    }

    return ret;
  }
Exemple #2
0
    public SignExtend(UnaryOp cast) {
      Iterator<Port> ports = cast.getDataPorts().iterator();
      Port d_port = ports.next();
      assert (d_port.isUsed()) : "Operand port in unary operation is set to unused.";
      Bus d_bus = d_port.getBus();
      assert (d_bus != null) : "Operand port in unary operation not attached to a bus.";
      PortWire pwire = new PortWire(d_port);
      if (pwire.getExpression() instanceof BaseNumber) {
        // input is a constant value, so the resize should be a no-op?
      } else {
        if (pwire.getExpression() instanceof Wire) {
          operand = (Wire) pwire.getExpression();
        } else {
          operand =
              new Wire(ID.toVerilogIdentifier(ID.showLogical(cast)), d_port.getValue().getSize());
          add(new Assign.Continuous(operand, new PortWire(d_port)));
          produced_nets.add(operand);
        }

        result_wire = NetFactory.makeNet(cast.getResultBus());
        produced_nets.add(result_wire);

        int result_width = result_wire.getWidth();

        /** unsigned value will be padded with zeros * */
        add(
            new Assign.Continuous(
                result_wire,
                new org.xronos.openforge.verilog.pattern.SignExtend(operand, result_width)));
      }
    }
Exemple #3
0
 /** Graphs the incoming connections to a component's ports. */
 protected void graphEdges(Component component, Bus src) {
   ComponentNode componentNode = (ComponentNode) nodeMap.get(component);
   graphEdge(componentNode, component.getGoPort());
   for (org.xronos.openforge.lim.Port port : component.getDataPorts()) {
     if (port.getBus() == src) {
       graphEdge(componentNode, port);
     }
   }
 }
Exemple #4
0
    Output(OutputPin opin, int nodeCount, int fontSize) {
      super(ID.showLogical(opin), nodeCount, fontSize);
      _graph.ln("Output Pin: " + opin);
      graph(opin, nodeCount++);
      Port p = opin.getPort();
      Bus b = p.getBus();
      graph(b.getOwner().getOwner(), nodeCount++);

      graphEdges(opin);
    }
Exemple #5
0
  /**
   * Completes RegisterRead and RegisterWrite connections passed up to the top-level as side-band
   * ports and buses.
   *
   * @param design the Design which has Registers
   * @param frame the ConnectionFrame which describes the read/write connections
   */
  private void connectGlobalRegisters(Design design, ConnectionFrame frame) {
    // boolean isLittleEndian = EngineThread.getGenericJob()
    // .getUnscopedBooleanOptionValue(OptionRegistry.LITTLE_ENDIAN);

    for (Register register : design.getRegisters()) {
      List<Connection> readList = frame.getReadConnections(register);
      List<Connection> writeList = frame.getWriteConnections(register);

      if (readList.isEmpty() && writeList.isEmpty()) {
        continue;
      }

      Component regPhys = register.makePhysicalComponent(readList, writeList);
      if (register.getInputSwapper() != null) {
        design.getDesignModule().addComponent(register.getInputSwapper());
      }
      design.getDesignModule().addComponent(regPhys);
      if (register.getOutputSwapper() != null) {
        design.getDesignModule().addComponent(register.getOutputSwapper());
      }

      assert regPhys != null;

      if (!writeList.isEmpty()) {
        final Iterator<Port> writePortIter = regPhys.getDataPorts().iterator();
        for (Iterator<Connection> writeListIter = writeList.iterator(); writeListIter.hasNext(); ) {
          final RegisterWriteConnection writeConn = (RegisterWriteConnection) writeListIter.next();
          if (writeConn != null) {
            assert writePortIter.hasNext() : "Too few ports on register physical (enable)";
            final Port enablePort = writePortIter.next();
            assert writePortIter.hasNext() : "Too few ports on register physical (data)";
            final Port dataPort = writePortIter.next();
            enablePort.setBus(writeConn.getEnable());
            dataPort.setBus(writeConn.getData());
          }
        }
      }

      if (!readList.isEmpty()) {
        Bus registerResultBus = null;
        Exit physicalExit = regPhys.getExit(Exit.DONE);
        registerResultBus = physicalExit.getDataBuses().get(0);

        for (Connection connection : readList) {
          RegisterReadConnection rp = (RegisterReadConnection) connection;
          // The read connetion may be null because we had
          // to pad out the pairs in the connection list for
          // the referee.
          if (rp != null) {
            rp.getDataPort().setBus(registerResultBus);
          }
        }
      }
    }
  }
 private boolean findUnknownGateDepthOnInputs(Component component) {
   for (Port port : component.getPorts()) {
     // assert (port.isConnected() &&
     // this.exitToGateDepthMap.containsKey(port.getBus().getOwner()));
     if (port.isConnected() && !exitToGateDepthMap.containsKey(port.getBus().getOwner())) {
       unresolvedGateDepthComponents.push(component);
       return true;
     }
   }
   return false;
 }
Exemple #7
0
    Input(InputPin ipin, int nodeCount, int fontSize) {
      super(ID.showLogical(ipin), nodeCount, fontSize);
      graph(ipin, nodeCount++);
      _graph.ln("Input Pin: " + ipin);

      Bus b = ipin.getBus();
      for (Port p : b.getPorts()) {
        Component c = p.getOwner();
        graph(c, nodeCount++);
        graphEdges(c, b);
      }
    }
 private int getMaxInputGateDepth(Component component) {
   int maxGateDepth = 0;
   component = (component instanceof InBuf) ? component.getOwner() : component;
   for (Port port : component.getPorts()) {
     if (port == component.getClockPort() || port == component.getResetPort()) {
       continue;
     }
     int gateDepth =
         port.isConnected() ? exitToGateDepthMap.get(port.getBus().getOwner()).intValue() : 0;
     maxGateDepth = Math.max(maxGateDepth, gateDepth);
   }
   return maxGateDepth;
 }
Exemple #9
0
  public UnaryOpAssignment(UnaryOp uo, boolean checkBalance) {
    Iterator<Port> ports = uo.getDataPorts().iterator();
    Port d_port = ports.next();
    assert (d_port.isUsed()) : "Operand port in unary operation is set to unused.";
    // Bus d_bus = d_port.getBus();
    // assert (d_bus != null) :
    // "Operand port in unary operation not attached to a bus.";
    assert (d_port.getValue() != null) : "Operand port in unary operation does not have a value.";
    operand = new PortWire(d_port);

    result_wire = NetFactory.makeNet(uo.getResultBus());

    add(new Assign.Continuous(result_wire, makeOpExpression(operand), checkBalance));
  }
Exemple #10
0
 private InputPin connectInputPin(Design design, Call call, Port port, String name) {
   Port procedurePort = call.getProcedurePort(port);
   InputPin pin = new InputPin(procedurePort);
   port.setBus(pin.getBus());
   IDSourceInfo info =
       (name != null)
           ? call.getProcedure().getIDSourceInfo().deriveField(name, -1, -1)
           : procedurePort.getIDSourceInfo();
   pin.setIDSourceInfo(info);
   Bus pinBus = pin.getBus();
   pinBus.setUsed(true);
   port.setBus(pinBus);
   design.addInputPin(pin, port);
   return pin;
 }
 @Override
 public void visit(OutBuf outBuf) {
   if (!findUnknownGateDepthOnInputs(outBuf)) {
     preFilter(outBuf);
     traverse(outBuf);
     final Integer currentGateDepth =
         new Integer(getMaxInputGateDepth(outBuf) + outBuf.getExitGateDepth());
     for (Port port : outBuf.getPorts()) {
       final Bus moduleBus = port.getPeer();
       if (moduleBus != null) {
         exitToGateDepthMap.put(moduleBus.getOwner(), currentGateDepth);
       }
     }
     if (currentGateDepth.intValue() >= taskMaxGateDepth) {
       taskMaxGateDepth = currentGateDepth.intValue();
     }
     if (_schedule.db)
       _schedule.ln(
           _schedule.GDA, outBuf + ", current gate depth: " + currentGateDepth.intValue());
     postFilter(outBuf);
   }
 }
Exemple #12
0
  public void stateLogic(Module module, StateMachine mach, Design design) {
    /*
     * if(allGos) begin <statements> end
     */
    SequentialBlock AllGos = new SequentialBlock();
    ConditionalStatement ifAllGos = new ConditionalStatement(mach.getAllGoWire(), AllGos);

    // benchNumReads = benchNumReads + 1; //
    AllGos.add(
        new Assign.Blocking(
            benchNumReads,
            new org.xronos.openforge.verilog.model.Math.Add(
                benchNumReads, new Constant(1, benchNumReads.getWidth()))));
    // benchInReadZone = 1; //
    AllGos.add(new Assign.Blocking(benchInReadZone, new Constant(1, benchInReadZone.getWidth())));

    /*
     * if(benchWorkInProgress === 0) begin benchWorkInProgress = 1;
     * benchFirstReadCycle = benchClockCount ; end
     */
    SequentialBlock bwp = new SequentialBlock();
    bwp.add(new Assign.Blocking(benchWorkInProgress, new Constant(1, benchInReadZone.getWidth())));
    bwp.add(new Assign.Blocking(benchFirstReadCycle, benchClockCount));

    Compare.EQ eq1 =
        new Compare.EQ(benchWorkInProgress, new Constant(0, benchWorkInProgress.getWidth()));
    ConditionalStatement ifbwp = new ConditionalStatement(eq1, bwp);
    AllGos.add(ifbwp);

    // benchReadZoneCyclesCounterSave = benchReadZoneCyclesCounter;
    AllGos.add(new Assign.Blocking(benchReadZoneCyclesCounterSave, benchReadZoneCyclesCounter));
    // benchCoreCyclesCounter = 0;
    AllGos.add(
        new Assign.Blocking(
            benchCoreCyclesCounter, new Constant(0, benchCoreCyclesCounter.getWidth())));

    /*
     * if(benchInWriteZone === 1) begin benchWriteZoneCycles =
     * benchWriteZoneCycles + benchWrietZoneCyclesCounterSave + 1;
     * benchWriteZoneCYlcesCounter = 0; benchInWriteZone = 0; end
     */
    SequentialBlock bwz = new SequentialBlock();
    bwz.add(
        new Assign.Blocking(
            benchWriteZoneCycles,
            new Math.Add(
                new Math.Add(benchWriteZoneCycles, benchWriteZoneCyclesCounterSave),
                new Constant(1, 32))));
    bwz.add(
        new Assign.Blocking(
            benchWriteZoneCyclesCounter, new Constant(0, benchWriteZoneCyclesCounter.getWidth())));
    bwz.add(new Assign.Blocking(benchInWriteZone, new Constant(0, benchInWriteZone.getWidth())));
    Compare.EQ eq2 = new Compare.EQ(benchInWriteZone, new Constant(1, benchInWriteZone.getWidth()));
    ConditionalStatement ifbwz = new ConditionalStatement(eq2, bwz);
    AllGos.add(ifbwz);

    /*
     * if(benchIdleFlag == 1) begin benchIdleCycles = benchIdleCycles +
     * benchIdleCyclesCounter - 1; benchIdleFlag = 0; end
     */
    SequentialBlock bif = new SequentialBlock();
    bif.add(
        new Assign.Blocking(
            benchIdleCycles,
            new Math.Subtract(
                new Math.Add(benchIdleCycles, benchIdleCyclesCounter),
                new Constant(1, benchIdleCycles.getWidth()))));
    bif.add(new Assign.Blocking(benchIdleFlag, new Constant(0, benchIdleFlag.getWidth())));
    Compare.EQ eq3 = new Compare.EQ(benchIdleFlag, new Constant(1, benchIdleFlag.getWidth()));
    ConditionalStatement ifbif = new ConditionalStatement(eq3, bif);
    AllGos.add(ifbif);

    /*
     * if(allDones) begin <statements> end
     */
    SequentialBlock AllDones = new SequentialBlock();
    ConditionalStatement ifAllDones = new ConditionalStatement(mach.getAllDoneWire(), AllDones);

    // benchNumWrites = benchNumWrites + 1; //
    AllDones.add(
        new Assign.Blocking(
            benchNumWrites,
            new Math.Add(benchNumWrites, new Constant(1, benchNumWrites.getWidth()))));
    // benchInWriteZone = 1; //
    AllDones.add(
        new Assign.Blocking(benchInWriteZone, new Constant(1, benchInWriteZone.getWidth())));

    /*
     * if(benchInReadZone === 1) begin benchReadZoneCycles =
     * benchReadZoneCycles + benchReadZoneCyclesCounterSave + 1;
     * benchReadZoneCyclesCounter = 0; benchInReadZone = 0;
     * benchWriteZoneCyclesCounter = 0; benchCoreCycles = benchCoreCycles +
     * benchCoreCyclesCounetr end
     */
    SequentialBlock brz = new SequentialBlock();
    brz.add(
        new Assign.Blocking(
            benchReadZoneCycles,
            new Math.Add(
                new Math.Add(benchReadZoneCycles, benchReadZoneCyclesCounterSave),
                new Constant(1, benchReadZoneCycles.getWidth()))));
    brz.add(
        new Assign.Blocking(
            benchReadZoneCyclesCounter, new Constant(0, benchReadZoneCyclesCounter.getWidth())));
    brz.add(new Assign.Blocking(benchInReadZone, new Constant(0, benchInReadZone.getWidth())));
    brz.add(
        new Assign.Blocking(
            benchWriteZoneCyclesCounter, new Constant(0, benchWriteZoneCyclesCounter.getWidth())));
    brz.add(
        new Assign.Blocking(
            benchCoreCycles, new Math.Add(benchCoreCycles, benchCoreCyclesCounter)));
    Compare.EQ eq4 = new Compare.EQ(benchInReadZone, new Constant(1, benchInReadZone.getWidth()));
    ConditionalStatement ifbrz = new ConditionalStatement(eq4, brz);
    AllDones.add(ifbrz);

    /*
     * if(allGos==1) begin benchCoreCycles = benchCoreCycles + 1; end
     */
    AllDones.add(
        new ConditionalStatement(
            new Compare.EQ(mach.getAllGoWire(), new Constant(1, 1)),
            new Assign.Blocking(
                benchCoreCycles,
                new Math.Add(benchCoreCycles, new Constant(1, benchCoreCycles.getWidth())))));

    // benchWriteZoneCyclesCounterSave = benchWriteZoneCyclesCounter;
    AllDones.add(new Assign.Blocking(benchWriteZoneCyclesCounterSave, benchWriteZoneCyclesCounter));
    // benchLastWriteCycle = benchClockCount + 1;
    AllDones.add(
        new Assign.Blocking(
            benchLastWriteCycle,
            new Math.Add(benchClockCount, new Constant(1, benchClockCount.getWidth()))));
    // benchIdleFlag = 1;
    AllDones.add(new Assign.Blocking(benchIdleFlag, new Constant(1, benchIdleFlag.getWidth())));
    // benchIdleCyclesCounter = 0;
    AllDones.add(
        new Assign.Blocking(
            benchIdleCyclesCounter, new Constant(0, benchIdleCyclesCounter.getWidth())));

    /*
     * if(done) begin <statements> end
     */
    SequentialBlock done = new SequentialBlock();
    ConditionalStatement ifdone = new ConditionalStatement(mach.getDone(), done);

    // benchWriteZoneCycles = benchWriteZoneCycles +
    // benchWriteZoneCyclesCounterSave + 1;
    done.add(
        new Assign.Blocking(
            benchWriteZoneCycles,
            new Math.Add(
                new Math.Add(benchWriteZoneCycles, benchWriteZoneCyclesCounterSave),
                new Constant(1, benchWriteZoneCycles.getWidth()))));
    // benchTotalCycles = benchLastWriteCycle - benchFirstReadCycle;
    done.add(
        new Assign.Blocking(
            benchTotalCycles, new Math.Subtract(benchLastWriteCycle, benchFirstReadCycle)));

    // Find the number of input bytes and number of outputbytes //
    Collection<Task> tasks = design.getTasks();
    // System.out.println("Number of tasks = " + tasks.size());
    int inputsize = 0, outputsize = 0;
    Iterator<Task> iter = tasks.iterator();
    while (iter.hasNext()) {
      Task task = iter.next();
      Call call = task.getCall();

      for (Port port : call.getDataPorts()) {
        inputsize += port.getSize();
      }

      // System.out.println("Input Size Bits = " + inputsize);

      for (Bus bus : call.getExit(Exit.DONE).getDataBuses()) {
        outputsize += bus.getSize();
      }

      // System.out.println("Output Size Bits = " + outputsize);
    }
    Constant benchArgSizeBytes = new Constant(inputsize / 8, 32);
    Constant benchResSizeBytes = new Constant(outputsize / 8, 32);

    Constant hunderd = new Constant(100, 32);

    // benchThroughput = (benchNumReads *
    // benchArgSizeBits/8.0)/(benchTotalCycles);
    done.add(
        new Assign.Blocking(
            benchThroughput,
            new Math.Divide(
                new Math.Multiply(benchNumReads, benchArgSizeBytes), benchTotalCycles)));
    // benchOverallInputUtil = (benchNumReads / benchTotalCycles) * 100.0;
    done.add(
        new Assign.Blocking(
            benchOverallInputUtil,
            new Math.Multiply(new Math.Divide(benchNumReads, benchTotalCycles), hunderd)));

    // benchOverallOutputUtil = (benchNumWrites / benchTotalCycles) * 100.0;
    done.add(
        new Assign.Blocking(
            benchOverallOutputUtil,
            new Math.Multiply(new Math.Divide(benchNumWrites, benchTotalCycles), hunderd)));

    // benchOverallCoreUtil = (benchCoreCycles / benchTotalCycles) * 100.0;
    done.add(
        new Assign.Blocking(
            benchOverallCoreUtil,
            new Math.Multiply(new Math.Divide(benchCoreCycles, benchTotalCycles), hunderd)));

    // benchIdlePercentage = (benchIdleCycles / benchTotalCycles) * 100.0;
    done.add(
        new Assign.Blocking(
            benchIdlePercentage,
            new Math.Multiply(new Math.Divide(benchIdleCycles, benchTotalCycles), hunderd)));

    // benchZoneInputUtil = (benchNumReads/benchReadZoneCycles) * 100.0;
    done.add(
        new Assign.Blocking(
            benchZoneInputUtil,
            new Math.Multiply(new Math.Divide(benchNumReads, benchReadZoneCycles), hunderd)));

    // benchZoneOutputUtil = (benchNumWrites/benchWriteZoneCycles) * 100.0;
    done.add(
        new Assign.Blocking(
            benchZoneOutputUtil,
            new Math.Multiply(new Math.Divide(benchNumWrites, benchWriteZoneCycles), hunderd)));

    // benchZoneCoreUtil = (benchCoreCycles/benchCoreCycles) * 100.0;
    done.add(
        new Assign.Blocking(
            benchZoneCoreUtil,
            new Math.Multiply(new Math.Divide(benchCoreCycles, benchCoreCycles), hunderd)));

    // WUSIWUG ! //
    CommaDelimitedStatement cds = new CommaDelimitedStatement();
    cds.append(
        new StringStatement("**********************************************************\\n"));
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    cds = new CommaDelimitedStatement();
    cds.append(
        new StringStatement("******************** BENCHMARK REPORT ********************\\n"));
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    cds = new CommaDelimitedStatement();
    cds.append(
        new StringStatement("**********************************************************\\n"));
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Total Number of Cycles               : %0d\n", benchClockCount);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Total Number of Cycles               : %0d\\n"));
    cds.append(benchClockCount);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Data Crunching Cycles                : %0d\n", benchTotalCycles);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Data Crunching Cycles                : %0d\\n"));
    cds.append(benchTotalCycles);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Number of Idle Cycles                : %0d\n", benchIdleCycles);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Number of Idle Cycles                : %0d\\n"));
    cds.append(benchIdleCycles);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Number of Reads                      : %0d\n", benchNumReads);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Number of Reads                      : %0d\\n"));
    cds.append(benchNumReads);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Bytes Consumed                       : %0g\n", benchNumReads *
    // benchArgSizeBits/8.0);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Bytes Consumed                       : %0d\\n"));
    cds.append(new Math.Multiply(benchNumReads, benchArgSizeBytes));
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Number of Writes                     : %0d\n", benchNumWrites);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Number of Writes                     : %0d\\n"));
    cds.append(benchNumWrites);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Bytes Produced                       : %0g\n", benchNumWrites *
    // benchResSizeBits/8.0);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Bytes Produced                       : %0d\\n"));
    cds.append(new Math.Multiply(benchNumWrites, benchResSizeBytes));
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "First Read Cycle                     : %0d\n", benchFirstReadCycle);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("First Read Cycle                     : %0d\\n"));
    cds.append(benchFirstReadCycle);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Last Write Cycle                     : %0d\n", benchLastWriteCycle);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Last Write Cycle                     : %0d\\n"));
    cds.append(benchLastWriteCycle);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Throughput(Bytes Consumed/Cycle)     : %0g\n", benchThroughput);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Throughput(Bytes Consumed/Cycle)     : %0g\\n"));
    cds.append(benchThroughput);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "****** Overall *******************************************\n");
    cds = new CommaDelimitedStatement();
    cds.append(
        new StringStatement("****** Overall *******************************************\\n"));
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    // $fwrite (benchmarkReportFile,
    // "Overall Input Link Utilization       : %0g\n",
    // benchOverallInputUtil);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Overall Input Link Utilization       : %0g\\n"));
    cds.append(benchOverallInputUtil);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    // $fwrite (benchmarkReportFile,
    // "Overall Core Utilization             : %0g\n",
    // benchOverallCoreUtil);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Overall Core Utilization             : %0g\\n"));
    cds.append(benchOverallCoreUtil);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    // $fwrite (benchmarkReportFile,
    // "Overall Output Link Utilization      : %0g\n",
    // benchOverallOutputUtil);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Overall Output Link Utilization      : %0g\\n"));
    cds.append(benchOverallOutputUtil);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    // $fwrite (benchmarkReportFile,
    // "Percentage of Idle Cycles            : %0g\n", benchIdlePercentage);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Percentage of Idle Cycles            : %0g\\n"));
    cds.append(benchIdlePercentage);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    // $fwrite (benchmarkReportFile,
    // "******** Zonal *******************************************\n");
    cds = new CommaDelimitedStatement();
    cds.append(
        new StringStatement("******** Zonal *******************************************\\n"));
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    // $fwrite (benchmarkReportFile,
    // "Zone Input Link Utilization          : %0g\n", benchZoneInputUtil);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Zone Input Link Utilization          : %0g\\n"));
    cds.append(benchZoneInputUtil);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    // $fwrite (benchmarkReportFile,
    // "Zone Core Utilization                : %0g\n", benchZoneCoreUtil);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Zone Core Utilization                : %0g\\n"));
    cds.append(benchZoneCoreUtil);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    // $fwrite (benchmarkReportFile,
    // "Zone Output Link Utilization         : %0g\n", benchZoneOutputUtil);
    cds = new CommaDelimitedStatement();
    cds.append(new StringStatement("Zone Output Link Utilization         : %0g\\n"));
    cds.append(benchZoneOutputUtil);
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));
    // $fwrite (benchmarkReportFile,
    // "**********************************************************\n");
    cds = new CommaDelimitedStatement();
    cds.append(
        new StringStatement("**********************************************************\\n"));
    done.add(new FStatement.FWrite(reportFile.getHandle(), cds));

    SequentialBlock sblock = new SequentialBlock();
    sblock.add(ifAllGos);
    sblock.add(ifAllDones);
    sblock.add(ifdone);

    // benchClockCount = benchClockCount + 1;
    sblock.add(
        new Assign.Blocking(
            benchClockCount,
            new Math.Add(benchClockCount, new Constant(1, benchClockCount.getWidth()))));
    // benchIdleCyclesCounter = benchIdleFlag == 1 ? benchIdleCyclesCounter
    // + 1 : benchIdleCyclesCounter;
    sblock.add(
        new ConditionalStatement(
            new Compare.EQ(benchIdleFlag, new Constant(1, benchIdleFlag.getWidth())),
            new Assign.Blocking(
                benchIdleCyclesCounter,
                new Math.Add(
                    benchIdleCyclesCounter, new Constant(1, benchIdleCyclesCounter.getWidth()))),
            new Assign.Blocking(benchIdleCyclesCounter, benchIdleCyclesCounter)));
    // benchCoreCyclesCounter = benchCoreCyclesCounter + 1;
    sblock.add(
        new Assign.Blocking(
            benchCoreCyclesCounter,
            new Math.Add(
                benchCoreCyclesCounter, new Constant(1, benchCoreCyclesCounter.getWidth()))));
    // benchReadZoneCyclesCounter = benchInReadZone == 1 ?
    // benchReadZoneCyclesCounter + 1 : benchReadZoneCyclesCounter;
    sblock.add(
        new ConditionalStatement(
            new Compare.EQ(benchInReadZone, new Constant(1, benchInReadZone.getWidth())),
            new Assign.Blocking(
                benchReadZoneCyclesCounter,
                new Math.Add(
                    benchReadZoneCyclesCounter,
                    new Constant(1, benchReadZoneCyclesCounter.getWidth()))),
            new Assign.Blocking(benchReadZoneCyclesCounter, benchReadZoneCyclesCounter)));
    // benchWriteZoneCyclesCounter = benchInWriteZone == 1 ?
    // benchWriteZoneCyclesCounter + 1 : benchWriteZoneCyclesCounter;
    sblock.add(
        new ConditionalStatement(
            new Compare.EQ(benchInWriteZone, new Constant(1, benchInWriteZone.getWidth())),
            new Assign.Blocking(
                benchWriteZoneCyclesCounter,
                new Math.Add(
                    benchWriteZoneCyclesCounter,
                    new Constant(1, benchWriteZoneCyclesCounter.getWidth()))),
            new Assign.Blocking(benchWriteZoneCyclesCounter, benchWriteZoneCyclesCounter)));

    ProceduralTimingBlock ptb =
        new ProceduralTimingBlock(
            new EventControl(new EventExpression.PosEdge(mach.getClock())), sblock);

    module.state(new Always(ptb));
  }
Exemple #13
0
  @SuppressWarnings("unchecked")
  @Override
  public Loop caseBlockWhile(BlockWhile blockWhile) {
    // Initialize members
    Map<Var, Port> inputs = new HashMap<Var, Port>();
    Map<Var, Bus> outputs = new HashMap<Var, Bus>();

    Map<Bus, Var> feedbackBusVar = new HashMap<Bus, Var>();
    Map<Bus, Var> completeBusVar = new HashMap<Bus, Var>();
    // -- Decision
    // Construct decision from the block while condition
    Block decisionBlock = null;
    Component valueComponent = new ExprToComponent().doSwitch(blockWhile.getCondition());

    Map<Var, Port> dBlockDataPorts = null;

    if (!(valueComponent instanceof Block)) {
      dBlockDataPorts = new HashMap<Var, Port>();
      Map<Var, Port> valueDataPorts =
          (Map<Var, Port>) blockWhile.getCondition().getAttribute("inputs").getObjectValue();
      decisionBlock = new Block(Arrays.asList(valueComponent));
      // Propagate DataPorts
      ComponentUtil.propagateDataPorts(decisionBlock, dBlockDataPorts, valueDataPorts);
      // Propagate DataBuses
      for (Bus dataBus : valueComponent.getExit(Exit.DONE).getDataBuses()) {
        Bus blockDataBus = decisionBlock.getExit(Exit.DONE).makeDataBus();
        Port blockDataBuspeer = blockDataBus.getPeer();
        ComponentUtil.connectDataDependency(dataBus, blockDataBuspeer, 0);
      }
    } else {
      decisionBlock = (Block) valueComponent;
      dBlockDataPorts =
          (Map<Var, Port>) blockWhile.getCondition().getAttribute("inputs").getObjectValue();
    }

    Component decisionComponent = ComponentUtil.decisionFindConditionComponent(decisionBlock);

    // Create decision
    Decision decision = new Decision(decisionBlock, decisionComponent);

    Debug.depGraphTo(decision, "deicions", "/tmp/decision1.dot", 1);

    // Propagate decisionBlockInputs to the decision one
    Map<Var, Port> dDataPorts = new HashMap<Var, Port>();
    ComponentUtil.propagateDataPorts(decision, dDataPorts, dBlockDataPorts);

    // -- Loop Body
    // Construct Loop Body Block from the block while blocks
    Map<Var, Port> blockDataPorts = new HashMap<Var, Port>();
    Map<Var, Bus> blockDataBuses = new HashMap<Var, Bus>();

    Module body =
        (Module)
            new BlocksToBlock(blockDataPorts, blockDataBuses, false)
                .doSwitch(blockWhile.getBlocks());

    // Loop body (While Body) inputs and outputs
    Map<Var, Port> lbDataPorts = new HashMap<Var, Port>();

    LoopBody loopBody = new WhileBody(decision, body);
    Debug.depGraphTo(loopBody, "loopBody", "/tmp/loopBody.dot", 1);
    // Propagate decision and body inputs to the loopBody
    // -- Propagate Decision data ports
    ComponentUtil.propagateDataPorts(loopBody, lbDataPorts, dDataPorts);

    // -- Propagate Body Blocks data ports
    ComponentUtil.propagateDataPorts(loopBody, lbDataPorts, blockDataPorts);

    // -- Complete Exit
    for (Var var : blockDataBuses.keySet()) {
      Type type = var.getType();
      Bus bus = blockDataBuses.get(var);
      // -- Make an complete exit data bus
      Bus cBus =
          loopBody
              .getLoopCompleteExit()
              .makeDataBus(var.getName() + "_fb", type.getSizeInBits(), type.isInt());
      // -- Connect
      Port cBusPeer = cBus.getPeer();
      ComponentUtil.connectDataDependency(bus, cBusPeer);
      // -- Save it to the feedbackBusVar
      completeBusVar.put(cBus, var);
    }

    // -- FeedBack Exit
    for (Var var : blockDataBuses.keySet()) {
      Type type = var.getType();
      // -- If the input does not exist create one because this is a
      // feedback
      if (!lbDataPorts.containsKey(var)) {
        Port lbPort =
            loopBody.makeDataPort(var.getName() + "_fb", type.getSizeInBits(), type.isInt());
        lbDataPorts.put(var, lbPort);
      }
      Bus bus = blockDataBuses.get(var);
      // -- Make an feedback exit data bus
      Bus fbBus =
          loopBody
              .getFeedbackExit()
              .makeDataBus(var.getName() + "_fb", type.getSizeInBits(), type.isInt());
      // -- Connect
      Port fbBusPeer = fbBus.getPeer();
      ComponentUtil.connectDataDependency(bus, fbBusPeer);
      // -- Save it to the feedbackBusVar
      feedbackBusVar.put(fbBus, var);
    }

    // -- From input to Complete Exit dependency
    for (Bus bus : completeBusVar.keySet()) {
      Var var = completeBusVar.get(bus);
      Port port = lbDataPorts.get(var);
      // -- Connect it
      Port busPeer = bus.getPeer();
      Bus portpeer = port.getPeer();
      ComponentUtil.connectDataDependency(portpeer, busPeer);
    }

    // Create Loop
    Loop loop = new Loop(loopBody);

    // -- Loop inputs comes from decision and body
    Set<Var> inVars = new HashSet<Var>();
    inVars.addAll(dDataPorts.keySet());
    inVars.addAll(lbDataPorts.keySet());

    for (Var var : inVars) {
      Type type = var.getType();
      Port dataPort = loop.makeDataPort(var.getName(), type.getSizeInBits(), type.isInt());
      inputs.put(var, dataPort);
    }

    // -- Init Dependencies
    Entry initEntry = loop.getBodyInitEntry();
    for (Var var : inputs.keySet()) {
      if (feedbackBusVar.containsValue(var)) {
        Port lPort = inputs.get(var);
        Port lbPort = lbDataPorts.get(var);
        Bus lPortPeer = lPort.getPeer();
        Dependency dep =
            (lbPort == lbPort.getOwner().getGoPort())
                ? new ControlDependency(lPortPeer)
                : new DataDependency(lPortPeer);
        initEntry.addDependency(lbPort, dep);
      }
    }

    // -- Feedback Dependencies
    Entry fbEntry = loop.getBodyFeedbackEntry();
    for (Bus bus : feedbackBusVar.keySet()) {
      Var var = feedbackBusVar.get(bus);
      Exit lfbExit = loop.getBody().getFeedbackExit();
      Port lbPort = lbDataPorts.get(var);

      // -- Create a feedback register
      Reg fbReg = loop.createDataRegister();
      fbReg.setIDLogical("fbReg_" + var.getName());
      // fbReg.getDataPort().setIDLogical(var.getName());
      // fbReg.getResultBus().setIDLogical(var.getName());

      // -- Dependencies
      Entry entry = fbReg.makeEntry(lfbExit);
      entry.addDependency(fbReg.getDataPort(), new DataDependency(bus));
      fbEntry.addDependency(lbPort, new DataDependency(fbReg.getResultBus()));
    }

    // -- Latch Dependencies
    Collection<Dependency> goInitDeps = initEntry.getDependencies(loop.getBody().getGoPort());
    Bus initDoneBus = goInitDeps.iterator().next().getLogicalBus();
    for (Var var : inVars) {
      if (!feedbackBusVar.containsValue(var)) {
        Port lPort = inputs.get(var);
        Bus lPortPeer = lPort.getPeer();

        // -- Create a latch
        Latch latch = loop.createDataLatch();
        latch.setIDLogical("latched_" + var.getName());

        // -- Dependencies
        Entry latchEntry = latch.makeEntry(initDoneBus.getOwner());
        latch.getDataPort().setIDLogical(var.getName());
        // -- Control dependency
        latchEntry.addDependency(latch.getEnablePort(), new ControlDependency(initDoneBus));
        // -- Data dependency in latch
        latchEntry.addDependency(latch.getDataPort(), new DataDependency(lPortPeer));
        // -- Data dependency out latch
        Bus latchResultBus = latch.getResultBus();
        latchResultBus.setIDLogical(var.getName() + "_result");

        Port lbPort = lbDataPorts.get(var);
        fbEntry.addDependency(lbPort, new DataDependency(latchResultBus));
      }
    }

    // -- Done Dependencies
    Entry outbufEntry = loop.getExit(Exit.DONE).getPeer().getEntries().get(0);
    for (Bus bus : loopBody.getLoopCompleteExit().getDataBuses()) {
      Var var = completeBusVar.get(bus);
      Type type = var.getType();
      Bus dataBus =
          loop.getExit(Exit.DONE).makeDataBus(var.getName(), type.getSizeInBits(), type.isInt());
      Port dataBusPeer = dataBus.getPeer();
      Dependency dep = new DataDependency(bus);
      outbufEntry.addDependency(dataBusPeer, dep);
      outputs.put(var, dataBus);
    }

    // -- Set control dependency
    Port lbDonePort = loopBody.getLoopCompleteExit().getDoneBus().getPeer();
    Bus lDoneBus = loop.getExit(Exit.DONE).getDoneBus();
    Dependency dep = new ControlDependency(lDoneBus);
    outbufEntry.addDependency(lbDonePort, dep);

    // -- IDSourceInfo
    Procedure procedure = EcoreHelper.getContainerOfType(blockWhile, Procedure.class);
    IDSourceInfo sinfo = new IDSourceInfo(procedure.getName(), blockWhile.getLineNumber());
    loop.setIDSourceInfo(sinfo);
    Debug.depGraphTo(loop, "loopBody", "/tmp/loop_new.dot", 1);

    // -- Set attributes
    blockWhile.setAttribute("inputs", inputs);
    blockWhile.setAttribute("outputs", outputs);
    return loop;
  }
Exemple #14
0
  /**
   * Utility method for wiring up the reads and writes captured in a frame to appropriate ports and
   * buses on a procedure.
   *
   * @param body DOCUMENT ME!
   * @param register DOCUMENT ME!
   * @param subFrame DOCUMENT ME!
   */
  private void connectRegister(Module body, Register register, ConnectionFrame subFrame) {
    // wire all the reads to a new port on the procedure's body
    List<Connection> readList = subFrame.getReadConnections(register);
    if (!readList.isEmpty()) {
      Port resourceRead = body.makeDataPort(Component.SIDEBAND);
      Bus resourceReadBus = resourceRead.getPeer();
      resourceReadBus.setIDLogical(register.showIDLogical() + "_read");
      resourceReadBus.setSize(register.getInitWidth(), Register.isSigned());

      recordRead(new RegisterReadConnection(register, resourceRead));

      for (Connection readConnections : readList) {
        RegisterReadConnection rp = (RegisterReadConnection) readConnections;
        rp.getDataPort().setBus(resourceReadBus);
      }
    }

    // wire the writes. a single write goes directly, multiple go through a
    // gateway
    List<Connection> writeList = subFrame.getWriteConnections(register);
    if (!writeList.isEmpty()) {
      Exit bodyExit = getSidebandExit(body);
      Bus writeEnable = bodyExit.makeDataBus(Component.SIDEBAND);
      writeEnable.setIDLogical(register.showIDLogical() + "_enable");
      writeEnable.setSize(1, false);
      // Port writeEnablePort = writeEnable.getPeer();
      Bus writeData = bodyExit.makeDataBus(Component.SIDEBAND);
      writeData.setIDLogical(register.showIDLogical() + "_write");
      writeData.setSize(register.getInitWidth(), Register.isSigned());

      recordWrite(new RegisterWriteConnection(register, writeEnable, writeData));

      if (writeList.size() == 1) {
        RegisterWriteConnection edp = (RegisterWriteConnection) writeList.get(0);
        writeEnable.getPeer().setBus(edp.getEnable());
        writeData.getPeer().setBus(edp.getData());
      } else {
        RegisterGateway regGateway = new RegisterGateway(writeList.size(), register);
        writeEnable.getPeer().setBus(regGateway.getGlobalEnableBus());
        writeData.getPeer().setBus(regGateway.getGlobalDataBus());
        Iterator<Port> gatewayLocalEnablePortIter = regGateway.getLocalEnablePorts().iterator();
        Iterator<Port> gatewayLocalDataPortIter = regGateway.getLocalDataPorts().iterator();

        // Wires up RegisterGateway's enable ports paired with data
        // ports.
        int pairCount = 0;
        for (Connection connection : writeList) {
          RegisterWriteConnection edPair = (RegisterWriteConnection) connection;
          edPair.getEnable().setIDLogical(register.showIDLogical() + "_we_" + pairCount);
          gatewayLocalEnablePortIter.next().setBus(edPair.getEnable());
          edPair.getData().setIDLogical(register.showIDLogical() + "_data_" + pairCount);
          gatewayLocalDataPortIter.next().setBus(edPair.getData());
          // edPair.getSize().setIDLogical(register.showIDLogical() +
          // "_size_" + pairCount);
          // ((Port)gatewayLocalSizePortIter.next()).setBus(edPair.getSize());
          pairCount++;
        }

        body.addComponent(regGateway);
      }
    }
  }
Exemple #15
0
  /**
   * Creates Pins on the design to connect each task's I/O.
   *
   * @param design the Design to be connected
   */
  @SuppressWarnings("deprecation")
  private void connectTasks(Design design) {
    // Map kickers = new HashMap();

    for (Task task : design.getTasks()) {
      Call call = task.getCall();

      // Note: when creating the InputPins, they are based on the related
      // procedure port instead of the call port, because the InputPin
      // needs
      // the Port's peer bus to get sizing information

      // might have a this port
      if (task.getCall().getThisPort() != null) {
        int width = task.getCall().getThisPort().getValue().getSize();

        /*
         * The base address of the top level object reference is always
         * 0, since it isn't actually stored in memory.
         */
        Constant constant = new SimpleConstant(0, width, false);
        task.setHiddenConstant(constant);
      }

      // If module_builder, then publish the ports, and don't use a kicker
      if (EngineThread.getGenericJob()
          .getUnscopedBooleanOptionValue(OptionRegistry.MODULE_BUILDER)) {
        // get the entry method
        EntryMethod em = call.getProcedure().getEntryMethod();

        Port go = call.getGoPort();
        if (go.isUsed()) {
          Pin p = connectInputPin(design, call, go, call.getGoName());
          if (em != null) {
            p.setApiPin(em.getGoPin());
          }
        }

        List<Port> dataPorts = new ArrayList<Port>(call.getDataPorts());

        // 'this' port is handled specially.
        dataPorts.remove(call.getThisPort());
        int index = 0;
        for (Port port : dataPorts) {
          if (port.getTag().equals(Component.NORMAL)) {
            if (port.isUsed()) {
              Pin p = connectInputPin(design, call, port, null);
              if (em != null) {
                p.setApiPin(em.getArgPin(index));
              }
            }
          }

          index++;
        }

        Exit exit = call.getExit(Exit.DONE);
        Bus done = exit.getDoneBus();
        if (done.isUsed()) {
          OutputPin pin = connectOutputPin(design, call, done, call.getProcedure().getDoneName());
          if (em != null) {
            pin.setApiPin(em.getDonePin());
          }
        }

        for (Bus bus : exit.getDataBuses()) {
          if (bus.getTag().equals(Component.NORMAL)) {
            if (bus.isUsed()) {
              OutputPin pin =
                  connectOutputPin(design, call, bus, call.getProcedure().getResultName());
              if (em != null) {
                pin.setApiPin(em.getResultPin());
              }
            }
          }
        }
      }
    }
  }