Examples of Bitstream


Examples of com.peterhi.runtime.BitStream

    assertEquals(2, bs.bytes());
  }
 
  @Test
  public void testToByteArray() throws Exception {
    BitStream bs = new BitStream(2);
    bs.writeBits(BigInteger.valueOf(255), 8);
    bs.writeBits(BigInteger.valueOf(255), 8);
    byte[] data = bs.toByteArray();
    assertEquals(-1, data[0]);
    assertEquals(-1, data[1]);
    bs.readBits(4, true);
    data = bs.toByteArray();
    assertEquals(-1, data[0]);
    assertEquals(15, data[1]);
    assertEquals(12, bs.available());
    assertEquals(2, bs.bytes());
  }
View Full Code Here

Examples of com.peterhi.runtime.BitStream

    assertEquals(2, bs.bytes());
  }
 
  @Test
  public void testClear() throws Exception {
    BitStream bs = new BitStream(2);
    bs.writeBit(1);
    bs.alignRead();
    bs.writeBit(0);
    bs.writeBit(1);
    assertEquals(1, bs.readBit());
    bs.clear();
    assertEquals(-1, bs.readBit());
    assertEquals(0, bs.available());
    assertEquals(2, bs.bytes());
    bs.writeBit(1);
    byte[] data = bs.toByteArray();
    assertEquals(1, data[0]);
    assertEquals(1, bs.available());
    assertEquals(2, bs.bytes());
  }
View Full Code Here

Examples of com.peterhi.runtime.BitStream

    assertEquals(2, bs.bytes());
  }
 
  @Test
  public void testSkipWrite() throws Exception {
    BitStream bs0 = new BitStream(1);
    bs0.writeBit(1);
    bs0.alignWrite();
    bs0.writeBit(1);
    BitStream bs1 = new BitStream(1);
    bs1.writeBit(1);
    bs1.skipWrite(7);
    bs1.writeBit(1);
    byte[] data = new byte[] { 1, 1 };
    assertArrayEquals(data, bs0.toByteArray());
    assertArrayEquals(data, bs1.toByteArray());
   
    try {
      bs0.skipWrite(-1);
      fail();
    } catch (IllegalArgumentException ex) {
View Full Code Here

Examples of com.peterhi.runtime.BitStream

  }
 
  @Test
  public void testSkipRead() throws Exception {
    byte[] data = new byte[] { 1, 1 };
    BitStream bs0 = new BitStream(data, 0, Byte.SIZE * data.length);
    BitStream bs1 = new BitStream(data, 0, Byte.SIZE * data.length);
    assertEquals(1, bs0.readBit());
    assertEquals(1, bs1.readBit());
    bs0.alignRead();
    bs1.skipRead(7);
    assertEquals(1, bs0.readBit());
    assertEquals(1, bs1.readBit());
    assertEquals(7, bs0.available());
    assertEquals(7, bs1.available());

    assertEquals(7, bs0.skipRead(7));
    assertEquals(0, bs0.available());
    assertEquals(0, bs0.skipRead(7));
   
View Full Code Here

Examples of com.peterhi.runtime.BitStream

  }
 
  @Test
  public void testConstructorCapacity() throws Exception {
    {
      BitStream bs = new BitStream(32);
      assertEquals(0, bs.available());
      assertEquals(32, bs.bytes());
    }
   
    try {
      BitStream bs = new BitStream(-1);
      fail();
    } catch (IllegalArgumentException ex) {
    }
  }
View Full Code Here

Examples of com.peterhi.runtime.BitStream

  }
 
  @Test
  public void testConstructorBufOffLen() throws Exception {
    {
      BitStream bs = new BitStream(new byte[32], Byte.SIZE * 16, Byte.SIZE * 16);
      assertEquals(Byte.SIZE * 16, bs.available());
      assertEquals(16, bs.bytes());
    }
   
    try {
      BitStream bs = new BitStream(null, 0, 1);
      fail();
    } catch (NullPointerException ex) {
    }
   
    try {
      BitStream bs = new BitStream(new byte[1], -1, 1);
      fail();
    } catch (IndexOutOfBoundsException ex) {
    }
   
    try {
      BitStream bs = new BitStream(new byte[1], 1, -1);
      fail();
    } catch (IndexOutOfBoundsException ex) {
    }
   
    try {
      BitStream bs = new BitStream(new byte[1], 1, Byte.SIZE);
      fail();
    } catch (IndexOutOfBoundsException ex) {
    }
  }
View Full Code Here

Examples of com.peterhi.runtime.BitStream

  }

  @Test
  public void testAvailable() throws Exception {
    {
      BitStream bs = new BitStream(32);
      assertEquals(0, bs.available());
      assertEquals(32, bs.bytes());
    }
   
    {
      byte[] data = new byte[32];
      BitStream bs = new BitStream(data, 0, Byte.SIZE * data.length);
      assertEquals(Byte.SIZE * data.length, bs.available());
      assertEquals(data.length, bs.bytes());
    }
   
    {
      BitStream bs = new BitStream(32);
      bs.writeBit(1);
      assertEquals(1, bs.available());
      assertEquals(32, bs.bytes());
    }
  }
View Full Code Here

Examples of com.peterhi.runtime.BitStream

  }
 
  @Test
  public void testSize() throws Exception {
    {
      BitStream bs = new BitStream(32);
      assertEquals(0, bs.available());
      assertEquals(32, bs.bytes());
    }
   
    {
      byte[] data = new byte[32];
      BitStream bs = new BitStream(data, Byte.SIZE * 16, Byte.SIZE * 16);
      assertEquals(Byte.SIZE * 16, bs.available());
      assertEquals(16, bs.bytes());
    }
   
    {
      BitStream bs = new BitStream(1);
     
      for (int i = 0; i < 9; i++) {
        bs.writeBit(1);
      }
     
      assertEquals(9, bs.available());
      assertEquals(129, bs.bytes());
    }
  }
View Full Code Here

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

    cmdLineParser.checkHelpOptionExitOnHelpMessage(options);
   
    /////////////////////////////////////////////////////////////////////
    // 1. Parse bitstream
    /////////////////////////////////////////////////////////////////////
    Bitstream bitstream = cmdLineParser.parseRequiredBitstreamFromOptionsExitOnError(options, true);
   
    //int printLevel = 1;
   
    // header only
    if (options.has(PRINT_HEADER_OPTION)) {
      System.out.println(bitstream.getHeader().toString());
      System.exit(1);
    }
    // print XML
    if (options.has(PRINT_XML_OPTION)) {
      System.out.println(bitstream.toXMLString());
      System.exit(1);     
    }
    // Print full bitstream
    PrintWriter pw = new PrintWriter(System.out);
    bitstream.toStream(true, true, pw);
    pw.flush();
    pw.close();       
    }
View Full Code Here

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

    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);     
      System.out.print("Successfully loaded operational bitstream - ");
     
      // TODO: Make sure the two bitstreams are the same size. Same part?     
      FPGA fpga2 = new FPGA(partInfo);
      fpga2.configureBitstream(opBitstream);

     
      if(options.has(XOR_STRING))
      {
        FPGAOperation.operation(fpga, fpga2, FPGAOperation.OPERATORS.XOR );
        System.out.println("XOR operation performed"); // use this to find differences in BRAM data.
      }
      else if(options.has(AND_STRING))
      {
        FPGAOperation.operation(fpga, fpga2, FPGAOperation.OPERATORS.AND );
        System.out.println("AND operation performed");
      }
      else if(options.has(OR_STRING))
      {
        FPGAOperation.operation(fpga, fpga2, FPGAOperation.OPERATORS.OR );
        System.out.println("OR operation performed");
      }
      else if(options.has(NOT_STRING))
      {
        FPGAOperation.operation(fpga, fpga2, FPGAOperation.OPERATORS.NOT );
        System.out.println("NOT operation performed");
      }
      else if(options.has(OVERWRITE_STRING))
      {
        fpga.configureBitstream(opBitstream);
        System.out.println("Overwrite operation performed");
      }
      else if(options.has(CLEAR_STRING))
      { 
        // Find all of the frames that are configured on fpga2
        ArrayList<Frame> fpga2configuredFrames = fpga2.getConfiguredFrames();
       
        // Clear all the corresponding frames on fpga1
        for (Frame fd : fpga2configuredFrames) {
          fd.clear();
        }
        System.out.println("Clear operation performed\n");
      }
      else if(options.has(APPEND_OPTION_STRING)) {
        // Append the packets of the operational bitstream to the packets of the original bitstream
        PacketList opPackets = opBitstream.getPackets();
        PacketList inPackets = bitstream.getPackets();
        inPackets.addAll(opPackets);
        if (writeBitstreamToBIT(bitstream, outputBitstreamFileName) == 0) {
          System.out.println("Generated BRAM Bitstream:"+outputBitstreamFileName);
        } else {
          System.err.println("Problem generating BRAM bitstream");
          System.exit(1);
        }       

        System.out.println("Append operation performed");
      }
    }
       
    /////////////////////////////////////////////////////////////////////
    // Perform Bitstreams Write Operations
    /////////////////////////////////////////////////////////////////////

    // create the bitstream
    Bitstream newBitstream = null;
    BitstreamHeader newHeader = null;

   

    if (options.has(NEW_ALGORITHM)) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.