3
0
Fork 0
mirror of https://github.com/YosysHQ/yosys synced 2025-06-27 08:28:45 +00:00

Add support for int stuff

This commit is contained in:
Akash Levy 2024-09-18 16:46:53 -07:00
parent 1801bb966a
commit db0317afc5
2 changed files with 11 additions and 0 deletions

View file

@ -214,6 +214,16 @@ RTLIL::Const::Const(const std::string &str)
} }
} }
RTLIL::Const::Const(int val, int width)
{
flags = RTLIL::CONST_FLAG_NONE;
bits.reserve(width);
for (int i = 0; i < width; i++) {
bits.push_back((val & 1) != 0 ? State::S1 : State::S0);
val = val >> 1;
}
}
RTLIL::Const::Const(long long val, int width) RTLIL::Const::Const(long long val, int width)
{ {
flags = RTLIL::CONST_FLAG_NONE; flags = RTLIL::CONST_FLAG_NONE;

View file

@ -663,6 +663,7 @@ struct RTLIL::Const
Const() : flags(RTLIL::CONST_FLAG_NONE) {} Const() : flags(RTLIL::CONST_FLAG_NONE) {}
Const(const std::string &str); Const(const std::string &str);
Const(int val, int width = 32);
Const(long long val, int width = 32); Const(long long val, int width = 32);
Const(RTLIL::State bit, int width = 1); Const(RTLIL::State bit, int width = 1);
Const(const std::vector<RTLIL::State> &bits) : bits(bits) { flags = CONST_FLAG_NONE; } Const(const std::vector<RTLIL::State> &bits) : bits(bits) { flags = CONST_FLAG_NONE; }