/
Main.scala
61 lines (54 loc) · 2.1 KB
/
Main.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
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
package rosetta
import Chisel._
import sys.process._
object Settings {
// Rosetta will use myInstFxn to instantiate your accelerator
// edit below to change which accelerator will be instantiated
//val myInstFxn = {() => new TestRegOps()}
//val myInstFxn = {() => new TestAccumulateVector(4)}
//val myInstFxn = {() => new BRAMExample(1024)}
//val myInstFxn = {() => new MemCpyExample()}
val myInstFxn = {() => new DRAMExample()}
}
// call this object's main method to generate Chisel Verilog and C++ emulation
// output products. all cmdline arguments are passed straight to Chisel.
object ChiselMain {
def main(args: Array[String]): Unit = {
chiselMain(args, () => Module(new RosettaWrapper(Settings.myInstFxn)))
}
}
// call this object's Main to generate Verilog and characterize it in terms of
// the hardware resources required (LUT, DSP, BRAM...) and achievable Fmax
// note: the characterization flow requires the following to be installed:
// https://bitbucket.org/maltanar/oh-my-xilinx
object CharacterizeMain {
def main(args: Array[String]): Unit = {
val instFxn = () => Module(new RosettaWrapper(Settings.myInstFxn))
val ret = VivadoSynth.characterize(instFxn)
ret.printSummary()
}
}
// call this object's main method to generate the register driver for your
// accelerator. expects the following command line arguments, in order:
// 1. path to output directory for generated files
// 2. path to Rosetta drivers
object DriverMain {
// utility functions to copy files inside Scala
def fileCopy(from: String, to: String) = {
s"cp -f $from $to" !
}
def fileCopyBulk(fromDir: String, toDir: String, fileNames: Seq[String]) = {
for(f <- fileNames)
fileCopy(s"$fromDir/$f", s"$toDir/$f")
}
def main(args: Array[String]): Unit = {
val outDir = args(0)
val drvSrcDir = args(1)
// instantiate the wrapper accelerator
val myModule = Module(new RosettaWrapper(Settings.myInstFxn))
// generate the register driver
myModule.generateRegDriver(outDir)
// copy additional driver files
fileCopyBulk(drvSrcDir, outDir, myModule.platformDriverFiles)
}
}