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

53 lines
645 B
Python
Raw Normal View History

2008-11-22 22:40:25 +01:00
from myhdl import *
def inc_comb(nextCount, count, n):
@always(count)
def logic():
# do nothing here
pass
nextCount.driven = "wire"
return logic
inc_comb.verilog_code =\
2008-11-22 22:40:25 +01:00
"""
assign $nextCount = ($count + 1) % $n;
2008-11-22 22:40:25 +01:00
"""
inc_comb.vhdl_code =\
2008-11-22 22:40:25 +01:00
"""
$nextCount <= ($count + 1) mod $n;
2008-11-22 22:40:25 +01:00
"""
def main():
m = 8
n = 2 ** m
count = Signal(intbv(0)[m:])
nextCount = Signal(intbv(0)[m:])
toVerilog(inc_comb, nextCount, count, n)
toVHDL(inc_comb, nextCount, count, n)
if __name__ == '__main__':
main()