Package edu.byu.ece.rapidSmith.bitstreamTools.bitstream

Examples of edu.byu.ece.rapidSmith.bitstreamTools.bitstream.Bitstream


    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


        // 3. Add ending packets
        createEndingFullBitstream(packets, fpga.spec);
       
        // 4. Create bitstream from the packets
        return new Bitstream(header, fpga.getDeviceSpecification().getSyncData(), packets);
    }
View Full Code Here

    }

    createEndingPartialBitstream(packets);

    // 4. Create bitstream from the packets
        return new Bitstream(header, fpga.getDeviceSpecification().getSyncData(), packets);
  }
View Full Code Here

      System.err.println("A bitstream filename must be specified with the "+
          bitstreamOption + " option");
      printUsageAndExit();
    }

    Bitstream bitstream = BitstreamParser.parseBitstreamExitOnError(bitstreamFileName);   
    if (printResultMessage)
      System.out.println("Bitstream parsed correctly:"+bitstreamFileName);
    return bitstream;
  }
View Full Code Here

    String bitstreamFileName = getBitstreamFileNameFromOptions(options,bitstreamOption);
    if (bitstreamFileName == null) {
      return null;
    }

    Bitstream bitstream = BitstreamParser.parseBitstreamExitOnError(bitstreamFileName);   
    if (printResultMessage)
      System.out.println("Bitstream parsed correctly:"+bitstreamFileName);
    return bitstream;
  }
View Full Code Here

     
      fpga = ReadbackFPGA.parseRawReadbackDataFromOptionsExitOnError(readbackfilename,
          part);

    } else {
      Bitstream bitstream = parseRequiredBitstreamFromOptionsExitOnError(options, regular_bitstream_file_option, true);
      // get data from a bitstream
      /////////////////////////////////////////////////////////////////////
      // 2. Obtain part information
      /////////////////////////////////////////////////////////////////////
      XilinxConfigurationSpecification partInfo = getPartInfoExitOnError(options, bitstream, true);
View Full Code Here

                // TODO Auto-generated catch block
                e.printStackTrace();
            }
           
            // generate output .bit and output .mcs
            Bitstream inputBitstream = null;
            try {
                inputBitstream = BitstreamParser.parseBitstream(inputBit);
            } catch (BitstreamParseException e) {
                e.printStackTrace();
            } catch (IOException e) {
                e.printStackTrace();
            }
           
            FileOutputStream os_bit = null;
            try {
                os_bit = new FileOutputStream(outputBit);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
           
            try {
                inputBitstream.outputHeaderBitstream(os_bit);
            } catch (IOException e) {
                e.printStackTrace();
            }
           
            FileOutputStream os_mcs = null;
            try {
                os_mcs = new FileOutputStream(outputMcs);
            } catch (FileNotFoundException e) {
                e.printStackTrace();
            }
           
            try {
                inputBitstream.writeBitstreamToMCS(os_mcs);
            } catch (IOException e) {
                e.printStackTrace();
            }
           
            // compare bitstreams
View Full Code Here

       
        String inputName = args[0];
        String outputName = args[1];
        String mcsName = args[2];
       
        Bitstream bs = null;
        try {
            bs = BitstreamParser.parseBitstream(inputName);
        } catch (BitstreamParseException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }
       
        FileOutputStream os_bit = null;
        try {
            os_bit = new FileOutputStream(new File(outputName));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
       
        try {
            bs.outputHeaderBitstream(os_bit);
        } catch (IOException e) {
            e.printStackTrace();
        }
       
        FileOutputStream os_mcs = null;
        try {
            os_mcs = new FileOutputStream(new File(mcsName));
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
       
        try {
            bs.writeBitstreamToMCS(os_mcs);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
View Full Code Here

                // Parse bitstream for ID code
                _deviceIDCodes.add(parseBitstreamForIDCode(kFilePrefix + ".bit"));

                // Parse bitstream for row counts
                Bitstream bitstream = null;
                try {
                    bitstream = BitstreamParser.parseBitstream(kFilePrefix + ".bit");
                } catch (BitstreamParseException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                } catch (IOException e) {
                    // TODO Auto-generated catch block
                    e.printStackTrace();
                }

                Set<Integer> topRows = new HashSet<Integer>();
                Set<Integer> bottomRows = new HashSet<Integer>();

                PacketList packets = bitstream.getPackets();
                for (Packet packet : packets) {
                    if (packet.getRegType() == RegisterType.LOUT) {
                        int farAddress = packet.getData().get(0);
                        int currentRow = (farAddress & _rowMask) >>> _rowBitPos;
                        int currentTopBottom = (farAddress & _topBottomMask) >>> _topBottomBitPos;
View Full Code Here

TOP

Related Classes of edu.byu.ece.rapidSmith.bitstreamTools.bitstream.Bitstream

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.