We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Typo in BusMonitor Causes python Exception
In the bus monitor function in_reset(), there is a typo causing a problem.

The code at lines 168-169, tests if self._reset is valid, but then it accesses self._reset_n when it should be accessing self._reset.


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `cocotb/monitors/__init__.py`
Content:
```
1 #!/bin/env python
2 
3 ''' Copyright (c) 2013 Potential Ventures Ltd
4 Copyright (c) 2013 SolarFlare Communications Inc
5 All rights reserved.
6 
7 Redistribution and use in source and binary forms, with or without
8 modification, are permitted provided that the following conditions are met:
9     * Redistributions of source code must retain the above copyright
10       notice, this list of conditions and the following disclaimer.
11     * Redistributions in binary form must reproduce the above copyright
12       notice, this list of conditions and the following disclaimer in the
13       documentation and/or other materials provided with the distribution.
14     * Neither the name of Potential Ventures Ltd,
15       SolarFlare Communications Inc nor the
16       names of its contributors may be used to endorse or promote products
17       derived from this software without specific prior written permission.
18 
19 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
20 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
21 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22 DISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY
23 DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
24 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
25 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
26 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. '''
29 
30 """
31 
32     Class defining the standard interface for a monitor within a testbench
33 
34     The monitor is responsible for watching the pins of the DUT and recreating
35     the transactions
36 """
37 
38 import math
39 
40 import cocotb
41 from cocotb.decorators import coroutine
42 from cocotb.triggers import Edge, Event, RisingEdge, ReadOnly, Timer
43 from cocotb.binary import BinaryValue
44 from cocotb.bus import Bus
45 from cocotb.log import SimLog
46 from cocotb.result import ReturnValue
47 
48 
49 class MonitorStatistics(object):
50     """Wrapper class for storing Monitor statistics"""
51     def __init__(self):
52         self.received_transactions = 0
53 
54 
55 class Monitor(object):
56 
57     def __init__(self, callback=None, event=None):
58         """
59         Constructor for a monitor instance
60 
61         callback will be called with each recovered transaction as the argument
62 
63         If the callback isn't used, received transactions will be placed on a
64         queue and the event used to notify any consumers.
65         """
66         self._event = event
67         self._wait_event = None
68         self._recvQ = []
69         self._callbacks = []
70         self.stats = MonitorStatistics()
71         self._wait_event = Event()
72 
73         # Subclasses may already set up logging
74         if not hasattr(self, "log"):
75             self.log = SimLog("cocotb.monitor.%s" % (self.__class__.__name__))
76 
77         if callback is not None:
78             self.add_callback(callback)
79 
80         # Create an independent coroutine which can receive stuff
81         self._thread = cocotb.scheduler.add(self._monitor_recv())
82 
83     def kill(self):
84         if self._thread:
85             self._thread.kill()
86             self._thread = None
87 
88     def __len__(self):
89         return len(self._recvQ)
90 
91     def __getitem__(self, idx):
92         return self._recvQ[idx]
93 
94     def add_callback(self, callback):
95         self.log.debug("Adding callback of function %s to monitor" %
96                        (callback.__name__))
97         self._callbacks.append(callback)
98 
99     @coroutine
100     def wait_for_recv(self, timeout=None):
101         if timeout:
102             t = Timer(timeout)
103             fired = yield [self._wait_event.wait(), t]
104             if fired is t:
105                 raise ReturnValue(None)
106         else:
107             yield self._wait_event.wait()
108 
109         pkt = self._wait_event.data
110         raise ReturnValue(pkt)
111 
112     @coroutine
113     def _monitor_recv(self):
114         """
115         actual impementation of the receiver
116 
117         subclasses should override this method to implement the actual receive
118         routine and call self._recv() with the recovered transaction
119         """
120         raise NotImplementedError("Attempt to use base monitor class without "
121                                   "providing a _monitor_recv method")
122 
123     def _recv(self, transaction):
124         """Common handling of a received transaction."""
125 
126         self.stats.received_transactions += 1
127 
128         # either callback based consumer
129         for callback in self._callbacks:
130             callback(transaction)
131 
132         # Or queued with a notification
133         if not self._callbacks:
134             self._recvQ.append(transaction)
135 
136         if self._event is not None:
137             self._event.set()
138 
139         # If anyone was waiting then let them know
140         if self._wait_event is not None:
141             self._wait_event.set(data=transaction)
142             self._wait_event.clear()
143 
144 
145 class BusMonitor(Monitor):
146     """
147     Wrapper providing common functionality for monitoring busses
148     """
149     _signals = []
150     _optional_signals = []
151 
152     def __init__(self, entity, name, clock, reset=None, reset_n=None,
153                  callback=None, event=None):
154         self.log = SimLog("cocotb.%s.%s" % (entity.name, name))
155         self.entity = entity
156         self.name = name
157         self.clock = clock
158         self.bus = Bus(self.entity, self.name, self._signals,
159                        optional_signals=self._optional_signals)
160         self._reset = reset
161         self._reset_n = reset_n
162         Monitor.__init__(self, callback=callback, event=event)
163 
164     @property
165     def in_reset(self):
166         if self._reset_n is not None:
167             return not bool(self._reset_n.value.integer)
168         if self._reset is not None:
169             return bool(self._reset_n.value.integer)
170         return False
171 
172     def __str__(self):
173         return "%s(%s)" % (self.__class__.__name__, self.name)
174
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/cocotb/monitors/__init__.py b/cocotb/monitors/__init__.py
--- a/cocotb/monitors/__init__.py
+++ b/cocotb/monitors/__init__.py
@@ -166,7 +166,7 @@
         if self._reset_n is not None:
             return not bool(self._reset_n.value.integer)
         if self._reset is not None:
-            return bool(self._reset_n.value.integer)
+            return bool(self._reset.value.integer)
         return False
 
     def __str__(self):

{"golden_diff": "diff --git a/cocotb/monitors/__init__.py b/cocotb/monitors/__init__.py\n--- a/cocotb/monitors/__init__.py\n+++ b/cocotb/monitors/__init__.py\n@@ -166,7 +166,7 @@\n         if self._reset_n is not None:\n             return not bool(self._reset_n.value.integer)\n         if self._reset is not None:\n-            return bool(self._reset_n.value.integer)\n+            return bool(self._reset.value.integer)\n         return False\n \n     def __str__(self):\n", "issue": "Typo in BusMonitor Causes python Exception\nIn the bus monitor function in_reset(), there is a typo causing a problem.\n\nThe code at lines 168-169, tests if self._reset is valid, but then it accesses self._reset_n when it should be accessing self._reset.\n\n", "before_files": [{"content": "#!/bin/env python\n\n''' Copyright (c) 2013 Potential Ventures Ltd\nCopyright (c) 2013 SolarFlare Communications Inc\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of Potential Ventures Ltd,\n      SolarFlare Communications Inc nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. '''\n\n\"\"\"\n\n    Class defining the standard interface for a monitor within a testbench\n\n    The monitor is responsible for watching the pins of the DUT and recreating\n    the transactions\n\"\"\"\n\nimport math\n\nimport cocotb\nfrom cocotb.decorators import coroutine\nfrom cocotb.triggers import Edge, Event, RisingEdge, ReadOnly, Timer\nfrom cocotb.binary import BinaryValue\nfrom cocotb.bus import Bus\nfrom cocotb.log import SimLog\nfrom cocotb.result import ReturnValue\n\n\nclass MonitorStatistics(object):\n    \"\"\"Wrapper class for storing Monitor statistics\"\"\"\n    def __init__(self):\n        self.received_transactions = 0\n\n\nclass Monitor(object):\n\n    def __init__(self, callback=None, event=None):\n        \"\"\"\n        Constructor for a monitor instance\n\n        callback will be called with each recovered transaction as the argument\n\n        If the callback isn't used, received transactions will be placed on a\n        queue and the event used to notify any consumers.\n        \"\"\"\n        self._event = event\n        self._wait_event = None\n        self._recvQ = []\n        self._callbacks = []\n        self.stats = MonitorStatistics()\n        self._wait_event = Event()\n\n        # Subclasses may already set up logging\n        if not hasattr(self, \"log\"):\n            self.log = SimLog(\"cocotb.monitor.%s\" % (self.__class__.__name__))\n\n        if callback is not None:\n            self.add_callback(callback)\n\n        # Create an independent coroutine which can receive stuff\n        self._thread = cocotb.scheduler.add(self._monitor_recv())\n\n    def kill(self):\n        if self._thread:\n            self._thread.kill()\n            self._thread = None\n\n    def __len__(self):\n        return len(self._recvQ)\n\n    def __getitem__(self, idx):\n        return self._recvQ[idx]\n\n    def add_callback(self, callback):\n        self.log.debug(\"Adding callback of function %s to monitor\" %\n                       (callback.__name__))\n        self._callbacks.append(callback)\n\n    @coroutine\n    def wait_for_recv(self, timeout=None):\n        if timeout:\n            t = Timer(timeout)\n            fired = yield [self._wait_event.wait(), t]\n            if fired is t:\n                raise ReturnValue(None)\n        else:\n            yield self._wait_event.wait()\n\n        pkt = self._wait_event.data\n        raise ReturnValue(pkt)\n\n    @coroutine\n    def _monitor_recv(self):\n        \"\"\"\n        actual impementation of the receiver\n\n        subclasses should override this method to implement the actual receive\n        routine and call self._recv() with the recovered transaction\n        \"\"\"\n        raise NotImplementedError(\"Attempt to use base monitor class without \"\n                                  \"providing a _monitor_recv method\")\n\n    def _recv(self, transaction):\n        \"\"\"Common handling of a received transaction.\"\"\"\n\n        self.stats.received_transactions += 1\n\n        # either callback based consumer\n        for callback in self._callbacks:\n            callback(transaction)\n\n        # Or queued with a notification\n        if not self._callbacks:\n            self._recvQ.append(transaction)\n\n        if self._event is not None:\n            self._event.set()\n\n        # If anyone was waiting then let them know\n        if self._wait_event is not None:\n            self._wait_event.set(data=transaction)\n            self._wait_event.clear()\n\n\nclass BusMonitor(Monitor):\n    \"\"\"\n    Wrapper providing common functionality for monitoring busses\n    \"\"\"\n    _signals = []\n    _optional_signals = []\n\n    def __init__(self, entity, name, clock, reset=None, reset_n=None,\n                 callback=None, event=None):\n        self.log = SimLog(\"cocotb.%s.%s\" % (entity.name, name))\n        self.entity = entity\n        self.name = name\n        self.clock = clock\n        self.bus = Bus(self.entity, self.name, self._signals,\n                       optional_signals=self._optional_signals)\n        self._reset = reset\n        self._reset_n = reset_n\n        Monitor.__init__(self, callback=callback, event=event)\n\n    @property\n    def in_reset(self):\n        if self._reset_n is not None:\n            return not bool(self._reset_n.value.integer)\n        if self._reset is not None:\n            return bool(self._reset_n.value.integer)\n        return False\n\n    def __str__(self):\n        return \"%s(%s)\" % (self.__class__.__name__, self.name)\n", "path": "cocotb/monitors/__init__.py"}], "after_files": [{"content": "#!/bin/env python\n\n''' Copyright (c) 2013 Potential Ventures Ltd\nCopyright (c) 2013 SolarFlare Communications Inc\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n    * Redistributions of source code must retain the above copyright\n      notice, this list of conditions and the following disclaimer.\n    * Redistributions in binary form must reproduce the above copyright\n      notice, this list of conditions and the following disclaimer in the\n      documentation and/or other materials provided with the distribution.\n    * Neither the name of Potential Ventures Ltd,\n      SolarFlare Communications Inc nor the\n      names of its contributors may be used to endorse or promote products\n      derived from this software without specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\nANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\nWARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\nDISCLAIMED. IN NO EVENT SHALL POTENTIAL VENTURES LTD BE LIABLE FOR ANY\nDIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\nLOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\nON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\nSOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. '''\n\n\"\"\"\n\n    Class defining the standard interface for a monitor within a testbench\n\n    The monitor is responsible for watching the pins of the DUT and recreating\n    the transactions\n\"\"\"\n\nimport math\n\nimport cocotb\nfrom cocotb.decorators import coroutine\nfrom cocotb.triggers import Edge, Event, RisingEdge, ReadOnly, Timer\nfrom cocotb.binary import BinaryValue\nfrom cocotb.bus import Bus\nfrom cocotb.log import SimLog\nfrom cocotb.result import ReturnValue\n\n\nclass MonitorStatistics(object):\n    \"\"\"Wrapper class for storing Monitor statistics\"\"\"\n    def __init__(self):\n        self.received_transactions = 0\n\n\nclass Monitor(object):\n\n    def __init__(self, callback=None, event=None):\n        \"\"\"\n        Constructor for a monitor instance\n\n        callback will be called with each recovered transaction as the argument\n\n        If the callback isn't used, received transactions will be placed on a\n        queue and the event used to notify any consumers.\n        \"\"\"\n        self._event = event\n        self._wait_event = None\n        self._recvQ = []\n        self._callbacks = []\n        self.stats = MonitorStatistics()\n        self._wait_event = Event()\n\n        # Subclasses may already set up logging\n        if not hasattr(self, \"log\"):\n            self.log = SimLog(\"cocotb.monitor.%s\" % (self.__class__.__name__))\n\n        if callback is not None:\n            self.add_callback(callback)\n\n        # Create an independent coroutine which can receive stuff\n        self._thread = cocotb.scheduler.add(self._monitor_recv())\n\n    def kill(self):\n        if self._thread:\n            self._thread.kill()\n            self._thread = None\n\n    def __len__(self):\n        return len(self._recvQ)\n\n    def __getitem__(self, idx):\n        return self._recvQ[idx]\n\n    def add_callback(self, callback):\n        self.log.debug(\"Adding callback of function %s to monitor\" %\n                       (callback.__name__))\n        self._callbacks.append(callback)\n\n    @coroutine\n    def wait_for_recv(self, timeout=None):\n        if timeout:\n            t = Timer(timeout)\n            fired = yield [self._wait_event.wait(), t]\n            if fired is t:\n                raise ReturnValue(None)\n        else:\n            yield self._wait_event.wait()\n\n        pkt = self._wait_event.data\n        raise ReturnValue(pkt)\n\n    @coroutine\n    def _monitor_recv(self):\n        \"\"\"\n        actual impementation of the receiver\n\n        subclasses should override this method to implement the actual receive\n        routine and call self._recv() with the recovered transaction\n        \"\"\"\n        raise NotImplementedError(\"Attempt to use base monitor class without \"\n                                  \"providing a _monitor_recv method\")\n\n    def _recv(self, transaction):\n        \"\"\"Common handling of a received transaction.\"\"\"\n\n        self.stats.received_transactions += 1\n\n        # either callback based consumer\n        for callback in self._callbacks:\n            callback(transaction)\n\n        # Or queued with a notification\n        if not self._callbacks:\n            self._recvQ.append(transaction)\n\n        if self._event is not None:\n            self._event.set()\n\n        # If anyone was waiting then let them know\n        if self._wait_event is not None:\n            self._wait_event.set(data=transaction)\n            self._wait_event.clear()\n\n\nclass BusMonitor(Monitor):\n    \"\"\"\n    Wrapper providing common functionality for monitoring busses\n    \"\"\"\n    _signals = []\n    _optional_signals = []\n\n    def __init__(self, entity, name, clock, reset=None, reset_n=None,\n                 callback=None, event=None):\n        self.log = SimLog(\"cocotb.%s.%s\" % (entity.name, name))\n        self.entity = entity\n        self.name = name\n        self.clock = clock\n        self.bus = Bus(self.entity, self.name, self._signals,\n                       optional_signals=self._optional_signals)\n        self._reset = reset\n        self._reset_n = reset_n\n        Monitor.__init__(self, callback=callback, event=event)\n\n    @property\n    def in_reset(self):\n        if self._reset_n is not None:\n            return not bool(self._reset_n.value.integer)\n        if self._reset is not None:\n            return bool(self._reset.value.integer)\n        return False\n\n    def __str__(self):\n        return \"%s(%s)\" % (self.__class__.__name__, self.name)\n", "path": "cocotb/monitors/__init__.py"}]}