Skip to content

Commit 62c3334

Browse files
committed
include working mxgen
1 parent 1dc42bd commit 62c3334

14 files changed

Lines changed: 41 additions & 1103 deletions

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@
77
[submodule "software/gemmini-rocc-tests"]
88
path = software/gemmini-rocc-tests
99
url = https://github.com/Rakanic/gemmini-rocc-tests.git
10-
[submodule "src/main/scala/gemmini/mxgen"]
11-
path = src/main/scala/gemmini/mxgen
10+
[submodule "mxgen"]
11+
path = mxgen
1212
url = git@github.com:ucb-bar/MxGen.git

build.sbt

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,25 @@ version := "3.1.0"
66

77
scalaVersion := "2.13.10"
88

9+
// Belt-and-suspenders exclusion of files inside the mxgen submodule that sbt
10+
// shouldn't compile as part of gemmini's main classpath:
11+
// - mxgen/test/** : mill-style test sources (depend on scalatest/chiseltest)
12+
// - mxgen/out/** : mill's transient build output (re-generates each mill invocation)
13+
// - mxgen/.../Main.scala: standalone Verilog emitter (App entry point)
14+
def mxgenStaleFile(f: java.io.File): Boolean = {
15+
val p = f.getAbsolutePath.replace('\\', '/')
16+
p.contains("/mxgen/test/") ||
17+
p.contains("/mxgen/out/") ||
18+
p.endsWith("/mxgen/src/main/scala/mxgen/Main.scala")
19+
}
20+
21+
Compile / unmanagedSources / excludeFilter ~= { prev =>
22+
prev || new sbt.io.SimpleFileFilter(f => mxgenStaleFile(f))
23+
}
24+
25+
Compile / unmanagedSources := (Compile / unmanagedSources).value.filterNot(mxgenStaleFile)
26+
Compile / sources := (Compile / sources).value.filterNot(mxgenStaleFile)
27+
928
// libraryDependencies ++= Seq(
1029
// "edu.berkeley.cs" %% "chisel3" % "3.6.0",
1130
// "edu.berkeley.cs" %% "rocketchip" % "1.2.+",

mxgen

Submodule mxgen added at d19258e

src/build.sbt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
// mxgen lives as a sibling of this directory (at <gemmini>/mxgen). Its sources
2+
// are not under sbt's scalaSource walk, so they have to be added explicitly.
3+
// Only src/main/scala is included — the mill workspace, tests, and Main.scala
4+
// (in elab/) stay invisible to sbt.
5+
Compile / unmanagedSourceDirectories +=
6+
baseDirectory.value.getParentFile / "mxgen" / "src" / "main" / "scala"

src/main/scala/gemmini/Arithmetic.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import freechips.rocketchip.tile.FType
77
import chisel3._
88
import chisel3.util._
99
import hardfloat._
10+
import mxgen.{MxConfig, MxFormat, MxTypeBundle, requiredPEMode}
1011

1112
// Bundles that represent the raw bits of custom datatypes
1213
case class Float(expWidth: Int, sigWidth: Int, isRecoded: Boolean = false) extends Bundle {
@@ -630,16 +631,22 @@ object Arithmetic {
630631

631632
override def mac_mx(m1: MxFloat, m2: MxFloat, fpProductPrecision: (Int, Int), fpAccPrecision: MxFloat, activation_mx_format: UInt, weight_mx_format: UInt): MxFloat = {
632633
require(!m1.isRecoded && !m2.isRecoded) // mxFloat inputs must be in standard format
633-
val macc = Module(new MxFpMul(lut = false)(fpProductPrecision, fpAccPrecision))
634+
val macConfig = MxConfig.mxGemmini.copy(
635+
inActBusWidth = m1.bits.getWidth,
636+
inWeiBusWidth = m2.bits.getWidth,
637+
productFormat = MxFormat(fpProductPrecision._1, fpProductPrecision._2),
638+
accFormat = MxFormat(fpAccPrecision.expWidth, fpAccPrecision.sigWidth)
639+
)
640+
val macc = Module(new mxgen.MxFpMul(macConfig, lut = false))
634641
val result = Wire(MxFloat(macc.cType.exp, macc.cType.sig, 4, true))
635642

636-
val typeA = Wire(new MxTypes)
643+
val typeA = Wire(new MxTypeBundle)
637644
typeA.exp := Mux(activation_mx_format === 2.U, 2.U,
638645
Mux(activation_mx_format === 1.U, 3.U, 4.U))
639646
typeA.sig := Mux(activation_mx_format === 2.U, 2.U,
640647
Mux(activation_mx_format === 1.U, 3.U, 4.U))
641648

642-
val typeW = Wire(new MxTypes)
649+
val typeW = Wire(new MxTypeBundle)
643650
typeW.exp := Mux(weight_mx_format === 2.U, 2.U,
644651
Mux(weight_mx_format === 1.U, 3.U, 4.U))
645652
typeW.sig := Mux(weight_mx_format === 2.U, 2.U,

src/main/scala/gemmini/Classifier.scala

Lines changed: 0 additions & 66 deletions
This file was deleted.

src/main/scala/gemmini/MACU.scala

Lines changed: 0 additions & 76 deletions
This file was deleted.

src/main/scala/gemmini/Mesh.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ package gemmini
44
import chisel3._
55
import chisel3.util._
66
import chisel3.experimental._
7+
import mxgen.{MxTypeBundle, requiredPEMode}
78

89
/**
910
* A Grid is a 2D array of Tile modules with registers in between each tile and
@@ -69,15 +70,15 @@ class Mesh[T <: Data : Arithmetic](inputType: T, weightType: T, outputType: T, a
6970
// tile.io.weight_mx_format := io.weight_mx_format
7071
// }
7172

72-
val typeA = Wire(new MxTypes)
73+
val typeA = Wire(new MxTypeBundle)
7374
typeA.exp := Mux(io.activation_mx_format === 2.U, 2.U,
7475
Mux(io.activation_mx_format === 1.U, 3.U, 4.U))
7576
typeA.sig := Mux(io.activation_mx_format === 2.U, 2.U,
7677
Mux(io.activation_mx_format === 1.U, 3.U, 4.U))
7778
val typeA_size = Mux(io.activation_mx_format === 2.U, 4.U,
7879
Mux(io.activation_mx_format === 1.U, 6.U, 8.U))
7980

80-
val typeW = Wire(new MxTypes)
81+
val typeW = Wire(new MxTypeBundle)
8182
typeW.exp := Mux(io.weight_mx_format === 2.U, 2.U,
8283
Mux(io.weight_mx_format === 1.U, 3.U, 4.U))
8384
typeW.sig := Mux(io.weight_mx_format === 2.U, 2.U,

src/main/scala/gemmini/Multiplier2x2.scala

Lines changed: 0 additions & 31 deletions
This file was deleted.

src/main/scala/gemmini/MxExp.scala

Lines changed: 0 additions & 57 deletions
This file was deleted.

0 commit comments

Comments
 (0)