Created
March 29, 2016 08:28
-
-
Save vadixidav/b28200a01a9fc9682be5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/ruby | |
| require 'fileutils' | |
| def show_usage | |
| STDERR.puts "usage: vbuild [build|run|buildrun] topmodule_path" | |
| exit 1 | |
| end | |
| # Sanity check | |
| show_usage if ARGV.length < 2 | |
| # Setup variables | |
| command = ARGV.shift | |
| show_usage if !['build', 'run', 'buildrun'].include? command | |
| build = ['build', 'buildrun'].include? command | |
| run = ['run', 'buildrun'].include? command | |
| top_file = ARGV.shift | |
| top_name = File.basename(top_file, '.sv') | |
| bin_dir = "out" | |
| bin_file = "#{bin_dir}/#{top_name}" | |
| if build | |
| puts "Building #{top_name}..." | |
| FileUtils.mkdir_p bin_dir | |
| cmd = ['iverilog', '-g2012', | |
| '-o', bin_file, | |
| '-s', top_name | |
| ].concat(Dir.glob("**/*.sv")) | |
| exit 1 if !system *cmd | |
| puts "Finished building." | |
| end | |
| if run | |
| puts "Running #{top_name}..." | |
| system bin_file | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment