字符界面看波形:-)

补充: 今天干别的事情时发现D:\Python39\Lib\site-packages\Verilog_VCD\下没有__init__.py,我当初from Verilog_VCD import *咋work的?目前合理的解释是:当初把Verilog_VCD.py复制到当前目录下了。不是因为发现找不到parse_vcd而这么做的,而是一开始就想修改它来着——结果没有发现潜在的问题。Verilog_VCD.py和quine_mccluskey都写得有问题: 一个没有__init__.py,另一个__init__.py是空文件。In the simplest case, __init__.py can just be an empty file, but it can also execute initialization code for the package or set the __all__ variable. The import statement uses the following convention: if a package’s __init__.py code defines a list named __all__, it is taken to be the list of module names that should be imported when from package import * is encountered.

What is a Value Change Dump (VCD) file?

   

from Verilog_VCD import * # pip install Verilog_VCD
vcd = parse_vcd('test-encoder.vcd')
max_t = 0
for k,v in vcd.items():
    # print(k, v)
    net = v['nets'][0]
    if net['type'] == 'wire': continue
    tv = v['tv']
    net['size'] = size = int(net['size'])
    for i in range(size):
        for j in range(len(tv)):
            t, s = tv[j]
            if t > max_t: max_t = t
            tv[j] = (t, s.rjust(size, 'x' if s[0] == 'x' else '0'))
print(len(vcd), 'vars,', f'{max_t = }')
for k,v in vcd.items():
    net = v['nets'][0]
    if net['type'] == 'wire': continue
    tv = v['tv']; size = net['size']
    #print(net, tv)
    for i in range(size):
        name = net['name'] + ('_' + str(size - 1 - i) if size > 1 else '')
        print(name.rjust(15), '', end='')
        k = 0; c = '?'
        #def ps(): global c, k; print('-' if c == '1' else '_', '', end=''); k += 1 # nonlocal
        def ps(): global c, k; print(c, end=''); k += 1 # nonlocal
        for (t,s) in tv:
            while k < t: ps()
            c = s[i:i+1]; ps()
        while k <= max_t: ps()
        print()
posted @ 2021-12-20 11:13  Fun_with_Words  阅读(240)  评论(0编辑  收藏  举报









 张牌。