mortbopet / VSRTL

Visual Simulation of Register Transfer Logic
MIT License
88 stars 18 forks source link

Make port value changes trigger modelindex updates #25

Open mortbopet opened 5 years ago

mortbopet commented 5 years ago

Currently, the entire Netlist/Register model is updated when the circuit is clocked - this is not scaleable.

model::data() should fetch values directly from their connected ports instead of this data being set during model initialization. Furthermore, a port emitting its updated signal should be connected to the specific treeItem (and QModelIndex) to update that specific index. This should allow us to completely remove the updateNetlistData() methods.

End goal is to remove the NetlistModelBase::invalidate() calls made in Netlist::reloadNetist()

mortbopet commented 5 years ago

TreeItems shall connect to the Port value changed signal. Given the stored QModelIndex within a treeItem, a call may be made: QModelIndex::model() to retreive the parent model. Then, QAbstractItemModel::dataChanged(index, index, {Qt::DisplayRole}) shall be emitted from the model, prompting the view to update the given index.

mortbopet commented 5 years ago

Initial investigation shows that QAbstractItemModel::dataChanged shows a significant overhead when it is called multiple times each clock cycle (given that multiple ports have changed), so for now, reloading the visible parts of the model each clock cycle seems to be the most efficient.

mortbopet commented 5 years ago

The core issue is that within Qt, data should be fully contained in a model, and any modifications to this data should be conducted through the model. However, in this case, the model hooks into the vsrtl::Design, wherein each time a design is changed, values within the model will be changed implicitly from the clocking action.

So currently, the way to notify this is to tell the view to update all currently visible QModelIndex'es, which will then fetch the updated values from the model. This might be the most "effective" way to hacking around the fact that model data is externally modified.