mirror of
https://github.com/YosysHQ/yosys
synced 2025-10-09 17:31:59 +00:00
Merge 42e4610e3a
into 47ca09a016
This commit is contained in:
commit
3048feb281
2 changed files with 28 additions and 1 deletions
|
@ -187,7 +187,11 @@ wire_stmt:
|
||||||
|
|
||||||
wire_options:
|
wire_options:
|
||||||
wire_options TOK_WIDTH TOK_INT {
|
wire_options TOK_WIDTH TOK_INT {
|
||||||
current_wire->width = $3;
|
if ($3 > 0x1000000) {
|
||||||
|
rtlil_frontend_yyerror("RTLIL error: invalid wire width, must be less than 2^24");
|
||||||
|
} else {
|
||||||
|
current_wire->width = $3;
|
||||||
|
}
|
||||||
} |
|
} |
|
||||||
wire_options TOK_WIDTH TOK_INVALID {
|
wire_options TOK_WIDTH TOK_INVALID {
|
||||||
rtlil_frontend_yyerror("RTLIL error: invalid wire width");
|
rtlil_frontend_yyerror("RTLIL error: invalid wire width");
|
||||||
|
|
|
@ -266,6 +266,9 @@ std::string& Const::get_str() {
|
||||||
|
|
||||||
RTLIL::Const::Const(const std::string &str)
|
RTLIL::Const::Const(const std::string &str)
|
||||||
{
|
{
|
||||||
|
if (str.size() * 8 > 0x1000000)
|
||||||
|
log_error("RTLIL Const width must be less than 2^24");
|
||||||
|
|
||||||
flags = RTLIL::CONST_FLAG_STRING;
|
flags = RTLIL::CONST_FLAG_STRING;
|
||||||
new ((void*)&str_) std::string(str);
|
new ((void*)&str_) std::string(str);
|
||||||
tag = backing_tag::string;
|
tag = backing_tag::string;
|
||||||
|
@ -273,6 +276,12 @@ RTLIL::Const::Const(const std::string &str)
|
||||||
|
|
||||||
RTLIL::Const::Const(long long val) // default width 32
|
RTLIL::Const::Const(long long val) // default width 32
|
||||||
{
|
{
|
||||||
|
if (width < 0)
|
||||||
|
log_error("RTLIL Const width must not be negative");
|
||||||
|
|
||||||
|
if (width > 0x1000000)
|
||||||
|
log_error("RTLIL Const width must be less than 2^24");
|
||||||
|
|
||||||
flags = RTLIL::CONST_FLAG_NONE;
|
flags = RTLIL::CONST_FLAG_NONE;
|
||||||
char bytes[] = {
|
char bytes[] = {
|
||||||
(char)(val >> 24), (char)(val >> 16), (char)(val >> 8), (char)val
|
(char)(val >> 24), (char)(val >> 16), (char)(val >> 8), (char)val
|
||||||
|
@ -311,6 +320,12 @@ RTLIL::Const::Const(long long val, int width)
|
||||||
|
|
||||||
RTLIL::Const::Const(RTLIL::State bit, int width)
|
RTLIL::Const::Const(RTLIL::State bit, int width)
|
||||||
{
|
{
|
||||||
|
if (width < 0)
|
||||||
|
log_error("RTLIL Const width must not be negative");
|
||||||
|
|
||||||
|
if (width > 0x1000000)
|
||||||
|
log_error("RTLIL Const width must be less than 2^24");
|
||||||
|
|
||||||
flags = RTLIL::CONST_FLAG_NONE;
|
flags = RTLIL::CONST_FLAG_NONE;
|
||||||
new ((void*)&bits_) bitvectype();
|
new ((void*)&bits_) bitvectype();
|
||||||
tag = backing_tag::bits;
|
tag = backing_tag::bits;
|
||||||
|
@ -322,6 +337,10 @@ RTLIL::Const::Const(RTLIL::State bit, int width)
|
||||||
|
|
||||||
RTLIL::Const::Const(const std::vector<bool> &bits)
|
RTLIL::Const::Const(const std::vector<bool> &bits)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (bits.size() > 0x1000000)
|
||||||
|
log_error("RTLIL Const width must be less than 2^24");
|
||||||
|
|
||||||
flags = RTLIL::CONST_FLAG_NONE;
|
flags = RTLIL::CONST_FLAG_NONE;
|
||||||
new ((void*)&bits_) bitvectype();
|
new ((void*)&bits_) bitvectype();
|
||||||
tag = backing_tag::bits;
|
tag = backing_tag::bits;
|
||||||
|
@ -573,6 +592,10 @@ std::string RTLIL::Const::as_string(const char* any) const
|
||||||
|
|
||||||
RTLIL::Const RTLIL::Const::from_string(const std::string &str)
|
RTLIL::Const RTLIL::Const::from_string(const std::string &str)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
if (str.size() > 0x1000000)
|
||||||
|
log_error("RTLIL width must be less than 2^24");
|
||||||
|
|
||||||
Const c;
|
Const c;
|
||||||
bitvectype& bv = c.get_bits();
|
bitvectype& bv = c.get_bits();
|
||||||
bv.reserve(str.size());
|
bv.reserve(str.size());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue