OpenASIP  2.0
Public Member Functions | Private Member Functions | List of all members
CoeImageWriter Class Reference

#include <CoeImageWriter.hh>

Inheritance diagram for CoeImageWriter:
Inheritance graph
Collaboration diagram for CoeImageWriter:
Collaboration graph

Public Member Functions

 CoeImageWriter (const BitVector &bits, int rowLength)
 
virtual ~CoeImageWriter ()
 
virtual void writeImage (std::ostream &stream) const
 
- Public Member Functions inherited from AsciiImageWriter
 AsciiImageWriter (const BitVector &bits, int rowLength)
 
virtual ~AsciiImageWriter ()
 
- Public Member Functions inherited from BitImageWriter
virtual ~BitImageWriter ()
 

Private Member Functions

void writeHeader (std::ostream &stream) const
 

Additional Inherited Members

- Protected Member Functions inherited from AsciiImageWriter
const BitVectorbits () const
 
int rowLength () const
 
void writeSequence (std::ostream &stream, int length, bool padEnd=false) const
 
void writeHexSequence (std::ostream &stream, int length, bool padEnd=false) const
 

Detailed Description

Writes the bit image in COE format. It's used at least by Xilinx tools

Definition at line 41 of file CoeImageWriter.hh.

Constructor & Destructor Documentation

◆ CoeImageWriter()

CoeImageWriter::CoeImageWriter ( const BitVector bits,
int  rowLength 
)

The constructor.

Parameters
bitsThe bits to write.
rowLengthLength of the rows to write.

Definition at line 46 of file CoeImageWriter.cc.

46  :
48 }

◆ ~CoeImageWriter()

CoeImageWriter::~CoeImageWriter ( )
virtual

The destructor.

Definition at line 53 of file CoeImageWriter.cc.

53  {
54 }

Member Function Documentation

◆ writeHeader()

void CoeImageWriter::writeHeader ( std::ostream &  stream) const
private

Writes header to the given stream.

Parameters
streamThe stream to write.

Definition at line 88 of file CoeImageWriter.cc.

88  {
89  stream << "; Created by generatebits" << endl;
90  stream << "memory_initialization_radix=2;" << endl
91  << "memory_initialization_vector=" << endl;
92 }

Referenced by writeImage().

◆ writeImage()

void CoeImageWriter::writeImage ( std::ostream &  stream) const
virtual

Writes the bit image to the given stream.

Parameters
streamThe stream to write.

Reimplemented from AsciiImageWriter.

Definition at line 61 of file CoeImageWriter.cc.

61  {
62  int lineCount = static_cast<int>(
63  ceil(static_cast<double>(bits().size()) / rowLength()));
64  writeHeader(stream);
65  if (lineCount == 0) {
66  for (int i = 0; i < rowLength(); i++) {
67  stream << "0";
68  }
69  } else {
70  bool padEndings = false;
71  for (int i = 0; i < lineCount-1; i++) {
72  writeSequence(stream, rowLength(), padEndings);
73  stream << "," << endl;
74  }
75  // last line might need padding
76  padEndings = true;
77  writeSequence(stream, rowLength(), padEndings);
78  }
79  // format requires semicolon at the end
80  stream << ";" << endl;
81 }

References AsciiImageWriter::bits(), AsciiImageWriter::rowLength(), writeHeader(), and AsciiImageWriter::writeSequence().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
AsciiImageWriter::AsciiImageWriter
AsciiImageWriter(const BitVector &bits, int rowLength)
Definition: AsciiImageWriter.cc:55
CoeImageWriter::writeHeader
void writeHeader(std::ostream &stream) const
Definition: CoeImageWriter.cc:88
AsciiImageWriter::rowLength
int rowLength() const
Definition: AsciiImageWriter.cc:112
AsciiImageWriter::writeSequence
void writeSequence(std::ostream &stream, int length, bool padEnd=false) const
Definition: AsciiImageWriter.cc:129
AsciiImageWriter::bits
const BitVector & bits() const
Definition: AsciiImageWriter.cc:101