byteman  1.3 (Build #225)
Bitstream relocation and manipulation tool
inlineParseParams.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 
17 /**************************************************************************/
32 inline void parseParams(std::string params){
33  selectedOptions = SelectedOptions();
34  selectedOptions.clk = false;
35  selectedOptions.clb = false;
36  selectedOptions.bram = false;
37  selectedOptions.blank = false;
38  selectedOptions.partialNotFull = true;
39  selectedOptions.op = MergeOP::SET;
40  selectedOptions.skipUnused = true;
41  selectedOptions.forceEndianness = false;
42  selectedOptions.word = false;
43  selectedOptions.intParam = 0;
44  replace(params.begin(), params.end(), ',', ' ');
45  std::stringstream ss(params);
46  std::string param;
47  while (!ss.eof()) {
48  ss >> param;
49  if(param == "clock" || param == "clk")selectedOptions.clk = true;
50  if(param == "logic" || param == "clb")selectedOptions.clb = true;
51  if(param == "blockram" || param == "bram")selectedOptions.bram = true;
52  if(param == "blank")selectedOptions.blank = true;
53  if(param == "full")selectedOptions.partialNotFull = false;
54  if(param == "partial")selectedOptions.partialNotFull = true;
55  if(param == "word")selectedOptions.word = true;
56  if(param == "set")selectedOptions.op = MergeOP::SET;
57  if(param == "xor")selectedOptions.op = MergeOP::XOR;
58  if(param == "or")selectedOptions.op = MergeOP::OR;
59  if(param == "and")selectedOptions.op = MergeOP::AND;
60  if(param == "bigendian"){
61  selectedOptions.forceEndianness = true;
62  selectedOptions.forcedEndianness = Endianness::BE;
63  }
64  if(param == "littleendian"){
65  selectedOptions.forceEndianness = true;
66  selectedOptions.forcedEndianness = Endianness::LE;
67  }
68  if(param == "bigendianwithbitswap"){
69  selectedOptions.forceEndianness = true;
70  selectedOptions.forcedEndianness = Endianness::BE_BS;
71  }
72  if(param == "littleendianwithbitswap"){
73  selectedOptions.forceEndianness = true;
74  selectedOptions.forcedEndianness = Endianness::LE_BS;
75  }
76  if(param == "nativeendian"){
77  selectedOptions.forceEndianness = true;
78  selectedOptions.forcedEndianness = Endianness::NATIVE;
79  }
80  param.clear();
81  }
82  if(!str::parse::multipleInts(params, selectedOptions.intParam))
83  selectedOptions.intParam = 0; //default 0 if there is nothing
84  if(!selectedOptions.clk && !selectedOptions.clb && !selectedOptions.bram){ // by default, choose all
85  selectedOptions.clk = selectedOptions.bram = selectedOptions.clb = true;
86  }
87 }
88 
@ BE_BS
Big endian with bit swaps inside each byte.
@ LE_BS
Little endian with bit swaps inside each byte.
@ LE
Little endian ("LE" instead of full-er name, so it does not conflict with linux's reserved endianess ...
@ BE
Big endian ("BE" instead of full-er name, so it does not conflict with linux's reserved endianess wor...
@ NATIVE
System native will always be the fastest endianess to process.
void parseParams(std::string params)
bool multipleInts(std::stringstream &ss)
Definition: parse.h:192
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.
Definition: str.h:41