Convert more log_error() to log_file_error() where possible.

Mostly statements that span over multiple lines and haven't been
caught with the previous conversion.
This commit is contained in:
Henner Zeller 2018-07-20 09:37:44 -07:00
parent 1de07eeee2
commit 68b5d0c3b1
4 changed files with 131 additions and 137 deletions

View File

@ -171,8 +171,8 @@ bool AstNode::get_bool_attribute(RTLIL::IdString id)
AstNode *attr = attributes.at(id); AstNode *attr = attributes.at(id);
if (attr->type != AST_CONSTANT) if (attr->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(attr->filename, attr->linenum, "Attribute `%s' with non-constant value!\n",
id.c_str(), attr->filename.c_str(), attr->linenum); id.c_str());
return attr->integer != 0; return attr->integer != 0;
} }
@ -955,8 +955,8 @@ static AstModule* process_module(AstNode *ast, bool defer)
for (auto &attr : ast->attributes) { for (auto &attr : ast->attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(ast->filename, ast->linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), ast->filename.c_str(), ast->linenum); attr.first.c_str());
current_module->attributes[attr.first] = attr.second->asAttrConst(); current_module->attributes[attr.first] = attr.second->asAttrConst();
} }
for (size_t i = 0; i < ast->children.size(); i++) { for (size_t i = 0; i < ast->children.size(); i++) {
@ -1044,8 +1044,8 @@ void AST::process(RTLIL::Design *design, AstNode *ast, bool dump_ast1, bool dump
if (design->has((*it)->str)) { if (design->has((*it)->str)) {
RTLIL::Module *existing_mod = design->module((*it)->str); RTLIL::Module *existing_mod = design->module((*it)->str);
if (!nooverwrite && !overwrite && !existing_mod->get_bool_attribute("\\blackbox")) { if (!nooverwrite && !overwrite && !existing_mod->get_bool_attribute("\\blackbox")) {
log_error("Re-definition of module `%s' at %s:%d!\n", log_file_error((*it)->filename, (*it)->linenum, "Re-definition of module `%s'!\n",
(*it)->str.c_str(), (*it)->filename.c_str(), (*it)->linenum); (*it)->str.c_str());
} else if (nooverwrite) { } else if (nooverwrite) {
log("Ignoring re-definition of module `%s' at %s:%d.\n", log("Ignoring re-definition of module `%s' at %s:%d.\n",
(*it)->str.c_str(), (*it)->filename.c_str(), (*it)->linenum); (*it)->str.c_str(), (*it)->filename.c_str(), (*it)->linenum);
@ -1197,4 +1197,3 @@ void AST::use_internal_line_num()
} }
YOSYS_NAMESPACE_END YOSYS_NAMESPACE_END

View File

@ -55,8 +55,8 @@ static RTLIL::SigSpec uniop2rtlil(AstNode *that, std::string type, int result_wi
if (gen_attributes) if (gen_attributes)
for (auto &attr : that->attributes) { for (auto &attr : that->attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(that->filename, that->linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), that->filename.c_str(), that->linenum); attr.first.c_str());
cell->attributes[attr.first] = attr.second->asAttrConst(); cell->attributes[attr.first] = attr.second->asAttrConst();
} }
@ -89,8 +89,8 @@ static void widthExtend(AstNode *that, RTLIL::SigSpec &sig, int width, bool is_s
if (that != NULL) if (that != NULL)
for (auto &attr : that->attributes) { for (auto &attr : that->attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(that->filename, that->linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), that->filename.c_str(), that->linenum); attr.first.c_str());
cell->attributes[attr.first] = attr.second->asAttrConst(); cell->attributes[attr.first] = attr.second->asAttrConst();
} }
@ -117,8 +117,8 @@ static RTLIL::SigSpec binop2rtlil(AstNode *that, std::string type, int result_wi
for (auto &attr : that->attributes) { for (auto &attr : that->attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(that->filename, that->linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), that->filename.c_str(), that->linenum); attr.first.c_str());
cell->attributes[attr.first] = attr.second->asAttrConst(); cell->attributes[attr.first] = attr.second->asAttrConst();
} }
@ -152,8 +152,8 @@ static RTLIL::SigSpec mux2rtlil(AstNode *that, const RTLIL::SigSpec &cond, const
for (auto &attr : that->attributes) { for (auto &attr : that->attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(that->filename, that->linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), that->filename.c_str(), that->linenum); attr.first.c_str());
cell->attributes[attr.first] = attr.second->asAttrConst(); cell->attributes[attr.first] = attr.second->asAttrConst();
} }
@ -207,8 +207,8 @@ struct AST_INTERNAL::ProcessGenerator
proc->name = stringf("$proc$%s:%d$%d", always->filename.c_str(), always->linenum, autoidx++); proc->name = stringf("$proc$%s:%d$%d", always->filename.c_str(), always->linenum, autoidx++);
for (auto &attr : always->attributes) { for (auto &attr : always->attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(always->filename, always->linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), always->filename.c_str(), always->linenum); attr.first.c_str());
proc->attributes[attr.first] = attr.second->asAttrConst(); proc->attributes[attr.first] = attr.second->asAttrConst();
} }
current_module->processes[proc->name] = proc; current_module->processes[proc->name] = proc;
@ -480,8 +480,8 @@ struct AST_INTERNAL::ProcessGenerator
for (auto &attr : ast->attributes) { for (auto &attr : ast->attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(ast->filename, ast->linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), ast->filename.c_str(), ast->linenum); attr.first.c_str());
sw->attributes[attr.first] = attr.second->asAttrConst(); sw->attributes[attr.first] = attr.second->asAttrConst();
} }
@ -648,8 +648,8 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
while (left_at_zero_ast->simplify(true, true, false, 1, -1, false, false)) { } while (left_at_zero_ast->simplify(true, true, false, 1, -1, false, false)) { }
while (right_at_zero_ast->simplify(true, true, false, 1, -1, false, false)) { } while (right_at_zero_ast->simplify(true, true, false, 1, -1, false, false)) { }
if (left_at_zero_ast->type != AST_CONSTANT || right_at_zero_ast->type != AST_CONSTANT) if (left_at_zero_ast->type != AST_CONSTANT || right_at_zero_ast->type != AST_CONSTANT)
log_error("Unsupported expression on dynamic range select on signal `%s' at %s:%d!\n", log_file_error(filename, linenum, "Unsupported expression on dynamic range select on signal `%s'!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
this_width = left_at_zero_ast->integer - right_at_zero_ast->integer + 1; this_width = left_at_zero_ast->integer - right_at_zero_ast->integer + 1;
delete left_at_zero_ast; delete left_at_zero_ast;
delete right_at_zero_ast; delete right_at_zero_ast;
@ -777,8 +777,8 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
if (GetSize(children) == 1) { if (GetSize(children) == 1) {
while (children[0]->simplify(true, false, false, 1, -1, false, true) == true) { } while (children[0]->simplify(true, false, false, 1, -1, false, true) == true) { }
if (children[0]->type != AST_CONSTANT) if (children[0]->type != AST_CONSTANT)
log_error("System function %s called with non-const argument at %s:%d!\n", log_file_error(filename, linenum, "System function %s called with non-const argument!\n",
RTLIL::unescape_id(str).c_str(), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str());
width_hint = max(width_hint, int(children[0]->asInt(true))); width_hint = max(width_hint, int(children[0]->asInt(true)));
} }
break; break;
@ -799,8 +799,8 @@ void AstNode::detectSignWidthWorker(int &width_hint, bool &sign_hint, bool *foun
default: default:
for (auto f : log_files) for (auto f : log_files)
current_ast->dumpAst(f, "verilog-ast> "); current_ast->dumpAst(f, "verilog-ast> ");
log_error("Don't know how to detect sign and width for %s node at %s:%d!\n", log_file_error(filename, linenum, "Don't know how to detect sign and width for %s node!\n",
type2str(type).c_str(), filename.c_str(), linenum); type2str(type).c_str());
} }
if (*found_real) if (*found_real)
@ -863,11 +863,11 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
// create an RTLIL::Wire for an AST_WIRE node // create an RTLIL::Wire for an AST_WIRE node
case AST_WIRE: { case AST_WIRE: {
if (current_module->wires_.count(str) != 0) if (current_module->wires_.count(str) != 0)
log_error("Re-definition of signal `%s' at %s:%d!\n", log_file_error(filename, linenum, "Re-definition of signal `%s'!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
if (!range_valid) if (!range_valid)
log_error("Signal `%s' with non-constant width at %s:%d!\n", log_file_error(filename, linenum, "Signal `%s' with non-constant width!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
log_assert(range_left >= range_right || (range_left == -1 && range_right == 0)); log_assert(range_left >= range_right || (range_left == -1 && range_right == 0));
@ -881,8 +881,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
for (auto &attr : attributes) { for (auto &attr : attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(filename, linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), filename.c_str(), linenum); attr.first.c_str());
wire->attributes[attr.first] = attr.second->asAttrConst(); wire->attributes[attr.first] = attr.second->asAttrConst();
} }
} }
@ -891,16 +891,16 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
// create an RTLIL::Memory for an AST_MEMORY node // create an RTLIL::Memory for an AST_MEMORY node
case AST_MEMORY: { case AST_MEMORY: {
if (current_module->memories.count(str) != 0) if (current_module->memories.count(str) != 0)
log_error("Re-definition of memory `%s' at %s:%d!\n", log_file_error(filename, linenum, "Re-definition of memory `%s'!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
log_assert(children.size() >= 2); log_assert(children.size() >= 2);
log_assert(children[0]->type == AST_RANGE); log_assert(children[0]->type == AST_RANGE);
log_assert(children[1]->type == AST_RANGE); log_assert(children[1]->type == AST_RANGE);
if (!children[0]->range_valid || !children[1]->range_valid) if (!children[0]->range_valid || !children[1]->range_valid)
log_error("Memory `%s' with non-constant width or size at %s:%d!\n", log_file_error(filename, linenum, "Memory `%s' with non-constant width or size!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
RTLIL::Memory *memory = new RTLIL::Memory; RTLIL::Memory *memory = new RTLIL::Memory;
memory->attributes["\\src"] = stringf("%s:%d", filename.c_str(), linenum); memory->attributes["\\src"] = stringf("%s:%d", filename.c_str(), linenum);
@ -917,8 +917,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
for (auto &attr : attributes) { for (auto &attr : attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(filename, linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), filename.c_str(), linenum); attr.first.c_str());
memory->attributes[attr.first] = attr.second->asAttrConst(); memory->attributes[attr.first] = attr.second->asAttrConst();
} }
} }
@ -937,8 +937,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
case AST_REALVALUE: case AST_REALVALUE:
{ {
RTLIL::SigSpec sig = realAsConst(width_hint); RTLIL::SigSpec sig = realAsConst(width_hint);
log_warning("converting real value %e to binary %s at %s:%d.\n", log_file_warning(filename, linenum, "converting real value %e to binary %s.\n",
realvalue, log_signal(sig), filename.c_str(), linenum); realvalue, log_signal(sig));
return sig; return sig;
} }
@ -964,19 +964,19 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
} }
else if (id2ast->type == AST_PARAMETER || id2ast->type == AST_LOCALPARAM) { else if (id2ast->type == AST_PARAMETER || id2ast->type == AST_LOCALPARAM) {
if (id2ast->children[0]->type != AST_CONSTANT) if (id2ast->children[0]->type != AST_CONSTANT)
log_error("Parameter %s does not evaluate to constant value at %s:%d!\n", log_file_error(filename, linenum, "Parameter %s does not evaluate to constant value!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
chunk = RTLIL::Const(id2ast->children[0]->bits); chunk = RTLIL::Const(id2ast->children[0]->bits);
goto use_const_chunk; goto use_const_chunk;
} }
else if (!id2ast || (id2ast->type != AST_WIRE && id2ast->type != AST_AUTOWIRE && else if (!id2ast || (id2ast->type != AST_WIRE && id2ast->type != AST_AUTOWIRE &&
id2ast->type != AST_MEMORY) || current_module->wires_.count(str) == 0) id2ast->type != AST_MEMORY) || current_module->wires_.count(str) == 0)
log_error("Identifier `%s' doesn't map to any signal at %s:%d!\n", log_file_error(filename, linenum, "Identifier `%s' doesn't map to any signal!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
if (id2ast->type == AST_MEMORY) if (id2ast->type == AST_MEMORY)
log_error("Identifier `%s' does map to an unexpanded memory at %s:%d!\n", log_file_error(filename, linenum, "Identifier `%s' does map to an unexpanded memory!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
wire = current_module->wires_[str]; wire = current_module->wires_[str];
chunk.wire = wire; chunk.wire = wire;
@ -994,8 +994,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
while (left_at_zero_ast->simplify(true, true, false, 1, -1, false, false)) { } while (left_at_zero_ast->simplify(true, true, false, 1, -1, false, false)) { }
while (right_at_zero_ast->simplify(true, true, false, 1, -1, false, false)) { } while (right_at_zero_ast->simplify(true, true, false, 1, -1, false, false)) { }
if (left_at_zero_ast->type != AST_CONSTANT || right_at_zero_ast->type != AST_CONSTANT) if (left_at_zero_ast->type != AST_CONSTANT || right_at_zero_ast->type != AST_CONSTANT)
log_error("Unsupported expression on dynamic range select on signal `%s' at %s:%d!\n", log_file_error(filename, linenum, "Unsupported expression on dynamic range select on signal `%s'!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
int width = left_at_zero_ast->integer - right_at_zero_ast->integer + 1; int width = left_at_zero_ast->integer - right_at_zero_ast->integer + 1;
AstNode *fake_ast = new AstNode(AST_NONE, clone(), children[0]->children.size() >= 2 ? AstNode *fake_ast = new AstNode(AST_NONE, clone(), children[0]->children.size() >= 2 ?
children[0]->children[1]->clone() : children[0]->children[0]->clone()); children[0]->children[1]->clone() : children[0]->children[0]->clone());
@ -1023,11 +1023,11 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
chunk.offset = (id2ast->range_left - id2ast->range_right + 1) - (chunk.offset + chunk.width); chunk.offset = (id2ast->range_left - id2ast->range_right + 1) - (chunk.offset + chunk.width);
if (chunk.offset >= source_width || chunk.offset + chunk.width < 0) { if (chunk.offset >= source_width || chunk.offset + chunk.width < 0) {
if (chunk.width == 1) if (chunk.width == 1)
log_warning("Range select out of bounds on signal `%s' at %s:%d: Setting result bit to undef.\n", log_file_warning(filename, linenum, "Range select out of bounds on signal `%s': Setting result bit to undef.\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
else else
log_warning("Range select out of bounds on signal `%s' at %s:%d: Setting all %d result bits to undef.\n", log_file_warning(filename, linenum, "Range select out of bounds on signal `%s': Setting all %d result bits to undef.\n",
str.c_str(), filename.c_str(), linenum, chunk.width); str.c_str(), chunk.width);
chunk = RTLIL::SigChunk(RTLIL::State::Sx, chunk.width); chunk = RTLIL::SigChunk(RTLIL::State::Sx, chunk.width);
} else { } else {
if (chunk.width + chunk.offset > source_width) { if (chunk.width + chunk.offset > source_width) {
@ -1040,11 +1040,11 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
chunk.offset += add_undef_bits_lsb; chunk.offset += add_undef_bits_lsb;
} }
if (add_undef_bits_lsb) if (add_undef_bits_lsb)
log_warning("Range select out of bounds on signal `%s' at %s:%d: Setting %d LSB bits to undef.\n", log_file_warning(filename, linenum, "Range select out of bounds on signal `%s': Setting %d LSB bits to undef.\n",
str.c_str(), filename.c_str(), linenum, add_undef_bits_lsb); str.c_str(), add_undef_bits_lsb);
if (add_undef_bits_msb) if (add_undef_bits_msb)
log_warning("Range select out of bounds on signal `%s' at %s:%d: Setting %d MSB bits to undef.\n", log_file_warning(filename, linenum, "Range select out of bounds on signal `%s': Setting %d MSB bits to undef.\n",
str.c_str(), filename.c_str(), linenum, add_undef_bits_msb); str.c_str(), add_undef_bits_msb);
} }
} }
} }
@ -1379,8 +1379,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
for (auto &attr : attributes) { for (auto &attr : attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(filename, linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), filename.c_str(), linenum); attr.first.c_str());
cell->attributes[attr.first] = attr.second->asAttrConst(); cell->attributes[attr.first] = attr.second->asAttrConst();
} }
@ -1401,10 +1401,10 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
new_left.append(left[i]); new_left.append(left[i]);
new_right.append(right[i]); new_right.append(right[i]);
} }
log_warning("Ignoring assignment to constant bits at %s:%d:\n" log_file_warning(filename, linenum, "Ignoring assignment to constant bits:\n"
" old assignment: %s = %s\n new assignment: %s = %s.\n", " old assignment: %s = %s\n new assignment: %s = %s.\n",
filename.c_str(), linenum, log_signal(left), log_signal(right), log_signal(left), log_signal(right),
log_signal(new_left), log_signal(new_right)); log_signal(new_left), log_signal(new_right));
left = new_left; left = new_left;
right = new_right; right = new_right;
} }
@ -1418,8 +1418,7 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
int port_counter = 0, para_counter = 0; int port_counter = 0, para_counter = 0;
if (current_module->count_id(str) != 0) if (current_module->count_id(str) != 0)
log_error("Re-definition of cell `%s' at %s:%d!\n", log_file_error(filename, linenum, "Re-definition of cell `%s'!\n", str.c_str());
str.c_str(), filename.c_str(), linenum);
RTLIL::Cell *cell = current_module->addCell(str, ""); RTLIL::Cell *cell = current_module->addCell(str, "");
cell->attributes["\\src"] = stringf("%s:%d", filename.c_str(), linenum); cell->attributes["\\src"] = stringf("%s:%d", filename.c_str(), linenum);
@ -1435,16 +1434,15 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
if (child->type == AST_PARASET) { if (child->type == AST_PARASET) {
IdString paraname = child->str.empty() ? stringf("$%d", ++para_counter) : child->str; IdString paraname = child->str.empty() ? stringf("$%d", ++para_counter) : child->str;
if (child->children[0]->type == AST_REALVALUE) { if (child->children[0]->type == AST_REALVALUE) {
log_warning("Replacing floating point parameter %s.%s = %f with string at %s:%d.\n", log_file_warning(filename, linenum, "Replacing floating point parameter %s.%s = %f with string.\n",
log_id(cell), log_id(paraname), child->children[0]->realvalue, log_id(cell), log_id(paraname), child->children[0]->realvalue);
filename.c_str(), linenum);
auto strnode = AstNode::mkconst_str(stringf("%f", child->children[0]->realvalue)); auto strnode = AstNode::mkconst_str(stringf("%f", child->children[0]->realvalue));
strnode->cloneInto(child->children[0]); strnode->cloneInto(child->children[0]);
delete strnode; delete strnode;
} }
if (child->children[0]->type != AST_CONSTANT) if (child->children[0]->type != AST_CONSTANT)
log_error("Parameter %s.%s with non-constant value at %s:%d!\n", log_file_error(filename, linenum, "Parameter %s.%s with non-constant value!\n",
log_id(cell), log_id(paraname), filename.c_str(), linenum); log_id(cell), log_id(paraname));
cell->parameters[paraname] = child->children[0]->asParaConst(); cell->parameters[paraname] = child->children[0]->asParaConst();
continue; continue;
} }
@ -1465,8 +1463,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
} }
for (auto &attr : attributes) { for (auto &attr : attributes) {
if (attr.second->type != AST_CONSTANT) if (attr.second->type != AST_CONSTANT)
log_error("Attribute `%s' with non-constant value at %s:%d!\n", log_file_error(filename, linenum, "Attribute `%s' with non-constant value!\n",
attr.first.c_str(), filename.c_str(), linenum); attr.first.c_str());
cell->attributes[attr.first] = attr.second->asAttrConst(); cell->attributes[attr.first] = attr.second->asAttrConst();
} }
} }
@ -1493,19 +1491,19 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
int width = width_hint; int width = width_hint;
if (GetSize(children) > 1) if (GetSize(children) > 1)
log_error("System function %s got %d arguments, expected 1 or 0 at %s:%d.\n", log_file_error(filename, linenum, "System function %s got %d arguments, expected 1 or 0.\n",
RTLIL::unescape_id(str).c_str(), GetSize(children), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str(), GetSize(children));
if (GetSize(children) == 1) { if (GetSize(children) == 1) {
if (children[0]->type != AST_CONSTANT) if (children[0]->type != AST_CONSTANT)
log_error("System function %s called with non-const argument at %s:%d!\n", log_file_error(filename, linenum, "System function %s called with non-const argument!\n",
RTLIL::unescape_id(str).c_str(), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str());
width = children[0]->asInt(true); width = children[0]->asInt(true);
} }
if (width <= 0) if (width <= 0)
log_error("Failed to detect width of %s at %s:%d!\n", log_file_error(filename, linenum, "Failed to detect width of %s!\n",
RTLIL::unescape_id(str).c_str(), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str());
Cell *cell = current_module->addCell(myid, str.substr(1)); Cell *cell = current_module->addCell(myid, str.substr(1));
cell->attributes["\\src"] = stringf("%s:%d", filename.c_str(), linenum); cell->attributes["\\src"] = stringf("%s:%d", filename.c_str(), linenum);
@ -1532,8 +1530,8 @@ RTLIL::SigSpec AstNode::genRTLIL(int width_hint, bool sign_hint)
for (auto f : log_files) for (auto f : log_files)
current_ast->dumpAst(f, "verilog-ast> "); current_ast->dumpAst(f, "verilog-ast> ");
type_name = type2str(type); type_name = type2str(type);
log_error("Don't know how to generate RTLIL code for %s node at %s:%d!\n", log_file_error(filename, linenum, "Don't know how to generate RTLIL code for %s node!\n",
type_name.c_str(), filename.c_str(), linenum); type_name.c_str());
} }
return RTLIL::SigSpec(); return RTLIL::SigSpec();

View File

@ -195,8 +195,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
{ {
int nargs = GetSize(children); int nargs = GetSize(children);
if (nargs < 1) if (nargs < 1)
log_error("System task `%s' got %d arguments, expected >= 1 at %s:%d.\n", log_file_error(filename, linenum, "System task `%s' got %d arguments, expected >= 1.\n",
str.c_str(), int(children.size()), filename.c_str(), linenum); str.c_str(), int(children.size()));
// First argument is the format string // First argument is the format string
AstNode *node_string = children[0]; AstNode *node_string = children[0];
@ -239,8 +239,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
case 'x': case 'x':
case 'X': case 'X':
if (next_arg >= GetSize(children)) if (next_arg >= GetSize(children))
log_error("Missing argument for %%%c format specifier in system task `%s' at %s:%d.\n", log_file_error(filename, linenum, "Missing argument for %%%c format specifier in system task `%s'.\n",
cformat, str.c_str(), filename.c_str(), linenum); cformat, str.c_str());
node_arg = children[next_arg++]; node_arg = children[next_arg++];
while (node_arg->simplify(true, false, false, stage, width_hint, sign_hint, false)) { } while (node_arg->simplify(true, false, false, stage, width_hint, sign_hint, false)) { }
@ -717,8 +717,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
paramname = "\\" + paramname.substr(pos+1); paramname = "\\" + paramname.substr(pos+1);
if (current_scope.at(modname)->type != AST_CELL) if (current_scope.at(modname)->type != AST_CELL)
log_error("Defparam argument `%s . %s` does not match a cell at %s:%d!\n", log_file_error(filename, linenum, "Defparam argument `%s . %s` does not match a cell!\n",
RTLIL::unescape_id(modname).c_str(), RTLIL::unescape_id(paramname).c_str(), filename.c_str(), linenum); RTLIL::unescape_id(modname).c_str(), RTLIL::unescape_id(paramname).c_str());
AstNode *paraset = new AstNode(AST_PARASET, children[1]->clone(), GetSize(children) > 2 ? children[2]->clone() : NULL); AstNode *paraset = new AstNode(AST_PARASET, children[1]->clone(), GetSize(children) > 2 ? children[2]->clone() : NULL);
paraset->str = paramname; paraset->str = paramname;
@ -865,8 +865,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
int width = std::abs(children[1]->range_left - children[1]->range_right) + 1; int width = std::abs(children[1]->range_left - children[1]->range_right) + 1;
if (children[0]->type == AST_REALVALUE) { if (children[0]->type == AST_REALVALUE) {
RTLIL::Const constvalue = children[0]->realAsConst(width); RTLIL::Const constvalue = children[0]->realAsConst(width);
log_warning("converting real value %e to binary %s at %s:%d.\n", log_file_warning(filename, linenum, "converting real value %e to binary %s.\n",
children[0]->realvalue, log_signal(constvalue), filename.c_str(), linenum); children[0]->realvalue, log_signal(constvalue));
delete children[0]; delete children[0];
children[0] = mkconst_bits(constvalue.bits, sign_hint); children[0] = mkconst_bits(constvalue.bits, sign_hint);
did_something = true; did_something = true;
@ -1095,8 +1095,7 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
{ {
for (size_t i = 0; i < children.size(); i++) for (size_t i = 0; i < children.size(); i++)
if (children[i]->type == AST_WIRE || children[i]->type == AST_MEMORY || children[i]->type == AST_PARAMETER || children[i]->type == AST_LOCALPARAM) if (children[i]->type == AST_WIRE || children[i]->type == AST_MEMORY || children[i]->type == AST_PARAMETER || children[i]->type == AST_LOCALPARAM)
log_error("Local declaration in unnamed block at %s:%d is an unsupported SystemVerilog feature!\n", log_file_error(children[i]->filename, children[i]->linenum, "Local declaration in unnamed block is an unsupported SystemVerilog feature!\n");
children[i]->filename.c_str(), children[i]->linenum);
} }
// transform block with name // transform block with name
@ -1285,8 +1284,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
if (type == AST_PRIMITIVE) if (type == AST_PRIMITIVE)
{ {
if (children.size() < 2) if (children.size() < 2)
log_error("Insufficient number of arguments for primitive `%s' at %s:%d!\n", log_file_error(filename, linenum, "Insufficient number of arguments for primitive `%s'!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
std::vector<AstNode*> children_list; std::vector<AstNode*> children_list;
for (auto child : children) { for (auto child : children) {
@ -1301,8 +1300,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
if (str == "bufif0" || str == "bufif1" || str == "notif0" || str == "notif1") if (str == "bufif0" || str == "bufif1" || str == "notif0" || str == "notif1")
{ {
if (children_list.size() != 3) if (children_list.size() != 3)
log_error("Invalid number of arguments for primitive `%s' at %s:%d!\n", log_file_error(filename, linenum, "Invalid number of arguments for primitive `%s'!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
std::vector<RTLIL::State> z_const(1, RTLIL::State::Sz); std::vector<RTLIL::State> z_const(1, RTLIL::State::Sz);
@ -1387,8 +1386,8 @@ bool AstNode::simplify(bool const_fold, bool at_zero, bool in_lvalue, int stage,
while (left_at_zero_ast->simplify(true, true, false, stage, -1, false, false)) { } while (left_at_zero_ast->simplify(true, true, false, stage, -1, false, false)) { }
while (right_at_zero_ast->simplify(true, true, false, stage, -1, false, false)) { } while (right_at_zero_ast->simplify(true, true, false, stage, -1, false, false)) { }
if (left_at_zero_ast->type != AST_CONSTANT || right_at_zero_ast->type != AST_CONSTANT) if (left_at_zero_ast->type != AST_CONSTANT || right_at_zero_ast->type != AST_CONSTANT)
log_error("Unsupported expression on dynamic range select on signal `%s' at %s:%d!\n", log_file_error(filename, linenum, "Unsupported expression on dynamic range select on signal `%s'!\n",
str.c_str(), filename.c_str(), linenum); str.c_str());
result_width = abs(int(left_at_zero_ast->integer - right_at_zero_ast->integer)) + 1; result_width = abs(int(left_at_zero_ast->integer - right_at_zero_ast->integer)) + 1;
} }
did_something = true; did_something = true;
@ -1737,12 +1736,12 @@ skip_dynamic_range_lvalue_expansion:;
int num_steps = 1; int num_steps = 1;
if (GetSize(children) != 1 && GetSize(children) != 2) if (GetSize(children) != 1 && GetSize(children) != 2)
log_error("System function %s got %d arguments, expected 1 or 2 at %s:%d.\n", log_file_error(filename, linenum, "System function %s got %d arguments, expected 1 or 2.\n",
RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str(), int(children.size()));
if (!current_always_clocked) if (!current_always_clocked)
log_error("System function %s is only allowed in clocked blocks at %s:%d.\n", log_file_error(filename, linenum, "System function %s is only allowed in clocked blocks.\n",
RTLIL::unescape_id(str).c_str(), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str());
if (GetSize(children) == 2) if (GetSize(children) == 2)
{ {
@ -1805,12 +1804,12 @@ skip_dynamic_range_lvalue_expansion:;
if (str == "\\$stable" || str == "\\$rose" || str == "\\$fell") if (str == "\\$stable" || str == "\\$rose" || str == "\\$fell")
{ {
if (GetSize(children) != 1) if (GetSize(children) != 1)
log_error("System function %s got %d arguments, expected 1 at %s:%d.\n", log_file_error(filename, linenum, "System function %s got %d arguments, expected 1.\n",
RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str(), int(children.size()));
if (!current_always_clocked) if (!current_always_clocked)
log_error("System function %s is only allowed in clocked blocks at %s:%d.\n", log_file_error(filename, linenum, "System function %s is only allowed in clocked blocks.\n",
RTLIL::unescape_id(str).c_str(), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str());
AstNode *present = children.at(0)->clone(); AstNode *present = children.at(0)->clone();
AstNode *past = clone(); AstNode *past = clone();
@ -1840,8 +1839,8 @@ skip_dynamic_range_lvalue_expansion:;
if (str == "\\$clog2") if (str == "\\$clog2")
{ {
if (children.size() != 1) if (children.size() != 1)
log_error("System function %s got %d arguments, expected 1 at %s:%d.\n", log_file_error(filename, linenum, "System function %s got %d arguments, expected 1.\n",
RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str(), int(children.size()));
AstNode *buf = children[0]->clone(); AstNode *buf = children[0]->clone();
while (buf->simplify(true, false, false, stage, width_hint, sign_hint, false)) { } while (buf->simplify(true, false, false, stage, width_hint, sign_hint, false)) { }
@ -1865,12 +1864,12 @@ skip_dynamic_range_lvalue_expansion:;
if (str == "\\$size" || str == "\\$bits") if (str == "\\$size" || str == "\\$bits")
{ {
if (str == "\\$bits" && children.size() != 1) if (str == "\\$bits" && children.size() != 1)
log_error("System function %s got %d arguments, expected 1 at %s:%d.\n", log_file_error(filename, linenum, "System function %s got %d arguments, expected 1.\n",
RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str(), int(children.size()));
if (str == "\\$size" && children.size() != 1 && children.size() != 2) if (str == "\\$size" && children.size() != 1 && children.size() != 2)
log_error("System function %s got %d arguments, expected 1 or 2 at %s:%d.\n", log_file_error(filename, linenum, "System function %s got %d arguments, expected 1 or 2.\n",
RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str(), int(children.size()));
int dim = 1; int dim = 1;
if (str == "\\$size" && children.size() == 2) { if (str == "\\$size" && children.size() == 2) {
@ -1943,19 +1942,19 @@ skip_dynamic_range_lvalue_expansion:;
if (func_with_two_arguments) { if (func_with_two_arguments) {
if (children.size() != 2) if (children.size() != 2)
log_error("System function %s got %d arguments, expected 2 at %s:%d.\n", log_file_error(filename, linenum, "System function %s got %d arguments, expected 2.\n",
RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str(), int(children.size()));
} else { } else {
if (children.size() != 1) if (children.size() != 1)
log_error("System function %s got %d arguments, expected 1 at %s:%d.\n", log_file_error(filename, linenum, "System function %s got %d arguments, expected 1.\n",
RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str(), int(children.size()));
} }
if (children.size() >= 1) { if (children.size() >= 1) {
while (children[0]->simplify(true, false, false, stage, width_hint, sign_hint, false)) { } while (children[0]->simplify(true, false, false, stage, width_hint, sign_hint, false)) { }
if (!children[0]->isConst()) if (!children[0]->isConst())
log_error("Failed to evaluate system function `%s' with non-constant argument at %s:%d.\n", log_file_error(filename, linenum, "Failed to evaluate system function `%s' with non-constant argument.\n",
RTLIL::unescape_id(str).c_str(), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str());
int child_width_hint = width_hint; int child_width_hint = width_hint;
bool child_sign_hint = sign_hint; bool child_sign_hint = sign_hint;
children[0]->detectSignWidth(child_width_hint, child_sign_hint); children[0]->detectSignWidth(child_width_hint, child_sign_hint);
@ -1965,8 +1964,8 @@ skip_dynamic_range_lvalue_expansion:;
if (children.size() >= 2) { if (children.size() >= 2) {
while (children[1]->simplify(true, false, false, stage, width_hint, sign_hint, false)) { } while (children[1]->simplify(true, false, false, stage, width_hint, sign_hint, false)) { }
if (!children[1]->isConst()) if (!children[1]->isConst())
log_error("Failed to evaluate system function `%s' with non-constant argument at %s:%d.\n", log_file_error(filename, linenum, "Failed to evaluate system function `%s' with non-constant argument.\n",
RTLIL::unescape_id(str).c_str(), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str());
int child_width_hint = width_hint; int child_width_hint = width_hint;
bool child_sign_hint = sign_hint; bool child_sign_hint = sign_hint;
children[1]->detectSignWidth(child_width_hint, child_sign_hint); children[1]->detectSignWidth(child_width_hint, child_sign_hint);
@ -2053,8 +2052,8 @@ skip_dynamic_range_lvalue_expansion:;
if (str == "\\$readmemh" || str == "\\$readmemb") if (str == "\\$readmemh" || str == "\\$readmemb")
{ {
if (GetSize(children) < 2 || GetSize(children) > 4) if (GetSize(children) < 2 || GetSize(children) > 4)
log_error("System function %s got %d arguments, expected 2-4 at %s:%d.\n", log_file_error(filename, linenum, "System function %s got %d arguments, expected 2-4.\n",
RTLIL::unescape_id(str).c_str(), int(children.size()), filename.c_str(), linenum); RTLIL::unescape_id(str).c_str(), int(children.size()));
AstNode *node_filename = children[0]->clone(); AstNode *node_filename = children[0]->clone();
while (node_filename->simplify(true, false, false, stage, width_hint, sign_hint, false)) { } while (node_filename->simplify(true, false, false, stage, width_hint, sign_hint, false)) { }
@ -3291,16 +3290,16 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)
continue; continue;
if (stmt->children.at(1)->type != AST_CONSTANT) if (stmt->children.at(1)->type != AST_CONSTANT)
log_error("Non-constant expression in constant function at %s:%d (called from %s:%d). X\n", log_file_error(stmt->filename, stmt->linenum, "Non-constant expression in constant function (called from %s:%d). X\n",
stmt->filename.c_str(), stmt->linenum, fcall->filename.c_str(), fcall->linenum); fcall->filename.c_str(), fcall->linenum);
if (stmt->children.at(0)->type != AST_IDENTIFIER) if (stmt->children.at(0)->type != AST_IDENTIFIER)
log_error("Unsupported composite left hand side in constant function at %s:%d (called from %s:%d).\n", log_file_error(stmt->filename, stmt->linenum, "Unsupported composite left hand side in constant function (called from %s:%d).\n",
stmt->filename.c_str(), stmt->linenum, fcall->filename.c_str(), fcall->linenum); fcall->filename.c_str(), fcall->linenum);
if (!variables.count(stmt->children.at(0)->str)) if (!variables.count(stmt->children.at(0)->str))
log_error("Assignment to non-local variable in constant function at %s:%d (called from %s:%d).\n", log_file_error(stmt->filename, stmt->linenum, "Assignment to non-local variable in constant function (called from %s:%d).\n",
stmt->filename.c_str(), stmt->linenum, fcall->filename.c_str(), fcall->linenum); fcall->filename.c_str(), fcall->linenum);
if (stmt->children.at(0)->children.empty()) { if (stmt->children.at(0)->children.empty()) {
variables[stmt->children.at(0)->str].val = stmt->children.at(1)->bitsAsConst(variables[stmt->children.at(0)->str].val.bits.size()); variables[stmt->children.at(0)->str].val = stmt->children.at(1)->bitsAsConst(variables[stmt->children.at(0)->str].val.bits.size());
@ -3339,8 +3338,8 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)
while (cond->simplify(true, false, false, 1, -1, false, true)) { } while (cond->simplify(true, false, false, 1, -1, false, true)) { }
if (cond->type != AST_CONSTANT) if (cond->type != AST_CONSTANT)
log_error("Non-constant expression in constant function at %s:%d (called from %s:%d).\n", log_file_error(stmt->filename, stmt->linenum, "Non-constant expression in constant function (called from %s:%d).\n",
stmt->filename.c_str(), stmt->linenum, fcall->filename.c_str(), fcall->linenum); fcall->filename.c_str(), fcall->linenum);
if (cond->asBool()) { if (cond->asBool()) {
block->children.insert(block->children.begin(), stmt->children.at(1)->clone()); block->children.insert(block->children.begin(), stmt->children.at(1)->clone());
@ -3360,8 +3359,8 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)
while (num->simplify(true, false, false, 1, -1, false, true)) { } while (num->simplify(true, false, false, 1, -1, false, true)) { }
if (num->type != AST_CONSTANT) if (num->type != AST_CONSTANT)
log_error("Non-constant expression in constant function at %s:%d (called from %s:%d).\n", log_file_error(stmt->filename, stmt->linenum, "Non-constant expression in constant function (called from %s:%d).\n",
stmt->filename.c_str(), stmt->linenum, fcall->filename.c_str(), fcall->linenum); fcall->filename.c_str(), fcall->linenum);
block->children.erase(block->children.begin()); block->children.erase(block->children.begin());
for (int i = 0; i < num->bitsAsConst().as_int(); i++) for (int i = 0; i < num->bitsAsConst().as_int(); i++)
@ -3398,8 +3397,8 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)
while (cond->simplify(true, false, false, 1, -1, false, true)) { } while (cond->simplify(true, false, false, 1, -1, false, true)) { }
if (cond->type != AST_CONSTANT) if (cond->type != AST_CONSTANT)
log_error("Non-constant expression in constant function at %s:%d (called from %s:%d).\n", log_file_error(stmt->filename, stmt->linenum, "Non-constant expression in constant function (called from %s:%d).\n",
stmt->filename.c_str(), stmt->linenum, fcall->filename.c_str(), fcall->linenum); fcall->filename.c_str(), fcall->linenum);
found_match = cond->asBool(); found_match = cond->asBool();
delete cond; delete cond;
@ -3428,8 +3427,8 @@ AstNode *AstNode::eval_const_function(AstNode *fcall)
continue; continue;
} }
log_error("Unsupported language construct in constant function at %s:%d (called from %s:%d).\n", log_file_error(stmt->filename, stmt->linenum, "Unsupported language construct in constant function (called from %s:%d).\n",
stmt->filename.c_str(), stmt->linenum, fcall->filename.c_str(), fcall->linenum); fcall->filename.c_str(), fcall->linenum);
log_abort(); log_abort();
} }

View File

@ -49,8 +49,7 @@ static int my_decimal_div_by_two(std::vector<uint8_t> &digits)
int carry = 0; int carry = 0;
for (size_t i = 0; i < digits.size(); i++) { for (size_t i = 0; i < digits.size(); i++) {
if (digits[i] >= 10) if (digits[i] >= 10)
log_error("Invalid use of [a-fxz?] in decimal constant at %s:%d.\n", log_file_error(current_filename, get_line_num(), "Invalid use of [a-fxz?] in decimal constant.\n");
current_filename.c_str(), get_line_num());
digits[i] += carry * 10; digits[i] += carry * 10;
carry = digits[i] % 2; carry = digits[i] % 2;
digits[i] /= 2; digits[i] /= 2;
@ -105,8 +104,8 @@ static void my_strtobin(std::vector<RTLIL::State> &data, const char *str, int le
int bits_per_digit = my_ilog2(base-1); int bits_per_digit = my_ilog2(base-1);
for (auto it = digits.rbegin(), e = digits.rend(); it != e; it++) { for (auto it = digits.rbegin(), e = digits.rend(); it != e; it++) {
if (*it > (base-1) && *it < 0xf0) if (*it > (base-1) && *it < 0xf0)
log_error("Digit larger than %d used in in base-%d constant at %s:%d.\n", log_file_error(current_filename, get_line_num(), "Digit larger than %d used in in base-%d constant.\n",
base-1, base, current_filename.c_str(), get_line_num()); base-1, base);
for (int i = 0; i < bits_per_digit; i++) { for (int i = 0; i < bits_per_digit; i++) {
int bitmask = 1 << i; int bitmask = 1 << i;
if (*it == 0xf0) if (*it == 0xf0)
@ -238,4 +237,3 @@ AstNode *VERILOG_FRONTEND::const2ast(std::string code, char case_type, bool warn
} }
YOSYS_NAMESPACE_END YOSYS_NAMESPACE_END