-
Notifications
You must be signed in to change notification settings - Fork 97
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
Powdr/RISCV executor #679
Powdr/RISCV executor #679
Conversation
b53d14f
to
22f76ec
Compare
b4071e1
to
d2a1bf3
Compare
91d16b6
to
5731b7b
Compare
d2a1bf3
to
c431978
Compare
powdr_cli/Cargo.toml
Outdated
@@ -4,7 +4,7 @@ version = "0.1.0" | |||
edition = "2021" | |||
|
|||
[features] | |||
default = [] # halo2 is disabled by default | |||
default = [] # halo2 is disabled by default |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why the extra space?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code formatter did this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you undo it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I asked chatgpt how to disable code formatting for Cargo.toml.
// remove all asm (except external instructions) | ||
log::debug!("Run asm_to_pil analysis step"); | ||
let file = asm_to_pil::compile(file); | ||
monitor.push(&file); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the best point to perform the execution, so the last step was separated into another function.
riscv_executor/src/lib.rs
Outdated
use number::{BigInt, FieldElement}; | ||
|
||
#[derive(Clone, Copy)] | ||
pub union Elem { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not an enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because the same binary string must be interpreted as either unsigned or signed, depending on the context.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ah I see
There must be something weird going on: I ran this on an empty Rust main function, and at the end the
A few weird things:
maybe I just don't understand yet how this works |
If I run it on this it seems to get into an infinite loop and runs OOM. |
d6443b2
to
cd23c52
Compare
(rebased) |
ok it looks like |
Ok if I print everything at the end properly it seems correct, although I don't know why pc=1 at the end:
|
I don't understand why there are 2 |
5731b7b
to
9130a65
Compare
Each line is a row |
analysis/src/lib.rs
Outdated
Ok(file) | ||
} | ||
|
||
pub fn consume_asm<T: FieldElement>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consume
is kind of weird because it does not say what it converts it to.
What about calling this convert_analyzed_to_pil
and the other convert_asm_to_pil
or something?
riscv_executor/src/lib.rs
Outdated
} | ||
|
||
/// set next value of register | ||
pub(crate) fn s(&mut self, idx: &str, value: impl Into<Elem>) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be much better readable if s
would return a mutable reference to the value?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my subjective opinion, no.
Instead of:
obj.s("pc", x + 42);
it would be
*obj.s("pc") = (x + 42).into();
or more conventionally
*obj.g_mut("pc") = (x + 42).into();
But most importantly, I can't have the logic to handle PC or x0 if I return a mut reference.
8c86254
to
883d55e
Compare
d9ecec4
to
a08fc5a
Compare
452dbd1
to
5862cef
Compare
rebased, last commit needs to be doubled checked because of some AST changes |
a0df34f
to
9ca3665
Compare
ce31e9f
to
80e2f87
Compare
riscv_executor/src/lib.rs
Outdated
"jump_and_link_dyn" => { | ||
let pc = self.proc.g("pc"); | ||
self.proc.s("x1", pc.u() + 1); | ||
self.proc.s("pc", args[0]); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe also add a set_pc
function? Is it actually legal to set the PC in a regular instruction? If not, we could remove the special case in the s
function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean, like in addi pc,pc,42
? Some random interwebs slides says it is not possible. I'll do it.
But still find the s(key, value)
solution more elegant than returning mut &
, and I still need to handle the special case of x0
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
f4c5077
to
070b6df
Compare
feeb9ba
to
edd1f10
Compare
rebased & squashed |
edd1f10
to
0b374b1
Compare
0b374b1
to
cd4449e
Compare
No description provided.