Source code for hwt.interfaces.hsStructIntf
from hwt.hdl.types.hdlType import HdlType
from hwt.interfaces.agents.handshaked import HandshakedAgent
from hwt.interfaces.std import HandshakeSync
from hwt.interfaces.structIntf import HdlType_to_Interface
from hwt.synthesizer.param import Param
from hwtSimApi.hdlSimulator import HdlSimulator
[docs]class HsStructIntf(HandshakeSync):
"""
A handshaked interface which has a data signal of type specified in configuration of this interface
"""
[docs] def _config(self):
self.T: HdlType = Param(None)
[docs] def _declr(self):
assert isinstance(self.T, HdlType), (self.T, self._name)
self._dtype = self.T
self.data = HdlType_to_Interface().apply(self.T)
HandshakeSync._declr(self)
[docs] def _initSimAgent(self, sim:HdlSimulator):
self._ag = HsStructIntfAgent(sim, self)
[docs]class HsStructIntfAgent(HandshakedAgent):
[docs] def __init__(self, sim:HdlSimulator, intf:"Handshaked", allowNoReset=False):
HandshakedAgent.__init__(self, sim, intf, allowNoReset=allowNoReset)
intf.data._initSimAgent(sim)
self._data_ag = intf.data._ag
[docs] def set_data(self, data):
return self._data_ag.set_data(data)
[docs] def get_data(self):
return self._data_ag.get_data()