Queue formal proof based on one-entry FIFO equivalence #11
No reviewers
Labels
No labels
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: libre-chip/fayalite#11
Loading…
Reference in a new issue
No description provided.
Delete branch "cesar/fayalite:fifo-proof"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
As it turns out, by filtering the observed input and output streams of a FIFO to consider just one in every N reads and writes (where N is the FIFO capacity), we can indeed reduce it to an one-entry FIFO, which is much easier to verify.
In particular, any counterexample of the FIFO behaving badly would be caught by one of the filtered versions (one which happens to be in phase with the offending input or output).
I do think the idea would be better explained in more details in a separate web page, instead of terse comments in the source code.
In this branch, I'm rewriting the existing FIFO proof to use this method. Or, maybe we could keep both versions? I do expect it to complete much faster, though.
Also, I replaced the hard-coded maximum bit-length of indices and counters (32 bits) by parameterized ones, I see no reason not to.
For now, I only checked the proof in Bounded Model Check mode. I'll start on Induction next. Like all designs involving memory, I'm expecting it to be somewhat intrusive to the queue module, unless we move the full proof inside of it.
@ -196,3 +196,3 @@
format_args!("test_queue_{capacity}_{inp_ready_is_comb}_{out_valid_is_comb}"),
queue_test(capacity, inp_ready_is_comb, out_valid_is_comb),
FormalMode::Prove,
FormalMode::BMC,
imo this should be changed this back to Prove before merging. ah, you already said that...
if you're going to change the queue module's interface (adding more outputs for tests), please mark them with
#[cfg(test)]
and#[doc(hidden)]
since they aren't intended to be available when just using the queueWIP: Queue formal proof based on one-entry FIFO equivalenceto Queue formal proof based on one-entry FIFO equivalenceThe induction proof works! I think my work is complete on this branch.
nice! there's some minor issues then I think it's ready to merge!
@ -52,0 +52,4 @@
/// This debug port is only meant to assist the formal proof of the queue.
#[doc(hidden)]
#[hdl]
pub struct QueueDebugPort<Element, Index> {
this should also be marked
#[cfg(test)]
since it only needs to be there when running the tests.Could you please try it on your end? If I do it,
cargo check
gives me an error:Note that the above code is also in a
#[cfg(test)]
block, the error makes no sense to me.ah, the
#[hdl_module]
macro doesn't properly handle additional attributes on IO ports...i'll work on fixing that soon, probably today. basically it generates an#[hdl] struct
from the list of IO ports but doesn't copy attributes to that struct's fields. though, i think the#[hdl]
macro doesn't handle#[cfg(...)]
on fields either...i'll fix that too.if you fix the grammar mistakes, i'll merge this (edit: nvm it's broken due to
#[cfg(...)]
not working correctly) and will fix the#[cfg(...)]
stuff later when i fix the#[hdl]
and#[hdl_module]
attribute macros.actually, since it doesn't properly handle
#[cfg(...)]
, the#[cfg(test)]
block will makequeue
unusable outside of runningfayalite
's tests, since the generated struct will still have the debugging port's field, but the module's body won't so it'll cause an assertion failure if you try to use the module.so, i'll wait on merging this until the
#[cfg(...)]
stuff gets fixed. sorryok, I got it to work when adding
#[cfg(test)]
and merging in the latest master. if you want to rebase on master, i can merge this.Rebased on master. Took the opportunity to fix the issues directly on the commits that introduced them.
Ended up pushing a "fifo-proof" branch on the main repository by mistake, sorry about that. Already deleted the branch. Master was not affected.
@ -206,0 +235,4 @@
/// The strategy derives from the observation that, if we filter its
/// input and output streams to consider just one in every N reads and
/// writes (where N is the FIFO capacity), then the FIFO effectively
/// behaves as an one-entry FIFO.
here use
a one-entry
-- theo
makes aw
sound so is treated as a consonant fora
vs.an
@ -318,0 +361,4 @@
connect(out_firing_data, ReadyValid::firing_data(dut.out));
}
// Implement an one-entry FIFO and ensure its equivalence to the
same here
8d7c691002
to3771cea78e
thanks! also nice that you started signing your commits :)