byteman  1.3 (Build #225)
Bitstream relocation and manipulation tool
XUSP_Merge.cpp
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 
17 #include<string>
18 
19 #include "XilinxUltraScalePlus.h"
20 #include "../../../Common/str.h"
21 
22 using namespace std;
23 
24 void XilinxUltraScalePlus::merge(XilinxUltraScalePlus* srcBitstream, string params, Rect2D src, Coord2D dst){
25  log("Merging bitstreams.");
26  //This function uses a pointer to the second XUSP instance, but this pointer should get optimized as it is statically provided in the main function
27  parseParams(params);
28 
29  if(!selectedOptions.partialNotFull){
30  log("Merging the whole FPGA");
31  src.position = {0, 0};
32  dst = {0, 0};
33  src.size.row = numberOfRows * XUSP_CLB_PER_CLOCK_REGION;
34  src.size.col = maxNumberOfCols;
35  }
36 
37  ensureRegionCompatibility(src, dst);
38 
40  throw runtime_error(string("Currently only full clock region height relocations are supported (use row numbers multiple of ").append(to_string(XUSP_CLB_PER_CLOCK_REGION)).append(")."));
42  throw runtime_error(string("Currently only full clock region height relocations are supported (use row numbers multiple of ").append(to_string(XUSP_CLB_PER_CLOCK_REGION)).append(")."));
43  if(dst.row%XUSP_CLB_PER_CLOCK_REGION != 0)
44  throw runtime_error(string("Currently only full clock region height relocations are supported (use row numbers multiple of ").append(to_string(XUSP_CLB_PER_CLOCK_REGION)).append(")."));
45 
46  Endianness endianDifference = Endian::diff(loadedBitstreamEndianness, srcBitstream->loadedBitstreamEndianness);
47 
48  if((Endianness::NATIVE == endianDifference) && MergeOP::SET == selectedOptions.op)
49  fastMerge(srcBitstream, src, dst);
50  else
51  flexiMerge(srcBitstream, endianDifference, src, dst);
52  log("Merging bitstreams complete.");
53 }
54 
Endianness
< Endianness in byteman is represented not only by big/little endian, but also by potential bit swapp...
Definition: Endianness.h:47
@ NATIVE
System native will always be the fastest endianess to process.
#define XUSP_CLB_PER_CLOCK_REGION
Definition: XUSP_Fabric.h:41
Endianness loadedBitstreamEndianness
The endianess of the currently loaded bitstream.
void merge(XilinxUltraScalePlus *, std::string, Rect2D, Coord2D)
Definition: XUSP_Merge.cpp:24
void ensureRegionCompatibility(Rect2D src, Coord2D dst)
Definition: inlineMerge.h:33
void fastMerge(XilinxConfigurationAccessPort *srcBitstream, Rect2D src, Coord2D dst)
Definition: inlineMerge.h:51
void flexiMerge(XilinxConfigurationAccessPort *srcBitstream, Endianness endianConversionNeeded, Rect2D src, Coord2D dst)
Definition: inlineMerge.h:86
void parseParams(std::string params)
std::string to_string(Endianness e)
Definition: Endianness.h:56
Endianness diff(Endianness e1, Endianness e2)
Definition: Endianness.h:117
Definition: Coords.h:23
int col
Definition: Coords.h:25
int row
Definition: Coords.h:24
Definition: Coords.h:29
Coord2D size
Definition: Coords.h:31
Coord2D position
Definition: Coords.h:30