2005-12-09 17:01:07 +00:00
|
|
|
from myhdl import Signal, delay, always, now, Simulation
|
2003-01-30 23:04:36 +00:00
|
|
|
|
2005-12-09 17:01:07 +00:00
|
|
|
def ClkDriver(clk):
|
2003-01-30 23:04:36 +00:00
|
|
|
|
2005-12-11 16:30:52 +00:00
|
|
|
halfPeriod = delay(10)
|
|
|
|
|
|
|
|
@always(halfPeriod)
|
2005-12-09 17:01:07 +00:00
|
|
|
def driveClk():
|
|
|
|
clk.next = not clk
|
2003-01-30 23:04:36 +00:00
|
|
|
|
2005-12-09 17:01:07 +00:00
|
|
|
return driveClk
|
|
|
|
|
|
|
|
|
|
|
|
def HelloWorld(clk):
|
|
|
|
|
|
|
|
@always(clk.posedge)
|
|
|
|
def sayHello():
|
2003-01-30 23:04:36 +00:00
|
|
|
print "%s Hello World!" % now()
|
|
|
|
|
2005-12-09 17:01:07 +00:00
|
|
|
return sayHello
|
|
|
|
|
|
|
|
|
|
|
|
|
2003-06-30 14:24:23 +00:00
|
|
|
def main():
|
2005-12-09 17:01:07 +00:00
|
|
|
clk = Signal(0)
|
|
|
|
clkdriver_inst = ClkDriver(clk)
|
|
|
|
hello_inst = HelloWorld(clk)
|
|
|
|
sim = Simulation(clkdriver_inst, hello_inst)
|
2003-06-30 14:24:23 +00:00
|
|
|
sim.run(50)
|
2003-01-30 23:04:36 +00:00
|
|
|
|
2003-06-30 14:24:23 +00:00
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|