41 using namespace AST_INTERNAL;
46 std::stringstream sstr;
58 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
60 cell->attributes[attr.first] = attr.second->asAttrConst();
75 if (width <= sig.
size()) {
76 sig.
extend(width, is_signed);
80 std::stringstream sstr;
92 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
94 cell->attributes[attr.first] = attr.second->asAttrConst();
109 std::stringstream sstr;
120 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
122 cell->attributes[attr.first] = attr.second->asAttrConst();
144 std::stringstream sstr;
155 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
157 cell->attributes[attr.first] = attr.second->asAttrConst();
210 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
212 proc->attributes[attr.first] = attr.second->asAttrConst();
215 current_case = &proc->root_case;
219 collect_lvalues(subst_lvalue_from, always,
true,
true);
220 subst_lvalue_to = new_temp_signal(subst_lvalue_from);
221 subst_lvalue_map = subst_lvalue_from.
to_sigbit_map(subst_lvalue_to);
223 bool found_anyedge_syncs =
false;
226 found_anyedge_syncs =
true;
228 if (found_anyedge_syncs) {
229 log(
"Note: Assuming pure combinatorial block at %s:%d in\n", always->
filename.c_str(), always->
linenum);
230 log(
"compliance with IEC 62142(E):2005 / IEEE Std. 1364.1(E):2002. Recommending\n");
231 log(
"use of @* instead of @(...) for better match of synthesis and simulation.\n");
235 bool found_clocked_sync =
false;
238 found_clocked_sync =
true;
239 if (found_anyedge_syncs)
243 syncrule->signal = child->children[0]->genRTLIL();
244 addChunkActions(syncrule->actions, subst_lvalue_from, subst_lvalue_to,
true);
245 proc->syncs.push_back(syncrule);
247 if (proc->syncs.empty()) {
251 addChunkActions(syncrule->
actions, subst_lvalue_from, subst_lvalue_to,
true);
252 proc->syncs.push_back(syncrule);
259 addChunkActions(current_case->actions, subst_lvalue_to, subst_lvalue_from);
267 if (initSyncSignals.size() > 0)
271 proc->syncs.push_back(sync);
273 log_assert(init_lvalue.size() == init_rvalue.size());
276 for (
auto &init_lvalue_c : init_lvalue.chunks()) {
279 remove_unwanted_lvalue_bits(lhs, rhs);
281 offset += lhs.
size();
293 for (
int i = 0; i <
GetSize(lhs); i++) {
294 if (lhs[i].wire ==
nullptr)
307 std::vector<RTLIL::SigChunk> chunks = sig.
chunks();
309 for (
int i = 0; i <
GetSize(chunks); i++)
315 std::string wire_name;
317 wire_name =
stringf(
"$%d%s[%d:%d]", new_temp_count[chunk.
wire]++,
319 if (chunk.
wire->
name.
str().find(
'$') != std::string::npos)
342 collect_lvalues(reg, child, type_eq, type_le,
false);
351 collect_lvalues(reg, child, type_eq, type_le,
false);
357 reg.
append(child->children[0]->genRTLIL());
359 reg.
append(child->children[0]->genRTLIL());
361 collect_lvalues(reg, child, type_eq, type_le,
false);
369 if (run_sort_and_unify) {
370 std::set<RTLIL::SigBit> sorted_reg;
373 sorted_reg.insert(bit);
384 for (
auto it = cs->
actions.begin(); it != cs->
actions.end(); it++)
385 it->first.remove2(pattern, &it->second);
388 for (
auto it2 = (*it)->cases.begin(); it2 != (*it)->cases.end(); it2++)
389 removeSignalFromCaseTree(pattern, *it2);
396 if (inSyncRule && initSyncSignals.size() > 0) {
397 init_lvalue.append(lvalue.
extract(initSyncSignals));
398 init_rvalue.append(lvalue.
extract(initSyncSignals, &rvalue));
399 lvalue.
remove2(initSyncSignals, &rvalue);
404 for (
auto &lvalue_c : lvalue.
chunks()) {
407 if (inSyncRule && lvalue_c.wire && lvalue_c.wire->get_bool_attribute(
"\\nosync"))
409 remove_unwanted_lvalue_bits(lhs, rhs);
411 offset += lhs.
size();
430 lvalue.replace(subst_lvalue_map.stdmap());
433 for (
int i = 0; i <
GetSize(unmapped_lvalue); i++)
434 subst_rvalue_map.set(unmapped_lvalue[i], rvalue[i]);
437 removeSignalFromCaseTree(lvalue.to_sigbit_set(), current_case);
438 remove_unwanted_lvalue_bits(lvalue, rvalue);
439 current_case->actions.push_back(
RTLIL::SigSig(lvalue, rvalue));
446 sw->
signal = ast->
children[0]->genWidthRTLIL(-1, &subst_rvalue_map.stdmap());
447 current_case->switches.push_back(sw);
451 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
453 sw->attributes[attr.first] = attr.second->asAttrConst();
457 collect_lvalues(this_case_eq_lvalue, ast,
true,
false);
459 RTLIL::SigSpec this_case_eq_ltemp = new_temp_signal(this_case_eq_lvalue);
462 this_case_eq_rvalue.
replace(subst_rvalue_map.stdmap());
472 subst_lvalue_map.save();
473 subst_rvalue_map.save();
475 for (
int i = 0; i <
GetSize(this_case_eq_lvalue); i++)
476 subst_lvalue_map.set(this_case_eq_lvalue[i], this_case_eq_ltemp[i]);
480 last_generated_case = current_case;
481 addChunkActions(current_case->actions, this_case_eq_ltemp, this_case_eq_rvalue);
482 for (
auto node : child->children) {
484 default_case = current_case;
488 current_case->compare.push_back(node->genWidthRTLIL(sw->
signal.
size(), &subst_rvalue_map.stdmap()));
490 if (default_case != current_case)
491 sw->
cases.push_back(current_case);
493 log_assert(current_case->compare.size() == 0);
494 current_case = backup_case;
496 subst_lvalue_map.restore();
497 subst_rvalue_map.restore();
501 last_generated_case->
compare.clear();
503 if (default_case ==
NULL) {
505 addChunkActions(default_case->
actions, this_case_eq_ltemp, this_case_eq_rvalue);
507 sw->
cases.push_back(default_case);
510 for (
int i = 0; i <
GetSize(this_case_eq_lvalue); i++)
511 subst_rvalue_map.set(this_case_eq_lvalue[i], this_case_eq_ltemp[i]);
513 this_case_eq_lvalue.
replace(subst_lvalue_map.stdmap());
514 removeSignalFromCaseTree(this_case_eq_lvalue.
to_sigbit_set(), current_case);
515 addChunkActions(current_case->actions, this_case_eq_lvalue, this_case_eq_ltemp);
536 std::string type_name;
537 bool sub_sign_hint =
true;
538 int sub_width_hint = -1;
543 bool local_found_real =
false;
544 if (found_real ==
NULL)
545 found_real = &local_found_real;
550 width_hint = std::max(width_hint,
int(bits.size()));
557 width_hint = std::max(width_hint, 32);
565 log_error(
"Failed to resolve identifier %s for width detection at %s:%d!\n", str.c_str(), filename.c_str(), linenum);
568 this_width = id_ast->
children[1]->range_left - id_ast->
children[1]->range_right + 1;
571 this_width = id_ast->
children[0]->bits.size();
573 log_error(
"Failed to detect width for parameter %s at %s:%d!\n", str.c_str(), filename.c_str(), linenum);
574 if (children.size() != 0)
585 log_error(
"Failed to detect with of signal access `%s' at %s:%d!\n", str.c_str(), filename.c_str(), linenum);
589 if (children.size() != 0)
595 if (!id_ast->
children[0]->range_valid)
596 log_error(
"Failed to detect with of memory access `%s' at %s:%d!\n", str.c_str(), filename.c_str(), linenum);
597 this_width = id_ast->
children[0]->range_left - id_ast->
children[0]->range_right + 1;
599 log_error(
"Failed to detect width for identifier %s at %s:%d!\n", str.c_str(), filename.c_str(), linenum);
605 AstNode *right_at_zero_ast = children[0]->
children.size() >= 2 ? children[0]->children[1]->clone() : left_at_zero_ast->
clone();
606 while (left_at_zero_ast->
simplify(
true,
true,
false, 1, -1,
false,
false)) { }
607 while (right_at_zero_ast->
simplify(
true,
true,
false, 1, -1,
false,
false)) { }
609 log_error(
"Unsupported expression on dynamic range select on signal `%s' at %s:%d!\n",
610 str.c_str(), filename.c_str(), linenum);
611 this_width = left_at_zero_ast->
integer - right_at_zero_ast->
integer + 1;
612 delete left_at_zero_ast;
613 delete right_at_zero_ast;
618 width_hint = std::max(width_hint, this_width);
624 while (children[0]->simplify(
true,
false,
false, 1, -1,
false,
false) ==
true) { }
626 log_error(
"Left operand of tobits expression is not constant at %s:%d!\n", filename.c_str(), linenum);
627 children[1]->detectSignWidthWorker(sub_width_hint, sign_hint);
628 width_hint = std::max(width_hint, children[0]->bitsAsConst().as_int());
632 children.at(0)->detectSignWidthWorker(width_hint, sub_sign_hint);
636 children.at(0)->detectSignWidthWorker(width_hint, sub_sign_hint);
641 for (
auto child : children) {
643 sub_sign_hint =
true;
644 child->detectSignWidthWorker(sub_width_hint, sub_sign_hint);
645 this_width += sub_width_hint;
647 width_hint = std::max(width_hint, this_width);
652 while (children[0]->simplify(
true,
false,
false, 1, -1,
false,
true) ==
true) { }
654 log_error(
"Left operand of replicate expression is not constant at %s:%d!\n", filename.c_str(), linenum);
655 children[1]->detectSignWidthWorker(sub_width_hint, sub_sign_hint);
656 width_hint = std::max(width_hint, children[0]->bitsAsConst().as_int() * sub_width_hint);
663 children[0]->detectSignWidthWorker(width_hint, sign_hint, found_real);
670 for (
auto child : children)
671 child->detectSignWidthWorker(width_hint, sign_hint, found_real);
679 width_hint = std::max(width_hint, 1);
688 children[0]->detectSignWidthWorker(width_hint, sign_hint, found_real);
699 width_hint = std::max(width_hint, 1);
708 for (
auto child : children)
709 child->detectSignWidthWorker(width_hint, sign_hint, found_real);
715 width_hint = std::max(width_hint, 1);
720 children.at(1)->detectSignWidthWorker(width_hint, sign_hint, found_real);
721 children.at(2)->detectSignWidthWorker(width_hint, sign_hint, found_real);
725 if (!id2ast->is_signed)
727 if (!id2ast->children[0]->range_valid)
728 log_error(
"Failed to detect with of memory access `%s' at %s:%d!\n", str.c_str(), filename.c_str(), linenum);
729 this_width = id2ast->children[0]->range_left - id2ast->children[0]->range_right + 1;
730 width_hint = std::max(width_hint, this_width);
737 log_error(
"Don't know how to detect sign and width for %s node at %s:%d!\n",
738 type2str(type).c_str(), filename.c_str(), linenum);
752 detectSignWidthWorker(width_hint, sign_hint, found_real);
768 std::string type_name;
799 log_error(
"Re-definition of signal `%s' at %s:%d!\n",
800 str.c_str(), filename.c_str(), linenum);
802 log_error(
"Signal `%s' with non-constant width at %s:%d!\n",
803 str.c_str(), filename.c_str(), linenum);
805 log_assert(range_left >= range_right || (range_left == -1 && range_right == 0));
808 wire->attributes[
"\\src"] =
stringf(
"%s:%d", filename.c_str(), linenum);
813 wire->
upto = range_swapped;
815 for (
auto &attr : attributes) {
817 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
818 attr.first.c_str(), filename.c_str(), linenum);
819 wire->attributes[attr.first] = attr.second->asAttrConst();
827 log_error(
"Re-definition of memory `%s' at %s:%d!\n",
828 str.c_str(), filename.c_str(), linenum);
834 if (!children[0]->range_valid || !children[1]->range_valid)
835 log_error(
"Memory `%s' with non-constant width or size at %s:%d!\n",
836 str.c_str(), filename.c_str(), linenum);
839 memory->attributes[
"\\src"] =
stringf(
"%s:%d", filename.c_str(), linenum);
841 memory->width = children[0]->range_left - children[0]->range_right + 1;
842 memory->start_offset = children[0]->range_right;
843 memory->size = children[1]->range_left - children[1]->range_right;
846 if (memory->size < 0)
848 memory->size += std::min(children[1]->range_left, children[1]->range_right) + 1;
850 for (
auto &attr : attributes) {
852 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
853 attr.first.c_str(), filename.c_str(), linenum);
854 memory->attributes[attr.first] = attr.second->asAttrConst();
863 detectSignWidth(width_hint, sign_hint);
865 is_signed = sign_hint;
872 log_warning(
"converting real value %e to binary %s at %s:%d.\n",
873 realvalue,
log_signal(sig), filename.c_str(), linenum);
885 int add_undef_bits_msb = 0;
886 int add_undef_bits_lsb = 0;
890 wire->attributes[
"\\src"] =
stringf(
"%s:%d", filename.c_str(), linenum);
893 log_warning(
"Identifier `%s' is implicitly declared at %s:%d.\n", str.c_str(), filename.c_str(), linenum);
895 log_error(
"Identifier `%s' is implicitly declared at %s:%d and `default_nettype is set to none.\n", str.c_str(), filename.c_str(), linenum);
899 log_error(
"Parameter %s does not evaluate to constant value at %s:%d!\n",
900 str.c_str(), filename.c_str(), linenum);
902 goto use_const_chunk;
906 log_error(
"Identifier `%s' doesn't map to any signal at %s:%d!\n",
907 str.c_str(), filename.c_str(), linenum);
910 log_error(
"Identifier `%s' does map to an unexpanded memory at %s:%d!\n",
911 str.c_str(), filename.c_str(), linenum);
915 chunk.
width = wire->width;
919 if (children.size() != 0) {
921 int source_width = id2ast->range_left - id2ast->range_right + 1;
922 int source_offset = id2ast->range_right;
923 if (!children[0]->range_valid) {
925 AstNode *right_at_zero_ast = children[0]->
children.size() >= 2 ? children[0]->children[1]->clone() : left_at_zero_ast->
clone();
926 while (left_at_zero_ast->
simplify(
true,
true,
false, 1, -1,
false,
false)) { }
927 while (right_at_zero_ast->
simplify(
true,
true,
false, 1, -1,
false,
false)) { }
929 log_error(
"Unsupported expression on dynamic range select on signal `%s' at %s:%d!\n",
930 str.c_str(), filename.c_str(), linenum);
931 int width = left_at_zero_ast->
integer - right_at_zero_ast->
integer + 1;
933 children[0]->children[1]->clone() : children[0]->children[0]->clone());
934 fake_ast->
children[0]->delete_children();
936 if (id2ast->range_right != 0) {
938 fake_ast->
children[1]->is_signed =
true;
940 if (id2ast->range_swapped) {
942 fake_ast->
children[1]->is_signed =
true;
945 fake_ast->
children[1]->is_signed =
true;
947 delete left_at_zero_ast;
948 delete right_at_zero_ast;
952 chunk.
width = children[0]->range_left - children[0]->range_right + 1;
953 chunk.
offset = children[0]->range_right - source_offset;
954 if (id2ast->range_swapped)
955 chunk.
offset = (id2ast->range_left - id2ast->range_right + 1) - (chunk.
offset + chunk.
width);
957 if (chunk.
width == 1)
958 log_warning(
"Range select out of bounds on signal `%s' at %s:%d: Setting result bit to undef.\n",
959 str.c_str(), filename.c_str(), linenum);
961 log_warning(
"Range select out of bounds on signal `%s' at %s:%d: Setting all %d result bits to undef.\n",
962 str.c_str(), filename.c_str(), linenum, chunk.
width);
966 add_undef_bits_msb = (chunk.
width + chunk.
offset) - source_width;
967 chunk.
width -= add_undef_bits_msb;
970 add_undef_bits_lsb = -chunk.
offset;
971 chunk.
width -= add_undef_bits_lsb;
972 chunk.
offset += add_undef_bits_lsb;
974 if (add_undef_bits_lsb)
975 log_warning(
"Range select out of bounds on signal `%s' at %s:%d: Setting %d LSB bits to undef.\n",
976 str.c_str(), filename.c_str(), linenum, add_undef_bits_lsb);
977 if (add_undef_bits_msb)
978 log_warning(
"Range select out of bounds on signal `%s' at %s:%d: Setting %d MSB bits to undef.\n",
979 str.c_str(), filename.c_str(), linenum, add_undef_bits_msb);
989 is_signed = children.size() > 0 ?
false : id2ast->is_signed && sign_hint;
997 if (sig.
size() < width_hint)
999 is_signed = sign_hint;
1006 for (
auto it = children.begin(); it != children.end(); it++)
1007 sig.
append((*it)->genRTLIL());
1008 if (sig.
size() < width_hint)
1018 log_error(
"Left operand of replicate expression is not constant at %s:%d!\n", filename.c_str(), linenum);
1019 int count = left.
as_int();
1021 for (
int i = 0; i < count; i++)
1023 if (sig.
size() < width_hint)
1031 if (0) {
case AST_POS: type_name =
"$pos"; }
1032 if (0) {
case AST_NEG: type_name =
"$neg"; }
1034 RTLIL::SigSpec arg = children[0]->genRTLIL(width_hint, sign_hint);
1035 is_signed = children[0]->is_signed;
1036 int width = arg.
size();
1037 if (width_hint > 0) {
1046 if (0) {
case AST_BIT_OR: type_name =
"$or"; }
1051 detectSignWidth(width_hint, sign_hint);
1052 RTLIL::SigSpec left = children[0]->genRTLIL(width_hint, sign_hint);
1053 RTLIL::SigSpec right = children[1]->genRTLIL(width_hint, sign_hint);
1054 int width = std::max(left.
size(), right.
size());
1057 is_signed = children[0]->is_signed && children[1]->is_signed;
1058 return binop2rtlil(
this, type_name, width, left, right);
1088 detectSignWidth(width_hint, sign_hint);
1089 RTLIL::SigSpec left = children[0]->genRTLIL(width_hint, sign_hint);
1091 int width = width_hint > 0 ? width_hint : left.
size();
1092 is_signed = children[0]->is_signed;
1093 return binop2rtlil(
this, type_name, width, left, right);
1101 children[1]->detectSignWidth(right_width, right_signed);
1103 detectSignWidth(width_hint, sign_hint);
1104 RTLIL::SigSpec left = children[0]->genRTLIL(width_hint, sign_hint);
1105 RTLIL::SigSpec right = children[1]->genRTLIL(right_width, right_signed);
1106 int width = width_hint > 0 ? width_hint : left.
size();
1107 is_signed = children[0]->is_signed;
1110 return binop2rtlil(
this,
"$pow", width, left, right);
1114 if (0) {
case AST_LT: type_name =
"$lt"; }
1115 if (0) {
case AST_LE: type_name =
"$le"; }
1116 if (0) {
case AST_EQ: type_name =
"$eq"; }
1117 if (0) {
case AST_NE: type_name =
"$ne"; }
1118 if (0) {
case AST_EQX: type_name =
"$eqx"; }
1119 if (0) {
case AST_NEX: type_name =
"$nex"; }
1120 if (0) {
case AST_GE: type_name =
"$ge"; }
1121 if (0) {
case AST_GT: type_name =
"$gt"; }
1123 int width = std::max(width_hint, 1);
1124 width_hint = -1, sign_hint =
true;
1125 children[0]->detectSignWidthWorker(width_hint, sign_hint);
1126 children[1]->detectSignWidthWorker(width_hint, sign_hint);
1127 RTLIL::SigSpec left = children[0]->genRTLIL(width_hint, sign_hint);
1128 RTLIL::SigSpec right = children[1]->genRTLIL(width_hint, sign_hint);
1134 if (0) {
case AST_ADD: type_name =
"$add"; }
1135 if (0) {
case AST_SUB: type_name =
"$sub"; }
1136 if (0) {
case AST_MUL: type_name =
"$mul"; }
1137 if (0) {
case AST_DIV: type_name =
"$div"; }
1138 if (0) {
case AST_MOD: type_name =
"$mod"; }
1141 detectSignWidth(width_hint, sign_hint);
1142 RTLIL::SigSpec left = children[0]->genRTLIL(width_hint, sign_hint);
1143 RTLIL::SigSpec right = children[1]->genRTLIL(width_hint, sign_hint);
1145 int width = std::max(left.
size(), right.
size());
1146 if (width > width_hint && width_hint > 0)
1148 if (width < width_hint) {
1151 if (type ==
AST_SUB && (!children[0]->is_signed || !children[1]->is_signed))
1154 width = std::min(left.
size() + right.
size(), width_hint);
1157 int width = std::max(std::max(left.
size(), right.
size()), width_hint);
1159 is_signed = children[0]->is_signed && children[1]->is_signed;
1160 return binop2rtlil(
this, type_name, width, left, right);
1169 return binop2rtlil(
this, type_name, std::max(width_hint, 1), left, right);
1176 return uniop2rtlil(
this,
"$logic_not", std::max(width_hint, 1), arg);
1183 detectSignWidth(width_hint, sign_hint);
1186 RTLIL::SigSpec val1 = children[1]->genRTLIL(width_hint, sign_hint);
1187 RTLIL::SigSpec val2 = children[2]->genRTLIL(width_hint, sign_hint);
1189 if (cond.
size() > 1)
1190 cond =
uniop2rtlil(
this,
"$reduce_bool", 1, cond,
false);
1192 int width = std::max(val1.
size(), val2.
size());
1193 is_signed = children[1]->is_signed && children[2]->is_signed;
1199 if (sig.
size() < width_hint)
1207 std::stringstream sstr;
1208 sstr <<
"$memrd$" << str <<
"$" << filename <<
":" << linenum <<
"$" << (
autoidx++);
1211 cell->attributes[
"\\src"] =
stringf(
"%s:%d", filename.c_str(), linenum);
1214 wire->attributes[
"\\src"] =
stringf(
"%s:%d", filename.c_str(), linenum);
1221 cell->setPort(
"\\ADDR", children[0]->genWidthRTLIL(addr_bits));
1226 cell->parameters[
"\\WIDTH"] =
RTLIL::Const(wire->width);
1238 std::stringstream sstr;
1239 sstr <<
"$memwr$" << str <<
"$" << filename <<
":" << linenum <<
"$" << (
autoidx++);
1242 cell->attributes[
"\\src"] =
stringf(
"%s:%d", filename.c_str(), linenum);
1249 cell->setPort(
"\\ADDR", children[0]->genWidthRTLIL(addr_bits));
1251 cell->setPort(
"\\EN", children[2]->genRTLIL());
1275 std::stringstream sstr;
1276 sstr <<
"$assert$" << filename <<
":" << linenum <<
"$" << (
autoidx++);
1279 cell->attributes[
"\\src"] =
stringf(
"%s:%d", filename.c_str(), linenum);
1281 for (
auto &attr : attributes) {
1283 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
1284 attr.first.c_str(), filename.c_str(), linenum);
1285 cell->attributes[attr.first] = attr.second->asAttrConst();
1288 cell->setPort(
"\\A", check);
1289 cell->setPort(
"\\EN", en);
1314 log_error(
"Re-definition of cell `%s' at %s:%d!\n",
1315 str.c_str(), filename.c_str(), linenum);
1318 cell->attributes[
"\\src"] =
stringf(
"%s:%d", filename.c_str(), linenum);
1320 for (
auto it = children.begin(); it != children.end(); it++) {
1330 log_error(
"Parameter `%s' with non-constant value at %s:%d!\n",
1331 child->
str.c_str(), filename.c_str(), linenum);
1332 if (child->
str.size() == 0) {
1334 snprintf(buf, 100,
"$%d", ++para_counter);
1344 sig = child->
children[0]->genRTLIL();
1345 if (child->
str.size() == 0) {
1347 snprintf(buf, 100,
"$%d", ++port_counter);
1356 for (
auto &attr : attributes) {
1358 log_error(
"Attribute `%s' with non-constant value at %s:%d!\n",
1359 attr.first.c_str(), filename.c_str(), linenum);
1360 cell->attributes[attr.first] = attr.second->asAttrConst();
1367 AstNode *always = this->clone();
1374 AstNode *always = this->clone();
1384 log_error(
"Don't know how to generate RTLIL code for %s node at %s:%d!\n",
1385 type_name.c_str(), filename.c_str(), linenum);
1401 bool sign_hint =
true;
1402 int width_hint = width;
1403 detectSignWidthWorker(width_hint, sign_hint);
std::map< std::string, AstNode * > current_scope
const char * c_str() const
RTLIL::SigSpec genWidthRTLIL(int width, const std::map< RTLIL::SigBit, RTLIL::SigBit > *new_subst_ptr=NULL)
stackmap< RTLIL::SigBit, RTLIL::SigBit > subst_lvalue_map
std::string stringf(const char *fmt,...)
RTLIL::SigSpec outputSignals
void log_warning(const char *format,...)
RTLIL::Cell * addCell(RTLIL::IdString name, RTLIL::IdString type)
void addChunkActions(std::vector< RTLIL::SigSig > &actions, RTLIL::SigSpec lvalue, RTLIL::SigSpec rvalue, bool inSyncRule=false)
#define YOSYS_NAMESPACE_END
void dumpAst(FILE *f, std::string indent)
std::map< RTLIL::IdString, RTLIL::Wire * > wires_
std::set< RTLIL::SigBit > to_sigbit_set() const
RTLIL_ATTRIBUTE_MEMBERS std::vector< RTLIL::CaseRule * > cases
const char * log_signal(const RTLIL::SigSpec &sig, bool autoint)
RTLIL::SigSpec genRTLIL(int width_hint=-1, bool sign_hint=false)
void setPort(RTLIL::IdString portname, RTLIL::SigSpec signal)
RTLIL::SigSpec Sub(RTLIL::IdString name, RTLIL::SigSpec sig_a, RTLIL::SigSpec sig_b, bool is_signed=false)
std::map< RTLIL::IdString, RTLIL::Memory * > memories
void(* set_line_num)(int)
std::map< RTLIL::IdString, AstNode * > attributes
static void widthExtend(AstNode *that, RTLIL::SigSpec &sig, int width, bool is_signed)
void log_error(const char *format,...)
std::set< RTLIL::IdString > avail_parameters
std::map< RTLIL::IdString, RTLIL::Const > parameters
void extend_u0(int width, bool is_signed=false)
std::map< RTLIL::Wire *, int > new_temp_count
std::vector< RTLIL::SigSpec > compare
void remove_unwanted_lvalue_bits(RTLIL::SigSpec &lhs, RTLIL::SigSpec &rhs)
bool get_bool_attribute(RTLIL::IdString id)
std::string type2str(AstNodeType type)
static RTLIL::SigSpec binop2rtlil(AstNode *that, std::string type, int result_width, const RTLIL::SigSpec &left, const RTLIL::SigSpec &right)
static RTLIL::SigSpec mux2rtlil(AstNode *that, const RTLIL::SigSpec &cond, const RTLIL::SigSpec &left, const RTLIL::SigSpec &right)
void collect_lvalues(RTLIL::SigSpec ®, AstNode *ast, bool type_eq, bool type_le, bool run_sort_and_unify=true)
RTLIL::CaseRule * current_case
RTLIL::SigSpec ignoreThisSignalsInInitial
void connect(const RTLIL::SigSig &conn)
YOSYS_NAMESPACE_BEGIN std::vector< FILE * > log_files
static RTLIL::SigSpec uniop2rtlil(AstNode *that, std::string type, int result_width, const RTLIL::SigSpec &arg, bool gen_attributes=true)
int GetSize(RTLIL::Wire *wire)
const BigUnsigned & check(const BigUnsigned &x)
#define log_assert(_assert_expr_)
bool is_fully_const() const
RTLIL::Wire * addWire(RTLIL::IdString name, int width=1)
void detectSignWidth(int &width_hint, bool &sign_hint, bool *found_real=NULL)
void processAst(AstNode *ast)
void remove2(const RTLIL::SigSpec &pattern, RTLIL::SigSpec *other)
std::vector< RTLIL::SigSig > actions
void detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *found_real=NULL)
RTLIL::SigSpec new_temp_signal(RTLIL::SigSpec sig)
std::map< RTLIL::IdString, RTLIL::Process * > processes
std::string substr(size_t pos=0, size_t len=std::string::npos) const
virtual size_t count_id(RTLIL::IdString id)
void replace(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec &with)
stackmap< RTLIL::SigBit, RTLIL::SigBit > subst_rvalue_map
std::string current_filename
#define YOSYS_NAMESPACE_BEGIN
bool simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage, int width_hint, bool sign_hint, bool in_param)
int as_int(bool is_signed=false) const
RTLIL::SigSpec init_rvalue
void log(const char *format,...)
RTLIL::SigSpec extract(const RTLIL::SigSpec &pattern, const RTLIL::SigSpec *other=NULL) const
void append(const RTLIL::SigSpec &signal)
void extend(int width, bool is_signed=false)
std::vector< AstNode * > children
void removeSignalFromCaseTree(const std::set< RTLIL::SigBit > &pattern, RTLIL::CaseRule *cs)
std::vector< RTLIL::SigSig > actions
ProcessGenerator(AstNode *always, RTLIL::SigSpec initSyncSignalsArg=RTLIL::SigSpec())
const std::map< RTLIL::SigBit, RTLIL::SigBit > * genRTLIL_subst_ptr
AstModule * current_module
std::map< RTLIL::SigBit, RTLIL::SigBit > to_sigbit_map(const RTLIL::SigSpec &other) const
std::vector< RTLIL::SwitchRule * > switches
std::pair< SigSpec, SigSpec > SigSig
YOSYS_NAMESPACE_BEGIN int autoidx
const std::vector< RTLIL::SigChunk > & chunks() const
RTLIL::SigSpec initSyncSignals