test: 🧪 add a first working test for VHDL execution <3
This commit is contained in:
parent
6ab33ff474
commit
5ada904040
6 changed files with 472 additions and 9 deletions
102
bin/console
102
bin/console
|
@ -23,6 +23,98 @@ $core.add_artefact_engine Comfpile::ParserEngine,
|
|||
regex: /\/\/\s*comf\.(?<key>\w+)[=:]\s*(?<value>.+)/
|
||||
}
|
||||
]
|
||||
$core.add_artefact_engine Comfpile::ParserEngine,
|
||||
file_regex: /^(.+)\.vhd$/,
|
||||
search_regexes: [
|
||||
{
|
||||
regex: /--+\s*comf\.(?<key>[^:]+)[=:]\s*(?<value>.+)/
|
||||
}
|
||||
]
|
||||
|
||||
$core.add_artefact_engine do |engine|
|
||||
engine.add_recipe(:ghdl_analysed, /^(.+)\.vhd/) do |match, a|
|
||||
a.parent_artefact :dependency_analysis_include, a.target
|
||||
|
||||
a.add_step do
|
||||
@parent_artefact.dependencies.each do |dependency|
|
||||
next if dependency.target == a.target
|
||||
|
||||
log "Adding dependency for ghdl analysis of #{dependency.target}..."
|
||||
|
||||
require_artefact :ghdl_analysed, dependency.target
|
||||
end
|
||||
end
|
||||
|
||||
a.add_step do
|
||||
work_library = find_parsed_parameter('vhdl.work')
|
||||
if work_library.nil?
|
||||
work_library = ''
|
||||
else
|
||||
work_library = '--work=' + work_library
|
||||
end
|
||||
|
||||
cmd = "ghdl -a -fsynopsys --std=08 #{work_library} #{self.file}"
|
||||
log "Executing: #{cmd}"
|
||||
|
||||
`#{cmd}`
|
||||
end
|
||||
end
|
||||
|
||||
engine.add_recipe(:ghdl_elaborated, /^(.+)\.vhd/) do |match, a|
|
||||
a.parent_artefact :dependency_analysis, a.target
|
||||
|
||||
a.add_step do
|
||||
dependencies.each do |dep|
|
||||
require_artefact :ghdl_analysed, dep.target
|
||||
end
|
||||
end
|
||||
|
||||
a.add_step do
|
||||
work_library = find_parsed_parameter('vhdl.work')
|
||||
if work_library.nil?
|
||||
work_library = ''
|
||||
else
|
||||
work_library = '--work=' + work_library
|
||||
end
|
||||
|
||||
elaborate_arch = find_parsed_parameter('vhdl.elaborate') || File.basename(@target).chomp(File.extname(@target))
|
||||
|
||||
cmd = "ghdl -e -fsynopsys --std=08 #{work_library} #{elaborate_arch}"
|
||||
log "Executing: #{cmd}"
|
||||
|
||||
`#{cmd}`
|
||||
end
|
||||
end
|
||||
|
||||
engine.add_recipe :ghdl_run, /^(.+)\.vhd/ do |match, a|
|
||||
a.parent_artefact :ghdl_elaborated, a.target
|
||||
|
||||
a.add_step do
|
||||
work_library = find_parsed_parameter('vhdl.work')
|
||||
if work_library.nil?
|
||||
work_library = ''
|
||||
else
|
||||
work_library = '--work=' + work_library
|
||||
end
|
||||
|
||||
elaborate_arch = find_parsed_parameter('vhdl.elaborate') || File.basename(@target).chomp(File.extname(@target))
|
||||
|
||||
@parameters[:ghdl_arch] = elaborate_arch
|
||||
|
||||
cmd = "ghdl -r -fsynopsys --std=08 #{work_library} #{elaborate_arch} --wave=#{elaborate_arch}.ghw"
|
||||
log "Executing: #{cmd}"
|
||||
|
||||
`#{cmd}`
|
||||
end
|
||||
end
|
||||
|
||||
engine.add_recipe(:gtkwave_output, /^(.+)\.vhd/) do |match, a|
|
||||
a.parent_artefact :ghdl_run, a.target
|
||||
a.add_step do
|
||||
`gtkwave #{@parent_artefact[:ghdl_arch]}.ghw`
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
$core.add_artefact_engine do |engine|
|
||||
|
||||
|
@ -54,20 +146,12 @@ $core.add_artefact_engine do |engine|
|
|||
end
|
||||
|
||||
t_start = Time.now()
|
||||
dep_art = $core.craft_and_complete(:dependency_analysis, "main.cpp")
|
||||
dep_art = $core.craft_and_complete(:gtkwave_output, "spi_master_tb.vhd")
|
||||
t_end = Time.now()
|
||||
|
||||
puts "Full dependency list is: #{dep_art.dependencies.map(&:target)} (took #{t_end - t_start})"
|
||||
puts "Includes of all source files:"
|
||||
|
||||
dep_art.dependencies.each do |art|
|
||||
next unless ['.cpp', '.c'].include? File.extname(art.target)
|
||||
|
||||
include_art = $core.craft_and_complete(:dependency_analysis_include, art.target)
|
||||
|
||||
puts "Included dependencies for #{art.target} are #{include_art.dependencies.map(&:target)}"
|
||||
end
|
||||
|
||||
# (If you use this, don't forget to add pry to your Gemfile!)
|
||||
require "pry"
|
||||
Pry.start
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue