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

bin spec and usage

This commit is contained in:
jand 2003-02-13 21:42:39 +00:00
parent 2abe0c675a
commit e4e0389375
2 changed files with 5 additions and 1 deletions

View File

@ -25,7 +25,7 @@ def testBench(width):
for i in range(2**width): for i in range(2**width):
B.next = intbv(i) B.next = intbv(i)
yield delay(10) yield delay(10)
print "B: %s | G: %s" % (bin(B.val, width), bin(G.val, width)) print "B: " + bin(B.val, width) + "| G: " + bin(G.val, width)
return (dut, stimulus()) return (dut, stimulus())

View File

@ -77,5 +77,9 @@ separate type.
addition, literal bit strings are accepted in concatenations, just as addition, literal bit strings are accepted in concatenations, just as
they are in intbv constructors. they are in intbv constructors.
* intbv has a bin(width) method that returns a binary string
representation. The optional width specifies the desired string
width: padding of the sign-bit is used.
* intbv supports the iterator protocol to iterate on its bits; again, * intbv supports the iterator protocol to iterate on its bits; again,
this requires a known length. this requires a known length.