Created
June 6, 2015 12:51
-
-
Save cfelton/748f5364a1a483f1e982 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 random import randint | |
from myhdl import * | |
# output from the following tristate example | |
# Driver1 Driver2 Tristate | |
# None None None | |
# None 1 1 | |
# 0 None 0 | |
# None 1 1 | |
# 1 None 1 | |
# None 1 1 | |
# 1 None 1 | |
# None 1 1 | |
# 0 None 0 | |
# None 1 1 | |
def tristate_values(): | |
tri = TristateSignal(bool(0)) | |
dr1 = tri.driver() | |
dr2 = tri.driver() | |
#def _stim(): | |
@instance | |
def tbstim(): | |
print("Driver1 Driver2 Tristate ") | |
for ii in range(10): | |
print(" {:4} {:4} {:4}".format( | |
str(dr1), str(dr2), str(tri) )) | |
if (ii % 2) == 0: | |
dr1.next = None | |
dr2.next = randint(0, 1) | |
else: | |
dr1.next = randint(0, 1) | |
dr2.next = None | |
yield delay(1) | |
#return tbstim | |
Simulation(tbstim).run() | |
if __name__ == '__main__': | |
tristate_values() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment