Skip to content

Instantly share code, notes, and snippets.

@vadixidav
Created March 29, 2016 21:03
Show Gist options
  • Select an option

  • Save vadixidav/7846ef771b77c190a5bb73f2f2f5fc97 to your computer and use it in GitHub Desktop.

Select an option

Save vadixidav/7846ef771b77c190a5bb73f2f2f5fc97 to your computer and use it in GitHub Desktop.
#!/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