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

Make clash-ffi a haskell library + FFI interface tests #2429

Merged
merged 5 commits into from
Mar 22, 2023
Merged

Conversation

kleinreact
Copy link
Member

@kleinreact kleinreact commented Feb 27, 2023

This PR reorganizes clash-ffi to be used like a normal Haskell library as part of an external project.

To this end, clash-ffi now gets built as a standard Haskell library, which then is imported by the external project setting up the specific simulator actions. The external project is built as a foreign-library, which then can be loaded into the simulator. This approach introduces more flexibility in the sense that every specific simulation application results in its own VPI-loadable shared library. This is the way of usage, as it is intended by standardized interfaces, like VPI, VHPI or FLI.

A guideline for setting up a project using clash-ffi has been added to the README.md.

A small example project has been added to the example folder. It is a standalone project, since integrating it into the clash-ffi.cabal causes cabal to shorten the clash-ffi library link, making it more complicated to load the library inside the simulator.

The PR also introduces a test suite, which checks that data does not get corrupted during the transfer via the FFI. After introducing the tests some bugs could be identified, which have been fixed as well.

@martijnbastiaan
Copy link
Member

A quick drive-by comment: cocotb builds one .so file (upon installation) and dynamically loads test benches / device under test drivers. We could replicate this behavior using hint. Still, the current proposal is an improvement over the status-quo. (And whether we want to go the hint route is up for debate.)

Copy link
Member

@martijnbastiaan martijnbastiaan left a comment

Choose a reason for hiding this comment

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

Very nice. Could you add the example to CI? Just GitLab CI should be good. Let me know if you need help.

@martijnbastiaan
Copy link
Member

Thanks! Feel free to (enable auto-)merge.

@kleinreact kleinreact force-pushed the ffi-fixes branch 2 times, most recently from c48225d to 082624f Compare March 3, 2023 09:31
Copy link
Member

@DigitalBrains1 DigitalBrains1 left a comment

Choose a reason for hiding this comment

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

I was just glancing through this and notice some natural language thingies.

clash-ffi/example/run-iverilog.sh Outdated Show resolved Hide resolved
clash-ffi/example/run-iverilog.sh Outdated Show resolved Hide resolved
@kleinreact kleinreact changed the title Make clash-ffi a haskell library Make clash-ffi a haskell library + FFI interface tests Mar 20, 2023
@kleinreact kleinreact force-pushed the ffi-fixes branch 3 times, most recently from 929f3e2 to b48e56b Compare March 20, 2023 11:17
Copy link
Member

@martijnbastiaan martijnbastiaan left a comment

Choose a reason for hiding this comment

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

I really like the testsuite and the example you've added. LGTM!

@kleinreact kleinreact merged commit e0da461 into master Mar 22, 2023
@kleinreact kleinreact deleted the ffi-fixes branch March 22, 2023 13:56
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.

3 participants