2015-02-01 18:00:29 -05:00
|
|
|
from __future__ import absolute_import
|
2011-05-18 10:36:04 +02:00
|
|
|
from myhdl import *
|
|
|
|
|
|
|
|
def timer_sig(flag, clock, reset, MAXVAL):
|
|
|
|
|
|
|
|
count = Signal(intbv(0, min=0, max=MAXVAL+1))
|
|
|
|
|
|
|
|
@always (clock.posedge, reset.posedge)
|
|
|
|
def logic():
|
|
|
|
if reset == 1:
|
|
|
|
count.next = 0
|
|
|
|
else:
|
|
|
|
flag.next = 0
|
|
|
|
if count == MAXVAL:
|
|
|
|
flag.next = 1
|
|
|
|
count.next = 0
|
|
|
|
else:
|
|
|
|
count.next = count + 1
|
|
|
|
|
|
|
|
return logic
|
|
|
|
|
|
|
|
|
|
|
|
def timer_var(flag, clock, reset, MAXVAL):
|
|
|
|
|
|
|
|
@instance
|
|
|
|
def logic():
|
|
|
|
count = intbv(0, min=0, max=MAXVAL+1)
|
|
|
|
while True:
|
|
|
|
yield clock.posedge, reset.posedge
|
|
|
|
if reset == 1:
|
|
|
|
count[:] = 0
|
|
|
|
else:
|
|
|
|
flag.next = 0
|
|
|
|
if count == MAXVAL:
|
|
|
|
flag.next = 1
|
|
|
|
count[:] = 0
|
|
|
|
else:
|
|
|
|
count += 1
|
|
|
|
|
|
|
|
return logic
|
|
|
|
|
|
|
|
|