ArgParser.scala (4b0d80d87574e82ba31737496d63ac30bed0d40a) ArgParser.scala (51e45dbbf87325e45ff2af6ca86ed6c7eed04464)
1/***************************************************************************************
2* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
3* Copyright (c) 2020-2021 Peng Cheng Laboratory
4*
5* XiangShan is licensed under Mulan PSL v2.
6* You can use this software according to the terms and conditions of the Mulan PSL v2.
7* You may obtain a copy of Mulan PSL v2 at:
8* http://license.coscl.org.cn/MulanPSL2

--- 24 unchanged lines hidden (view full) ---

33 |--num-cores <Int>
34 |--with-dramsim3
35 |--fpga-platform
36 |--enable-difftest
37 |--enable-log
38 |--with-chiseldb
39 |--with-rollingdb
40 |--disable-perf
1/***************************************************************************************
2* Copyright (c) 2020-2021 Institute of Computing Technology, Chinese Academy of Sciences
3* Copyright (c) 2020-2021 Peng Cheng Laboratory
4*
5* XiangShan is licensed under Mulan PSL v2.
6* You can use this software according to the terms and conditions of the Mulan PSL v2.
7* You may obtain a copy of Mulan PSL v2 at:
8* http://license.coscl.org.cn/MulanPSL2

--- 24 unchanged lines hidden (view full) ---

33 |--num-cores <Int>
34 |--with-dramsim3
35 |--fpga-platform
36 |--enable-difftest
37 |--enable-log
38 |--with-chiseldb
39 |--with-rollingdb
40 |--disable-perf
41 |--mfc
42 |""".stripMargin
43
44 def getConfigByName(confString: String): Parameters = {
45 var prefix = "top." // default package is 'top'
46 if(confString.contains('.')){ // already a full name
47 prefix = ""
48 }
49 val c = Class.forName(prefix + confString).getConstructor(Integer.TYPE)
50 c.newInstance(1.asInstanceOf[Object]).asInstanceOf[Parameters]
51 }
41 |""".stripMargin
42
43 def getConfigByName(confString: String): Parameters = {
44 var prefix = "top." // default package is 'top'
45 if(confString.contains('.')){ // already a full name
46 prefix = ""
47 }
48 val c = Class.forName(prefix + confString).getConstructor(Integer.TYPE)
49 c.newInstance(1.asInstanceOf[Object]).asInstanceOf[Parameters]
50 }
52 def parse(args: Array[String]): (Parameters, Array[String], FirrtlCompiler, Array[String]) = {
51 def parse(args: Array[String]): (Parameters, Array[String], Array[String]) = {
53 val default = new DefaultConfig(1)
54 var firrtlOpts = Array[String]()
52 val default = new DefaultConfig(1)
53 var firrtlOpts = Array[String]()
55 var firrtlCompiler: FirrtlCompiler = SFC
56 var firtoolOpts = Array[String]()
57 @tailrec
58 def nextOption(config: Parameters, list: List[String]): Parameters = {
59 list match {
60 case Nil => config
61 case "--xs-help" :: tail =>
62 println(usage)
63 if(tail == Nil) exit(0)

--- 25 unchanged lines hidden (view full) ---

89 case "--fpga-platform" :: tail =>
90 nextOption(config.alter((site, here, up) => {
91 case DebugOptionsKey => up(DebugOptionsKey).copy(FPGAPlatform = true)
92 }), tail)
93 case "--enable-difftest" :: tail =>
94 nextOption(config.alter((site, here, up) => {
95 case DebugOptionsKey => up(DebugOptionsKey).copy(EnableDifftest = true)
96 }), tail)
54 var firtoolOpts = Array[String]()
55 @tailrec
56 def nextOption(config: Parameters, list: List[String]): Parameters = {
57 list match {
58 case Nil => config
59 case "--xs-help" :: tail =>
60 println(usage)
61 if(tail == Nil) exit(0)

--- 25 unchanged lines hidden (view full) ---

87 case "--fpga-platform" :: tail =>
88 nextOption(config.alter((site, here, up) => {
89 case DebugOptionsKey => up(DebugOptionsKey).copy(FPGAPlatform = true)
90 }), tail)
91 case "--enable-difftest" :: tail =>
92 nextOption(config.alter((site, here, up) => {
93 case DebugOptionsKey => up(DebugOptionsKey).copy(EnableDifftest = true)
94 }), tail)
97 case "--disable-always-basic-diff" :: tail =>
98 nextOption(config.alter((site, here, up) => {
99 case DebugOptionsKey => up(DebugOptionsKey).copy(AlwaysBasicDiff = false)
100 }), tail)
101 case "--enable-log" :: tail =>
102 nextOption(config.alter((site, here, up) => {
103 case DebugOptionsKey => up(DebugOptionsKey).copy(EnableDebug = true)
104 }), tail)
105 case "--disable-perf" :: tail =>
106 nextOption(config.alter((site, here, up) => {
107 case DebugOptionsKey => up(DebugOptionsKey).copy(EnablePerfDebug = false)
108 }), tail)
95 case "--enable-log" :: tail =>
96 nextOption(config.alter((site, here, up) => {
97 case DebugOptionsKey => up(DebugOptionsKey).copy(EnableDebug = true)
98 }), tail)
99 case "--disable-perf" :: tail =>
100 nextOption(config.alter((site, here, up) => {
101 case DebugOptionsKey => up(DebugOptionsKey).copy(EnablePerfDebug = false)
102 }), tail)
109 case "--mfc" :: tail =>
110 firrtlCompiler = MFC
111 nextOption(config, tail)
112 case "--firtool-opt" :: option :: tail =>
103 case "--firtool-opt" :: option :: tail =>
113 firtoolOpts :+= option
104 firtoolOpts ++= option.split(" ").filter(_.nonEmpty)
114 nextOption(config, tail)
115 case option :: tail =>
116 // unknown option, maybe a firrtl option, skip
117 firrtlOpts :+= option
118 nextOption(config, tail)
119 }
120 }
121 var config = nextOption(default, args.toList)
105 nextOption(config, tail)
106 case option :: tail =>
107 // unknown option, maybe a firrtl option, skip
108 firrtlOpts :+= option
109 nextOption(config, tail)
110 }
111 }
112 var config = nextOption(default, args.toList)
122 (config, firrtlOpts, firrtlCompiler, firtoolOpts)
113 (config, firrtlOpts, firtoolOpts)
123 }
124}
114 }
115}