mirror of
https://github.com/YosysHQ/yosys
synced 2025-11-03 13:07:58 +00:00
Fix try_as_const/as_wire/as_chunk
This commit is contained in:
parent
000c081965
commit
a0e9e2d364
1 changed files with 12 additions and 9 deletions
|
|
@ -5625,11 +5625,12 @@ std::optional<RTLIL::Const> RTLIL::SigSpec::try_as_const() const
|
|||
{
|
||||
cover("kernel.rtlil.sigspec.as_const");
|
||||
|
||||
auto it = chunks().begin();
|
||||
if (it == chunks().end())
|
||||
Chunks cs = chunks();
|
||||
auto it = cs.begin();
|
||||
if (it == cs.end())
|
||||
return RTLIL::Const();
|
||||
SigChunk chunk = *it;
|
||||
if (chunk.wire != NULL || ++it != chunks().end())
|
||||
if (chunk.wire != NULL || ++it != cs.end())
|
||||
return std::nullopt;
|
||||
return RTLIL::Const(std::move(chunk.data));
|
||||
}
|
||||
|
|
@ -5647,10 +5648,11 @@ RTLIL::Wire *RTLIL::SigSpec::as_wire() const
|
|||
{
|
||||
cover("kernel.rtlil.sigspec.as_wire");
|
||||
|
||||
auto it = chunks().begin();
|
||||
log_assert(it != chunks().end());
|
||||
Chunks cs = chunks();
|
||||
auto it = cs.begin();
|
||||
log_assert(it != cs.end());
|
||||
RTLIL::SigChunk chunk = *it;
|
||||
log_assert(++it == chunks().end() && chunk.wire && chunk.wire->width == width_);
|
||||
log_assert(++it == cs.end() && chunk.wire && chunk.wire->width == width_);
|
||||
return chunk.wire;
|
||||
}
|
||||
|
||||
|
|
@ -5658,10 +5660,11 @@ RTLIL::SigChunk RTLIL::SigSpec::as_chunk() const
|
|||
{
|
||||
cover("kernel.rtlil.sigspec.as_chunk");
|
||||
|
||||
auto it = chunks().begin();
|
||||
log_assert(it != chunks().end());
|
||||
Chunks cs = chunks();
|
||||
auto it = cs.begin();
|
||||
log_assert(it != cs.end());
|
||||
RTLIL::SigChunk chunk = *it;
|
||||
log_assert(++it == chunks().end());
|
||||
log_assert(++it == cs.end());
|
||||
return chunk;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue