- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
编辑:只有当我从 iPython notebook 内部运行代码时才会发生这种情况。 。它在常规 .py 文件中运行良好
我刚刚开始学习 myHDL,但使用 @instance 或 @always_comb 生成器时遇到编译错误,如下所示:
TypeError: compile() expected string without null bytes
例如:3.2 信号、端口和并发:
from myhdl import Signal, delay, always, instance, now, Simulation
def ClkDriver(clk, period=20):
lowTime = int(period/2)
highTime = period - lowTime
@instance
def driveClk():
while True:
yield delay(lowTime)
clk.next = 1
yield delay(highTime)
clk.next = 0
return driveClk
clk = Signal(0)
clkdriver_inst = ClkDriver(clk)
给出堆栈跟踪:
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-47-4252bd2f72e0> in <module>()
16
17 clk = Signal(0)
---> 18 clkdriver_inst = ClkDriver(clk)
<ipython-input-47-4252bd2f72e0> in ClkDriver(clk, period)
5 highTime = period - lowTime
6
----> 7 @instance
8 def driveClk():
9 while True:
C:\Python27\lib\site-packages\myhdl\_instance.pyc in instance(genFunc)
40 if genFunc.func_code.co_argcount > 0:
41 raise InstanceError(_error.NrOfArgs)
---> 42 return _Instantiator(genFunc)
43
44 class _Instantiator(object):
C:\Python27\lib\site-packages\myhdl\_instance.pyc in __init__(self, genFunc)
47 self.genfunc = genFunc
48 self.gen = genFunc()
---> 49 self.waiter = _inferWaiter(self.gen)
50
C:\Python27\lib\site-packages\myhdl\_Waiter.pyc in _inferWaiter(gen)
209 s = inspect.getsource(f)
210 s = _dedent(s)
--> 211 root = ast.parse(s)
212 root.symdict = f.f_globals.copy()
213 root.symdict.update(f.f_locals)
C:\Python27\lib\ast.pyc in parse(source, filename, mode)
35 Equivalent to compile(source, filename, mode, PyCF_ONLY_AST).
36 """
---> 37 return compile(source, filename, mode, PyCF_ONLY_AST)
38
39
TypeError: compile() expected string without null bytes
有什么线索可以说明我做错了什么吗?
最佳答案
这看起来像是 myhdl._util._dedent() 中 unicode 支持的问题
这是说明问题的代码片段:
为了快速修复,我添加了以下代码:
def _dedent(s):
"""Dedent python code string."""
# RL convert to ascii
s = s.encode('ascii','ignore')
result = [t[:2] for t in generate_tokens(StringIO(s).readline)]
# set initial indent to 0 if any
if result[0][0] == INDENT:
result[0] = (INDENT, '')
return untokenize(result)
关于python - iPython 笔记本中 myHDL 手册中基本示例的 AST 编译错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19451398/
在 VHDL 中,我经常使用记录将相关信号分组为可以作为单个对象传递的东西,例如在港口 map 中。这样做的 MyHDL 方式是什么? 最佳答案 接口(interface)在 0.9-dev 和 很简
我目前正在研究 myHdl,看它是否值得使用。但是,我遇到了有关模块实例化的问题。我有两个文件,一个是模块,一个是测试平台。在测试台内,我按照网站上的示例实例化了模块: http://www.myhd
我正在尝试在 Windows 10 上使用 Python2 设置 myHDL,以便使用 Python 作为源代码来处理 VHDL/Verilog 测试平台。可以找到相应的说明here . 我已经在我的
我正在尝试学习 MyHDL,为此我尝试创建一个非常简单的人工神经元,稍后可以在简单的人工神经网络中使用它。首先,我设计了一个只能处理单个输入和权重信号并返回输出信号的人工神经元。 @block def
Here is an example我从 myHDL manual 复制的。在我的代码中,生成器 FSM() 永远不会被调用,因此状态始终为“SEARCH”。 我不明白为什么生成器没有被调用。 编辑:
我正在使用 MyHDL 包进行硬件仿真,但我想围绕它放置一个 GUI,以便用户可以交互地更改信号并查看其他信号更新。 问题是,MyHDL使用模拟器如下 模拟器有几个发电机 每个生成器都可以监听信号变化
我正在尝试创建一个Python库,用于使用myHDL 1.0dev使用pySerial在PC和FPGA之间动态创建UART接口(interface) 它获取数据类型及其属性的名称,并实例化 RAM b
编辑:只有当我从 iPython notebook 内部运行代码时才会发生这种情况。 。它在常规 .py 文件中运行良好 我刚刚开始学习 myHDL,但使用 @instance 或 @always_c
对于我实现并成功转换为 VHDL 的算法,我在“顶级 VHDL 设计的静态阐述”期间收到此错误: no index value can belong to null index range 我将代码简
我是一名优秀的程序员,十分优秀!