OpenASIP
2.0
|
#include <Bin2nImageWriter.hh>
Public Member Functions | |
Bin2nImageWriter (const BitVector &bits, int rowLength) | |
virtual | ~Bin2nImageWriter () |
virtual void | writeImage (std::ostream &stream) const |
const BitVector & | bits () const |
void | writeSequence (std::ostream &stream, unsigned int length) const |
Public Member Functions inherited from BitImageWriter | |
virtual | ~BitImageWriter () |
Private Member Functions | |
unsigned int | nextPowerOf2 (unsigned int n) const |
Static Private Member Functions | |
static char | character (const BitVector &bits, unsigned int startIndex, int length) |
Private Attributes | |
const BitVector & | bits_ |
The bits to be written. More... | |
int | rowLength_ |
The length of a row in the output. More... | |
unsigned int | nextBitIndex_ |
The index of the next bit to be written. More... | |
Writes the data image with binary 1's and 0's. Pads from the left to next multiple of 2 of rowLength_ and after that reverses the byte endianness. Used for programming the FPGA with Jupyter through AlmaIF
Definition at line 46 of file Bin2nImageWriter.hh.
Bin2nImageWriter::Bin2nImageWriter | ( | const BitVector & | bits, |
int | rowLength | ||
) |
Definition at line 40 of file Bin2nImageWriter.cc.
|
virtual |
Definition at line 45 of file Bin2nImageWriter.cc.
const BitVector & Bin2nImageWriter::bits | ( | ) | const |
Definition at line 157 of file Bin2nImageWriter.cc.
References bits_.
Referenced by character(), and Bin2nProgramImageWriter::writeImage().
|
staticprivate |
Returns the byte of the given bit vector that starts at the given index and is 'length' bits long. Pads from the left to size 8.
bits | The bit vector. |
startIndex | The start index. |
length | How many indexes forward is read. 0-8. |
Pad from the left with zeros.
Read the first bit.
Read the rest of the bits.
Definition at line 77 of file Bin2nImageWriter.cc.
References bits().
Referenced by writeSequence().
|
private |
Returns the next power of 2 of the given parameter
n |
Definition at line 168 of file Bin2nImageWriter.cc.
Referenced by writeSequence().
|
virtual |
Writes the data bits to the given stream. Reverses the byte endianness
stream | The output stream. |
Bitvector-size has to always be exactly divisible by rowlength
Implements BitImageWriter.
Reimplemented in Bin2nProgramImageWriter.
Definition at line 54 of file Bin2nImageWriter.cc.
References bits_, rowLength_, and writeSequence().
void Bin2nImageWriter::writeSequence | ( | std::ostream & | stream, |
unsigned int | length | ||
) | const |
Writes a sequence of bits to the given stream.
When this method is called sequentially, the first bit to be written is the next bit to the last bit written in the previous method call. Pads the sequence from the left with zeroes up to the nearest multiple of 2. After that, reverses the string before writing it to the stream.
stream | The output stream. |
length | The length of the sequence to be written. |
Pad from the left the correct amount of "0 bytes".
There might be a partial byte, which needs to be padded from the left
If there is no partial byte, we don't want to insert anything
Create the full bytes.
Update this for the next iteration of the function.
Reverse the byte endianness and write the stream.
Definition at line 112 of file Bin2nImageWriter.cc.
References bits_, character(), nextBitIndex_, and nextPowerOf2().
Referenced by Bin2nProgramImageWriter::writeImage(), and writeImage().
|
private |
The bits to be written.
Definition at line 63 of file Bin2nImageWriter.hh.
Referenced by bits(), writeImage(), and writeSequence().
|
mutableprivate |
The index of the next bit to be written.
Definition at line 67 of file Bin2nImageWriter.hh.
Referenced by writeSequence().
|
private |
The length of a row in the output.
Definition at line 65 of file Bin2nImageWriter.hh.
Referenced by writeImage().