byteman  1.3 (Build #225)
Bitstream relocation and manipulation tool
inlineBlank.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2022 Kristiyan Manev (University of Manchester)
3  *
4  * Licensed under the Apache License, Version 2.0(the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 
18 {
19  initializedResourceStringShortPartName = "";
20  memset(&resourceString, 0, MAX_ROWS * MAX_COLS * sizeof(char));
21 }
22 
23 inline void blankBuffers()
24 {
25  uint8_t blankByte = selectedOptions.intParam % 256;
26  if(regionSelection.empty()) {
27  if(selectedOptions.clb && selectedOptions.clk) {
28  memset(&bitstreamBegin[0], blankByte, ((uint64_t)&bitstreamBRAM[0][0][0]-(uint64_t)&bitstreamBegin[0]));
29  }
30  else if(selectedOptions.clb || selectedOptions.clk){
31  for(int r = 0 ; r < numberOfRows ; r++){
32  for(int c = 0 ; c < numberOfCols[r] ; c++){
33  for(int m = 0 ; m < LUT_numberOfFramesForResourceLetter[(uint8_t)resourceString[r][c]] ; m++){
34  if(selectedOptions.clb){
35  memset(&bitstreamCLB[r][c][m*WORDS_PER_FRAME], blankByte, (WORDS_BEFORE_CLK * 4));
36  memset(&bitstreamCLB[r][c][m*WORDS_PER_FRAME+(WORDS_BEFORE_CLK+WORDS_AT_CLK)], blankByte, (WORDS_AFTER_CLK * 4));
37  }
38  if(selectedOptions.clk){
39  for(int w = 0 ; w < WORDS_AT_CLK ; w++){
40  bitstreamCLB[r][c][m*WORDS_PER_FRAME + WORDS_BEFORE_CLK + w] = ((blankByte << 24) | (blankByte << 16) | (blankByte << 8) | (blankByte));
41  }
42  }
43  }
44  }
45  }
46  }
47  if(selectedOptions.bram)
48  memset(&bitstreamBRAM[0][0][0], blankByte, ((uint64_t)&bitstreamEnd[0]-(uint64_t)&bitstreamBRAM[0][0][0]));
49  } else {
50  for (Rect2D &selRect : regionSelection) {
51  int fromRow = selRect.position.row / CLB_PER_CLOCK_REGION;
52  int toRow = (selRect.position.row + selRect.size.row) / CLB_PER_CLOCK_REGION;
53  int fromCol = selRect.position.col;
54  int toCol = selRect.position.col + selRect.size.col;
55  for(int r = fromRow ; r < toRow ; r++){
56  if(selectedOptions.clb && selectedOptions.clk){
57  int blankSize = numberOfFramesBeforeCol[r][toCol] - numberOfFramesBeforeCol[r][fromCol];
58  blankSize *= WORDS_PER_FRAME * 4;
59  memset(&bitstreamCLB[r][fromCol][0], blankByte, blankSize);
60  }
61  else if(selectedOptions.clb || selectedOptions.clk){
62  for(int c = fromCol ; c < toCol ; c++){
63  for(int m = 0 ; m < LUT_numberOfFramesForResourceLetter[(uint8_t)resourceString[r][c]] ; m++){
64  if(selectedOptions.clb){
65  memset(&bitstreamCLB[r][c][m*WORDS_PER_FRAME], blankByte, (WORDS_BEFORE_CLK * 4));
66  memset(&bitstreamCLB[r][c][m*WORDS_PER_FRAME+(WORDS_BEFORE_CLK+WORDS_AT_CLK)], blankByte, (WORDS_AFTER_CLK * 4));
67  }
68  if(selectedOptions.clk){
69  for(int w = 0 ; w < WORDS_AT_CLK ; w++){
70  bitstreamCLB[r][c][m*WORDS_PER_FRAME + WORDS_BEFORE_CLK + w] = ((blankByte << 24) | (blankByte << 16) | (blankByte << 8) | (blankByte));
71  }
72  }
73  }
74  }
75  }
76  if(selectedOptions.bram){
77  int blankSize = numberOfBRAMsBeforeCol[r][toCol] - numberOfBRAMsBeforeCol[r][fromCol];
78  blankSize *= FRAMES_PER_BRAM_CONTENT_COLUMN * WORDS_PER_FRAME * 4;
79  memset(&bitstreamCLB[r][numberOfBRAMsBeforeCol[r][fromCol]][0], blankByte, blankSize); //memset with size 0 is safe, no need to check anything
80  }
81  }
82  }
83  }
84  bitstreamHasValidData = true;
85 }
void blankBuffers()
Definition: inlineBlank.h:23
void clearResourceStringArrays()
Definition: inlineBlank.h:17
Definition: Coords.h:29