1
0
mirror of https://github.com/myhdl/myhdl.git synced 2024-12-14 07:44:38 +08:00

26 lines
395 B
Python
Raw Normal View History

2016-03-10 20:27:07 +01:00
import myhdl
2005-12-14 14:41:53 +00:00
from myhdl import *
2003-05-09 21:11:41 +00:00
ACTIVE_LOW, INACTIVE_HIGH = 0, 1
2003-05-12 16:57:17 +00:00
def dff(q, d, clk, reset):
2003-05-09 21:11:41 +00:00
""" D flip-flop.
q -- output
d -- input
clock -- clock input
reset -- asynchronous reset input
"""
2005-12-14 14:41:53 +00:00
@always(clk.posedge, reset.negedge)
def logic():
2003-05-09 21:11:41 +00:00
if reset == ACTIVE_LOW:
q.next = 0
else:
q.next = d
2005-12-14 14:41:53 +00:00
return logic