mirror of https://github.com/YosysHQ/yosys.git
kernel: rtlil: imposed a hard limit on RTLIL::Const of 2^24 (closes #3317)
This commit is contained in:
parent
9ffaae91ff
commit
2b9982101a
|
@ -201,6 +201,9 @@ const pool<IdString> &RTLIL::builtin_ff_cell_types() {
|
|||
|
||||
RTLIL::Const::Const(const std::string &str)
|
||||
{
|
||||
if (str.size() * 8 > 0x1000000)
|
||||
throw std::length_error("RTLIL Const width must be less than 2^24");
|
||||
|
||||
flags = RTLIL::CONST_FLAG_STRING;
|
||||
bits.reserve(str.size() * 8);
|
||||
for (int i = str.size()-1; i >= 0; i--) {
|
||||
|
@ -214,6 +217,12 @@ RTLIL::Const::Const(const std::string &str)
|
|||
|
||||
RTLIL::Const::Const(int val, int width)
|
||||
{
|
||||
if (width < 0)
|
||||
throw std::length_error("RTLIL Const width must not be negative");
|
||||
|
||||
if (width > 0x1000000)
|
||||
throw std::length_error("RTLIL Const width must be less than 2^24");
|
||||
|
||||
flags = RTLIL::CONST_FLAG_NONE;
|
||||
bits.reserve(width);
|
||||
for (int i = 0; i < width; i++) {
|
||||
|
@ -224,6 +233,12 @@ RTLIL::Const::Const(int val, int width)
|
|||
|
||||
RTLIL::Const::Const(RTLIL::State bit, int width)
|
||||
{
|
||||
if (width < 0)
|
||||
throw std::length_error("RTLIL Const width must not be negative");
|
||||
|
||||
if (width > 0x1000000)
|
||||
throw std::length_error("RTLIL Const width must be less than 2^24");
|
||||
|
||||
flags = RTLIL::CONST_FLAG_NONE;
|
||||
bits.reserve(width);
|
||||
for (int i = 0; i < width; i++)
|
||||
|
@ -232,6 +247,10 @@ RTLIL::Const::Const(RTLIL::State bit, int width)
|
|||
|
||||
RTLIL::Const::Const(const std::vector<bool> &bits)
|
||||
{
|
||||
|
||||
if (bits.size() > 0x1000000)
|
||||
throw std::length_error("RTLIL Const width must be less than 2^24");
|
||||
|
||||
flags = RTLIL::CONST_FLAG_NONE;
|
||||
this->bits.reserve(bits.size());
|
||||
for (const auto &b : bits)
|
||||
|
@ -296,6 +315,10 @@ std::string RTLIL::Const::as_string() const
|
|||
|
||||
RTLIL::Const RTLIL::Const::from_string(const std::string &str)
|
||||
{
|
||||
|
||||
if (str.size() > 0x1000000)
|
||||
throw std::length_error("RTLIL width must be less than 2^24");
|
||||
|
||||
Const c;
|
||||
c.bits.reserve(str.size());
|
||||
for (auto it = str.rbegin(); it != str.rend(); it++)
|
||||
|
|
Loading…
Reference in New Issue