字符界面看波形:-)

补充: 今天干别的事情时发现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 @   Fun_with_Words  阅读(245)  评论(0编辑  收藏  举报
(评论功能已被禁用)
编辑推荐:
· .NET Core 中如何实现缓存的预热?
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
阅读排行:
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· 三行代码完成国际化适配,妙~啊~
· .NET Core 中如何实现缓存的预热?
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?









 和5张牌。

点击右上角即可分享
微信分享提示