litex/migScope/tools/conv.py

13 lines
160 B
Python
Raw Normal View History

2012-08-26 14:56:56 -04:00
import datetime
def dec2bin(d,nb=0):
if d=="x":
return "x"*nb
elif d==0:
b="0"
else:
b=""
while d!=0:
b="01"[d&1]+b
d=d>>1
return b.zfill(nb)