byteman  1.3 (Build #225)
Bitstream relocation and manipulation tool
XUS_Devices.cpp
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2022 Kristiyan Manev, Joseph Powell (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<iostream>
18 #include<algorithm> //transform
19 #include<string>
20 #include<stdexcept>
21 
22 #include "XilinxUltraScale.h"
23 #include "XUS_Devices.h"
24 #include "../../../Common/str.h"
25 
26 using namespace std;
27 
29 {
30  int deviceID = getDeviceByIDCODE(IDCODE);
31  if(deviceID == XUS_DEVICE_NULL)
32  throw runtime_error(string("Unknown device with IDCODE = ").append(to_string(IDCODE)).append(" . Maybe the device is not Xilinx UltraScale device?"));
33  return deviceID;
34 }
35 
37 {
38  int deviceID = getDeviceByName(name);
39  if(deviceID == XUS_DEVICE_NULL)
40  throw runtime_error(string("Unknown device: ").append(name).append(". Maybe the device is not Xilinx UltraScale device?"));
41  return deviceID;
42 }
43 
45  setDeviceByNameOrThrow(partName);
46 }
47 
49  int deviceID = getDeviceByNameOrThrow(name);
50  setDevice(deviceID, name);
51 }
52 
54  int deviceID = getDeviceByIDCODEorThrow(idcode);
55  setDevice(deviceID);
56 }
57 
59 {
60  //US Kintex
61  #ifdef XUSKINTEX
62  if(IDCODE == XCKU025_IDCODE)
63  return XUS_DEVICE_XCKU025;
64  if(IDCODE == XCKU035_IDCODE)
65  return XUS_DEVICE_XCKU035;
66  if(IDCODE == XCKU040_IDCODE)
67  return XUS_DEVICE_XCKU040;
68  if(IDCODE == XCKU060_IDCODE)
69  return XUS_DEVICE_XCKU060;
70  if(IDCODE == XCKU085_IDCODE)
71  return XUS_DEVICE_XCKU085;
72  if(IDCODE == XCKU095_IDCODE)
73  return XUS_DEVICE_XCKU095;
74  if(IDCODE == XCKU115_IDCODE)
75  return XUS_DEVICE_XCKU115;
76  #endif
77  //US Virtex
78  #ifdef XUSVIRTEX
79  if(IDCODE == XCVU065_IDCODE)
80  return XUS_DEVICE_XCVU065;
81  if(IDCODE == XCVU080_IDCODE)
82  return XUS_DEVICE_XCVU080;
83  if(IDCODE == XCVU095_IDCODE)
84  return XUS_DEVICE_XCVU095;
85  if(IDCODE == XCVU125_IDCODE)
86  return XUS_DEVICE_XCVU125;
87  if(IDCODE == XCVU160_IDCODE)
88  return XUS_DEVICE_XCVU160;
89  if(IDCODE == XCVU190_IDCODE)
90  return XUS_DEVICE_XCVU190;
91  if(IDCODE == XCVU440_IDCODE)
92  return XUS_DEVICE_XCVU440;
93  #endif
94 
95  return XUS_DEVICE_NULL;
96 }
98 {
99  name = str::removeSpaces(name);
100  name = str::stringToLower(name);
101 
102  //US Kintex
103  #ifdef XUSKINTEX
105  return XUS_DEVICE_XCKU025;
107  return XUS_DEVICE_XCKU035;
108  if(str::iff::stringContains(name, XCKU040_NAME, "xqku040"))
109  return XUS_DEVICE_XCKU040;
110  if(str::iff::stringContains(name, XCKU060_NAME, "xqku060", "xqrku060"))
111  return XUS_DEVICE_XCKU060;
113  return XUS_DEVICE_XCKU085;
114  if(str::iff::stringContains(name, XCKU095_NAME, "xqku095"))
115  return XUS_DEVICE_XCKU095;
116  if(str::iff::stringContains(name, XCKU115_NAME, "xqku115"))
117  return XUS_DEVICE_XCKU115;
118  #endif
119  //US Virtex
120  #ifdef XUSVIRTEX
122  return XUS_DEVICE_XCVU065;
124  return XUS_DEVICE_XCVU080;
126  return XUS_DEVICE_XCVU095;
128  return XUS_DEVICE_XCVU125;
130  return XUS_DEVICE_XCVU160;
132  return XUS_DEVICE_XCVU190;
134  return XUS_DEVICE_XCVU440;
135  #endif
136 
137  return XUS_DEVICE_NULL;
138 }
139 /************************************************************************** /**
140  * setPartName if available. Otherwise will put a default name.
141  *****************************************************************************/
142 void XilinxUltraScale::setDevice(int deviceID, string customPartName)
143 {
145  bool customNameSet = false;
146  #define setCustomPartName(x) {customNameSet = true; partName = x;}
147  switch(deviceID){
148  //US Kintex
149  #ifdef XUSKINTEX
150  case XUS_DEVICE_XCKU025:
151  XCKU025();
152  break;
153  case XUS_DEVICE_XCKU035:
154  XCKU035();
155  break;
156  case XUS_DEVICE_XCKU040:
157  XCKU040();
158  break;
159  case XUS_DEVICE_XCKU060:
160  XCKU060();
161  break;
162  case XUS_DEVICE_XCKU085:
163  XCKU085();
164  break;
165  case XUS_DEVICE_XCKU095:
166  XCKU095();
167  break;
168  case XUS_DEVICE_XCKU115:
169  XCKU115();
170  break;
171  #endif
172  //US Virtex
173  #ifdef XUSVIRTEX
174  case XUS_DEVICE_XCVU065:
175  XCVU065();
176  break;
177  case XUS_DEVICE_XCVU080:
178  XCVU080();
179  break;
180  case XUS_DEVICE_XCVU095:
181  XCVU095();
182  break;
183  case XUS_DEVICE_XCVU125:
184  XCVU125();
185  break;
186  case XUS_DEVICE_XCVU160:
187  XCVU160();
188  break;
189  case XUS_DEVICE_XCVU190:
190  XCVU190();
191  break;
192  case XUS_DEVICE_XCVU440:
193  XCVU440();
194  break;
195  #endif
196  default:throw runtime_error("Unknown device ID.");
197  }
198  #undef setCustomPartName
199  if(!customNameSet) // if we didn't set already a good full name
200  if(customPartName != "")// if not empty string
201  partName = customPartName;
202 
203 
204  log("Initialized device resource string for \"" + initializedResourceStringShortPartName + "\"");
205 }
206 
208 {
209  if(initializedResourceStringShortPartName == "") {//if no device is initialized
210  cout << "A list of currently supported Xilinx UltraScale devices: " << endl;
211  #ifdef XUSKINTEX
212  cout << " UltraScale Kintex: " << endl;
213  cout << " XCKU025, XCKU035, XCKU040, XQKU040, XCKU060, XQKU060, XQRKU060, XCKU085, XCKU095, XQKU095, XCKU115, XQKU0115" << endl;
214  #endif
215  #ifdef XUSVIRTEX
216  cout << " UltraScale Virtex: " << endl;
217  cout << " XCVU065, XCVU080, XCVU095, XCVU125, XCVU160, XCVU190, XCVU440" << endl;
218  #endif
219  } else {
221  }
222 }
#define XCKU085_NAME
Definition: XUS_Devices.h:147
#define XCKU035_NAME
Definition: XUS_Devices.h:103
#define XCVU440()
Definition: XUS_Devices.h:389
#define XCVU080_IDCODE
Definition: XUS_Devices.h:236
#define XCVU095_NAME
Definition: XUS_Devices.h:250
#define XCVU160_IDCODE
Definition: XUS_Devices.h:298
#define XCKU085()
Definition: XUS_Devices.h:166
#define XCKU035_IDCODE
Definition: XUS_Devices.h:106
#define XCKU095()
Definition: XUS_Devices.h:185
#define XCVU440_IDCODE
Definition: XUS_Devices.h:365
#define XCVU065()
Definition: XUS_Devices.h:227
#define XCKU115_IDCODE
Definition: XUS_Devices.h:194
#define XCKU095_NAME
Definition: XUS_Devices.h:173
#define XCVU125_NAME
Definition: XUS_Devices.h:268
#define XCKU040_IDCODE
Definition: XUS_Devices.h:120
#define XCVU065_IDCODE
Definition: XUS_Devices.h:221
#define XCVU160()
Definition: XUS_Devices.h:322
#define XCKU025()
Definition: XUS_Devices.h:97
#define XCVU095_IDCODE
Definition: XUS_Devices.h:253
#define XCVU440_NAME
Definition: XUS_Devices.h:362
#define XCKU040()
Definition: XUS_Devices.h:126
#define XCKU060_IDCODE
Definition: XUS_Devices.h:134
#define XCKU060_NAME
Definition: XUS_Devices.h:131
#define XCKU060()
Definition: XUS_Devices.h:140
#define XCKU115()
Definition: XUS_Devices.h:210
#define XCKU095_IDCODE
Definition: XUS_Devices.h:176
#define XCKU025_IDCODE
Definition: XUS_Devices.h:91
#define XCVU190_NAME
Definition: XUS_Devices.h:329
#define XCKU025_NAME
Definition: XUS_Devices.h:88
#define XCKU085_IDCODE
Definition: XUS_Devices.h:150
#define XCVU080()
Definition: XUS_Devices.h:245
#define XCVU095()
Definition: XUS_Devices.h:262
#define XCVU190()
Definition: XUS_Devices.h:356
#define XCVU080_NAME
Definition: XUS_Devices.h:233
#define XCKU040_NAME
Definition: XUS_Devices.h:117
#define XCVU065_NAME
Definition: XUS_Devices.h:218
#define XCVU160_NAME
Definition: XUS_Devices.h:295
#define XCVU125()
Definition: XUS_Devices.h:287
@ XUS_DEVICE_NULL
Definition: XUS_Devices.h:24
@ XUS_DEVICE_XCVU080
Definition: XUS_Devices.h:35
@ XUS_DEVICE_XCVU190
Definition: XUS_Devices.h:39
@ XUS_DEVICE_XCVU065
Definition: XUS_Devices.h:34
@ XUS_DEVICE_XCKU035
Definition: XUS_Devices.h:27
@ XUS_DEVICE_XCKU040
Definition: XUS_Devices.h:28
@ XUS_DEVICE_XCKU060
Definition: XUS_Devices.h:29
@ XUS_DEVICE_XCVU440
Definition: XUS_Devices.h:40
@ XUS_DEVICE_XCKU115
Definition: XUS_Devices.h:32
@ XUS_DEVICE_XCVU125
Definition: XUS_Devices.h:37
@ XUS_DEVICE_XCVU095
Definition: XUS_Devices.h:36
@ XUS_DEVICE_XCKU085
Definition: XUS_Devices.h:30
@ XUS_DEVICE_XCVU160
Definition: XUS_Devices.h:38
@ XUS_DEVICE_XCKU095
Definition: XUS_Devices.h:31
@ XUS_DEVICE_XCKU025
Definition: XUS_Devices.h:26
#define XCKU035()
Definition: XUS_Devices.h:112
#define XCVU125_IDCODE
Definition: XUS_Devices.h:271
#define XCVU190_IDCODE
Definition: XUS_Devices.h:332
#define XCKU115_NAME
Definition: XUS_Devices.h:191
int getDeviceByIDCODEorThrow(int) override
Definition: XUS_Devices.cpp:28
void setDevice(int, std::string="") override
void setDeviceByNameOrThrow(std::string) override
Definition: XUS_Devices.cpp:48
void setDeviceByPartNameOrThrow() override
Definition: XUS_Devices.cpp:44
int getDeviceByName(std::string) override
Definition: XUS_Devices.cpp:97
void setDeviceByIDCODEOrThrow(int) override
Definition: XUS_Devices.cpp:53
int getDeviceByNameOrThrow(std::string) override
Definition: XUS_Devices.cpp:36
int getDeviceByIDCODE(int) override
Definition: XUS_Devices.cpp:58
void clearResourceStringArrays()
Definition: inlineBlank.h:17
void printResourceStringInfo()
std::string to_string(Endianness e)
Definition: Endianness.h:56
bool stringContains(std::string checkedString)
Returns false. End of recursion for template.
Definition: iff.h:57
std::string stringToLower(std::string str)
Replaces all uppercase characters in str with lowercase and returns the resulting string.
Definition: str.h:59
std::string removeSpaces(std::string str)
Removes all space chars of str returns the resulting string.
Definition: str.h:47