<commit_before>from hdl_toolkit.simulator.shortcuts import afterRisingEdge

class AgentBase():
    def __init__(self, intf):
        self.intf = intf
        self.enable = True
        self.data = []
    
    def getSubDrivers(self):
        return []
    
    def getSubMonitors(self):
        return []

    def driver(self, s):
        raise NotImplementedError()
    
    def monitor(self, s):
        raise NotImplementedError()
    
class SyncAgentBase(AgentBase):
    def __init__(self, intf, clk=None, rstn=None):
        super().__init__(intf)
        
        # resolve clk and rstn
        p = intf._parent
        if clk is None:
            self.clk = p.clk
        else:
            self.clk = clk
        if rstn is None:
            self.rst_n = p.rst_n 
        else:
            self.rst_n = rstn

        
        self.monitor = afterRisingEdge(self.clk, self.monitor)
        self.driver = afterRisingEdge(self.clk, self.driver)<commit_msg>extract get rst, clk to functions<commit_after>from hdl_toolkit.simulator.shortcuts import afterRisingEdge

class AgentBase():
    def __init__(self, intf):
        self.intf = intf
        self.enable = True
        self.data = []
    
    def getSubDrivers(self):
        return []
    
    def getSubMonitors(self):
        return []

    def driver(self, s):
        raise NotImplementedError()
    
    def monitor(self, s):
        raise NotImplementedError()

   
class SyncAgentBase(AgentBase):
    def getRst_n(self, unit, allowNoReset):
        try:
            return unit.rst_n 
        except AttributeError:
            pass
        
        try:
            return ~unit.rst 
        except AttributeError:
            pass
        
        if allowNoReset:
            return None
        else:
            raise Exception("Can not find reset on unit %s" % (repr(unit)))
        
    
    def notReset(self, s):
        if self.rst_n is None:
            return True
        else:
            s.r(self.rst_n).val
        
    def __init__(self, intf, clk=None, rstn=None, allowNoReset=False):
        super().__init__(intf)
        
        # resolve clk and rstn
        p = intf._parent
        if clk is None:
            self.clk = p.clk
        else:
            self.clk = clk
            
        if rstn is None:
            self.rst_n = self.getRst_n(p, allowNoReset=allowNoReset)
        else:
            self.rst_n = rstn

        
        self.monitor = afterRisingEdge(self.clk, self.monitor)
        self.driver = afterRisingEdge(self.clk, self.driver)
{'fraction_non_alphanumeric': 0.086905230043256, 'fraction_numerical': 0.0, 'mean_word_length': 1.6417445482866044, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3420971', 'n_tokens_mistral': 794, 'n_tokens_neox': 767, 'n_words': 183}