Skip to content

Modules, Hierarchy, Composability

Julian Kemmerer edited this page Oct 15, 2020 · 24 revisions

stylediagram

Feed forward nested functions

// 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);
}

Point to point wires between modules

// 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);
}

Using both