litex/miscope/tools/conv.py
Florent Kermarrec e95e8b03b7 - reworking WIP
2013-02-22 16:40:49 +01:00

11 lines
145 B
Python

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)