Class: Modelsim
- Inherits:
-
Fhlow::Plugin
- Object
- Fhlow::Plugin
- Modelsim
- Defined in:
- lib/plugins/Modelsim.rb
Instance Attribute Summary
Attributes inherited from Fhlow::Plugin
Instance Method Summary collapse
- #compile ⇒ Object
-
#initialize(_actualLeaf, _pen, _log) ⇒ Modelsim
constructor
A new instance of Modelsim.
- #plsim ⇒ Object
- #simulate ⇒ Object
Constructor Details
#initialize(_actualLeaf, _pen, _log) ⇒ Modelsim
Returns a new instance of Modelsim.
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 |
# File 'lib/plugins/Modelsim.rb', line 30 def initialize(_actualLeaf, _pen, _log) super(_actualLeaf, _pen, _log) @vcom_options = [] @vsim_options = [] # default settings @vcom_options = @actualLeaf.conf["Modelsim"]["CompileOptions"].split(/\s/) if @actualLeaf.conf["Modelsim"]["CompileQuiet"] == true @vcom_options.push("-quiet") unless @vcom_options.include?("-quiet") end @vsim_simtime = @actualLeaf.conf["Modelsim"]["SimulateRun"] @vsim_options.push(@actualLeaf.conf["Modelsim"]["SimulateOptions"]) @vsim_options.push("-c") if @actualLeaf.conf["Modelsim"]["SimulateConsole"]=="true" @buildall = @actualLeaf.conf["Modelsim"]["CompileBuildAll"] == "true" @vsim_sdf = @actualLeaf.conf["Modelsim"]["PostLayoutSimSDF"] @vsim_tblabel = @actualLeaf.conf["Modelsim"]["PostLayoutSimTbLabel"] # this functioncall is optional describeCmd("Plugin vor Modelsim.", "Supported versions: Modelsim 6.1 b") # --- compile --- # create an options object = CmdParse::OptionParserWrapper.new do |opt| opt.separator "<compile-options>:" opt.on("-q", "--quiet", "Make vcom quiet.") { @vcom_options.push("-quiet") unless @vcom_options.include?("-quiet") } opt.on("-o", "--options VAL", "Options that will be passed to vcom") { |val| @vcom_options.push(val) } opt.on("-b", "--buildall", "Rebuilds all sources and libraries.") { @buildall = true } end # register the subcommand registerSubCmd( "compile", # name of the subcmd "Compiles the configured sources.", # short description (optional) "Compiles the configured sources.", # description (optional) # the option object (optional) ) { compile() } # the action which should be run when this subcmd is invoked # --- simulate --- # create an options object = CmdParse::OptionParserWrapper.new do |opt| opt.separator "<simlation-options>:" opt.on("-r", "--run TIME", "Simulation time. Format: \"<value> [ms|us|ns|ps]\"") do |time| if time =~ /\d+[ ](ms|us|ns|ps)/ @vsim_simtime = time else raise Fhlow::FhlowPluginException.new("Modelsim"), "Simulation time has wrong format: #{time}" end end opt.on("-c", "--console", "Run simulation in console. Do not start GUI.") { @vsim_options.push("-c") } opt.on("-o", "--options VAL", "Options that will be passed to vsim.") { |val| @vsim_options.push(val) } opt.on("-q", "--quiet", "Make vcom quiet.") { @vcom_options.push("-quiet") unless @vcom_options.include?("-quiet") } opt.on("-b", "--buildall", "Rebuilds all sources and libraries.") { @buildall = true } end # register the subcommand registerSubCmd( "simulate", # name of the subcmd "Simulates the design.", # short description (optional) "Simulates the design.", # description (optional) # the option object (optional) ) { simulate() } # the action which should be run when this subcmd is invoked # --- post layout simulation --- # create an options object = CmdParse::OptionParserWrapper.new do |opt| opt.separator "<plsim-options>:" opt.on("-r", "--run TIME", "Simulation time. Format: \"<value> [ms|us|ns|ps]\"") do |time| if time =~ /\d+[ ](ms|us|ns|ps)/ @vsim_simtime = time else raise Fhlow::FhlowPluginException.new("Modelsim"), "Simulation time has wrong format: #{time}" end end opt.on("-c", "--console", "Run simulation in console. Do not start GUI.") { @vsim_options.push("-c") } opt.on("-o", "--options VAL", "Options that will be passed to vsim.") { |val| @vsim_options.push(val) } opt.on("-b", "--buildall", "Rebuilds all sources and libraries.") { @buildall = true } end # register the subcommand registerSubCmd( "plsim", # name of the subcmd "Runs post layout simulation of the synthesized design.", # short description (optional) "Runs post layout simulation of the synthesized design.", # description (optional) # the option object (optional) ) { plsim() } # the action which should be run when this subcmd is invoked end |
Instance Method Details
#compile ⇒ Object
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/plugins/Modelsim.rb', line 127 def compile() initWork() @pen.puts @actualLeaf.printMe width = 87 @pen.seperator begin @pen.print ",", "-"*width,"+\n" @pen.print "|", " Compilation".ljust(width), "|\n" @pen.print "+", "-"*width,"+\n" unless @actualLeaf.getFiles("Libraries").empty? @pen.puts "| Libraries:" @actualLeaf.getFiles("Libraries").each do |libhash| libhash.each do |libname, files| if @buildall or !File.directory?(@varDir+libname) @pen.puts "| Library: #{libname}" runInVarDir { `#{@actualLeaf.conf["Modelsim"]["BinDir"]}vlib #{@varDir}#{libname}` } runInVarDir { `#{@actualLeaf.conf["Modelsim"]["BinDir"]}vmap #{libname} #{@varDir}#{libname}` } files.each do |f| msg = callVcom(f) printFile(f, $? == 0, @pen.yellow) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 end else @pen.puts "| Library: #{libname} exists, skipping (use --buildall to rebuild)" end end end @pen.print "+", "-"*width,"+\n" end @pen.puts "| Packages:" @actualLeaf.getFiles("Packages").each do |f| msg = callVcom(f) printFile(f, $? == 0, @pen.lightyellow) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 end @pen.print "+", "-"*width,"+\n" @pen.puts "| Units:" @actualLeaf.getFiles("Units").each do |f| msg = callVcom(f) printFile(f, $? == 0, @pen.magenta) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 end @pen.print "+", "-"*width,"+\n" @pen.puts "| BhvUnits:" @actualLeaf.getFiles("BhvUnits").each do |f| msg = callVcom(f) printFile(f, $? == 0, @pen.magenta) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 end @pen.print "+", "-"*width,"+\n" @pen.puts "| tbUnits:" @actualLeaf.getFiles("tbUnits").each do |f| msg = callVcom(f) printFile(f, $? == 0, @pen.magenta) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 end ensure @pen.print "`", "-"*width,"+\n" end end |
#plsim ⇒ Object
219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 |
# File 'lib/plugins/Modelsim.rb', line 219 def plsim() width = 87 @pen.print ",", "-"*width,"+\n" @pen.print "|", " Compilation".ljust(width), "|\n" @pen.print "+", "-"*width,"+\n" begin @pen.puts "| SimulationLibraries of #{@actualLeaf.getTarget("Name")}:" @actualLeaf.getFiles("SimulationLibraries").each do |libhash| libhash.each do |libname, files| if @buildall or !File.directory?(@varDir+libname) @pen.puts "| Library: #{libname}" runInVarDir { `#{@actualLeaf.conf["Modelsim"]["BinDir"]}vlib #{@varDir}#{libname}` } runInVarDir { `#{@actualLeaf.conf["Modelsim"]["BinDir"]}vmap #{libname} #{@varDir}#{libname}` } files.each do |f| msg = callVcom(f, libname) printFile(f, $? == 0, @pen.yellow) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 end else @pen.puts "| Library: #{libname} exists, skipping (use --buildall to rebuild)" end end end @pen.print "+", "-"*width,"+\n" @pen.puts "| Netlist:" f = @shareDir+"net#{@actualLeaf.name}-#{@actualLeaf.getArchitectures(@actualLeaf)["Units"][0]}-ea.vhd" msg = callVcom(f) printFile(f, $? == 0, @pen.magenta) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 @pen.print "+", "-"*width,"+\n" @pen.puts "| Packages:" @actualLeaf.getFiles("Packages").each do |f| msg = callVcom(f) printFile(f, $? == 0, @pen.yellow) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 end @pen.print "+", "-"*width,"+\n" @pen.puts "| BhvUnits:" @actualLeaf.getFiles("BhvUnits").each do |f| msg = callVcom(f) printFile(f, $? == 0, @pen.magenta) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 end @pen.print "+", "-"*width,"+\n" @pen.puts "| tbUnits:" @actualLeaf.getFiles("tbUnits").each do |f| msg = callVcom(f) printFile(f, $? == 0, @pen.magenta) raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors while compiling #{f}!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 end ensure @pen.print "`", "-"*width,"+\n" end @pen.seperator @pen.puts "Running post layout simulation with Modelsim:" ENV["LM_LICENSE_FILE"] = @actualLeaf.conf["Modelsim"]["LicenseFile"] @log.debug("Modelsim", "Setting environment variable LM_LICENSE_FILE to #{@actualLeaf.conf["Modelsim"]["LicenseFile"]}") instruction = "#{@actualLeaf.conf["Modelsim"]["BinDir"]}vsim work.tb#{@actualLeaf.name} " instruction += "#{@vsim_options.join(" ")} " instruction += "-do \"source #{@actualLeaf.getPath}src/wave.do; run #{@vsim_simtime}; #{ @vsim_options.include?("-c") ? 'exit' : ''}\" " instruction += "-sdfmax /DUT=#{@shareDir}/#{@actualLeaf.name}.sdf -noglitch -t ps " instruction += "2>&1" msg = ""; runInVarDir { msg = `#{instruction}` } raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors during simulation!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 @pen.print msg end |
#simulate ⇒ Object
203 204 205 206 207 208 209 210 211 212 213 214 215 216 |
# File 'lib/plugins/Modelsim.rb', line 203 def simulate() compile @pen.seperator ENV["LM_LICENSE_FILE"] = @actualLeaf.conf["Modelsim"]["LicenseFile"] @log.debug("Modelsim", "Setting environment variable LM_LICENSE_FILE to #{@actualLeaf.conf["Modelsim"]["LicenseFile"]}") @pen.puts "Running Modelsim:" instruction = "#{@actualLeaf.conf["Modelsim"]["BinDir"]}vsim work.tb#{@actualLeaf.name} " instruction += "#{@vsim_options.join(" ")} " instruction += "-do \"source #{@actualLeaf.getPath}src/wave.do; run #{@vsim_simtime}; #{ @vsim_options.include?("-c") ? 'exit' : ''}\" " instruction += "2>&1" msg = ""; runInVarDir { msg = `#{instruction}` } raise Fhlow::FhlowPluginException.new("Modelsim"), "There were some errors during simulation!\n Message from Modelsim:\n-----\n#{msg}\n-----" if $? != 0 @pen.puts msg end |