mirror of
https://github.com/myhdl/myhdl.git
synced 2024-12-14 07:44:38 +08:00
21 lines
424 B
Python
21 lines
424 B
Python
from __future__ import generators
|
|
from myhdl import Signal, intbv, posedge, negedge
|
|
|
|
ACTIVE_LOW, INACTIVE_HIGH = 0, 1
|
|
|
|
def dff(q, d, clk, reset):
|
|
""" D flip-flop.
|
|
|
|
q -- output
|
|
d -- input
|
|
clock -- clock input
|
|
reset -- asynchronous reset input
|
|
"""
|
|
while 1:
|
|
yield posedge(clk), negedge(reset)
|
|
if reset == ACTIVE_LOW:
|
|
q.next = 0
|
|
else:
|
|
q.next = d
|
|
|