PipelineC
PipelineC copied to clipboard
Allow FSM style functions to be used as top level
Currently FSM style functions cannot be marked as top level MAIN
functions. This is because of the ready+valid handshake
that is built into the hardware implementation of these functions for inputs and outputs. Having those internal handshaking signals as top level IO is unlikely to be desired.
Instead a wrapper
MAIN function without inputs or outputs driving the handshake signals to the _FSM
module is used.
// Derived fsm from main
#include "main_FSM.h"
// Wrap up main FSM as top level
#pragma MAIN main_wrapper
void main_wrapper()
{
main_INPUT_t i;
i.input_valid = 1;
i.output_ready = 1;
main_OUTPUT_t o = main_FSM(i);
}
If the FSM function does not take arguments, and returns void then it should be possible to generate those constant valid+ready signals internally for the user. Use should be able to just mark FSM func as MAIN directly, ex. #pragma MAIN main
instead of the wrapper main function.
This should be handled as part of https://github.com/JulianKemmerer/PipelineC/issues/86 when it gets done
I was mistaken, this will not be part of #86 (in a good way that clarified things that #86)
An interesting thing to think about is how if you want multiple of the MAIN fsms - is that part of a #pragma MAIN_FSM my_func 2
for two instances? Keeping existing syntax lets these FSMS be wired up in any arrangement like modules in hdl - could have a grid array of interconnected instances of the MAIN for ex.