在同步上运行测试台时总是出错

2024-09-28 23:32:28 发布

您现在位置:Python中文网/ 问答频道 /正文

我在运行一个测试台时遇到了这个错误,同时运行了一个基于两个现有D-FFs的同步器。在

File "/home/runner/design.py", line 28, in Sync
    @always_seq(clk.posedge, reset=reset)
  File "/usr/share/myhdl-0.8/lib/python/myhdl/_always_seq.py", line 76, in _always_seq_decorator
    raise AlwaysSeqError(_error.ArgType)
myhdl.AlwaysError: decorated object should be a classic (non-generator) function

我的测试台概述如下

^{pr2}$

我的同步器编码如下。在

from myhdl import *
from DFF import *

def Sync(dout,din,clk,reset):

    """ The module consists of two FFs with one internal signal

    External signals 

    dout : output
    din  : input
    clk  : input

    Internal signal:

    F2F : output-to-input signal that connects two FFs together

    """
### Connectivity

    F2F = Signal(intbv(0))

    F1 = DFF(F2F,din,clk,reset)  
    F2 = DFF(dout,F2F,clk,reset)

### Function

    @always_seq(clk.posedge,reset=reset)
    def SyncLogic():
        if reset:
            F2F.next = 0
            dout.next = 0
        else:
        F2F.next = din
        yield(WIRE_DELAY)
        dout.next = F2F
    return SyncLogic

原型代码如下。在

from myhdl import *

def DFF(dout,din,clk,reset):

    @always_seq(clk.posedge, reset=reset)
    def Flogic():
        if reset:
            dout.next = 0
        else:
            dout.next = din
    return Flogic

testbench确实可以使用我之前编写的类似testbench(稍作修改),但是当将两个模块组合在一起时,它就不能工作了。请澄清。非常感谢。在


Tags: fromimportdefalwaysseqnextresetffs
1条回答
网友
1楼 · 发布于 2024-09-28 23:32:28

要对线延迟建模,请在信号中使用“delay”参数。在

改变

@always_seq(clk.posedge,reset=reset)
def SyncLogic():
    if reset:
        F2F.next = 0
        dout.next = 0
    else:
    F2F.next = din
    yield(WIRE_DELAY)
    dout.next = F2F
return SyncLogic

收件人:

^{pr2}$

使用“总是”时,不要定义重置(它是自动添加的)。如果要显式定义重置,请使用“@always”(时钟.posedge, 重置.negedge)". 在

相关问题 更多 >