-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathFlow.py
47 lines (36 loc) · 1.52 KB
/
Flow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import cocotb
from cocotb.triggers import RisingEdge, Event
from cocotblib.misc import Bundle
###############################################################################
# Flow
#
class Flow:
#==========================================================================
# Constructor
#==========================================================================
def __init__(self, dut, name):
# interface
self.valid = dut.__getattr__(name + "_valid")
self.payload = Bundle(dut,name + "_payload")
# Event
self.event_valid = Event()
#==========================================================================
# Start to monitor the valid signal
#==========================================================================
def startMonitoringValid(self, clk):
self.clk = clk
self.fork_valid = cocotb.fork(self.monitor_valid())
#==========================================================================
# Stop monitoring
#==========================================================================
def stopMonitoring(self):
self.fork_valid.kill()
#==========================================================================
# Monitor the valid signal
#==========================================================================
@cocotb.coroutine
def monitor_valid(self):
while True:
yield RisingEdge(self.clk)
if int(self.valid) == 1:
self.event_valid.set( self.payload )