Dataset Viewer
Auto-converted to Parquet Duplicate
task_id
stringclasses
24 values
path
stringlengths
30
94
left_context
stringlengths
13
172k
right_context
stringlengths
0
96.2k
groundtruth
stringlengths
10
665
crossfile_context
stringclasses
1 value
chiffre
chiffre/le-chiffre/src/main/scala/leChiffre/Header.scala
// Copyright 2017 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
// scalastyle:off magic.number case class ChiffreParameters ( checksumWidth: Int = 32, cycleWidth: Int = 32 ) trait LeChiffreH { implicit val p: Parameters val f_ECHO = 0 val f_CYCLE = 1 val f_ENABLE = 2 val cycleWidth = p(BuildChiffre).cycleWidth val checksumWidth = p(BuildChiffre).checksumWidth ...
case object BuildChiffre extends Field[ChiffreParameters]
chiffre
chiffre/le-chiffre/src/main/scala/leChiffre/LeChiffre.scala
// Copyright 2017 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
assert(RegNext(state) =/= s_ERROR, "[ERROR] LeChiffre: Hit error state\n") }
when (do_unknown) { state := s_ERROR }
chiffre
chiffre/le-chiffre/src/main/scala/rocketchip/Configs.scala
// Copyright 2017 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
class LeChiffreConfig extends Config(new WithLeChiffre ++ new DefaultConfig)
chiffre
chiffre/src/main/scala/chiffre/InjectorInfo.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
.stripMargin } def toBits(): String = fields.map(_.toBits()).mkString def bind(in: Seq[ScanField]): InjectorInfo = { val widthIn = in.foldLeft(0)( (l, r) => l + r.width ) if (width != widthIn) { throw new InjectorInfoBindingException(s"Unable to bind, widths differ ($width vs. $widthIn) betw...
|${fields.map(a => s"${a.serialize(tab + " ")}").mkString("\n")}"""
chiffre
chiffre/src/main/scala/chiffre/Instrumentation.scala
// Copyright 2017 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
def transformClass = classOf[FaultInstrumentationTransform] }) } }
def toFirrtl = FaultInjectionAnnotation(component.toNamed, id, gen)
chiffre
chiffre/src/main/scala/chiffre/ScanChain.scala
// Copyright 2017 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
|${injector.serialize(indent + " ")}""" .stripMargin def toBits(): String = injector.toBits() }
s"""|${indent}- $name:
chiffre
chiffre/src/main/scala/chiffre/ScanField.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
trait HasWidth { val width: Int } trait HasName { val name: String } /** A configurable field of the scan chain */ trait ScanField extends HasName with HasWidth with Equals { var value: Option[BigInt] = None val name: String = this.getClass.getSimpleName if (width < 1) { throw new ScanFieldException(...
case class ScanFieldBindingException(msg: String) extends Exception(msg)
chiffre
chiffre/src/main/scala/chiffre/inject/CycleInjector.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
case class CycleInject(width: Int) extends ScanField case class CycleInjectorInfo(bitWidth: Int, cycleWidth: Int) extends InjectorInfo { val fields = Seq(Cycle(cycleWidth), CycleInject(bitWidth)) } class CycleInjector(bitWidth: Int, val cycleWidth: Int) extends Injector(bitWidth) { val cycleTarget = Reg(UInt(cycl...
case class Cycle(width: Int) extends ScanField
chiffre
chiffre/src/main/scala/chiffre/inject/IdentityInjector.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
val info = NoInjectorInfo io.out := io.in io.scan.out := io.scan.in }
case object NoInjectorInfo extends InjectorInfo { val fields = Seq.empty }
chiffre
chiffre/src/main/scala/chiffre/inject/Injector.scala
// Copyright 2017 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
} /** An injector composed of individual single-bit injectors */ abstract class InjectorBitwise(bitWidth: Int, gen: => Injector) extends Injector(bitWidth) { lazy val injectors = Seq.fill(bitWidth)(Module(gen)) var scanLast = io.scan.in injectors .zipWithIndex .map{ case (injector, i) => injector....
when (io.scan.en) { enabled := ~enabled }
chiffre
chiffre/src/main/scala/chiffre/inject/LfsrInjector.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
case class LfsrInjectorInfo(bitWidth: Int, lfsrWidth: Int) extends InjectorInfo { val fields = Seq.fill(bitWidth)(Seq(Seed(lfsrWidth), Difficulty(lfsrWidth))).flatten } sealed class LfsrInjector(val lfsrWidth: Int) extends Injector(1) { val difficulty = RegInit(0.U(lfsrWidth.W)) val seed = RegInit(1.U(lfsrWidth...
case class Difficulty(width: Int) extends ScanField with ProbabilityBind
chiffre
chiffre/src/main/scala/chiffre/inject/StuckAt.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
class StuckAtInjectorWithId(bitWidth: Int, val scanId: String) extends StuckAtInjector(bitWidth) with ChiffreInjector
chiffre
chiffre/src/main/scala/chiffre/passes/FaultInstrumentation.scala
// Copyright 2017 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
|${renames.map{case (a, b) => s"$indent - $a: $b"}.mkString("\n")}""" .stripMargin } class FaultInstrumentation(compMap: Map[String, Seq[(ComponentName, String, Class[_ <: Injector])]]) extends Transform { def inputForm: CircuitForm = MidForm def outputForm: CircuitForm = MidForm def execute(state...
|${indent}renames:
chiffre
chiffre/src/main/scala/chiffre/passes/FaultInstrumentationTransform.scala
// Copyright 2017 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
def outputForm: CircuitForm = HighForm def transforms(compMap: Map[String, Seq[(ComponentName, String, Class[_ <: Injector])]]): Seq[Transform] = Seq( new FaultInstrumentation(compMap), /* After FaultInstrumentation, the inline compilation needs to be cleaned * up. this massive list is what is helping ...
def inputForm: CircuitForm = MidForm
chiffre
chiffre/src/main/scala/chiffre/passes/ScanChainTransform.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
|${tab}description: |${description.map{case(k,v)=>s"${tab} ${k.name}: $v"}.mkString("\n")}""" .stripMargin // scalastyle:on line.size.limit def toFaultyComponent: Seq[FaultyComponent] = injectors .map{ case(c, m) => FaultyComponent(c.serialize, description(c)) } .toSeq } sealed trai...
|${injectors.map{ case (k, v) => s"${tab} ${v.name}, ${k.module.name}, ${slaveIn(k).module.name}.${slaveIn(k).name}, ${slaveOut(k).module.name}.${slaveOut(k).name}"}.mkString("\n")}
chiffre
chiffre/src/main/scala/chiffre/scan/JsonProtocol.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
object JsonProtocol { /** The name/key to use for the name--value pair holding a Scala class * * @note this matches what FIRRTL does */ val classId: String = "class" // A base serialization format private val baseFormat = DefaultFormats .preservingEmptyValues .withTypeHintFieldName(classId...
case class JsonSerializationException(msg: String) extends Exception(msg)
chiffre
chiffre/src/main/scala/chiffre/util/Bits.scala
package chiffre.util import firrtl.bitWidth import firrtl.ir._ import firrtl.Mappers._ object removeZeroWidth {
def apply(t: Type): Type = t match { case tx @ (_: GroundType | _: VectorType) => tx case tx: BundleType => tx.copy(fields = tx.fields filter (f => bitWidth(f.tpe) > 0)) map apply }
chiffre
chiffre/src/main/scala/chiffre/util/ScanChainConfig.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
println(s"[info] bytes: ${raw.grouped(8).toArray.map(BigInt(_, 2).toByte).mkString(" ")}") require(raw.size % 32 == 0) raw.grouped(8).toArray.reverse.map(BigInt(_, 2).toByte) } // scalastyle:on magic.number } object Driver { val parser = new OptionParser[Arguments]("ScanChainConfig") { help("help...
s"""[info] raw: ${raw.grouped(4).toList.map(BigInt(_, 2).toString(16)).mkString.grouped(16).mkString(" ")}""")
chiffre
chiffre/src/test/scala/chiffreTests/ChiffreSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
}
def backToInt(f: ScanField): Int = Integer.parseInt(f.toBits, 2)
chiffre
chiffre/src/test/scala/chiffreTests/InjectorInfoSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
case class F(i: Option[BigInt] = None, width: Int = 4) extends ScanField { bind(i) } case class G(i: Option[BigInt] = None, width: Int = 5) extends ScanField { bind(i) } def f(): F = F() def f(x: Int): F = F(Some(x)) def g(): G = G() def g(x: Int): G = G(i = Some(x)) behavior of "The InjectoInfo trait"...
case class DummyInjectorInfo(fields: Seq[ScanField]) extends InjectorInfo
chiffre
chiffre/src/test/scala/chiffreTests/InstrumentationSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
behavior of "Chiffree Injectee annotation" it should "emit an annotation" in { val circuit = ChiselStage.elaborate(new DummyInjectee)
chiffre
chiffre/src/test/scala/chiffreTests/ScanChainConfigSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
val scanChain: ScanChain = Map( "id-0" -> Seq( FaultyComponent("Top.Top.x", StuckAtInjectorInfo(5)), FaultyComponent("Top.Top.y", LfsrInjectorInfo(4, 32)), FaultyComponent("Top.Top.z", CycleInjectorInfo(3, 8)) ) ) val scanFile = s"$test_dir/scan-chain.json" writeScanChainToFile(scanCh...
val test_dir = s"test_run_dir/${this.getClass.getSimpleName}"
chiffre
chiffre/src/test/scala/chiffreTests/ScanFieldSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
info(s"""${x.getOrElse("u")} $op ${y.getOrElse("u")}""") a == b should be (pass) } } val sameTypeSameWidth = Map( (None, None) -> true, (Some(1), None) -> false, (Some(1), Some(1)) -> true, (Some(2...
val op = if (pass) "==" else "!="
chiffre
chiffre/src/test/scala/chiffreTests/inject/CycleInjectorSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
} }
Driver(() => new CycleInjector(13, 8)) { dut => new TimingTester(dut, 42) }
chiffre
chiffre/src/test/scala/chiffreTests/inject/IdentityInjectorSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
} it should "do nothing when enabled" in { Driver(() => new IdentityInjector(21, "dummy")) { dut => new IdentityInjectorTester(dut) } } }
Driver(() => new IdentityInjector(42, "dummy")) { dut => new IdentityInjectorTransparencyTester(dut) }
chiffre
chiffre/src/test/scala/chiffreTests/inject/InjectorSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
class InjectorTester[T <: Injector](dut: T) extends PeekPokeTester(dut) { private def load(bitString: String): String = { val out = new StringBuilder(bitString.size) bitString.reverse.map(x => s"$x".toInt).foreach{ bit => poke(dut.io.scan.clk, 0) poke(dut.io.scan.in, bit) out ++= peek(dut.i...
case class Chunk(width: Int) extends ScanField
chiffre
chiffre/src/test/scala/chiffreTests/inject/LfsrInjectorSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
} ) behavior of "LfsrInjectorN" it should "be able to cycle a configuration" in { Driver(() => new LfsrInjectorN(4, 16, "main")) { dut => new InjectorCycleTester(dut) } } }
Driver(() => new LfsrInjector(8)) { dut => new ProbabilisticTester(dut, probability) }
chiffre
chiffre/src/test/scala/chiffreTests/inject/StuckAtInjectorSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
} }
Driver(() => new StuckAtInjector(8)) { dut => new StuckAtTester(dut) }
chiffre
chiffre/src/test/scala/chiffreTests/passes/FaultInstrumentationSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
val circuit = Parser.parse(input) val state = CircuitState(circuit, MidForm, Seq.empty, None) val connections = new ArrayBuffer[Connect]() f.execute(state).circuit.modules.filter(_.name == component.module.name).foreach(_.mapStmt(collect(connections))) connections.map(_.serialize) should contain ("x...
| input in: $tpe | output out: $tpe | reg x: $tpe, Clock | x <= in
chiffre
chiffre/src/test/scala/chiffreTests/passes/FaultInstrumentationTransformSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
class InjectorB(bitWidth: Int, id: String) extends InjectorA(bitWidth, id) class InjectorC(bitWidth: Int, id: String) extends InjectorB(bitWidth, id) class TestInjector(bitWidth: Int, scanId: String) extends IdentityInjector(bitWidth, scanId) { assert(io.scan.clk =/= io.scan.en) io.out := ~io.in } class TestContr...
class InjectorA(bitWidth: Int, id: String) extends IdentityInjector(bitWidth, id)
chiffre
chiffre/src/test/scala/chiffreTests/passes/ScanChainTransformSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
| input clock: Clock |""".stripMargin val circuit = Parser.parse(input) val m = ModuleName("Top", CircuitName("Top")) val annos = Seq( ScanChainAnnotation(ComponentName("controller.io.scan", m), "master", "scan", "foo", None), ScanChainInjectorAnnotation(ComponentName("x", ...
| input clock: Clock | reg x: UInt<1>, clock | inst controller of Controller | inst injector of Injector
chiffre
chiffre/src/test/scala/chiffreTests/scan/JsonProtocolSpec.scala
// Copyright 2018 IBM // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing,...
info("unbinding the bound value causes it to not match") roundTrip should not be (scanChain) }
diagrammer
diagrammer/src/main/scala/dotvisualizer/FirrtlDiagrammer.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer import dotvisualizer.stage.DiagrammerStage import firrtl.FileUtils.isCommandAvailable import firrtl._ /** * This library implements a graphviz dot file render. */ object FirrtlDiagrammer {
private val LinuxPattern = """.*n[iu]x.*""".r private val WindowsPattern = """.*win.*""".r def getOpenForOs: String = { System.getProperty("os.name").toLowerCase match { case MacPattern() => "open" case LinuxPattern() if isCommandAvailable(Seq("x...
def main(args: Array[String]): Unit = { (new DiagrammerStage).execute(args, Seq.empty) }
diagrammer
diagrammer/src/main/scala/dotvisualizer/RenderSvg.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer import java.io.{File, PrintWriter} import scala.concurrent.ExecutionContext.Implicits.global import scala.concurrent.duration.Duration import scala.concurrent.{blocking, Await, Future, TimeoutException} import scala.sys.process._ class RenderSvg(dotProgra...
| --> |<!-- Title: TopLevel Pages: 1 --> |<svg width="351pt" height="44pt" | viewBox="0.00 0.00 351.26 44.00" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">...
|<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" | "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
diagrammer
diagrammer/src/main/scala/dotvisualizer/Scope.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer case class Scope(depth: Int = -1, maxDepth: Int = -1) { def doComponents(): Boolean = { val result = depth >= 0 && (maxDepth == -1 || depth < maxDepth) result }
def descend: Scope = { if (depth == -1) { Scope() } else { val newDepth = if (depth == maxDepth) -1 else depth + 1 Scope(newDepth, maxDepth) } } override def toString: String = { val s = (depth, maxDepth) match { case (-1, -1) => "out" case (_, -1) => "in, no depth...
def doPorts(): Boolean = depth >= 0 && (maxDepth == -1 || depth <= maxDepth)
diagrammer
diagrammer/src/main/scala/dotvisualizer/ToLoFirrtl.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer import firrtl.CompilerUtils.getLoweringTransforms import firrtl.Mappers._ import firrtl.PrimOps.Dshl import firrtl._ import firrtl.ir._ import firrtl.options.{Dependency, Phase} import firrtl.stage.{FirrtlCircuitAnnotation, Forms} import firrtl.transforms.B...
def execute(state: CircuitState): CircuitState = { state.copy(circuit = state.circuit.map(onMod)) } }
private def onMod(mod: DefModule): DefModule = mod.map(onStmt)
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/DotNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes import scala.collection.mutable.ArrayBuffer trait DotNode { def render: String def name: String def parentOpt: Option[DotNode] def absoluteName: String = { parentOpt match {
case _ => name } } def in: String = absoluteName def out: String = absoluteName def asRhs: String = absoluteName val children: ArrayBuffer[DotNode] = new ArrayBuffer[DotNode] }
case Some(parent) => s"${parent.absoluteName}_$name"
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/LiteralNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes case class LiteralNode(name: String, value: BigInt, parentOpt: Option[DotNode]) extends DotNode {
def render: String = { s"""$absoluteName [shape="circle" style="filled" BGCOLOR="#C0C0C0" label="$value"] """.stripMargin }
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/MemNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes import firrtl.ir.DefMemory import scala.collection.mutable case class MemNode( name: String, parentOpt: Option[DotNode], firrtlName: String, defMem: DefMemory, nameToNode: mutable.HashMap[String, DotNode]) extends DotNode...
} defMem.readers.foreach { readerName => addMemoryPort("read port", readerName, Seq("en", "addr", "data", "clk")) } defMem.writers.foreach { readerName => addMemoryPort("write port", readerName, Seq("en", "addr", "data", "mask", "clk")) } defMem.readwriters.foreach { readerName => addMemoryPort...
fields.foreach { portName => addPort(memPortName, firrtlMemPortName, portName) }
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/ModuleNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes import dotvisualizer.transforms.MakeOneDiagram import firrtl.graph.DiGraph import scala.annotation.tailrec import scala.collection.mutable import scala.collection.mutable.ArrayBuffer case class ModuleNode( name: String, parentOpt: ...
| bgcolor="$backgroundColor" | ${children.map(_.render).mkString("\n")} | | ${connections.map { case (k, v) => s"$v -> $k" }.mkString("", "\n ", "")} | ${analogConnections.map { case (k, v) => expandBiConnects(k, v) }.mkString("", "\n ", "...
| URL="${url_string.getOrElse("")}"
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/MuxNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes import java.io.{File, PrintWriter} case class MuxNode( name: String, parentOpt: Option[DotNode], arg0ValueOpt: Option[String] = None, arg1ValueOpt: Option[String] = None) extends DotNode { val select: String = s"$...
writer.println(s"\n${mux2.out} -> ${reg1.in}") writer.println(s"\n${reg1.out} -> ${mux2.in2}") writer.println(s"}") writer.close() "dot -Tpng -O mux1.dot".!! "open mux1.dot.png".!! } }
writer.println(s"\n${mux1.out} -> ${mux2.in1}")
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/NodeNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes
case class NodeNode(name: String, parentOpt: Option[DotNode]) extends DotNode { def render: String = s"""$absoluteName [label = "$name" shape="rectangle"]; """ }
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/PortNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes case class PortNode(name: String, parentOpt: Option[DotNode], rank: Int = 10, isInput: Boolean = false) extends DotNode { def render: String = { val color = if (!isInput) { s"#E0FFFF" }
s"""$absoluteName [shape = "rectangle" style="filled" fillcolor="$color" label="$name" rank="$rank"] """.stripMargin } }
else { s"#CCCCCC" }
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/PrimOpNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes object PrimOpNode { /* the pseudoHash is necessary because case classes with identical args have identical hashes */ var pseudoHash: Long = 0 def hash: Long = { pseudoHash += 1 pseudoHash } val BlackDot = "&#x25cf;" } case class...
override val asRhs: String = s"$absoluteName:out" def render: String = { s""" |$absoluteName [shape = "plaintext" label=< |<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4" BGCOLOR="#D8BFD8"> | <TR> | <TD PORT="in1">${arg0ValueOpt.getOrElse(PrimOpNode.Black...
override val absoluteName: String = s"op_${name}_${PrimOpNode.hash}"
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/PrintfNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes import scala.collection.mutable case class PrintfNode(name: String, formatString: String, parentOpt: Option[DotNode]) extends DotNode { val text = new mutable.StringBuilder() override def absoluteName: String = "struct_" + super.absoluteName...
def render: String = { s""" |<TR><TD PORT="$connectTarget">$name</TD></TR> """.stripMargin }
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/RegisterNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes case class RegisterNode(name: String, parentOpt: Option[DotNode]) extends DotNode { override val in: String = s"struct_$absoluteName:in" override val out: String = s"struct_$absoluteName:out" override val asRhs: String = s"struct_$absolu...
| </TR> |</TABLE>>];""".stripMargin } }
| <TD PORT="out">${PrimOpNode.BlackDot}</TD>
diagrammer
diagrammer/src/main/scala/dotvisualizer/dotnodes/ValidIfNode.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.dotnodes case class ValidIfNode(name: String, parentOpt: Option[DotNode]) extends DotNode { val select: String = s"$name:select" val in1: String = s"$name:in1" override val asRhs: String = s"$name:out"
| <TD PORT="out">&#x25cf;</TD> | </TR> |</TABLE>>]; """.stripMargin } }
def render: String = { s""" |$name [shape = "plaintext" label=< |<TABLE BORDER="0" CELLBORDER="1" CELLSPACING="0" CELLPADDING="4" BGCOLOR="#FA8072">
diagrammer
diagrammer/src/main/scala/dotvisualizer/stage/DiagrammerAnnotations.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.stage import firrtl.annotations.{Annotation, NoTargetAnnotation} import firrtl.options.{HasShellOptions, ShellOption, Unserializable} sealed trait DiagrammerAnnotation { this: Annotation => } case class StartModuleNameAnnotation(name: String) extend...
object RankDirAnnotation extends HasShellOptions { val options = Seq( new ShellOption[String]( longOption = "rank-dir", toAnnotationSeq = (a: String) => Seq(RankDirAnnotation(a)), helpText = "use to set ranking direction, default is LR, TB is good alternative" ) ) } case object RankEleme...
case class RankDirAnnotation(name: String) extends DiagrammerAnnotation with NoTargetAnnotation with Unserializable
diagrammer
diagrammer/src/main/scala/dotvisualizer/stage/DiagrammerCli.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.stage import firrtl.options.Shell trait DiagrammerCli { this: Shell => parser.note("Diagrammer Front End Options") Seq( StartModuleNameAnnotation, OpenCommandAnnotation, SetRenderProgramAnnotation, JustTopLevelAnnotation, RankDi...
DotTimeoutSecondsAnnotation ).foreach(_.addOptions(parser)) }
ShowPrintfsAnnotation,
diagrammer
diagrammer/src/main/scala/dotvisualizer/stage/DiagrammerException.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.stage
class DiagrammerException(msg: String) extends Exception(msg)
diagrammer
diagrammer/src/main/scala/dotvisualizer/stage/DiagrammerPhase.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.stage import dotvisualizer.stage.phase.{ CheckPhase, GenerateDotFilePhase, GetFirrtlCircuitPhase, OptionallyBuildTargetDirPhase } import firrtl.options.phases.DeletedWrapper import firrtl.options.{Dependency, Phase, PhaseManager} class DiagrammerPh...
) }
val targets: Seq[PhaseManager.PhaseDependency] = Seq( Dependency[CheckPhase], Dependency[GetFirrtlCircuitPhase],
diagrammer
diagrammer/src/main/scala/dotvisualizer/stage/DiagrammerStage.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.stage import chisel3.stage.ChiselCli import firrtl.AnnotationSeq import firrtl.options.{Shell, Stage} import firrtl.stage.FirrtlCli /** DiagrammerState creates a diagram of a firrtl circuit. The firrtl circuit can be in any one of the following * forms ...
(new DiagrammerPhase).transform(annotations) } }
val shell: Shell = new Shell("chisel") with DiagrammerCli with ChiselCli with FirrtlCli
diagrammer
diagrammer/src/main/scala/dotvisualizer/stage/phase/CheckPhase.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.stage.phase import chisel3.stage.ChiselGeneratorAnnotation import dotvisualizer.stage.DiagrammerException import firrtl.AnnotationSeq import firrtl.options.{Phase, TargetDirAnnotation} import firrtl.stage.{FirrtlFileAnnotation, FirrtlSourceAnnotation} clas...
}
if (targetCount > 1) { throw new DiagrammerException(s"Error: There can only be 1 TargetDir, $targetCount found") }
diagrammer
diagrammer/src/main/scala/dotvisualizer/stage/phase/GenerateDotFilePhase.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.stage.phase import java.io.{File, PrintWriter} import dotvisualizer.RenderSvg import dotvisualizer.stage.{ DotTimeoutSecondsAnnotation, JustTopLevelAnnotation, OpenCommandAnnotation, SetRenderProgramAnnotation } import dotvisualizer.transforms.{Mak...
override def optionalPrerequisites = Seq.empty override def optionalPrerequisiteOf = Seq.empty override def invalidates(a: Phase) = false /** * Make a simple css file that controls highlighting * * @param targetDir where to put the css */ def addCss(targetDir: String): Unit = { val fil...
override def prerequisites = Seq(Dependency[OptionallyBuildTargetDirPhase])
diagrammer
diagrammer/src/main/scala/dotvisualizer/stage/phase/GetFirrtlCircuitPhase.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.stage.phase import chisel3.stage.{ChiselGeneratorAnnotation, ChiselStage} import dotvisualizer.ToLoFirrtl import dotvisualizer.stage.DiagrammerException import firrtl.options.{Dependency, Phase} import firrtl.stage.{FirrtlCircuitAnnotation, FirrtlFileAnnota...
override def optionalPrerequisites = Seq.empty override def optionalPrerequisiteOf = Seq.empty override def invalidates(a: Phase) = false def buildFirrtlCircuitAnnotation(firrtlText: String): FirrtlCircuitAnnotation = { val rawFirrtl = firrtl.Parser.parse(firrtlText) val processedFirrtlCircuit = (new T...
override def prerequisites = Seq(Dependency[CheckPhase])
diagrammer
diagrammer/src/main/scala/dotvisualizer/stage/phase/OptionallyBuildTargetDirPhase.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.stage.phase import java.io.File import dotvisualizer.stage.DiagrammerException import firrtl.options.{Dependency, Phase, TargetDirAnnotation} import firrtl.stage.FirrtlCircuitAnnotation import firrtl.{AnnotationSeq, FileUtils} class OptionallyBuildTargetD...
} } else { FileUtils.makeDirectory(targetDir) if (!targetDirFile.exists()) { <TARGET> } } case _ => } newAnnotations } }
throw new DiagrammerException(s"Error: Target dir ${targetDir} exists and is not a directory")
diagrammer
diagrammer/src/main/scala/dotvisualizer/transforms/MakeDiagramGroup.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.transforms import dotvisualizer._ import dotvisualizer.stage.StartModuleNameAnnotation import firrtl.options.TargetDirAnnotation import firrtl.{CircuitForm, CircuitState, DependencyAPIMigration, LowForm, Transform} import scala.collection.mutable class Ma...
override def invalidates(a: Transform) = false /** * Creates a series of diagrams starting with the startModule and continuing * through all descendant sub-modules. * @param state the state to be diagrammed * @return */ override def execute(state: CircuitState): CircuitState = { val tar...
override def optionalPrerequisites = Seq.empty
diagrammer
diagrammer/src/main/scala/dotvisualizer/transforms/MakeOneDiagram.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.transforms import java.io.PrintWriter import dotvisualizer._ import dotvisualizer.dotnodes._ import dotvisualizer.stage.{RankDirAnnotation, RankElementsAnnotation, ShowPrintfsAnnotation, StartModuleNameAnnotation} import firrtl.PrimOps._ import firrtl.ir._...
moduleNode += uInt uInt.absoluteName case c: SIntLiteral => <TARGET> moduleNode += uInt uInt.absoluteName case other => // throw new Exception(s"renameExpression:error: unhandled expression $expression") other.getClass.getName ...
val uInt = LiteralNode(s"lit${PrimOpNode.hash}", c.value, Some(moduleNode))
diagrammer
diagrammer/src/main/scala/dotvisualizer/transforms/ModuleLevelDiagrammer.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.transforms import java.io.PrintWriter import dotvisualizer.RenderSvg import dotvisualizer.stage.StartModuleNameAnnotation import firrtl.Mappers._ import firrtl._ import firrtl.ir.{Block, Statement} import firrtl.options.TargetDirAnnotation import scala.co...
override def optionalPrerequisites = Seq.empty override def optionalPrerequisiteOf = Seq.empty override def invalidates(a: Transform) = false def execute(circuitState: CircuitState): CircuitState = { val c = circuitState.circuit val targetDir = circuitState.annotations.collectFirst { case TargetDirA...
override def prerequisites = Seq.empty
diagrammer
diagrammer/src/main/scala/dotvisualizer/transforms/RemoveTempWires.scala
// SPDX-License-Identifier: Apache-2.0 package dotvisualizer.transforms import dotvisualizer.ToLoFirrtl import dotvisualizer.stage.DiagrammerException import firrtl.ir._ import firrtl.stage.FirrtlCircuitAnnotation import firrtl.{ CircuitForm, CircuitState, DependencyAPIMigration, FileUtils, LowForm, Parse...
if (node.name.startsWith(RemoveTempWires.GenPrefix) || node.name.startsWith(RemoveTempWires.TempPrefix)) { None } else { Some(node.mapExpr(removeGen)) } case other: Statement => Some(other.mapExpr(removeGen)) case _ => Some(...
val result = Some(Block(block.stmts.flatMap { substatement => removeGenStatement(substatement) }))
End of preview. Expand in Data Studio

MHRC-Bench / HDL-RepoBench

Multilingual hardware code completion data for Chisel, Verilog/SystemVerilog, VHDL, and HLS C/C++. The standard task files linked from this release contain the full training, validation, and test task splits: 47,200 examples in total.

Split sizes

Language Train Validation Test
Chisel 2,573 119 323
Verilog / SystemVerilog 25,586 107 508
VHDL 13,039 104 496
HLS C/C++ 3,766 123 456
Total 44,964 453 1,783

The raw and content files describe the same examples. The classified test file adds annotations to the test examples; it is not an additional split. Count examples once, rather than summing records across these representations.

Load the data

from datasets import load_dataset

data = load_dataset("Zanehpn/MHRC-Bench", "chisel")
print(data["train"].num_rows)       # 2573
print(data["validation"].num_rows)  # 119
print(data["test"].num_rows)        # 323

Available configurations: chisel, systemverilog, vhdl, and hls. Each configuration loads the content representation of its three splits.

Files and fields

Each language directory contains:

  • train.jsonl, valid.jsonl, test.jsonl: source paths, target positions, syntax metadata, and target text.
  • train_content.jsonl, valid_content.jsonl, test_content.jsonl: completion examples with task_id, path, left_context, right_context, groundtruth, and crossfile_context fields.
  • test_content_classfied.jsonl: the same test examples with category, subcategory, confidence, and category_reason annotations. The existing filename spelling is retained for compatibility.

For the content representation, the source text is reconstructed as left_context + groundtruth + right_context. The standard content files keep crossfile_context empty. For repository context, use the enriched validation/test variants documented below or download the original repository snapshot archive.

sample_manifest.json lists the per-file record counts, sizes, and SHA-256 checksums. The repository URL and manifest filename are retained for compatibility.

Repository context and functional resources

See DATA_ACCESS.md for pinned source archive downloads, SHA-256 checksums, extraction paths, toolchains, and testbench commands. The enriched valid_content_with_crossfile_context.jsonl and test_content_with_crossfile_context.jsonl files preserve the original tasks and provide other-file context. They exclude the unmasked target file and whitespace-normalised exact copies of it. Do not count these as extra examples.

resources/resource_manifest.json links the source archive, testbench bundle, and preserved license notices. resources/functional_coverage.json records available DUTs and testbenches, including missing assets. This is a partial legacy testbench collection, not verified full-test functional coverage.

License and source attribution

LICENSE.md explains the MIT terms for author-created annotations and documentation, and the separate upstream terms for source code. provenance/repositories.json lists all 583 source repositories, checkout revisions, and located root license notices. Some repositories have copyleft notices or no located root notice; no blanket permissive license is asserted for the upstream source collection.

Croissant and Responsible AI documentation

Download croissant.json for the release's Croissant metadata, including the NeurIPS 2026 E&D RAI fields and source provenance. Upload this manual file to OpenReview. Hugging Face's automatic Croissant endpoint is a separate generated document and may omit these RAI fields.

The metadata documents intended uses, public-code and language biases, limitations, preserved public attribution identifiers, and potential misuse. The original completion tasks are drawn from source code rather than LLM-generated completions. The separate legacy testbench bundle is not part of that source-task claim.

Downloads last month
196