User manual
Tutorial: Using the logic estimator
LOGIC ESTIMATION SUMMARY FOR VERSION2 PROJECT
LONGEST PATH SUMMARY FOR VERSION2 PROJECT
The RecurseAdd macro expression can be re-written to build such an adder tree. This is achieved by
writing a recursive macro expression which locates the middle element of the array it has been asked to
add, then makes two calls to itself; one from
Bottom to Middle, and the other from Middle+1 to Top,
as shown below.
macro expr RecurseAdd(Array, Index) =
let macro expr RecurseAddAux(Array, Top, Bottom) =
let macro expr Middle = Bottom + (Top-Bottom)/2; in
select (Top == Bottom,
Array[Top],
RecurseAddAux(Array, Top, Middle + 1) +
RecurseAddAux(Array, Middle, Bottom));
in
RecurseAddAux(Array, Index, 0);
The
let...in syntax allows further macro expressions to be defined for use within the RecurseAdd
macro.
RecurseAdd is now only called once, and it calls RecurseAddAux, which is recursive. The
macro expression
Middle is also defined to locate the middle element of the array. When
RecurseAddAux is called, it checks to see if the Top and Bottom indices are equal, and if so it returns
the value from the specified array element. If
Top and Bottom are not equal, RecurseAddAux makes
two calls to itself with the top and bottom halves of the array, and adds the results together.
As well as producing a more efficient adder tree, this new version of
RecurseAdd will also result in
faster compile times. This style of writing recursive macros can be applied in a variety of situations, and
should be used whenever possible.
The improved version of
RecurseAdd is used in the Version3 project in the TutorialFIR workspace,
accessible from
Start>Programs>Celoxica>Platform Developer's Kit>Tutorials>TutorialFIR on the Start Menu.
www.celoxica.com
Page 110