-
Notifications
You must be signed in to change notification settings - Fork 4
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
WIP: integration test #368
base: master
Are you sure you want to change the base?
Conversation
85fcacd
to
6e3799c
Compare
8c31993
to
80a1cd4
Compare
b3648c9
to
447001f
Compare
aed3b11
to
9dd45db
Compare
We need to resolve #245 to support writes to X0. |
#368 + #369 --------- Co-authored-by: Aurélien Nicolas <[email protected]>
This is just a temporary fix of the memory errors caused by wrong assignment to memory init / finalize table. --------- Co-authored-by: naure <[email protected]>
889973a
to
c5fef04
Compare
54a7488
to
efed100
Compare
e8cf906
to
bb0cbbf
Compare
Summary of changes
|
@kunxian-xia Ready for review. |
@@ -62,10 +62,15 @@ pub struct ProgramDataTable; | |||
impl NonVolatileTable for ProgramDataTable { | |||
const RAM_TYPE: RAMType = RAMType::Memory; | |||
const V_LIMBS: usize = 1; // See `MemoryExpr`. | |||
const WRITABLE: bool = false; | |||
const WRITABLE: bool = true; |
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 is this table writable?
0x4000_0000 | ||
} | ||
|
||
pub const fn program_data_end(&self) -> Addr { | ||
0x3000_1000 - 1 | ||
0x5000_0000 - 1 |
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 leave some comments for these two magic numbers.
"{} len {} must be a power of 2", | ||
NVRAM::name(), | ||
NVRAM::len() | ||
); |
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.
Nitpick: It's also good to assert that NVRAM::OFFSET_ADDR
and NVRAM::END_ADDR
are divisible by 4.
let unused_addrs = (NVRAM::OFFSET_ADDR..NVRAM::END_ADDR) | ||
.step_by(WORD_SIZE) | ||
.filter(|&addr| !accessed_addrs.contains(&addr)) | ||
.take(NVRAM::len() - init_mem.len()) |
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.
(NVRAM::END_ADDR - NVRAM::OFFSET_ADDR) / 4 != NVRAM::len()
?
@@ -111,7 +112,12 @@ impl<NVRAM: NonVolatileTable + Send + Sync + Clone> NonVolatileTableConfig<NVRAM | |||
num_fixed: usize, | |||
init_mem: &[MemInitRecord], | |||
) -> RowMajorMatrix<F> { | |||
assert!(NVRAM::len().is_power_of_two()); | |||
assert!( |
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.
According to L109, it's also good to assert that init_mem
is sorted.
self.addr, | ||
(NVRAM::addr(paddin_entry_start + i) as u64).into() | ||
); | ||
init_table |
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 think the correct way to assign init_table is like this because the init_table.addr
will not depend on init_mem
.
init_table
.par_iter_mut()
.zip((NVRAM::OFFSET_ADDR..NVRAM::END_ADDR).step_by(WORD_SIZE).take(NVRAM::len()))
.for_each(|(row, addr)| {
if accessed_addrs.contains(addr) {
// assign `init_mem.value` to `self.init_v`
} else {
// assign zero to `self.init_v`
}
});
set_val!(row, self.final_cycle, 0u64); | ||
}); | ||
} | ||
final_table |
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 think the assignment of final table is incorrect if [item.addr for item in init_mem] != [item.addr for item in final_mem]
. For example, if the addresses in init_mem
are vec![4, 12, 16]
and the addresses in final_mem
are vec![12, 16, 20]
, then this cause prod_r != prod_w
error.
@@ -306,6 +317,15 @@ impl<NVRAM: NonVolatileTable + Send + Sync + Clone> PubIOTableConfig<NVRAM> { | |||
set_val!(row, self.final_cycle, rec.cycle); |
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 think the old assignment is incorrect as it assumes that
final_mem
.iter()
.enumerate()
.for_each(|(i, rec)| {
assert_eq!(NVRAM::addr(i), rec.addr);
});
}); | ||
} | ||
set_val!(row, self.addr, addr as u64); | ||
} |
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.
Forget to assign 0 to self.final_cycle
?
let stack_addrs = (1..=STACK_SIZE) | ||
.map(|i| STACK_TOP - i * WORD_SIZE as u32) | ||
.map(|addr| MemInitRecord { addr, value: 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.
why does stack occurs in program data section?
This PR aims to add an integration test in which we proves the
fibonacci
rust program. The goal will be achieved by two steps:This PR currently builds on top of the changes to
ceno_emul
in #487.