Skip to content

Instantly share code, notes, and snippets.

@jschpp
Last active August 29, 2015 14:08
Show Gist options
  • Save jschpp/2128b09e0cdebf30f03a to your computer and use it in GitHub Desktop.
Save jschpp/2128b09e0cdebf30f03a to your computer and use it in GitHub Desktop.
Generates VHDL Signal inputs to test components
class meh():
value = True
name = ""
def __init__(self, name):
self.name = name
def __repr__(self):
if self.value:
return "1"
else:
return "0"
def toggle(self):
self.value = not self.value
min_time = int(input("Smallest time intervall in ns: >>> "))
lst = list(map(lambda x: meh(x), input("Enter arguments>>> ").split()))
count = 1
MAX_TIME = min_time * (2**len(lst))
for c in range(len(lst)):
item = lst[c]
print(item.name+" <= ")
time = 0
for i in range(2**count):
item.toggle()
print("'" + str(item) + "' after " + str(time) + "ns,")
time += MAX_TIME // (2**count)
print("'0' after " + str((time + 20)) + "ns;\n")
count +=1
Smallest time intervall in ns: >>> 20
Enter arguments>>> a1 a2 a3 a4
a1 <=
'0' after 0ns,
'1' after 160ns,
'0' after 340ns;
a2 <=
'0' after 0ns,
'1' after 80ns,
'0' after 160ns,
'1' after 240ns,
'0' after 340ns;
a3 <=
'0' after 0ns,
'1' after 40ns,
'0' after 80ns,
'1' after 120ns,
'0' after 160ns,
'1' after 200ns,
'0' after 240ns,
'1' after 280ns,
'0' after 340ns;
a4 <=
'0' after 0ns,
'1' after 20ns,
'0' after 40ns,
'1' after 60ns,
'0' after 80ns,
'1' after 100ns,
'0' after 120ns,
'1' after 140ns,
'0' after 160ns,
'1' after 180ns,
'0' after 200ns,
'1' after 220ns,
'0' after 240ns,
'1' after 260ns,
'0' after 280ns,
'1' after 300ns,
'0' after 340ns;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment