-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathGCD.scala
36 lines (30 loc) · 1.19 KB
/
GCD.scala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// SPDX-License-Identifier: Unlicense
// SPDX-FileCopyrightText: 2024 Jiuyang Liu <[email protected]>
package org.chipsalliance.gcd.elaborator
import mainargs._
import org.chipsalliance.gcd.{GCD, GCDParameter}
import org.chipsalliance.gcd.elaborator.Elaborator
object GCDMain extends Elaborator {
@main
case class GCDParameterMain(
@arg(name = "xLen") xLen: Int,
@arg(name = "useAsyncReset") useAsyncReset: Boolean) {
require(xLen > 0, "xLen must be a non-negative integer")
require(chisel3.util.isPow2(xLen), "xLen must be a power of 2")
def convert: GCDParameter = GCDParameter(xLen, useAsyncReset)
}
implicit def GCDParameterMainParser: ParserForClass[GCDParameterMain] =
ParserForClass[GCDParameterMain]
@main
def config(@arg(name = "parameter") parameter: GCDParameterMain) = configImpl(
parameter.convert
)
@main
def design(
@arg(name = "parameter") parameter: os.Path,
@arg(name = "run-firtool") runFirtool: mainargs.Flag,
@arg(name = "target-dir") targetDir: os.Path
) =
designImpl[GCD, GCDParameter](parameter, runFirtool.value, targetDir)
def main(args: Array[String]): Unit = ParserForMethods(this).runOrExit(args)
}