35 int main(
int argc,
char * argv[])
40 bytemanInstance.
help(
"", 1);
42 bool readSTDIN =
false;
43 for(
int argi = 1 ; argi < argc ; argi++) {
44 if(argv[argi][0] ==
'-' && !command.empty()){
45 bytemanInstance.
parse(command);
49 command.append(argv[argi]);
51 command.append(
" ").append(argv[argi]);
52 if(command ==
"-stdin" || command ==
"-s"){
58 bytemanInstance.
parse(command);
60 getline(cin, command);
63 if(command !=
"" && command.at(command.find_first_not_of(
" \t")) !=
'#'){
64 if(string::npos != command.find(
"#"))
65 command = command.substr(0, command.find(
"#"));
66 bytemanInstance.
parse(command);
69 }
catch (
const exception &e){
70 cout <<
"The program was terminated with message: \n\t'" << e.what() <<
"'\nWhile trying to execute command: \n\t'" << command <<
"'" << endl;
78 mainXS7.instanceName =
"Main Xil S7";
79 tempXS7.instanceName =
"Temp Xil S7";
83 mainXUS.instanceName =
"Main Xil US";
84 tempXUS.instanceName =
"Temp Xil US";
88 mainXUSP.instanceName =
"Main Xil US+ ";
89 tempXUSP.instanceName =
"Temp Xil US+ ";
100 if (command.at(0) ==
'-') command.erase(0, 1);
106 else if(Architecture::Unknown == selectedArchitecture)
107 setArchitecture(command);
109 parseVerbose(params);
127 parseAssembly(params);
135 throw runtime_error(
"Could not parse command. Consider checking out \"bytemap -help\".");
148 string commandWithoutTheValidParams =
"";
151 stringstream ss(params);
155 if(
"main" == param ||
"first" == param)options.mainBufferSelected =
true;
156 else if(
"temp" == param ||
"second" == param)options.tempBufferSelected =
true;
158 if(commandWithoutTheValidParams !=
"")
159 commandWithoutTheValidParams.append(
" ");
160 commandWithoutTheValidParams.append(param);
164 if(!options.mainBufferSelected && !options.tempBufferSelected)
165 options.mainBufferSelected =
true;
166 return commandWithoutTheValidParams;
175 if(Architecture::Xilinx_Series7 == selectedArchitecture){
176 mainXS7.enableLog = verboseValue;
177 tempXS7.enableLog = verboseValue;
181 if(Architecture::Xilinx_UltraScale == selectedArchitecture){
182 mainXUS.enableLog = verboseValue;
183 tempXUS.enableLog = verboseValue;
187 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture){
188 mainXUSP.enableLog = verboseValue;
189 tempXUSP.enableLog = verboseValue;
199 if(Architecture::Xilinx_Series7 == selectedArchitecture){
200 mainXS7.enableWarn = warnValue;
201 tempXS7.enableWarn = warnValue;
205 if(Architecture::Xilinx_UltraScale == selectedArchitecture){
206 mainXUS.enableWarn = warnValue;
207 tempXUS.enableWarn = warnValue;
211 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture){
212 mainXUSP.enableWarn = warnValue;
213 tempXUSP.enableWarn = warnValue;
223 if(Architecture::Xilinx_Series7 == selectedArchitecture){
224 mainXS7.region(params,
rect);
225 tempXS7.region(params,
rect);
229 if(Architecture::Xilinx_UltraScale == selectedArchitecture){
230 mainXUS.region(params,
rect);
231 tempXUS.region(params,
rect);
235 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture){
236 mainXUSP.region(params,
rect);
237 tempXUSP.region(params,
rect);
243 string params = parseParamsAndRemoveThemFromString(blankCmd);
245 if(Architecture::Xilinx_Series7 == selectedArchitecture){
246 if(options.mainBufferSelected)
247 mainXS7.blank(params);
248 if(options.tempBufferSelected)
249 tempXS7.blank(params);
253 if(Architecture::Xilinx_UltraScale == selectedArchitecture){
254 if(options.mainBufferSelected)
255 mainXUS.blank(params);
256 if(options.tempBufferSelected)
257 tempXUS.blank(params);
261 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture){
262 if(options.mainBufferSelected)
263 mainXUSP.blank(params);
264 if(options.tempBufferSelected)
265 tempXUSP.blank(params);
271 string changeParams = parseParamsAndRemoveThemFromString(changeCmd);
273 if(Architecture::Xilinx_Series7 == selectedArchitecture){
274 if(options.mainBufferSelected)
275 mainXS7.change(changeParams);
276 if(options.tempBufferSelected)
277 tempXS7.change(changeParams);
281 if(Architecture::Xilinx_UltraScale == selectedArchitecture){
282 if(options.mainBufferSelected)
283 mainXUS.change(changeParams);
284 if(options.tempBufferSelected)
285 tempXUS.change(changeParams);
289 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture){
290 if(options.mainBufferSelected)
291 mainXUSP.change(changeParams);
292 if(options.tempBufferSelected)
293 tempXUSP.change(changeParams);
299 string deviceName = parseParamsAndRemoveThemFromString(deviceCmd);
301 if(Architecture::Xilinx_Series7 == selectedArchitecture){
302 if(options.mainBufferSelected)
303 mainXS7.setDeviceByNameOrThrow(deviceName);
304 if(options.tempBufferSelected)
305 tempXS7.setDeviceByNameOrThrow(deviceName);
309 if(Architecture::Xilinx_UltraScale == selectedArchitecture){
310 if(options.mainBufferSelected)
311 mainXUS.setDeviceByNameOrThrow(deviceName);
312 if(options.tempBufferSelected)
313 tempXUS.setDeviceByNameOrThrow(deviceName);
317 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture){
318 if(options.mainBufferSelected)
319 mainXUSP.setDeviceByNameOrThrow(deviceName);
320 if(options.tempBufferSelected)
321 tempXUSP.setDeviceByNameOrThrow(deviceName);
327 string params = parseParamsAndRemoveThemFromString(inputCmd);
330 if(Architecture::Xilinx_Series7 == selectedArchitecture){
331 if(options.mainBufferSelected)
332 mainXS7.readBitstream(filename);
333 if(options.tempBufferSelected)
334 tempXS7.readBitstream(filename);
338 if(Architecture::Xilinx_UltraScale == selectedArchitecture){
339 if(options.mainBufferSelected)
340 mainXUS.readBitstream(filename);
341 if(options.tempBufferSelected)
342 tempXUS.readBitstream(filename);
346 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture){
347 if(options.mainBufferSelected)
348 mainXUSP.readBitstream(filename);
349 if(options.tempBufferSelected)
350 tempXUSP.readBitstream(filename);
361 if(Architecture::Xilinx_Series7 == selectedArchitecture){
362 mainXS7.writeBitstream(filename, params,
rect);
366 if(Architecture::Xilinx_UltraScale == selectedArchitecture){
367 mainXUS.writeBitstream(filename, params,
rect);
371 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture){
372 mainXUSP.writeBitstream(filename, params,
rect);
383 if(Architecture::Xilinx_Series7 == selectedArchitecture){
384 mainXS7.merge(&tempXS7, params,
rect, dst);
388 if(Architecture::Xilinx_UltraScale == selectedArchitecture){
389 mainXUS.merge(&tempXUS, params,
rect, dst);
393 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture){
394 mainXUSP.merge(&tempXUSP, params,
rect, dst);
403 if(Architecture::Xilinx_Series7 == selectedArchitecture)
404 mainXS7.assembler(filenameIn, filenameOut);
407 if(Architecture::Xilinx_UltraScale == selectedArchitecture)
408 mainXUS.assembler(filenameIn, filenameOut);
411 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture)
412 mainXUSP.assembler(filenameIn, filenameOut);
423 bool usableFramesOnly =
false;
425 usableFramesOnly =
true;
427 bool testValueEqual =
true;
429 testValueEqual =
false;
431 if(Architecture::Xilinx_Series7 == selectedArchitecture)
432 mainXS7.test(usableFramesOnly, testValueEqual, testValue);
435 if(Architecture::Xilinx_UltraScale == selectedArchitecture)
436 mainXUS.test(usableFramesOnly, testValueEqual, testValue);
439 if(Architecture::Xilinx_UltraScalePlus == selectedArchitecture)
440 mainXUSP.test(usableFramesOnly, testValueEqual, testValue);
455 selectedArchitecture = Architecture::Xilinx_UltraScalePlus;
465 selectedArchitecture = Architecture::Xilinx_UltraScale;
476 selectedArchitecture = Architecture::Xilinx_Series7;
480 throw runtime_error(
string(
"Unknown architecture: \"").append(arch).append(
"\"."));
int main(int argc, char *argv[])
void parseAssembly(std::string)
void setArchitecture(std::string)
void parseVerbose(std::string)
void parseBlank(std::string)
void parseMerge(std::string)
std::string parseParamsAndRemoveThemFromString(std::string)
void help(std::string, int)
void parseRegion(std::string)
void parseOutput(std::string)
void parseTest(std::string)
void parseInput(std::string)
void parseDevice(std::string)
void parseChange(std::string)
void parseWarn(std::string)
bool firstStringWordIs(std::string checkedString, std::string nextString, Rest ... restStrings)
Returns true if string checkedString's first word matches fully any of strings nextString or restStri...
bool stringContains(std::string checkedString)
Returns false. End of recursion for template.
std::string lastStringWord(std::string s)
Parses a string s, removes all integers and returns the last of all string words.
bool multipleUints(std::stringstream &ss)
std::string allStringWordsWithoutLastStringWord(std::string s)
Parses a string s, removes all integers and the last string word. Returns the rest.
std::string allStringWords(std::string s)
Parses a string s, removes all integers and returns the rest.
bool multipleInts(std::stringstream &ss)
std::string nthStringWord(std::string s, int n)
Parses a string s, returns the n-th string word that is not an integer.
std::string stringToLower(std::string str)
Replaces all uppercase characters in str with lowercase and returns the resulting string.
std::string replace(std::string str, char oldChar, char newChar)
Replaces all instances of oldChar in string str with newChar and returns the resulting string.
std::string findStringAndGetAllAfter(std::string checkedString, std::string searchString)
Finds string searchString inside checkedString and returns all to the right inside checkedString....