140 log_warning(
"Yosys does not support tri-state logic at the moment. (%s:%d)\n",
145 const char *str = code.c_str();
149 int len = strlen(str) - 2;
150 std::vector<RTLIL::State> data;
151 data.reserve(len * 8);
152 for (
int i = 0; i < len; i++) {
153 unsigned char ch = str[len - i];
154 for (
int j = 0; j < 8; j++) {
159 AstNode *ast = AstNode::mkconst_bits(data,
false);
164 for (
size_t i = 0; i < code.size(); i++)
165 if (code[i] ==
'_' || code[i] ==
' ' || code[i] ==
'\t' || code[i] ==
'\r' || code[i] ==
'\n')
166 code.erase(code.begin()+(i--));
170 long len_in_bits = strtol(str, &endptr, 10);
174 std::vector<RTLIL::State> data;
178 return AstNode::mkconst_bits(data,
true);
188 std::vector<RTLIL::State> data;
189 bool is_signed =
false;
190 if (*(endptr+1) ==
's') {
198 my_strtobin(data, endptr+2, len_in_bits, 2, case_type);
202 my_strtobin(data, endptr+2, len_in_bits, 8, case_type);
206 my_strtobin(data, endptr+2, len_in_bits, 10, case_type);
210 my_strtobin(data, endptr+2, len_in_bits, 16, case_type);
215 if (len_in_bits < 0) {
216 if (is_signed && data.back() ==
RTLIL::S1)
218 while (data.size() < 32)
221 return AstNode::mkconst_bits(data, is_signed);
void log_warning(const char *format,...)
int frontend_verilog_yyget_lineno(void)
std::string current_filename
AST::AstNode * const2ast(std::string code, char case_type=0, bool warn_z=false)
static bool find(V &ts, const T &t)
std::vector< RTLIL::State > bits
static void my_strtobin(std::vector< RTLIL::State > &data, const char *str, int len_in_bits, int base, char case_type)