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

misc: add riscemu as an optional dependency #1019

Merged
merged 14 commits into from Jun 7, 2023
Merged

misc: add riscemu as an optional dependency #1019

merged 14 commits into from Jun 7, 2023

Conversation

superlopuh
Copy link
Member

@superlopuh superlopuh commented May 29, 2023

This PR adds riscemu as a dependency of xDSL, adds a target to xdsl-opt to emulate using riscemu, and adds some unit and filecheck tests.

@superlopuh superlopuh self-assigned this May 29, 2023
xdsl/dialects/riscv.py Outdated Show resolved Hide resolved
xdsl/dialects/riscv.py Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented May 29, 2023

Codecov Report

Patch coverage: 98.55% and project coverage change: +0.08 🎉

Comparison is base (a77fc33) 86.71% compared to head (fba7804) 86.79%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1019      +/-   ##
==========================================
+ Coverage   86.71%   86.79%   +0.08%     
==========================================
  Files         132      134       +2     
  Lines       20686    20813     +127     
  Branches     3129     3130       +1     
==========================================
+ Hits        17938    18065     +127     
+ Misses       2234     2231       -3     
- Partials      514      517       +3     
Impacted Files Coverage Δ
xdsl/interpreters/riscv_emulator.py 93.93% <93.93%> (ø)
tests/dialects/test_riscv.py 100.00% <100.00%> (ø)
tests/interpreters/test_riscv_emulator.py 100.00% <100.00%> (ø)
xdsl/dialects/riscv.py 86.99% <100.00%> (+0.43%) ⬆️
xdsl/xdsl_opt_main.py 98.24% <100.00%> (+0.04%) ⬆️

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@AntonLydike
Copy link
Collaborator

add pyproject.toml

Finally an excuse to move riscemu to poetry! Lovely!

@AntonLydike
Copy link
Collaborator

I guess a way to capture stdout from riscemu is also wanted soon then?

@superlopuh
Copy link
Member Author

Yeah would be great. In the xdsl interpreter, I added an IO to the interpreter class, which all printers print to, would be nice to have a similar thing in riscemu

@superlopuh superlopuh force-pushed the sasha/riscemu branch 3 times, most recently from a38275d to f017ad9 Compare June 1, 2023 21:50
@tobiasgrosser
Copy link
Contributor

I think adding riscemu as an optional dependency is OK. It has no binary requirements and is reasonably lightweight. It will also allow us to have better notebooks and have things work 'out of the box'.

@superlopuh
Copy link
Member Author

Ok @AntonLydike I think the only thing that we'd need is a new riscemu version with all the changes in the commit, and we should be good to merge!

Copy link
Collaborator

@webmiche webmiche left a comment

Choose a reason for hiding this comment

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

Nice, this is really cool!

Comment on lines 10 to 11
from ..emulator.emulator_iop import RV_Debug, run_riscv
from .utils import riscv_code
Copy link
Collaborator

Choose a reason for hiding this comment

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

As usual, I am not very happy about relative imports. So I pose the classic question: Could we integrate this more deeply into xDSL? If we want, we could have a requirements file for only running with riscemu as the backend 🤔

Copy link
Member Author

Choose a reason for hiding this comment

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

Why don't you like relative imports? I generally like them more

Copy link
Member Author

Choose a reason for hiding this comment

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

But yeah this file would move to xdsl before I open the PR up for review :)

Copy link
Collaborator

Choose a reason for hiding this comment

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

It feels quite rigid to me, making things depend on the folder structure it is used in. Then again, that's always the case in python world 🤔

@superlopuh superlopuh changed the title [WIP] add riscemu as a dependency misc: add riscemu as an optional dependency Jun 6, 2023
@superlopuh superlopuh marked this pull request as ready for review June 6, 2023 19:43
Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't sure where to put this xdsl/interpreters seemed most appropriate, happy to take suggestions

Copy link
Collaborator

@math-fehr math-fehr left a comment

Choose a reason for hiding this comment

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

👍

@superlopuh superlopuh merged commit bfd5599 into main Jun 7, 2023
12 checks passed
@superlopuh superlopuh deleted the sasha/riscemu branch June 7, 2023 09:54
Comment on lines +4 to +9
from riscemu.config import RunConfig
from riscemu import RV32I, RV32M
from riscemu.CPU import UserModeCPU
from riscemu.parser import AssemblyFileLoader
from riscemu.instructions.instruction_set import InstructionSet
from riscemu.types.instruction import Instruction
Copy link
Collaborator

Choose a reason for hiding this comment

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

This should probably be in a try .. catch ... block somewhere instead of the top level?

Copy link
Member Author

Choose a reason for hiding this comment

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

See #1094

cigarichard pushed a commit to cigarichard/xdsl that referenced this pull request Jun 17, 2023
This PR adds riscemu as a dependency of xDSL, adds a target to xdsl-opt
to emulate using riscemu, and adds some unit and filecheck tests.
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.

None yet

6 participants