Synthesizable Higher-Order Patterns (HOPs) for C++
State-of-the-art C/C++ hardware synthesis tools lack abstractions and conveniences that are pervasive in modern software languages. Higher-order functions are particularly important as they increase productivity by concisely representing common design patterns. Providing these in hardware design environments improve the accessibility of hardware tools for software engineers by providing familiar interfaces and abstractions.
Higher-order functions are difficult to implement in C/C++ hardware synthesis tools because parallel hardware must be defined statically: types, functions, interfaces, and loops must be resolved at compile time. In contrast, software higher order functions rely on dynamic features: dynamic allocation, dispatch, typing, and loop bounds.
This project created an open-source library of higher-order functions synthesizable in C/C++ hardware development tools. We concluded that our library produces results that are generally statistically indistinguishable non-recursive techniques, but with increased flexibility and the possibility of code reuse.
HOPS (this link opens in a new window) by drichmond (this link opens in a new window)
Synthesizable Higher-Order Functions (Patterns) for C++
Here is an example of using the map and reduce higher order functions in Python:
def mulby2(x):
return x * 2
def add(x, y):
return x + y
l = [1, 2, 3, 4]
m = map(mulby2, l)
r = reduce(add, m)
print(r) # prints '20'
Here is an example of using the map and reduce synthesizable higher order functions from the HOPs library:
// Implementation of mulby2 and add not shown
array<int, 4> l = {1, 2, 3, 4};
m = map(mulby2, l);
r = reduce(add, m);