19 time_t timestamp = time(0);
22 tstruct = *localtime(×tamp);
23 strftime(buf,
sizeof(buf),
"%Y/%m/%d", &tstruct);
24 fileDate = std::string(buf);
25 strftime(buf,
sizeof(buf),
"%H:%M:%S", &tstruct);
26 fileTime = std::string(buf);
48 headerLocationOfRemainingFileLength = fout.tellp();
54 std::streamoff finalFileSize = fout.tellp();
55 std::streamoff reportDiff = finalFileSize - (headerLocationOfRemainingFileLength + 4);
56 fout.seekp(headerLocationOfRemainingFileLength);
62 for(
int i = 0 ; i < 16 ; i++)
74 outputBitstreamEmptySLRHeaderSequence(fout, slr,
false, loadedBitstreamEndianness);
79 void *blankFrame = calloc(WORDS_PER_FRAME, 4);
83 int srcR = writeRect.
position.
row / CLB_PER_CLOCK_REGION;
84 int sizeR = writeRect.
size.
row / CLB_PER_CLOCK_REGION;
85 for(
int r = 0 ; r < sizeR ; r++){
88 if(selectedOptions.skipUnused){
89 for( ; (fromCol < numberOfCols[r] && LUT_isFrameUnusedForResourceLetter[(uint8_t)resourceString[srcR + r][fromCol]]) ; fromCol++);
90 for( ; (toCol > 0 && LUT_isFrameUnusedForResourceLetter[(uint8_t)resourceString[srcR + r][toCol]]) ; toCol--);
94 if(selectedOptions.clb){
95 int framesToWrite = numberOfFramesBeforeCol[r][toCol]-numberOfFramesBeforeCol[r][fromCol];
96 uint32_t farValue =
XCAP_getFAR(slr, BLOCKTYPE_LOGIC, srcR + r, fromCol, 0);
97 if(selectedOptions.blank){
101 XCAP_writeFDRI(fout, ((framesToWrite + 1)*WORDS_PER_FRAME), loadedBitstreamEndianness);
102 for(
int i = 0 ; i <= framesToWrite ; i++)
103 fout.write((
char*)blankFrame, WORDS_PER_FRAME * 4);
108 XCAP_writeFDRI(fout, ((framesToWrite + 1)*WORDS_PER_FRAME), loadedBitstreamEndianness);
110 fout.write((
char*)&bitstreamCLB[srcR + r][fromCol][0], framesToWrite * WORDS_PER_FRAME * 4);
111 fout.write((
char*)blankFrame, WORDS_PER_FRAME * 4);
113 if(selectedOptions.bram){
114 int framesToWrite = FRAMES_PER_BRAM_CONTENT_COLUMN * (numberOfBRAMsBeforeCol[r][toCol]-numberOfBRAMsBeforeCol[r][fromCol]);
115 if(framesToWrite > 0) {
116 uint32_t farValue =
XCAP_getFAR(slr, BLOCKTYPE_BLOCKRAM, srcR + r, numberOfBRAMsBeforeCol[r][fromCol], 0);
120 XCAP_writeFDRI(fout, ((framesToWrite + 1)*WORDS_PER_FRAME), loadedBitstreamEndianness);
122 fout.write((
char*)&bitstreamBRAM[srcR + r][numberOfBRAMsBeforeCol[r][fromCol]][0], framesToWrite * WORDS_PER_FRAME * 4);
123 fout.write((
char*)blankFrame, WORDS_PER_FRAME * 4);
131 Rect2D slrCoordsRect = {{0, 0}, {0, 0}};
132 slrCoordsRect.
position.
row = SLRinfo[slr].fromRow * CLB_PER_CLOCK_REGION;
133 slrCoordsRect.
size.
row = (SLRinfo[slr].toRow - SLRinfo[slr].fromRow + 1) * CLB_PER_CLOCK_REGION;
134 slrCoordsRect.
size.
col = maxNumberOfCols;
137 outputBitstreamSLRHeaderBitstreamSequence(fout, slr, (!selectedOptions.partialNotFull), loadedBitstreamEndianness);
139 if(selectedOptions.partialNotFull){
140 for (
Rect2D selRect : regionSelection) {
148 outputBitstreamSLRFooterBitstreamSequence(fout, slr, (!selectedOptions.partialNotFull), loadedBitstreamEndianness);
149 outputBitstreamSLRHeaderAfterBitstreamSequence(fout, slr, (!selectedOptions.partialNotFull), loadedBitstreamEndianness);
154 bool overlap[MAX_SLRS];
155 for(
int slr = 0 ; slr < numberOfSLRs ; slr++){
157 Rect2D slrCoordsRect = {{0, 0}, {0, 0}};
158 slrCoordsRect.
position.
row = SLRinfo[slr].fromRow * CLB_PER_CLOCK_REGION;
159 slrCoordsRect.
size.
row = (SLRinfo[slr].toRow - SLRinfo[slr].fromRow + 1) * CLB_PER_CLOCK_REGION;
160 slrCoordsRect.
size.
col = maxNumberOfCols;
161 overlap[slr] =
false;
162 if(selectedOptions.partialNotFull){
163 for (
Rect2D selRect : regionSelection) {
175 for(
int slr = 0 ; slr < numberOfSLRs ; slr++){
181 for(
int slr = numberOfSLRs - 2 ; slr >= 0 ; slr--){
183 outputBitstreamSLRWrapUpSequence(fout, slr, (!selectedOptions.partialNotFull), loadedBitstreamEndianness);
185 outputBitstreamEmptySLRWrapUpSequence(fout, slr,
false, loadedBitstreamEndianness);
193 if(selectedOptions.partialNotFull)
194 designName.append(
";PARTIAL=TRUE");
195 designName.append(
";bytemanVersion=").append(VERSION).append(
":").append(VERSION_BUILD);
200 outputBitstreamGlobalHeaderSequence(fout, (!selectedOptions.partialNotFull), loadedBitstreamEndianness);
202 outputBitstreamGlobalFooterSequence(fout, (!selectedOptions.partialNotFull), loadedBitstreamEndianness);
209 outputBitstreamGlobalHeaderSequence(fout, (!selectedOptions.partialNotFull), loadedBitstreamEndianness);
211 outputBitstreamGlobalFooterSequence(fout, (!selectedOptions.partialNotFull), loadedBitstreamEndianness);
Endianness
< Endianness in byteman is represented not only by big/little endian, but also by potential bit swapp...
void XCAP_writeRegister(std::ofstream &fout, XCAP::Register reg, int writeValue, Endianness e)
Generate the encoding for writing a CAP register and write it to file ofstream.
uint32_t XCAP_getSyncInstruction()
Generate and return the encoding for a SYNC instruction.
void XCAP_writeCommand(std::ofstream &fout, XCAP::Command cmd, Endianness e)
Generate the encoding for writing a CAP command and write it to file ofstream.
void XCAP_writeFDRI(std::ofstream &fout, int wordCount, Endianness e)
Generate and write an FDRI command. Always uses type 2 command for simplicity.
void XCAP_writeNOP(std::ofstream &fout, int cnt, int payload, Endianness e)
Generate the encoding for NOP instructions and write them to file ofstream.
uint32_t XCAP_getFAR(int slr, int blockType, int globalRowAddress, int columnAddress, int minorAddress)
void writeBitstreamBIT(std::ofstream &fout, Rect2D cmdRect)
void outputBITheader(std::ofstream &fout, Endianness e)
void writeBitstreamBIN(std::ofstream &fout, Rect2D cmdRect)
void writeBitstreamMain(std::ofstream &fout, Rect2D cmdRect)
void writeBitstreamMainEmptySLR(std::ofstream &fout, int slr)
void writeBitstreamMainSingleSLR(std::ofstream &fout, int slr, Rect2D cmdRect)
void outputCAPheaderConstant(std::ofstream &fout, Endianness e)
void outputBITheaderLengthField(std::ofstream &fout, Endianness e)
void outputBITheader16bString(std::ofstream &fout, Endianness e, std::string s)
void writeBitstreamMainSingleRegion(std::ofstream &fout, int slr, Rect2D writeRect)
std::string to_string(Endianness e)
void writeString(std::ofstream &fout, std::string writeString, size_t outputSize=0)
void write16(std::ofstream &fout, uint16_t writeValue, Endianness e=Endianness::NATIVE)
void write8(std::ofstream &fout, uint8_t writeValue, Endianness e=Endianness::NATIVE)
void write32(std::ofstream &fout, uint32_t writeValue, Endianness e=Endianness::NATIVE)
Rect2D getOverlap(Rect2D r1, Rect2D r2)