Python 2.4 introduced a new feature called decorators. MyHDL 0.5 takes advantage of this new feature by defining a number of decorators that facilitate hardware descriptions. However, many users may not yet be familiar with decorators. Therefore, an introduction is included here.
A decorator consists of special syntax in front of a function declaration. It refers to a decorator function. The decorator function automatically transforms the declared function into some other callable object.
A decorator function deco is used in a decorator statement as follows:
@deco
def func(arg1, arg2, ...):
<body>
This code is equivalent to the following:
def func(arg1, arg2, ...):
<body>
func = deco(func)
Note that the decorator statement goes directly in front of the function declaration, and that the function name func is automatically reused for the final result.
MyHDL 0.5 uses decorators to create ready-to-simulate generators from local function definitions. Their functionality and usage will be described extensively in this manual.
For more info about Python decorators, consult the on-line Python documentation, e.g. at http://www.python.org/doc/2.4/whatsnew/node6.html.