stop exceptions on empty conf files (#43)
* stop exceptions on empty conf files * emit empty verilog file | warn users * put else's on same line as closing bracket
This commit is contained in:
committed by
Colin Schmidt
parent
de94c2376a
commit
817726ff1f
@@ -839,6 +839,19 @@ object MacroCompiler extends App {
|
||||
}
|
||||
case None =>
|
||||
}
|
||||
} else {
|
||||
// Warn user
|
||||
System.err println "WARNING: Empty *.mems.conf file. No memories generated."
|
||||
|
||||
// Emit empty verilog file if no macros found
|
||||
params.get(Verilog) match {
|
||||
case Some(verilogFile: String) => {
|
||||
// Create an empty verilog file
|
||||
val verilogWriter = new FileWriter(new File(verilogFile))
|
||||
verilogWriter.close()
|
||||
}
|
||||
case None =>
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
case e: java.util.NoSuchElementException =>
|
||||
|
||||
@@ -47,9 +47,13 @@ object MemConf {
|
||||
val regex = raw"\s*name\s+(\w+)\s+depth\s+(\d+)\s+width\s+(\d+)\s+ports\s+([^\s]+)\s+(?:mask_gran\s+(\d+))?\s*".r
|
||||
|
||||
def fromString(s: String): Seq[MemConf] = {
|
||||
s.split("\n").toSeq.map(_ match {
|
||||
case MemConf.regex(name, depth, width, ports, maskGran) => MemConf(name, depth.toInt, width.toInt, MemPort.fromString(ports), Option(maskGran).map(_.toInt))
|
||||
case _ => throw new Exception(s"Error parsing MemConf string : ${s}")
|
||||
})
|
||||
if (s.isEmpty) {
|
||||
Seq[MemConf]()
|
||||
} else {
|
||||
s.split("\n").toSeq.map(_ match {
|
||||
case MemConf.regex(name, depth, width, ports, maskGran) => MemConf(name, depth.toInt, width.toInt, MemPort.fromString(ports), Option(maskGran).map(_.toInt))
|
||||
case _ => throw new Exception(s"Error parsing MemConf string : ${s}")
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user