Created
June 9, 2016 18:04
-
-
Save ravijain056/0c2d394861eff12ce0cb58e0179fb77e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from myhdl import Signal, block, always_seq, instance, delay | |
@block | |
def deadlock(): # not convertible | |
sig1 = Signal(bool(0)) | |
@instance | |
def initialpush(): | |
yield delay(10) | |
sig1.next = True | |
@always_seq(sig1.posedge, reset=None) | |
def posdriver(): | |
sig1.next = not sig1 | |
@always_seq(sig1.negedge, reset=None) | |
def negdriver(): | |
sig1.next = not sig1 | |
return initialpush, posdriver, negdriver | |
dlinst = deadlock() | |
dlinst.config_sim(trace=True) | |
dlinst.run_sim(duration=100) | |
@block | |
def deadlock2(): # can be convertible | |
sig1 = Signal(bool(0)) | |
sig2 = Signal(bool(0)) | |
sig3 = Signal(bool(0)) | |
@instance | |
def initialpush(): | |
while True: | |
yield delay(10) | |
sig1.next = True | |
@always_seq(sig1.posedge, reset=None) | |
def posdriver(): | |
sig1.next = not sig1 | |
sig2.next = sig1 | |
@always_seq(sig1.negedge, reset=None) | |
def negdriver(): | |
sig3.next = sig1 | |
return initialpush, posdriver, negdriver | |
dlinst2 = deadlock2() | |
dlinst2.config_sim(trace=True) | |
dlinst2.run_sim(duration=100) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment