Skip to content

Instantly share code, notes, and snippets.

@vadixidav
Created March 29, 2016 08:28
Show Gist options
  • Select an option

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

Select an option

Save vadixidav/b28200a01a9fc9682be5 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_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