forked from chipsalliance/rocket-chip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.wake
142 lines (117 loc) · 5.45 KB
/
build.wake
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
global def hardfloatScalaModule =
makeScalaModuleFromJSON here "hardfloat"
| setScalaModuleRootDir "berkeley-hardfloat"
| setScalaModuleDeps (chisel3ScalaModule, Nil)
| setScalaModuleScalacOptions ("-Xsource:2.11", Nil)
global def rocketchipMacros =
makeScalaModuleFromJSON here "rocketchipMacros"
| setScalaModuleRootDir "rocket-chip/macros"
| addMacrosParadiseCompilerPlugin
global def rocketchipScalaModule =
makeScalaModuleFromJSON here "rocketchip"
| setScalaModuleRootDir "rocket-chip"
| setScalaModuleDeps (rocketchipMacros, hardfloatScalaModule, Nil)
| setScalaModuleScalacOptions ("-Xsource:2.11", Nil)
| addMacrosParadiseCompilerPlugin
def vlsi_mem_gen = source "rocket-chip/scripts/vlsi_mem_gen"
def vlsi_rom_gen = source "rocket-chip/scripts/vlsi_rom_gen"
tuple VLSIRomGenOptions =
global ConfFile: Path
global HexFile: String
global OutputFile: String
global def makeVLSIRomGenOptions confFile hexFile outputFile = VLSIRomGenOptions confFile hexFile outputFile
global def rocket_vlsi_rom_gen options =
def cmdline =
def confFile = options.getVLSIRomGenOptionsConfFile.getPathName
def hexFile = options.getVLSIRomGenOptionsHexFile
vlsi_rom_gen.getPathName, confFile, hexFile, Nil
def inputs =
def confFile = options.getVLSIRomGenOptionsConfFile
def outputFile = options.getVLSIRomGenOptionsOutputFile
def outputDir = simplify "{outputFile}/.." | mkdir
vlsi_rom_gen, confFile, outputDir, Nil
def outputFile = options.getVLSIRomGenOptionsOutputFile
match (job cmdline inputs | getJobStdout)
Pass content = write outputFile content
Fail error = makeBadPath error
tuple VLSIMemGenOptions =
global BlackBox: Boolean
global ConfFile: Path
global OutputFile: String
global def makeVLSIMemGenOptions confFile outputFile = VLSIMemGenOptions False confFile outputFile
global def rocket_vlsi_mem_gen options =
def cmdline =
def blackBox = if options.getVLSIMemGenOptionsBlackBox then "-b", Nil else Nil
def outputFile = "-o", options.getVLSIMemGenOptionsOutputFile, Nil
def confFile = options.getVLSIMemGenOptionsConfFile.getPathName, Nil
vlsi_mem_gen.getPathName, (blackBox ++ outputFile ++ confFile)
def inputs =
def confFile = options.getVLSIMemGenOptionsConfFile
def outputFile = options.getVLSIMemGenOptionsOutputFile
def outputDir = simplify "{outputFile}/.." | mkdir
vlsi_mem_gen, confFile, outputDir, Nil
job cmdline inputs | getJobOutput
tuple RocketChipGeneratorOptions =
global Jars: List Path
global TargetDir: Path
global TopModuleName: String
global ConfigNames: List String
global ExtraSources: List Path
global BaseFileName: Option String
global def makeRocketChipGeneratorOptions jars targetDir topModule configs =
RocketChipGeneratorOptions jars targetDir topModule configs Nil None
tuple RocketChipGeneratorOutputs =
DTS_: Path
FirrtlFile_: Path
FirrtlAnnoFile_: Path
RomConf_: Path
AllOutputs_: List Path
InputOptions_: RocketChipGeneratorOptions
OMFile_: Option Path
global def getRocketChipGeneratorOutputsDTS = getRocketChipGeneratorOutputsDTS_
global def getRocketChipGeneratorOutputsFirrtlFile = getRocketChipGeneratorOutputsFirrtlFile_
global def getRocketChipGeneratorOutputsFirrtlAnnoFile = getRocketChipGeneratorOutputsFirrtlAnnoFile_
global def getRocketChipGeneratorOutputsRomConf = getRocketChipGeneratorOutputsRomConf_
global def getRocketChipGeneratorOutputsAllOutputs = getRocketChipGeneratorOutputsAllOutputs_
global def getRocketChipGeneratorOutputsInputOptions = getRocketChipGeneratorOutputsInputOptions_
global def getRocketChipGeneratorOutputsObjectModelFile = getRocketChipGeneratorOutputsOMFile_
global def runRocketChipGenerator options =
def jars = options.getRocketChipGeneratorOptionsJars
def runDir = "rocket-chip"
def targetDir = options.getRocketChipGeneratorOptionsTargetDir
def cmdline =
def rootPackage = "_root_"
def main = "freechips.rocketchip.system.Generator"
def configs = catWith "_" options.getRocketChipGeneratorOptionsConfigNames
def topModule = options.getRocketChipGeneratorOptionsTopModuleName
def relJars = jars | map getPathName | map (relative runDir)
def classpath = catWith ":" relJars
def relTargetDir = relative runDir targetDir.getPathName
def baseFileName = match options.getRocketChipGeneratorOptionsBaseFileName
Some name = name, Nil
None = Nil
which "java", "-cp", classpath, main,
relTargetDir,
rootPackage, topModule,
rootPackage, configs,
baseFileName
def inputs =
def bootrom = source 'rocket-chip/bootrom/bootrom.img'
def extras = options.getRocketChipGeneratorOptionsExtraSources
(bootrom, targetDir, extras) ++ jars
def generatorJob =
makePlan cmdline inputs
| setPlanDirectory runDir
| runJob
def filterFiles regex = filter (matches regex _.getPathName) allOutputs
def getFile regex = filterFiles regex | head | getOrElse (makeBadPath (makeError "File not found"))
def getFileOpt regex = match (filterFiles regex)
Nil = None
head, tail = Some head
def allOutputs = generatorJob.getJobOutputs
def annoFile = getFile `.*\.anno\.json`
def firrtlFile = getFile `.*\.fir`
def romConfFile = getFile `.*\.rom\.conf`
def dtsFile = getFile `.*\.dts`
def omFile = getFileOpt `.*\.objectModel\.json`
RocketChipGeneratorOutputs dtsFile firrtlFile annoFile romConfFile allOutputs options omFile