1
두 개의 기존 D-FF로 작성된 싱크로 나이저와 함께 테스트 벤치를 실행할 때이 오류가 발생했습니다.싱크로 나이저에서 테스트 벤치를 실행할 때 AlwaysError
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
내 테스트 벤치는
from myhdl import *
from random import randrange
HALF_PERIOD = delay(10) ### This makes a 20-ns clock signal
ACTIVE_HIGH = 1
G_DELAY = delay(15)
def Main():
### Signal declaration
clk, d, dout = [Signal(intbv(0)) for i in range(3)]
reset = ResetSignal(1,active=ACTIVE_HIGH,async=True)
### Module Instantiation
S1 = Sync(dout, d, clk,reset)
### Clk generator
@always(HALF_PERIOD)
def ClkGen():
clk.next = not clk
### TB def
@instance
def Driver():
yield(HALF_PERIOD)
reset.next = 0
for i in range(4):
yield(G_DELAY)
d.next = not d
raise StopSimulation
return ClkGen, Driver, S1
m1 = traceSignals(Main)
sim = Simulation(m1)
sim.run()
을 다음과 같이 설명되어 다음과 같이 내 동기는 코딩된다.
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
FF 프로토 타입은 다음과 같이 코딩된다.
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
테스트 벤치는 (약간 수정에) 앞서 코딩 유사한 테스트 벤치와 함께 일을했지만 두 개의 모듈을 결합 할 때 그것은 작동하지 않았다. 명확히하십시오. 고맙습니다.
유익한 출처 인 Veedrac에 감사드립니다. 나는 당신의 연결을 따르고 그것을 연구 할 것입니다. – user3663339