mirror of
https://github.com/YosysHQ/yosys
synced 2026-05-25 19:36:21 +00:00
Cleanup.
This commit is contained in:
parent
c6c44c5c9d
commit
d55f4daae2
4 changed files with 14 additions and 21 deletions
|
|
@ -615,6 +615,15 @@ int RTLIL::Const::as_int_saturating(bool is_signed) const
|
||||||
return as_int(is_signed);
|
return as_int(is_signed);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RTLIL::Const::tag_bare_integer_const(const std::string &value)
|
||||||
|
{
|
||||||
|
if (value.empty() || value.find('\'') != std::string::npos)
|
||||||
|
return;
|
||||||
|
size_t start = (value[0] == '-' || value[0] == '+') ? 1 : 0;
|
||||||
|
if (start < value.size() && std::all_of(value.begin() + start, value.end(), ::isdigit))
|
||||||
|
flags |= RTLIL::CONST_FLAG_SIGNED;
|
||||||
|
}
|
||||||
|
|
||||||
int RTLIL::Const::get_min_size(bool is_signed) const
|
int RTLIL::Const::get_min_size(bool is_signed) const
|
||||||
{
|
{
|
||||||
if (empty()) return 0;
|
if (empty()) return 0;
|
||||||
|
|
|
||||||
|
|
@ -1091,6 +1091,8 @@ public:
|
||||||
// over/underflow, otherwise the max/min value for int depending on the sign.
|
// over/underflow, otherwise the max/min value for int depending on the sign.
|
||||||
int as_int_saturating(bool is_signed = false) const;
|
int as_int_saturating(bool is_signed = false) const;
|
||||||
|
|
||||||
|
void tag_bare_integer_const(const std::string &value);
|
||||||
|
|
||||||
std::string as_string(const char* any = "-") const;
|
std::string as_string(const char* any = "-") const;
|
||||||
static Const from_string(const std::string &str);
|
static Const from_string(const std::string &str);
|
||||||
std::vector<RTLIL::State> to_bits() const;
|
std::vector<RTLIL::State> to_bits() const;
|
||||||
|
|
|
||||||
|
|
@ -41,13 +41,7 @@ struct setunset_t
|
||||||
if (!RTLIL::SigSpec::parse(sig_value, nullptr, set_value))
|
if (!RTLIL::SigSpec::parse(sig_value, nullptr, set_value))
|
||||||
log_cmd_error("Can't decode value '%s'!\n", set_value);
|
log_cmd_error("Can't decode value '%s'!\n", set_value);
|
||||||
value = sig_value.as_const();
|
value = sig_value.as_const();
|
||||||
|
value.tag_bare_integer_const(set_value);
|
||||||
if (!set_value.empty() && set_value.find('\'') == std::string::npos) {
|
|
||||||
size_t start = (set_value[0] == '-' || set_value[0] == '+') ? 1 : 0;
|
|
||||||
if (start < set_value.size() && std::all_of(set_value.begin() + start, set_value.end(), ::isdigit)) {
|
|
||||||
value.flags |= RTLIL::CONST_FLAG_SIGNED;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -986,13 +986,7 @@ struct HierarchyPass : public Pass {
|
||||||
if (!RTLIL::SigSpec::parse(sig_value, NULL, para.second))
|
if (!RTLIL::SigSpec::parse(sig_value, NULL, para.second))
|
||||||
log_cmd_error("Can't decode value '%s'!\n", para.second);
|
log_cmd_error("Can't decode value '%s'!\n", para.second);
|
||||||
RTLIL::Const c = sig_value.as_const();
|
RTLIL::Const c = sig_value.as_const();
|
||||||
|
c.tag_bare_integer_const(para.second);
|
||||||
if (!para.second.empty() && para.second.find('\'') == std::string::npos) {
|
|
||||||
size_t start = (para.second[0] == '-' || para.second[0] == '+') ? 1 : 0;
|
|
||||||
if (start < para.second.size() && std::all_of(para.second.begin() + start, para.second.end(), ::isdigit))
|
|
||||||
c.flags |= RTLIL::CONST_FLAG_SIGNED;
|
|
||||||
}
|
|
||||||
|
|
||||||
top_parameters[RTLIL::escape_id(para.first)] = c;
|
top_parameters[RTLIL::escape_id(para.first)] = c;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1082,13 +1076,7 @@ struct HierarchyPass : public Pass {
|
||||||
if (!RTLIL::SigSpec::parse(sig_value, NULL, para.second))
|
if (!RTLIL::SigSpec::parse(sig_value, NULL, para.second))
|
||||||
log_cmd_error("Can't decode value '%s'!\n", para.second);
|
log_cmd_error("Can't decode value '%s'!\n", para.second);
|
||||||
RTLIL::Const c = sig_value.as_const();
|
RTLIL::Const c = sig_value.as_const();
|
||||||
|
c.tag_bare_integer_const(para.second);
|
||||||
if (!para.second.empty() && para.second.find('\'') == std::string::npos) {
|
|
||||||
size_t start = (para.second[0] == '-' || para.second[0] == '+') ? 1 : 0;
|
|
||||||
if (start < para.second.size() && std::all_of(para.second.begin() + start, para.second.end(), ::isdigit))
|
|
||||||
c.flags |= RTLIL::CONST_FLAG_SIGNED;
|
|
||||||
}
|
|
||||||
|
|
||||||
top_parameters[RTLIL::escape_id(para.first)] = c;
|
top_parameters[RTLIL::escape_id(para.first)] = c;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue