chiffre
chiffre copied to clipboard
Injecting Faults into Member of Aggregate Type
When attempting to inject faults into a (ground) member of an aggregate type, FIRRTL reports an error during one of its passes. For example, if I try to inject an error into the program counter of Rocket Chip, which is defined in IBuf.scala, using:
isFaulty(buf.pc, "main", classOf[inject.StuckAt])
Chiffre reports the following circuit changes:
[info] IBuf
[info] defines:
[info] - inst StuckAt of StuckAt
[info] - wire buf_.pc_fault : UInt<40>
[info] connects:
[info] - StuckAt.clock <= clock
[info] - StuckAt.reset <= reset
[info] - StuckAt.io.in <= asUInt(buf_.pc)
[info] - buf_.pc_fault <= asUInt(StuckAt.io.out)
[info] - StuckAt.io.scan.en is invalid
[info] - StuckAt.io.scan.clk is invalid
[info] - StuckAt.io.scan.in is invalid
[info] modules:
[info] - StuckAt
[info] annotations:
[info] - ScanChainDescriptionAnnotation(ModuleName(StuckAt,CircuitName(StuckAt)),main,StuckAtInjectorInfo(40))
[info] - SinkAnnotation(ComponentName(StuckAt.io.scan.en,ModuleName(IBuf,CircuitName(TestHarness))),scan_en)
[info] - SinkAnnotation(ComponentName(StuckAt.io.scan.clk,ModuleName(IBuf,CircuitName(TestHarness))),scan_clk)
[info] - ScanChainInjectorAnnotation(ComponentName(buf_.pc,ModuleName(IBuf,CircuitName(TestHarness))),main,StuckAt,StuckAt)
[info] - ScanChainAnnotation(ComponentName(StuckAt.io.scan.in,ModuleName(IBuf,CircuitName(TestHarness))),slave,in,main,Some(ComponentName(buf_.pc,ModuleName(IBuf,CircuitName(TestHarness)))))
[info] - ScanChainAnnotation(ComponentName(StuckAt.io.scan.out,ModuleName(IBuf,CircuitName(TestHarness))),slave,out,main,Some(ComponentName(buf_.pc,ModuleName(IBuf,CircuitName(TestHarness)))))
[info] renames:
[info] - buf_.pc: buf_.pc_fault
But then FIRRTL eventually reports the following error during transform CheckInitialization
:
Exception in thread "main" firrtl.passes.CheckInitialization$RefNotInitializedException: : [module IBuf] Reference buf_.pc_fault is not fully initialized.
: buf_.pc_fault <= VOID
at firrtl.passes.CheckInitialization$$anonfun$firrtl$passes$CheckInitialization$$checkInitM$1$2.apply(CheckInitialization.scala:83)
at firrtl.passes.CheckInitialization$$anonfun$firrtl$passes$CheckInitialization$$checkInitM$1$2.apply(CheckInitialization.scala:78)
at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:733)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
at scala.collection.mutable.HashMap$$anonfun$foreach$1.apply(HashMap.scala:130)
at scala.collection.mutable.HashTable$class.foreachEntry(HashTable.scala:236)
at scala.collection.mutable.HashMap.foreachEntry(HashMap.scala:40)
at scala.collection.mutable.HashMap.foreach(HashMap.scala:130)
at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:732)
at firrtl.passes.CheckInitialization$.firrtl$passes$CheckInitialization$$checkInitM$1(CheckInitialization.scala:78)
at firrtl.passes.CheckInitialization$$anonfun$run$1.apply(CheckInitialization.scala:89)
at firrtl.passes.CheckInitialization$$anonfun$run$1.apply(CheckInitialization.scala:88)
at scala.collection.immutable.List.foreach(List.scala:392)
at firrtl.passes.CheckInitialization$.run(CheckInitialization.scala:88)
at firrtl.passes.Pass$class.execute(Passes.scala:24)
at firrtl.passes.CheckInitialization$.execute(CheckInitialization.scala:17)
at firrtl.Transform$$anonfun$2.apply(Compiler.scala:257)
at firrtl.Transform$$anonfun$2.apply(Compiler.scala:257)
at firrtl.Utils$.time(Utils.scala:182)
at firrtl.Transform.runTransform(Compiler.scala:257)
at chiffre.passes.FaultInstrumentationTransform$$anonfun$2.apply(FaultInstrumentationTransform.scala:68)
at chiffre.passes.FaultInstrumentationTransform$$anonfun$2.apply(FaultInstrumentationTransform.scala:68)
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:124)
at scala.collection.immutable.List.foldLeft(List.scala:84)
at chiffre.passes.FaultInstrumentationTransform.execute(FaultInstrumentationTransform.scala:68)
at firrtl.Transform$$anonfun$2.apply(Compiler.scala:257)
at firrtl.Transform$$anonfun$2.apply(Compiler.scala:257)
at firrtl.Utils$.time(Utils.scala:182)
at firrtl.Transform.runTransform(Compiler.scala:257)
at firrtl.Compiler$$anonfun$7$$anonfun$apply$8.apply(Compiler.scala:471)
at firrtl.Compiler$$anonfun$7$$anonfun$apply$8.apply(Compiler.scala:471)
at scala.collection.LinearSeqOptimized$class.foldLeft(LinearSeqOptimized.scala:124)
at scala.collection.immutable.List.foldLeft(List.scala:84)
at firrtl.Compiler$$anonfun$7.apply(Compiler.scala:471)
at firrtl.Compiler$$anonfun$7.apply(Compiler.scala:471)
at firrtl.Utils$.time(Utils.scala:182)
at firrtl.Compiler$class.compile(Compiler.scala:470)
at firrtl.VerilogCompiler.compile(LoweringCompilers.scala:140)
at firrtl.Driver$$anonfun$execute$1.apply(Driver.scala:226)
at firrtl.Driver$$anonfun$execute$1.apply(Driver.scala:210)
at logger.Logger$$anonfun$makeScope$1.apply(Logger.scala:129)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at logger.Logger$.makeScope(Logger.scala:127)
at firrtl.Driver$.execute(Driver.scala:210)
at firrtl.Driver$.execute(Driver.scala:287)
at firrtl.Driver$.main(Driver.scala:303)
at firrtl.Driver.main(Driver.scala)
For some reason, the connection made to buf_.pc_fault
that is reported in Chiffre's log output appears to either get erased during one of the later transforms or not actually get created in the first place.
Should be fixed via #18.
This actually isn't fixed by #18. Adding this feature is more complicated, because it requires connecting fields one by one, intercepting the ones that are annotated and replacing them with injector outputs, rather than in bulk as #18 does. I haven't pursued this because it occurred to me that you can get similar results using a bit mask, although that does get a little unwieldy for large bundles.
You're right! I read this too quickly.
Your existing workaround of injecting into the bundle and then bit-masking seems reasonable for the time being.