Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimal code to run LF on FlexPRET with uC runtime #2417

Closed
wants to merge 2 commits into from

Conversation

magnmaeh
Copy link
Member

@magnmaeh magnmaeh commented Oct 1, 2024

Currently a draft only

fun generateCtorDefinition() = with(PrependOperator) {
"""
| void ${reactor.name}_ctor(${reactor.name} *self, Environment *env) {
| size_t trigger_idx = 0;
| Reactor_ctor(&self->super, "${reactor.name}", env, ${if (numChildren > 0) "self->_children" else "NULL"}, $numChildren, ${if (reactor.reactions.size > 0) "self->_reactions" else "NULL"}, ${reactor.reactions.size}, ${if (numTriggers() > 0) "self->_triggers" else "NULL"}, ${numTriggers()});
| Reactor_ctor(&self->super, "${reactor.name}", env, NULL, ${if (numChildren > 0) "self->_children" else "NULL"}, $numChildren, ${if (reactor.reactions.size > 0) "self->_reactions" else "NULL"}, ${reactor.reactions.size}, ${if (numTriggers() > 0) "self->_triggers" else "NULL"}, ${numTriggers()});
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@erlingrj I had to add NULL here to make it compile, but I assume it should be self->parent for all reactors that are not the main reactor. This might be needed on the base branch as well?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Thanks. Unfortunately, I have made some changes to the reactor-uc API that are not reflected yet in the code-generator. I will try to bring everything up-to-date soon

@erlingrj
Copy link
Collaborator

erlingrj commented Oct 2, 2024

@magnmaeh, I am in the process of making some bigger changes to the reactor-uc API and will have to make some updates here in the code-generator as well. One key thing to realize is that we want the code generator to just output a CMake/Make project that can be included in another project. I.e. the main CMakeLists.txt lives outside, and also the main function. For the POSIX platform we have added a main function because it is convenient for quick testing. But we envision that for other platforms we generate a subdirectory in a project and include it in the existing build-flow

@erlingrj
Copy link
Collaborator

erlingrj commented Oct 3, 2024

@magnmaeh I have now merged in comprehensive changes to lingua-franca and reactor-uc. Please check them. To support FlexPRET we should require very little changes to the code-generator. Only in the platform-specific CMake.

I am planning to fork lingua-franca and bring it into the reactor-uc repo so we just have a simple monorepo while we develop the runtime and code-generator and reach a stable v0.1

@magnmaeh
Copy link
Member Author

magnmaeh commented Oct 3, 2024

Great work! I'll have a look :)

@magnmaeh
Copy link
Member Author

magnmaeh commented Oct 3, 2024

I think this is ready for review as well. But I guess you don't want the main/CMake and main/main.c files to be part of the PR? I used it just to verify that it worked, which it did.

After your additions it even magically solved my one issue with it not printing the "Hello world from FlexPRET!". So that was nice :)

Copy link
Collaborator

@erlingrj erlingrj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Looks mostly good, just a question about the including the toolchain file

Comment on lines +54 to +61
|set(PLATFORM "FLEXPRET" CACHE STRING "Platform to target")
|
|if ($S{PLATFORM} STREQUAL "FLEXPRET")
| # Must include toolchain file before project(), otherwise cmake
| # will determine its own compiler settings
| include(${S}ENV{FP_SDK_PATH}/cmake/riscv-toolchain.cmake)
|endif()
|
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dont think this is necessary as long as the generated CMakeLists.txt is included from a project where the riscv-toolchain is include

@erlingrj
Copy link
Collaborator

erlingrj commented Oct 5, 2024

Can you instead add these changes directly to https://github.com/erlingrj/reactor-uc which now contains the code-generator also?

@erlingrj erlingrj closed this Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants