1
0
mirror of https://github.com/myhdl/myhdl.git synced 2025-01-24 21:52:56 +08:00

print with >>

This commit is contained in:
jand 2004-02-03 14:39:38 +00:00
parent 0c7cca721b
commit f800e21adc
2 changed files with 45 additions and 1 deletions

View File

@ -211,6 +211,13 @@ class _NotSupportedVisitor(_ToVerilogMixin):
self.visit(suite, _context.UNKNOWN)
if node.else_:
self.visit(node.else_, _context.UNKNOWN)
def visitPrintnl(self, node, *args):
if node.dest is not None:
self.raiseError(node, _error.NotSupported, "printing to a file with >> syntax")
self.visitChildNodes(node, *args)
visitPrint = visitPrintnl
def getNrBits(obj):

View File

@ -145,6 +145,29 @@ def taskReturnVal(count, enable, clock, reset, n):
h2(cnt)
count.next = count + 1
def printnlToFile(count, enable, clock, reset, n):
cnt = intbv()[8:]
while 1:
yield posedge(clock), negedge(reset)
if reset == ACTIVE_LOW:
count.next = 0
else:
if enable:
print >> f, count
count.next = count + 1
def printToFile(count, enable, clock, reset, n):
cnt = intbv()[8:]
while 1:
yield posedge(clock), negedge(reset)
if reset == ACTIVE_LOW:
count.next = 0
else:
if enable:
print >> f, count,
count.next = count + 1
objfile = "inc_inst.o"
@ -291,7 +314,21 @@ class TestErr(TestCase):
else:
self.fail()
def testPrintnlToFile(self):
try:
self.bench(printnlToFile)
except ToVerilogError, e:
self.assertEqual(e.kind, _error.NotSupported)
else:
self.fail()
def testPrintToFile(self):
try:
self.bench(printToFile)
except ToVerilogError, e:
self.assertEqual(e.kind, _error.NotSupported)
else:
self.fail()
if __name__ == '__main__':