From 643816d5b5c17ac82efae7b2f6afab531c922390 Mon Sep 17 00:00:00 2001 From: Jacob Lifshay Date: Wed, 4 Dec 2024 21:03:29 -0800 Subject: [PATCH] vcd: handle enums with fields --- crates/fayalite/src/sim.rs | 2 +- crates/fayalite/src/sim/vcd.rs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/crates/fayalite/src/sim.rs b/crates/fayalite/src/sim.rs index ea09e83..009e599 100644 --- a/crates/fayalite/src/sim.rs +++ b/crates/fayalite/src/sim.rs @@ -1428,7 +1428,7 @@ impl Compiler { index: discriminant, ty, }), - name, + name: "$tag".intern(), ty, flow, }; diff --git a/crates/fayalite/src/sim/vcd.rs b/crates/fayalite/src/sim/vcd.rs index 1ec2aeb..8b5a58c 100644 --- a/crates/fayalite/src/sim/vcd.rs +++ b/crates/fayalite/src/sim/vcd.rs @@ -491,7 +491,21 @@ impl WriteTrace for TraceArray { impl WriteTrace for TraceEnumWithFields { fn write_trace(self, writer: &mut W, arg: A) -> io::Result<()> { - todo!() + let arg = arg.in_type(); + let Self { + name, + discriminant, + non_empty_fields, + ty: _, + flow: _, + } = self; + write_vcd_scope(writer, "struct", &name, |writer| { + discriminant.write_trace(writer, arg)?; + for field in non_empty_fields { + field.write_trace(writer, arg)?; + } + Ok(()) + }) } }