Compare commits

...

2 commits

Author SHA1 Message Date
8616ee4737
tests/sim: test_enums works!
All checks were successful
/ deps (push) Successful in 17s
/ test (push) Successful in 5m18s
/ deps (pull_request) Successful in 14s
/ test (pull_request) Successful in 5m20s
2024-12-11 00:01:04 -08:00
5087f16099
sim: fix assignments graph by properly including conditions as assignment inputs 2024-12-11 00:00:21 -08:00
4 changed files with 1760 additions and 1 deletions

View file

@ -458,6 +458,9 @@ impl Assignments {
slot_readers
.keys_for_assignment(assignment_index)
.extend([&assignment.inputs]);
slot_readers
.keys_for_assignment(assignment_index)
.extend(&assignment.conditions);
let SlotSet(TypeParts {
small_slots,
big_slots,
@ -1400,6 +1403,30 @@ impl<'a> Extend<&'a SlotSet> for SlotToAssignmentIndexFullMapKeysForAssignment<'
}
}
impl<'a> Extend<&'a Cond> for SlotToAssignmentIndexFullMapKeysForAssignment<'_> {
fn extend<T: IntoIterator<Item = &'a Cond>>(&mut self, iter: T) {
iter.into_iter().for_each(|cond| match cond.body {
CondBody::IfTrue { cond } | CondBody::IfFalse { cond } => {
let CompiledValue {
range:
TypeIndexRange {
small_slots,
big_slots,
},
layout: _,
write: _,
} = cond;
self.extend(small_slots.iter());
self.extend(big_slots.iter());
}
CondBody::MatchArm {
discriminant,
variant_index: _,
} => self.extend([discriminant]),
});
}
}
impl Assignment {
fn new(
conditions: Interned<[Cond]>,

View file

@ -363,7 +363,6 @@ pub fn enums() {
}
}
#[cfg(todo)] // FIXME: enum lowering currently broken
#[hdl]
#[test]
fn test_enums() {

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,94 @@
$timescale 1 ps $end
$scope module enums $end
$scope struct cd $end
$var wire 1 ! clk $end
$var wire 1 " rst $end
$upscope $end
$var wire 1 # en $end
$var wire 2 $ which_in $end
$var wire 4 % data_in $end
$var wire 2 & which_out $end
$var wire 4 ' data_out $end
$scope struct the_reg $end
$var string 1 ( \$tag $end
$scope struct B $end
$var reg 1 ) \0 $end
$var reg 1 * \1 $end
$upscope $end
$scope struct C $end
$scope struct a $end
$var reg 1 + \[0] $end
$var reg 1 , \[1] $end
$upscope $end
$var reg 2 - b $end
$upscope $end
$upscope $end
$upscope $end
$enddefinitions $end
$dumpvars
0!
1"
0#
b0 $
b0 %
b0 &
b0 '
sA\x20(0) (
0)
0*
0+
0,
b0 -
$end
#1000000
1!
#1100000
0"
#2000000
0!
#3000000
1!
#4000000
1#
b1 $
0!
#5000000
1!
b1 &
sB\x20(1) (
#6000000
0#
b0 $
0!
#7000000
1!
#8000000
1#
b1 $
b1111 %
0!
#9000000
1!
b11 '
1)
1*
1+
1,
#10000000
0!
#11000000
1!
#12000000
b10 $
0!
#13000000
1!
b10 &
b1111 '
sC\x20(2) (
b11 -
#14000000
0!
#15000000
1!
#16000000