-
Notifications
You must be signed in to change notification settings - Fork 257
Expand file tree
/
Copy pathTopMain.scala
More file actions
91 lines (83 loc) · 3.12 KB
/
TopMain.scala
File metadata and controls
91 lines (83 loc) · 3.12 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**************************************************************************************
* Copyright (c) 2020 Institute of Computing Technology, CAS
* Copyright (c) 2020 University of Chinese Academy of Sciences
*
* NutShell is licensed under Mulan PSL v2.
* You can use this software according to the terms and conditions of the Mulan PSL v2.
* You may obtain a copy of Mulan PSL v2 at:
* http://license.coscl.org.cn/MulanPSL2
*
* THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY OR
* FIT FOR A PARTICULAR PURPOSE.
*
* See the Mulan PSL v2 for more details.
***************************************************************************************/
package top
import chisel3._
import chisel3.stage.ChiselGeneratorAnnotation
import circt.stage._
import device.AXI4VGA
import difftest.{DifftestModule, DifftestTopIO, HasDiffTestInterfaces}
import nutcore.NutCoreConfig
import sim.NutShellSim
import system.NutShell
class Top extends Module {
val io = IO(new Bundle{})
val nutshell = Module(new NutShell()(NutCoreConfig()))
val vga = Module(new AXI4VGA)
nutshell.io := DontCare
vga.io := DontCare
dontTouch(nutshell.io)
dontTouch(vga.io)
}
class FpgaDiffTop extends NutShell()(NutCoreConfig(FPGADifftest = true)) with HasDiffTestInterfaces {
override def desiredName: String = "NutShell"
override def cpuName: Option[String] = Some("NutShell")
}
object TopMain extends App {
def parseArgs(info: String, args: Array[String]): String = {
var target = ""
for (arg <- args) { if (arg.startsWith(info + "=") == true) { target = arg } }
require(target != "")
target.substring(info.length()+1)
}
val (newArgs, firtoolOptions) = DifftestModule.parseArgs(args)
val board = parseArgs("BOARD", newArgs)
val core = parseArgs("CORE", newArgs)
val s = (board match {
case "sim" => Nil
case "pynq" => PynqSettings()
case "axu3cg" => Axu3cgSettings()
case "fpgadiff" => FpgaDiffSettings()
case "PXIe" => PXIeSettings()
} ) ++ ( core match {
case "inorder" => InOrderSettings()
case "ooo" => OOOSettings()
case "embedded"=> EmbededSettings()
} )
s.foreach{Settings.settings += _} // add and overwrite DefaultSettings
println("====== Settings = (" + board + ", " + core + ") ======")
Settings.settings.toList.sortBy(_._1)(Ordering.String).foreach {
case (f, v: Long) =>
println(f + " = 0x" + v.toHexString)
case (f, v) =>
println(f + " = " + v)
}
val generator = if (board == "sim") {
ChiselGeneratorAnnotation(() => DifftestModule.top(new NutShellSim))
} else if (board == "fpgadiff") {
ChiselGeneratorAnnotation(() => DifftestModule.top(new FpgaDiffTop))
}
else {
ChiselGeneratorAnnotation(() => new Top)
}
var exe_args = newArgs.filter{
value => value.forall(char => char!='=')
}
(new ChiselStage).execute(newArgs, Seq(generator) ++ firtoolOptions
:+ CIRCTTargetAnnotation(CIRCTTarget.SystemVerilog)
:+ FirtoolOption("--disable-annotation-unknown")
:+ FirtoolOption("--default-layer-specialization=enable")
)
}