-
Notifications
You must be signed in to change notification settings - Fork 50
Modules, Hierarchy, Composability
Julian Kemmerer edited this page Oct 15, 2020
·
24 revisions
// sub.c
output_t sub(input_t input)
{
// Do work on input to get output
return work(input);
}
// top.c
#include "sub.c"
output_t top(input_t input)
{
return sub(input);
}
// top.c
// Globally visible ports/wires with built in READ and WRITE
input_t top_to_sub; // Output from top, input to sub
output_t sub_to_top; // Input into top, output from sub
output_t top(input_t input)
{
WRITE(top_to_sub, input);
return READ(sub_to_top);
}
// sub.c
#include "top.c"
void sub()
{
// Do work on input to get output
input_t input = READ(top_to_sub);
output_t output = work(input);
WRITE(sub_to_top, output);
}