Package edu.byu.ece.rapidSmith.bitstreamTools.examples.support

Examples of edu.byu.ece.rapidSmith.bitstreamTools.examples.support.BitstreamOptionParser


   * @param args bitstream name
   */
  public static void main(String[] args) {

    /** Setup parser **/
    BitstreamOptionParser cmdLineParser = new BitstreamOptionParser();
    cmdLineParser.addInputBitstreamOption();
    //cmdLineParser.addPartNameOption();
    cmdLineParser.addHelpOption();
    cmdLineParser.accepts(PRINT_HEADER_OPTION, PRINT_HEADER_OPTION_HELP);
    cmdLineParser.accepts(PRINT_XML_OPTION, PRINT_XML_OPTION_HELP);

    OptionSet options = cmdLineParser.parseArgumentsExitOnError(args);

    //
    BitstreamOptionParser.printExecutableHeaderMessage(NonEmptyFrames.class);
   
    /////////////////////////////////////////////////////////////////////
    // Begin basic command line parsing
    /////////////////////////////////////////////////////////////////////   
    cmdLineParser.checkHelpOptionExitOnHelpMessage(options);
   
    /////////////////////////////////////////////////////////////////////
    // 1. Parse bitstream
    /////////////////////////////////////////////////////////////////////
    Bitstream bitstream = cmdLineParser.parseRequiredBitstreamFromOptionsExitOnError(options, true);
   
    //int printLevel = 1;
   
    // header only
    if (options.has(PRINT_HEADER_OPTION)) {
View Full Code Here


  public static void main(String[] args) {

    /////////////////////////////////////////////////////////////////////
    // Begin command line parsing
    /////////////////////////////////////////////////////////////////////   
    BitstreamOptionParser cmdLineParser = new BitstreamOptionParser();
    cmdLineParser.addInputBitstreamOption();
    cmdLineParser.addPartNameOption();
    cmdLineParser.addHelpOption();
    cmdLineParser.addOutputBitstreamOption();
    cmdLineParser.addDebugOption();
   
    // Add More commands
    cmdLineParser.accepts(BRAM_OPTION_STRING, "Generate BRAM");
    cmdLineParser.accepts(PARTIAL_OPTION_STRING, "Generate Partial");
    cmdLineParser.accepts(FULL_OPTION_STRING, "Generate Full bitstream");
    //cmdLineParser.accepts(CONDENSE_OPTION_STRING, "Generate condensed bitstream");
    cmdLineParser.accepts(XOR_STRING,
        "Perform XOR operation with operational bitfile");
    cmdLineParser.accepts(OVERWRITE_STRING,
           "Perform overwrite operation with operational bitfile");
    cmdLineParser.accepts(CLEAR_STRING,
      "Perform clear operation with operational bitfile");
    cmdLineParser.accepts(AND_STRING,
      "Perform and operation with operational bitfile");
    cmdLineParser.accepts(NOT_STRING,
      "Perform not operation with operational bitfile");
    cmdLineParser.accepts(OR_STRING,
      "Perform or operation with operational bitfile");
    cmdLineParser.accepts("r","Name of operational bitfile").withRequiredArg().ofType(String.class);
    cmdLineParser.accepts(NEW_ALGORITHM, "Use new algorithms for bit manipulation");
    cmdLineParser.accepts(APPEND_OPTION_STRING, APPEND_OPTION_STRING_HELP);
   
    // Parse arguments
    OptionSet options = cmdLineParser.parseArgumentsExitOnError(args);
    // Print executable header
    BitstreamOptionParser.printExecutableHeaderMessage(BitstreamManipulation.class);
    // Check for and print help
    cmdLineParser.checkHelpOptionExitOnHelpMessage(options);
    DEBUG = cmdLineParser.debugEnabled(options);
   
    /////////////////////////////////////////////////////////////////////
    // 1. Parse bitstream
    /////////////////////////////////////////////////////////////////////
    Bitstream bitstream = cmdLineParser.parseRequiredBitstreamFromOptionsExitOnError(options, true);
   
    /////////////////////////////////////////////////////////////////////
    // 2. Obtain part information
    /////////////////////////////////////////////////////////////////////
    XilinxConfigurationSpecification partInfo = cmdLineParser.getPartInfoExitOnError(options, bitstream, true);
   
    // 3. Create FPGA object
    FPGA fpga = new FPGA(partInfo);   
    // Configure FPGA
    fpga.configureBitstream(bitstream);
   
    String outputBitstreamFileName = cmdLineParser.getOutputFileNameStringExitOnError(options);
   
    /////////////////////////////////////////////////////////////////////
    // Perform Bitstreams Operations
    /////////////////////////////////////////////////////////////////////

    if (options.has(XOR_STRING) || options.has(OVERWRITE_STRING) ||options.has(CLEAR_STRING) ||
        options.has(AND_STRING) ||options.has(NOT_STRING) ||options.has(OR_STRING)
        || options.has(APPEND_OPTION_STRING)) {

      if (!options.has("r")) {
        System.err.println("Operational bitfile name needed for bitstream operation");
        cmdLineParser.printUsageAndExit();
      }
      String operationalBitstreamFileName = (String) options.valueOf("r");
     
      // load operational bitstream (this is an odd way of doing it but I am copying Ben's code)
      Bitstream opBitstream = BitstreamParser.parseBitstreamExitOnError(operationalBitstreamFileName);     
View Full Code Here

  public static void main(String[] args) {
 
    String PRINT_ALL_FRAMES = "a";
   
    /** Setup parser **/
    BitstreamOptionParser cmdLineParser = new BitstreamOptionParser();
    cmdLineParser.addInputBitstreamOption();
    cmdLineParser.addPartNameOption();
    cmdLineParser.addHelpOption();
    cmdLineParser.accepts(PRINT_ALL_FRAMES, "Prints all frames");
   
    OptionSet options = cmdLineParser.parseArgumentsExitOnError(args);

    cmdLineParser.checkHelpOptionExitOnHelpMessage(options);

    BitstreamOptionParser.printExecutableHeaderMessage(FrameWriteSummary.class);

    Bitstream bitstream = cmdLineParser.parseRequiredBitstreamFromOptionsExitOnError(options, true);

    XilinxConfigurationSpecification partInfo = cmdLineParser.getPartInfoExitOnError(options, bitstream, true)

    boolean printAllFrames =(options.has(PRINT_ALL_FRAMES));

    // Get part packets
    PacketList packets = bitstream.getPackets();
View Full Code Here

   * @param args bitstream name
   */
  public static void main(String[] args) {

    /** Setup parser **/
    BitstreamOptionParser cmdLineParser = new BitstreamOptionParser(HELP_DESCRIPTION);
    // Options for input bitstream or readback file
    cmdLineParser.addInputBitstreamOption();
    cmdLineParser.addRawReadbackInputOption();
    cmdLineParser.addPartNameOption();
   
    cmdLineParser.accepts(COMPARE_BITSTREAM_OPTION, COMPARE_BITSTREAM_OPTION_HELP).withRequiredArg().ofType(String.class);   
    cmdLineParser.accepts(COMPARE_READBACK_OPTION,
        COMPARE_READBACK_OPTION_HELP).withRequiredArg().ofType(String.class);;
    cmdLineParser.accepts(MASK_BITSTREAM_OPTION,
        MASK_BITSTREAM_OPTION_HELP);

    cmdLineParser.addHelpOption();
    cmdLineParser.accepts(IGNORE_UNCONFIGURED_FRAMES_OPTION,
        IGNORE_UNCONFIGURED_FRAMES_OPTION_HELP);
    cmdLineParser.accepts(SILENT_MODE_OPTION,
        SILENT_MODE_OPTION_HELP);
    cmdLineParser.accepts(PRINT_DATA_OPTION,
        PRINT_DATA_OPTION_HELP);

    OptionSet options = cmdLineParser.parseArgumentsExitOnError(args);

    //
    BitstreamOptionParser.printExecutableHeaderMessage(BitstreamDiff.class);
   
    /////////////////////////////////////////////////////////////////////
    // Begin basic command line parsing
    /////////////////////////////////////////////////////////////////////   
    cmdLineParser.checkHelpOptionExitOnHelpMessage(options);
   
    boolean ignoreUnconfiguredFrames =
      options.has(IGNORE_UNCONFIGURED_FRAMES_OPTION);
    boolean silentMode =
      options.has(SILENT_MODE_OPTION);
    boolean printData = options.has(PRINT_DATA_OPTION);
   
    /////////////////////////////////////////////////////////////////////
    // 1. Get base FPGA object
    /////////////////////////////////////////////////////////////////////
    FPGA fpga1 = null;   
    fpga1 = cmdLineParser.createFPGAFromBitstreamOrReadbackFileExitOnError(options);
    XilinxConfigurationSpecification part = fpga1.getDeviceSpecification();
   
    /////////////////////////////////////////////////////////////////////
    // 2. Get compare FPGA object
    /////////////////////////////////////////////////////////////////////
    FPGA fpga2 = null;
    fpga2 = cmdLineParser.createFPGAFromBitstreamOrReadbackFileExitOnError(options,
        COMPARE_READBACK_OPTION,
        COMPARE_BITSTREAM_OPTION, part);

    /////////////////////////////////////////////////////////////////////
    // 3. Get mask FPGA object (if it exists)
    /////////////////////////////////////////////////////////////////////
    Bitstream maskBitstream = cmdLineParser.parseOptionalBitstreamFromOptionsExitOnError(options, MASK_BITSTREAM_OPTION, true);
    if (maskBitstream != null) {
      XilinxConfigurationSpecification partInfo = cmdLineParser.getPartInfoExitOnError(options, maskBitstream, true);
      FPGA maskFPGA = new FPGA(partInfo);   
      // Configure FPGA
      maskFPGA.configureBitstream(maskBitstream);
     
      // Now mask the two FPGAs
View Full Code Here

    // Setup class and Options
    /////////////////////////////////////////////////////////////////////
    String PRINT_DETAIL = "d";
   
    /** Setup parser **/
    BitstreamOptionParser cmdLineParser = new BitstreamOptionParser();
    cmdLineParser.addInputBitstreamOption();
    cmdLineParser.addPartNameOption();
    cmdLineParser.addHelpOption();
    cmdLineParser.accepts(PRINT_DETAIL, "Prints all details");

    OptionSet options = cmdLineParser.parseArgumentsExitOnError(args);

    BitstreamOptionParser.printExecutableHeaderMessage(NonEmptyFrames.class);
   
    /////////////////////////////////////////////////////////////////////
    // Begin basic command line parsing
    /////////////////////////////////////////////////////////////////////   
    cmdLineParser.checkHelpOptionExitOnHelpMessage(options);
   
    /////////////////////////////////////////////////////////////////////
    // 1. Parse bitstream
    /////////////////////////////////////////////////////////////////////
    Bitstream bitstream = cmdLineParser.parseRequiredBitstreamFromOptionsExitOnError(options, true);
   
    /////////////////////////////////////////////////////////////////////
    // 2. Obtain part information
    /////////////////////////////////////////////////////////////////////
    XilinxConfigurationSpecification partInfo = cmdLineParser.getPartInfoExitOnError(options, bitstream, true);
   
    boolean printDetail =(options.has(PRINT_DETAIL));

   
    // Create FPGA object
View Full Code Here

  public static void main(String args[]) {

    /////////////////////////////////////////////////////////////////////
    // Begin command line parsing
    /////////////////////////////////////////////////////////////////////   
    BitstreamOptionParser cmdLineParser = new BitstreamOptionParser();
    cmdLineParser.addHelpOption();
    cmdLineParser.addDebugOption();   

    // Custom options
    String FULL_OPTION = "full";
    String STATIC_OPTION = "static";
    String PARTIAL_OPTION = "partial";
    String VERBOSE = "v";
    String VERBOSE_HELP = "Verbose output";
    cmdLineParser.accepts(FULL_OPTION,"Name of full bitfile (static+partial)").withRequiredArg().ofType(String.class);
    cmdLineParser.accepts(STATIC_OPTION,"Name of static bitfile (static that is empty)").withRequiredArg().ofType(String.class);
    cmdLineParser.accepts(PARTIAL_OPTION,"Name of partial bitfile").withRequiredArg().ofType(String.class);
    //cmdLineParser.accepts(VERBOSE,VERBOSE_HELP).withOptionalArg().ofType(String.class);
    cmdLineParser.accepts(VERBOSE,VERBOSE_HELP).withRequiredArg().ofType(String.class);

    String PATCH_PARTIAL = "patchPartial";
    cmdLineParser.accepts(PATCH_PARTIAL,"Changes will be made in the partial, not static").withRequiredArg().ofType(String.class);

    // Parse arguments
    OptionSet options = cmdLineParser.parseArgumentsExitOnError(args);
    // Print executable header
    BitstreamOptionParser.printExecutableHeaderMessage(BitstreamManipulation.class);
    // Check for and print help
    cmdLineParser.checkHelpOptionExitOnHelpMessage(options);

    // Get bitstreams
    Bitstream fullBitstream = cmdLineParser.parseRequiredBitstreamFromOptionsExitOnError(options, FULL_OPTION,
        true);   
    Bitstream staticBitstream = cmdLineParser.parseRequiredBitstreamFromOptionsExitOnError(options, STATIC_OPTION,
        true);   
    Bitstream partialBitstream = cmdLineParser.parseRequiredBitstreamFromOptionsExitOnError(options, PARTIAL_OPTION,
        true);   
   
    boolean patchPartial = false;
    if (options.has(PATCH_PARTIAL))
      patchPartial = true;
   
    boolean verbose = false;
    if (options.has(VERBOSE)) {
      verbose = true;
   
    boolean printData = false;
   
    // Get and check parts
    XilinxConfigurationSpecification partInfo = cmdLineParser.getPartInfoExitOnError(options, fullBitstream, true);
    XilinxConfigurationSpecification staticPartInfo = cmdLineParser.getPartInfoExitOnError(options, staticBitstream, false);
    XilinxConfigurationSpecification partialPartInfo = cmdLineParser.getPartInfoExitOnError(options, partialBitstream, false);
   
    if (staticPartInfo != partInfo || partialPartInfo != partInfo) {
      System.err.println("Bitstreams do not match");
      System.exit(1);
    }

    // 3. Create FPGA object
    FPGA fullFPGA = new FPGA(partInfo);   
    FPGA staticFPGA = new FPGA(partInfo);   
    FPGA partialFPGA = new FPGA(partInfo);   

    // Configure FPGA
    fullFPGA.configureBitstream(fullBitstream);
    staticFPGA.configureBitstream(staticBitstream);
    partialFPGA.configureBitstream(partialBitstream);
   
    boolean staticChanged = false;
    boolean partialChanged = false;
   
    // Iterate over all of the frames
    FrameAddressRegister far = new FrameAddressRegister(partInfo);
    for (; far.validFARAddress(); far.incrementFAR()) {
      //System.out.println(far);
     
      Frame fullFrame = fullFPGA.getFrame(far);
      if (!fullFrame.isConfigured()) {
        System.err.println("Error: Unconfigured Frame in the full bitstream at FAR:"+far.getHexAddress());
        System.exit(1);
      }
     
      Frame staticFrame = staticFPGA.getFrame(far);
      Frame partialFrame = partialFPGA.getFrame(far);

      FrameData fullData = fullFrame.getData();
      FrameData staticData = staticFrame.getData();
      FrameData partialData = partialFrame.getData();
     
      if (staticFrame.isConfigured() && partialFrame.isConfigured()) {
        // Both static and partial frames configured
        if (fullData.isEqual(staticData)) {
          if (fullData.isEqual(partialData)) {
            // TODO: All equal: could probably remove the partial frame (future)
            if (verbose)
              System.out.println(far.getHexAddress()+" Static, full, and partial all equal");           
          } else {
            // full and static equal, partial not equal
            System.out.println("Full and static equal, partial not equal:"+far.getHexAddress());           
            if (printData) {
              System.out.println("Full Data\n"+fullData);
              System.out.println("Static Data\n"+staticData);             
              System.out.println("Partial Data\n"+partialData);             
            }
          }       
        } else {
          // full is not equal to static
          if (fullData.isEqual(partialData)) {
            // This is OK. Don't need to do anything here.
            if (staticData.isEmpty())
              System.out.println(far.getHexAddress() + " Full and partial equal, static empty");
            else
              System.out.println(far.getHexAddress() + " Full and partial equal, static not equal and not empty");
            if (printData) {
              System.out.println("Full Data\n"+fullData);
              System.out.println("Static Data\n"+staticData);             
              System.out.println("Partial Data\n"+partialData);             
            }
          } else {
            // Full data is NOT equal to partial data
            if (staticData.isEqual(partialData)) {
              System.out.println("*** Full not equal but static and partial equal:"+far.getHexAddress());                         
            } else {
              System.out.println("*** All three not equal:"+far.getHexAddress());                         
            }
          }
        }     
      } else if (staticFrame.isConfigured()) {
        // static frame is configured and partial frame is NOT configured
        if (fullData.isEqual(staticData)) {
          if (verbose)
            System.out.println(far.getHexAddress()+" Static and full Equal (partial not configured)");
        } else {
          if (!fullData.isEmpty()) {
            // full has data
            if (!staticData.isEmpty()) {
              // Full and static have data
              System.out.println(far.getHexAddress()+" * Full and static NOT equal (partial not configured)");
              if (printData) {
                System.out.println("Full Data\n"+fullData);
                System.out.println("Static Data\n"+staticData);
              }
            } else {
              // full has data , static is empty
              System.out.println(far.getHexAddress()+" * Full has data, static is empty (partial not configured)");
            }
          } else {
            // full does not have data
            System.out.println(far.getHexAddress()+" * Full empty and static NOT equal (partial not configured)");
          }
          if (!patchPartial) {
            staticData.setData(fullData);
            staticChanged = true;
          } else {
            partialData.setData(fullData);
            partialChanged = true;
          }
        }
      } else if (partialFrame.isConfigured()) {
        // partial frame is configured, static frame is NOT configured
        if (fullData.isEqual(partialData)) {
          System.out.println("Partial and full Equal (static not configured):"+far.getHexAddress());
        } else {
          System.out.println("Partial Not Equal:"+far.getHexAddress());         
        }
      } else {
        // neither frame is configured
        if (!fullData.isEmpty()) {
          System.out.println("Frame not empty and static/partial not conifgured:"+far);
        }
      }
    }
   
    if (staticChanged) {
      String oldStaticFileName = cmdLineParser.getBitstreamFileNameFromOptions(options,STATIC_OPTION);
      String newStaticFilename = oldStaticFileName + ".new";
      // create the bitstream
      Bitstream newBitstream = partInfo.getBitstreamGenerator().createFullBitstream(staticFPGA, staticBitstream.getHeader());
      BitstreamManipulation.writeBitstreamToBIT(newBitstream, newStaticFilename);
    }
    if (partialChanged) {
      String oldPartialFileName = cmdLineParser.getBitstreamFileNameFromOptions(options,PARTIAL_OPTION);
      String newPartialFilename = oldPartialFileName + ".new";
      // create the bitstream
      Bitstream newBitstream = partInfo.getBitstreamGenerator().createPartialBitstream(partialFPGA, partialBitstream.getHeader());
      BitstreamManipulation.writeBitstreamToBIT(newBitstream, newPartialFilename);
    }
View Full Code Here

    /////////////////////////////////////////////////////////////////////
    // Setup class and Options
    /////////////////////////////////////////////////////////////////////
       
    /** Setup parser **/
    BitstreamOptionParser cmdLineParser = new BitstreamOptionParser();
    cmdLineParser.addInputBitstreamOption();
    cmdLineParser.addPartNameOption();
    cmdLineParser.addHelpOption();
    cmdLineParser.addRawReadbackInputOption();
   
    cmdLineParser.accepts(FAR_START_ADDRESS_OPTION, FAR_START_ADDRESS_OPTION_HELP).
        withRequiredArg().ofType(String.class);   
    cmdLineParser.accepts(NUMBER_OF_FRAMES_OPTION, NUMBER_OF_FRAMES_OPTION_HELP).
      withRequiredArg().ofType(String.class);

    OptionSet options = null;
    try {
      options = cmdLineParser.parse(args);
    }
    catch(Exception e){
      System.err.println(e.getMessage());
      System.exit(1);     
    }   

    BitstreamOptionParser.printExecutableHeaderMessage(FrameContents.class);
       
    /////////////////////////////////////////////////////////////////////
    // Begin basic command line parsing
    /////////////////////////////////////////////////////////////////////
    cmdLineParser.checkHelpOptionExitOnHelpMessage(options);

   
    /////////////////////////////////////////////////////////////////////
    // 1. Parse bitstream
    /////////////////////////////////////////////////////////////////////
    FPGA fpga = null;
   
    fpga = cmdLineParser.createFPGAFromBitstreamOrReadbackFileExitOnError(options);

    /*
    if(options.has(READBACK_RAW_FILE_OPTION)){
      // get data from a readback file
      XilinxConfigurationSpecification part = cmdLineParser.getRequiredPartInfoExitOnError(options);
      String readbackfilename = (String) options.valueOf(READBACK_RAW_FILE_OPTION);   

      fpga = ReadbackFPGA.parseRawReadbackDataFromOptionsExitOnError(readbackfilename,
          part);
     
    } else {
      Bitstream bitstream = cmdLineParser.parseBitstreamFromOptionsExitOnError(options, true);
      // get data from a bitstream
      /////////////////////////////////////////////////////////////////////
      // 2. Obtain part information
      /////////////////////////////////////////////////////////////////////
      XilinxConfigurationSpecification partInfo = cmdLineParser.getPartInfoExitOnError(options, bitstream, true);
      fpga = new FPGA(partInfo);   
      // Configure FPGA
      fpga.configureBitstream(bitstream);

    }
    */
   
    /////////////////////////////////////////////////////////////////////
    // 3. Parameters
    /////////////////////////////////////////////////////////////////////
   
    // Start frame
    int startFrame = cmdLineParser.getIntegerStringExitOnError(options, FAR_START_ADDRESS_OPTION, 16, 0);

    // Number of frames
    XilinxConfigurationSpecification partInfo = fpga.getDeviceSpecification();
    int defaultNumberOfFrames = FrameAddressRegister.getNumberOfFrames(partInfo);
    int numberOfFrames = cmdLineParser.getIntegerStringExitOnError(options, NUMBER_OF_FRAMES_OPTION, 10, defaultNumberOfFrames);     

    System.out.println(fpga.getFrameContents(startFrame, numberOfFrames));
 
View Full Code Here

TOP

Related Classes of edu.byu.ece.rapidSmith.bitstreamTools.examples.support.BitstreamOptionParser

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.