mirror of
https://github.com/YosysHQ/yosys.git
synced 2026-08-22 06:07:26 +02:00
rtlil: Add {from,to}_hdl_index methods to Wire
In the past we had the occasional bug due to some place not handling all 4 combinations of upto/downto and zero/nonzero start_offset correctly.
This commit is contained in:
committed by
Emil J. Tywoniak
parent
28c768e7b8
commit
7cd822b7f5
@@ -1673,6 +1673,19 @@ public:
|
||||
RTLIL::Cell *driverCell() const { log_assert(driverCell_); return driverCell_; };
|
||||
RTLIL::IdString driverPort() const { log_assert(driverCell_); return driverPort_; };
|
||||
|
||||
int from_hdl_index(int hdl_index) {
|
||||
int zero_index = hdl_index - start_offset;
|
||||
int rtlil_index = upto ? width - 1 - zero_index : zero_index;
|
||||
return rtlil_index >= 0 && rtlil_index < width ? rtlil_index : INT_MIN;
|
||||
}
|
||||
|
||||
int to_hdl_index(int rtlil_index) {
|
||||
if (rtlil_index < 0 || rtlil_index >= width)
|
||||
return INT_MIN;
|
||||
int zero_index = upto ? width - 1 - rtlil_index : rtlil_index;
|
||||
return zero_index + start_offset;
|
||||
}
|
||||
|
||||
#ifdef WITH_PYTHON
|
||||
static std::map<unsigned int, RTLIL::Wire*> *get_all_wires(void);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user