示例#1
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)));
      }
    }
示例#2
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));
  }
示例#3
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());
              }
            }
          }
        }
      }
    }
  }