Created
March 29, 2016 21:03
-
-
Save vadixidav/7846ef771b77c190a5bb73f2f2f5fc97 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_name = ARGV.shift | |
| 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,v}")) | |
| 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