HDLRuby 2.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +9 -0
- data/.travis.yml +5 -0
- data/.yardopts +1 -0
- data/Gemfile +4 -0
- data/HDLRuby.gemspec +36 -0
- data/LICENSE.txt +21 -0
- data/README.md +2774 -0
- data/README.pdf +0 -0
- data/Rakefile +10 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/exe/hdrcc +3 -0
- data/lib/HDLRuby/alcc.rb +137 -0
- data/lib/HDLRuby/backend/hruby_allocator.rb +69 -0
- data/lib/HDLRuby/backend/hruby_c_allocator.rb +76 -0
- data/lib/HDLRuby/hdr_samples/adder.rb +7 -0
- data/lib/HDLRuby/hdr_samples/adder_assign_error.rb +11 -0
- data/lib/HDLRuby/hdr_samples/adder_bench.rb +27 -0
- data/lib/HDLRuby/hdr_samples/adder_gen.rb +7 -0
- data/lib/HDLRuby/hdr_samples/adder_nodef_error.rb +7 -0
- data/lib/HDLRuby/hdr_samples/addsub.rb +19 -0
- data/lib/HDLRuby/hdr_samples/addsubz.rb +22 -0
- data/lib/HDLRuby/hdr_samples/alu.rb +47 -0
- data/lib/HDLRuby/hdr_samples/calculator.rb +48 -0
- data/lib/HDLRuby/hdr_samples/counter_bench.rb +83 -0
- data/lib/HDLRuby/hdr_samples/dff.rb +9 -0
- data/lib/HDLRuby/hdr_samples/dff_bench.rb +66 -0
- data/lib/HDLRuby/hdr_samples/dff_counter.rb +20 -0
- data/lib/HDLRuby/hdr_samples/include.rb +14 -0
- data/lib/HDLRuby/hdr_samples/instance_open.rb +23 -0
- data/lib/HDLRuby/hdr_samples/mei8.rb +256 -0
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +309 -0
- data/lib/HDLRuby/hdr_samples/multer_gen.rb +8 -0
- data/lib/HDLRuby/hdr_samples/multer_seq.rb +29 -0
- data/lib/HDLRuby/hdr_samples/neural/a.rb +9 -0
- data/lib/HDLRuby/hdr_samples/neural/a_sub.rb +5 -0
- data/lib/HDLRuby/hdr_samples/neural/bw.rb +23 -0
- data/lib/HDLRuby/hdr_samples/neural/counter.rb +16 -0
- data/lib/HDLRuby/hdr_samples/neural/dadz.rb +9 -0
- data/lib/HDLRuby/hdr_samples/neural/dadz_sub.rb +4 -0
- data/lib/HDLRuby/hdr_samples/neural/forward.rb +153 -0
- data/lib/HDLRuby/hdr_samples/neural/forward_sub.rb +62 -0
- data/lib/HDLRuby/hdr_samples/neural/forward_sub_rand.rb +41 -0
- data/lib/HDLRuby/hdr_samples/neural/forward_sub_rand_typedef.rb +47 -0
- data/lib/HDLRuby/hdr_samples/neural/mem.rb +30 -0
- data/lib/HDLRuby/hdr_samples/neural/random.rb +23 -0
- data/lib/HDLRuby/hdr_samples/neural/selector.rb +29 -0
- data/lib/HDLRuby/hdr_samples/neural/sigmoid.rb +20 -0
- data/lib/HDLRuby/hdr_samples/neural/z.rb +33 -0
- data/lib/HDLRuby/hdr_samples/prog.obj +256 -0
- data/lib/HDLRuby/hdr_samples/ram.rb +18 -0
- data/lib/HDLRuby/hdr_samples/register_with_code_bench.rb +98 -0
- data/lib/HDLRuby/hdr_samples/rom.rb +10 -0
- data/lib/HDLRuby/hdr_samples/struct.rb +14 -0
- data/lib/HDLRuby/hdr_samples/sumprod.rb +29 -0
- data/lib/HDLRuby/hdr_samples/sw_encrypt_bench.rb +103 -0
- data/lib/HDLRuby/hdr_samples/sw_encrypt_cpu_bench.rb +261 -0
- data/lib/HDLRuby/hdr_samples/sw_encrypt_cpusim_bench.rb +302 -0
- data/lib/HDLRuby/hdr_samples/system_open.rb +11 -0
- data/lib/HDLRuby/hdr_samples/tuple.rb +16 -0
- data/lib/HDLRuby/hdr_samples/with_channel.rb +118 -0
- data/lib/HDLRuby/hdr_samples/with_class.rb +199 -0
- data/lib/HDLRuby/hdr_samples/with_decoder.rb +17 -0
- data/lib/HDLRuby/hdr_samples/with_fsm.rb +34 -0
- data/lib/HDLRuby/hdr_samples/with_reconf.rb +103 -0
- data/lib/HDLRuby/hdrcc.rb +623 -0
- data/lib/HDLRuby/high_samples/_adder_fault.rb +23 -0
- data/lib/HDLRuby/high_samples/_generic_transmission2.rb +146 -0
- data/lib/HDLRuby/high_samples/adder.rb +21 -0
- data/lib/HDLRuby/high_samples/adder_common_errors.rb +25 -0
- data/lib/HDLRuby/high_samples/addsub.rb +33 -0
- data/lib/HDLRuby/high_samples/addsubz.rb +37 -0
- data/lib/HDLRuby/high_samples/after.rb +28 -0
- data/lib/HDLRuby/high_samples/all_signals.rb +29 -0
- data/lib/HDLRuby/high_samples/alu.rb +61 -0
- data/lib/HDLRuby/high_samples/anonymous.rb +41 -0
- data/lib/HDLRuby/high_samples/before.rb +28 -0
- data/lib/HDLRuby/high_samples/blockblock.rb +26 -0
- data/lib/HDLRuby/high_samples/bugs/dadz.rb +22 -0
- data/lib/HDLRuby/high_samples/bugs/misample_instan.rb +20 -0
- data/lib/HDLRuby/high_samples/bugs/misample_updown.rb +22 -0
- data/lib/HDLRuby/high_samples/bugs/sample_add.rb +16 -0
- data/lib/HDLRuby/high_samples/bugs/sample_barrel.rb +13 -0
- data/lib/HDLRuby/high_samples/bugs/sample_daice.rb +57 -0
- data/lib/HDLRuby/high_samples/bugs/sample_kumiawase.rb +52 -0
- data/lib/HDLRuby/high_samples/bugs/sample_multi.rb +18 -0
- data/lib/HDLRuby/high_samples/bugs/sample_sub.rb +14 -0
- data/lib/HDLRuby/high_samples/bugs/z2.rb +32 -0
- data/lib/HDLRuby/high_samples/case.rb +32 -0
- data/lib/HDLRuby/high_samples/case2.rb +30 -0
- data/lib/HDLRuby/high_samples/change.rb +23 -0
- data/lib/HDLRuby/high_samples/clocks.rb +35 -0
- data/lib/HDLRuby/high_samples/comparer.rb +21 -0
- data/lib/HDLRuby/high_samples/conditionals.rb +29 -0
- data/lib/HDLRuby/high_samples/dff.rb +23 -0
- data/lib/HDLRuby/high_samples/each.rb +28 -0
- data/lib/HDLRuby/high_samples/exporter.rb +42 -0
- data/lib/HDLRuby/high_samples/functions.rb +60 -0
- data/lib/HDLRuby/high_samples/if_seq.rb +26 -0
- data/lib/HDLRuby/high_samples/inherit_as_dff.rb +32 -0
- data/lib/HDLRuby/high_samples/inherit_dff.rb +36 -0
- data/lib/HDLRuby/high_samples/instance.rb +37 -0
- data/lib/HDLRuby/high_samples/memory.rb +64 -0
- data/lib/HDLRuby/high_samples/multi_file.rb +27 -0
- data/lib/HDLRuby/high_samples/overload.rb +32 -0
- data/lib/HDLRuby/high_samples/paper_after.rb +49 -0
- data/lib/HDLRuby/high_samples/ram.rb +27 -0
- data/lib/HDLRuby/high_samples/registers.rb +139 -0
- data/lib/HDLRuby/high_samples/rom.rb +23 -0
- data/lib/HDLRuby/high_samples/scopeblockname.rb +37 -0
- data/lib/HDLRuby/high_samples/scopescope.rb +26 -0
- data/lib/HDLRuby/high_samples/shift.rb +31 -0
- data/lib/HDLRuby/high_samples/shift2.rb +40 -0
- data/lib/HDLRuby/high_samples/simple_instance.rb +31 -0
- data/lib/HDLRuby/high_samples/test_all.sh +10 -0
- data/lib/HDLRuby/high_samples/typedef.rb +24 -0
- data/lib/HDLRuby/high_samples/values.rb +70 -0
- data/lib/HDLRuby/high_samples/vector.rb +22 -0
- data/lib/HDLRuby/high_samples/with_decoder.rb +30 -0
- data/lib/HDLRuby/high_samples/with_fsm.rb +46 -0
- data/lib/HDLRuby/high_samples/with_pipe.rb +43 -0
- data/lib/HDLRuby/high_samples/with_seq.rb +25 -0
- data/lib/HDLRuby/hruby_bstr.rb +1085 -0
- data/lib/HDLRuby/hruby_check.rb +317 -0
- data/lib/HDLRuby/hruby_db.rb +432 -0
- data/lib/HDLRuby/hruby_error.rb +44 -0
- data/lib/HDLRuby/hruby_high.rb +4103 -0
- data/lib/HDLRuby/hruby_low.rb +4735 -0
- data/lib/HDLRuby/hruby_low2c.rb +1986 -0
- data/lib/HDLRuby/hruby_low2high.rb +738 -0
- data/lib/HDLRuby/hruby_low2seq.rb +248 -0
- data/lib/HDLRuby/hruby_low2sym.rb +126 -0
- data/lib/HDLRuby/hruby_low2vhd.rb +1437 -0
- data/lib/HDLRuby/hruby_low_bool2select.rb +295 -0
- data/lib/HDLRuby/hruby_low_cleanup.rb +193 -0
- data/lib/HDLRuby/hruby_low_fix_types.rb +437 -0
- data/lib/HDLRuby/hruby_low_mutable.rb +1803 -0
- data/lib/HDLRuby/hruby_low_resolve.rb +165 -0
- data/lib/HDLRuby/hruby_low_skeleton.rb +129 -0
- data/lib/HDLRuby/hruby_low_with_bool.rb +141 -0
- data/lib/HDLRuby/hruby_low_with_port.rb +167 -0
- data/lib/HDLRuby/hruby_low_with_var.rb +302 -0
- data/lib/HDLRuby/hruby_low_without_bit2vector.rb +88 -0
- data/lib/HDLRuby/hruby_low_without_concat.rb +162 -0
- data/lib/HDLRuby/hruby_low_without_connection.rb +113 -0
- data/lib/HDLRuby/hruby_low_without_namespace.rb +718 -0
- data/lib/HDLRuby/hruby_low_without_outread.rb +107 -0
- data/lib/HDLRuby/hruby_low_without_select.rb +206 -0
- data/lib/HDLRuby/hruby_serializer.rb +398 -0
- data/lib/HDLRuby/hruby_tools.rb +37 -0
- data/lib/HDLRuby/hruby_types.rb +239 -0
- data/lib/HDLRuby/hruby_values.rb +64 -0
- data/lib/HDLRuby/hruby_verilog.rb +1888 -0
- data/lib/HDLRuby/hruby_verilog_name.rb +52 -0
- data/lib/HDLRuby/low_samples/adder.yaml +97 -0
- data/lib/HDLRuby/low_samples/after.yaml +228 -0
- data/lib/HDLRuby/low_samples/before.yaml +223 -0
- data/lib/HDLRuby/low_samples/blockblock.yaml +48 -0
- data/lib/HDLRuby/low_samples/bugs/sample_add.yaml +97 -0
- data/lib/HDLRuby/low_samples/bugs/sample_daice.yaml +444 -0
- data/lib/HDLRuby/low_samples/bugs/sample_kumiawase.yaml +332 -0
- data/lib/HDLRuby/low_samples/bugs/sample_sub.yaml +97 -0
- data/lib/HDLRuby/low_samples/bugs/seqpar.yaml +184 -0
- data/lib/HDLRuby/low_samples/case.yaml +327 -0
- data/lib/HDLRuby/low_samples/change.yaml +135 -0
- data/lib/HDLRuby/low_samples/clocks.yaml +674 -0
- data/lib/HDLRuby/low_samples/cloner.rb +22 -0
- data/lib/HDLRuby/low_samples/comparer.yaml +85 -0
- data/lib/HDLRuby/low_samples/conditionals.yaml +133 -0
- data/lib/HDLRuby/low_samples/dff.yaml +107 -0
- data/lib/HDLRuby/low_samples/each.yaml +1328 -0
- data/lib/HDLRuby/low_samples/exporter.yaml +226 -0
- data/lib/HDLRuby/low_samples/functions.yaml +298 -0
- data/lib/HDLRuby/low_samples/generic_transmission.yaml +597 -0
- data/lib/HDLRuby/low_samples/inherit_as_dff.yaml +125 -0
- data/lib/HDLRuby/low_samples/inherit_dff.yaml +107 -0
- data/lib/HDLRuby/low_samples/load_yaml.rb +11 -0
- data/lib/HDLRuby/low_samples/memory.yaml +678 -0
- data/lib/HDLRuby/low_samples/namespace_extractor.rb +23 -0
- data/lib/HDLRuby/low_samples/overload.yaml +226 -0
- data/lib/HDLRuby/low_samples/paper_after.yaml +431 -0
- data/lib/HDLRuby/low_samples/port_maker.rb +14 -0
- data/lib/HDLRuby/low_samples/ram.yaml +207 -0
- data/lib/HDLRuby/low_samples/registers.yaml +228 -0
- data/lib/HDLRuby/low_samples/rom.yaml +2950 -0
- data/lib/HDLRuby/low_samples/shift.yaml +230 -0
- data/lib/HDLRuby/low_samples/shift2.yaml +2095 -0
- data/lib/HDLRuby/low_samples/simple_instance.yaml +102 -0
- data/lib/HDLRuby/low_samples/test_all.sh +43 -0
- data/lib/HDLRuby/low_samples/typedef.yaml +115 -0
- data/lib/HDLRuby/low_samples/values.yaml +577 -0
- data/lib/HDLRuby/low_samples/variable_maker.rb +14 -0
- data/lib/HDLRuby/low_samples/vector.yaml +56 -0
- data/lib/HDLRuby/low_samples/with_seq.yaml +188 -0
- data/lib/HDLRuby/low_samples/yaml2hdr.rb +10 -0
- data/lib/HDLRuby/low_samples/yaml2vhd.rb +19 -0
- data/lib/HDLRuby/sim/Makefile +19 -0
- data/lib/HDLRuby/sim/hruby_sim.h +590 -0
- data/lib/HDLRuby/sim/hruby_sim_calc.c +2362 -0
- data/lib/HDLRuby/sim/hruby_sim_core.c +589 -0
- data/lib/HDLRuby/sim/hruby_sim_list.c +93 -0
- data/lib/HDLRuby/sim/hruby_sim_vizualize.c +91 -0
- data/lib/HDLRuby/sim/hruby_value_pool.c +64 -0
- data/lib/HDLRuby/std/channel.rb +354 -0
- data/lib/HDLRuby/std/clocks.rb +165 -0
- data/lib/HDLRuby/std/counters.rb +82 -0
- data/lib/HDLRuby/std/decoder.rb +214 -0
- data/lib/HDLRuby/std/fsm.rb +516 -0
- data/lib/HDLRuby/std/pipeline.rb +220 -0
- data/lib/HDLRuby/std/reconf.rb +309 -0
- data/lib/HDLRuby/test_hruby_bstr.rb +2259 -0
- data/lib/HDLRuby/test_hruby_high.rb +594 -0
- data/lib/HDLRuby/test_hruby_high_low.rb +99 -0
- data/lib/HDLRuby/test_hruby_low.rb +934 -0
- data/lib/HDLRuby/v_samples/adder.v +10 -0
- data/lib/HDLRuby/v_samples/dff.v +12 -0
- data/lib/HDLRuby/v_samples/ram.v +20 -0
- data/lib/HDLRuby/v_samples/rom.v +270 -0
- data/lib/HDLRuby/version.rb +3 -0
- data/lib/HDLRuby.rb +11 -0
- data/makedoc +1 -0
- data/metadata.yaml +4 -0
- metadata +299 -0
|
@@ -0,0 +1,623 @@
|
|
|
1
|
+
#!/usr/bin/ruby
|
|
2
|
+
|
|
3
|
+
require 'fileutils'
|
|
4
|
+
require 'HDLRuby'
|
|
5
|
+
require 'HDLRuby/hruby_check.rb'
|
|
6
|
+
require 'ripper'
|
|
7
|
+
require 'HDLRuby/hruby_low2high'
|
|
8
|
+
require 'HDLRuby/hruby_low2c'
|
|
9
|
+
require 'HDLRuby/hruby_low2vhd'
|
|
10
|
+
require 'HDLRuby/hruby_low_fix_types'
|
|
11
|
+
require 'HDLRuby/hruby_low_without_outread'
|
|
12
|
+
require 'HDLRuby/hruby_low_with_bool'
|
|
13
|
+
require 'HDLRuby/hruby_low_bool2select'
|
|
14
|
+
require 'HDLRuby/hruby_low_without_select'
|
|
15
|
+
require 'HDLRuby/hruby_low_without_namespace'
|
|
16
|
+
require 'HDLRuby/hruby_low_without_bit2vector'
|
|
17
|
+
require 'HDLRuby/hruby_low_with_port'
|
|
18
|
+
require 'HDLRuby/hruby_low_with_var'
|
|
19
|
+
require 'HDLRuby/hruby_low_without_concat'
|
|
20
|
+
require 'HDLRuby/hruby_low_without_connection'
|
|
21
|
+
require 'HDLRuby/hruby_low_cleanup'
|
|
22
|
+
|
|
23
|
+
require 'HDLRuby/hruby_verilog.rb'
|
|
24
|
+
|
|
25
|
+
require 'HDLRuby/backend/hruby_allocator'
|
|
26
|
+
require 'HDLRuby/backend/hruby_c_allocator'
|
|
27
|
+
|
|
28
|
+
##
|
|
29
|
+
# HDLRuby compiler interface program
|
|
30
|
+
#####################################
|
|
31
|
+
|
|
32
|
+
module HDLRuby
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
# Class for loading HDLRuby files.
|
|
37
|
+
class HDRLoad
|
|
38
|
+
|
|
39
|
+
# TOP_NAME = "__hdr_top_instance__"
|
|
40
|
+
TOP_NAME = "__"
|
|
41
|
+
|
|
42
|
+
# The top instance, only accessible after parsing the files.
|
|
43
|
+
attr_reader :top_instance
|
|
44
|
+
|
|
45
|
+
# The required files.
|
|
46
|
+
attr_reader :requires
|
|
47
|
+
|
|
48
|
+
# Creates a new loader for a +top_system+ system in file +top_file+
|
|
49
|
+
# from directory +dir+ with generic parameters +params+.
|
|
50
|
+
def initialize(top_system,top_file,dir,*params)
|
|
51
|
+
# Sets the top and the looking directory.
|
|
52
|
+
@top_system = top_system.to_s
|
|
53
|
+
@top_file = top_file.to_s
|
|
54
|
+
@dir = dir.to_s
|
|
55
|
+
@params = params
|
|
56
|
+
|
|
57
|
+
# The list of required files.
|
|
58
|
+
@requires = []
|
|
59
|
+
|
|
60
|
+
# The list of the code texts (the first one should be the one
|
|
61
|
+
# containing the top system).
|
|
62
|
+
@texts = []
|
|
63
|
+
|
|
64
|
+
# The list of the code checkers.
|
|
65
|
+
@checks = []
|
|
66
|
+
|
|
67
|
+
# The name of the top instance
|
|
68
|
+
@top_name = TOP_NAME
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
# Loads a single +file+.
|
|
72
|
+
def read(file)
|
|
73
|
+
@texts << File.read(File.join(@dir,file) )
|
|
74
|
+
@checks << Checker.new(@texts[-1],file)
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Loads all the files from +file+.
|
|
78
|
+
def read_all(file = @top_file)
|
|
79
|
+
# puts "read_all with file=#{file}"
|
|
80
|
+
# Read the file
|
|
81
|
+
read(file)
|
|
82
|
+
# Get its required files.
|
|
83
|
+
requires = @checks[-1].get_all_requires
|
|
84
|
+
requires.each do |file|
|
|
85
|
+
read_all(file) if file != "HDLRuby"
|
|
86
|
+
end
|
|
87
|
+
@requires += requires
|
|
88
|
+
@requires.uniq!
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Checks the read files.
|
|
92
|
+
def check_all
|
|
93
|
+
@checks.each { |check| check.assign_check }
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
# Displays the syntax tree of all the files.
|
|
97
|
+
def show_all(outfile = $stdout)
|
|
98
|
+
# puts "@checks.size=#{@checks.size}"
|
|
99
|
+
@checks.each { |check| check.show(outfile) }
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Gets the (first) top system.
|
|
103
|
+
def get_top
|
|
104
|
+
# Get all the systems.
|
|
105
|
+
systems = @checks.reduce([]) {|ar,check| ar + check.get_all_systems}
|
|
106
|
+
# puts "First systems=#{systems}"
|
|
107
|
+
# Remove the systems that are instantiated or included
|
|
108
|
+
# (they cannot be tops)
|
|
109
|
+
@checks.each do |check|
|
|
110
|
+
# The instances
|
|
111
|
+
check.get_all_instances(systems).each do |instance|
|
|
112
|
+
systems.delete(check.get_instance_system(instance))
|
|
113
|
+
end
|
|
114
|
+
# The explicitly included systems
|
|
115
|
+
check.get_all_includes(systems).each do |included|
|
|
116
|
+
systems.delete(check.get_include_system(included))
|
|
117
|
+
end
|
|
118
|
+
# The system included when declaring (inheritance)
|
|
119
|
+
check.get_all_inherits(systems).each do |inherit|
|
|
120
|
+
systems -= check.get_inherit_systems(inherit)
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
# puts "Now systems=#{systems}"
|
|
124
|
+
# Return the first top of the list.
|
|
125
|
+
return systems[-1]
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
# Load the HDLRuby structure from an instance of the top module.
|
|
130
|
+
def parse
|
|
131
|
+
# Is there a top system specified yet?
|
|
132
|
+
if @top_system == "" then
|
|
133
|
+
# No, look for it.
|
|
134
|
+
@top_system = get_top
|
|
135
|
+
# puts "@top_system=#{@top_system}"
|
|
136
|
+
unless @top_system then
|
|
137
|
+
# Not found? Error.
|
|
138
|
+
# Maybe it is a parse error, look for it.
|
|
139
|
+
bind = TOPLEVEL_BINDING.clone
|
|
140
|
+
eval("require 'HDLRuby'\n\nconfigure_high\n\n",bind)
|
|
141
|
+
eval(@texts[0],bind,@top_file,1)
|
|
142
|
+
# No parse error found.
|
|
143
|
+
raise "Cannot find a top system." unless @top_system
|
|
144
|
+
end
|
|
145
|
+
end
|
|
146
|
+
# Initialize the environment for processing the hdr file.
|
|
147
|
+
bind = TOPLEVEL_BINDING.clone
|
|
148
|
+
eval("require 'HDLRuby'\n\nconfigure_high\n\n",bind)
|
|
149
|
+
# Process it.
|
|
150
|
+
eval(@texts[0],bind,@top_file,1)
|
|
151
|
+
# Get the resulting instance
|
|
152
|
+
if @params.empty? then
|
|
153
|
+
# There is no generic parameter
|
|
154
|
+
@top_instance =
|
|
155
|
+
eval("#{@top_system} :#{@top_name}\n#{@top_name}",bind)
|
|
156
|
+
else
|
|
157
|
+
# There are generic parameters
|
|
158
|
+
@top_instance =
|
|
159
|
+
# eval("#{@top_system} :#{@top_name},#{@params.join(",")}\n#{@top_name}",bind)
|
|
160
|
+
eval("#{@top_system}(#{@params.join(",")}).(:#{@top_name})\n#{@top_name}",bind)
|
|
161
|
+
end
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# Extend the Code class with generation of file for the content.
|
|
167
|
+
class HDLRuby::Low::Code
|
|
168
|
+
|
|
169
|
+
## Creates a file in +path+ containing the content of the code.
|
|
170
|
+
def to_file(path = "")
|
|
171
|
+
self.each_chunk do |chunk|
|
|
172
|
+
# Process the lumps of the chunk.
|
|
173
|
+
# NOTE: for now use the C code generation of Low2C
|
|
174
|
+
content = chunk.to_c
|
|
175
|
+
# Dump to a file.
|
|
176
|
+
if chunk.name != :sim then
|
|
177
|
+
# The chunk is to be dumbed to a file.
|
|
178
|
+
# puts "Outputing chunk:#{HDLRuby::Low::Low2C.obj_name(chunk)}"
|
|
179
|
+
outfile = File.open(path + "/" +
|
|
180
|
+
HDLRuby::Low::Low2C.obj_name(chunk) + "." +
|
|
181
|
+
chunk.name.to_s,"w")
|
|
182
|
+
outfile << content
|
|
183
|
+
outfile.close
|
|
184
|
+
end
|
|
185
|
+
end
|
|
186
|
+
end
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
|
|
194
|
+
if __FILE__ == $0 then
|
|
195
|
+
# From hdrcc.rb
|
|
196
|
+
$hdr_dir = File.dirname(__FILE__)
|
|
197
|
+
else
|
|
198
|
+
# Form hdrcc
|
|
199
|
+
$hdr_dir = File.dirname(Gem.bin_path("HDLRuby","hdrcc")).chomp("exe") +
|
|
200
|
+
"lib/HDLRuby"
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
require 'optparse'
|
|
204
|
+
# Used standalone, check the files given in the standard input.
|
|
205
|
+
include HDLRuby
|
|
206
|
+
|
|
207
|
+
# Process the command line options
|
|
208
|
+
$options = {}
|
|
209
|
+
$optparse = OptionParser.new do |opts|
|
|
210
|
+
opts.banner = "Usage: hdrcc.rb [options] <input file> [<output file>]"
|
|
211
|
+
|
|
212
|
+
opts.separator ""
|
|
213
|
+
opts.separator "Where:"
|
|
214
|
+
opts.separator "* `options` is a list of options"
|
|
215
|
+
opts.separator "* `<input file>` is the initial file to compile (mandatory)"
|
|
216
|
+
opts.separator "* `<output file>` is the output file"
|
|
217
|
+
opts.separator ""
|
|
218
|
+
opts.separator "Options:"
|
|
219
|
+
|
|
220
|
+
opts.on("-y", "--yaml", "Output in YAML format") do |y|
|
|
221
|
+
$options[:yaml] = y
|
|
222
|
+
end
|
|
223
|
+
opts.on("-r", "--hdr","Output in HDLRuby format") do |v|
|
|
224
|
+
$options[:hdr] = v
|
|
225
|
+
end
|
|
226
|
+
opts.on("-C", "--clang","Output in C format (simulator)") do |v|
|
|
227
|
+
$options[:clang] = v
|
|
228
|
+
$options[:multiple] = v
|
|
229
|
+
end
|
|
230
|
+
opts.on("--allocate=LOW,HIGH,WORD","Allocate signals to addresses") do |v|
|
|
231
|
+
$options[:allocate] = v
|
|
232
|
+
end
|
|
233
|
+
opts.on("-S", "--sim","Output in C format (simulator)") do |v|
|
|
234
|
+
$options[:clang] = v
|
|
235
|
+
$options[:multiple] = v
|
|
236
|
+
$options[:sim] = v
|
|
237
|
+
end
|
|
238
|
+
opts.on("-v", "--verilog","Output in Verlog HDL format") do |v|
|
|
239
|
+
$options[:verilog] = v
|
|
240
|
+
$options[:multiple] = v
|
|
241
|
+
end
|
|
242
|
+
opts.on("-V", "--vhdl","Output in VHDL format") do |v|
|
|
243
|
+
HDLRuby::Low::Low2VHDL.vhdl08 = false
|
|
244
|
+
$options[:vhdl] = v
|
|
245
|
+
$options[:multiple] = v
|
|
246
|
+
$options[:vhdl08] = false
|
|
247
|
+
end
|
|
248
|
+
opts.on("-A", "--alliance","Output in Alliance-compatible VHDL format") do |v|
|
|
249
|
+
HDLRuby::Low::Low2VHDL.vhdl08 = false
|
|
250
|
+
HDLRuby::Low::Low2VHDL.alliance = true
|
|
251
|
+
$options[:vhdl] = v
|
|
252
|
+
$options[:alliance] = v
|
|
253
|
+
$options[:multiple] = v
|
|
254
|
+
$options[:vhdl08] = false
|
|
255
|
+
end
|
|
256
|
+
opts.on("-U", "--vhdl08","Output in VHDL'08 format") do |v|
|
|
257
|
+
HDLRuby::Low::Low2VHDL.vhdl08 = true
|
|
258
|
+
$options[:vhdl] = v
|
|
259
|
+
$options[:multiple] = v
|
|
260
|
+
$options[:vhdl08] = true
|
|
261
|
+
end
|
|
262
|
+
opts.on("-s", "--syntax","Output the Ruby syntax tree") do |s|
|
|
263
|
+
$options[:syntax] = s
|
|
264
|
+
end
|
|
265
|
+
opts.on("-m", "--multiple", "Produce multiple files for the result.\nThe output name is then interpreted as a directory name.") do |v|
|
|
266
|
+
$options[:multiple] = v
|
|
267
|
+
end
|
|
268
|
+
opts.on("-d", "--directory dir","Specify the base directory for loading the hdr files") do |d|
|
|
269
|
+
$options[:directory] = d
|
|
270
|
+
end
|
|
271
|
+
opts.on("-D", "--debug","Set the HDLRuby debug mode") do |d|
|
|
272
|
+
$options[:debug] = d
|
|
273
|
+
end
|
|
274
|
+
opts.on("-t", "--top system", "Specify the top system to process") do|t|
|
|
275
|
+
$options[:top] = t
|
|
276
|
+
end
|
|
277
|
+
opts.on("-p", "--param x,y,z", "Specify the generic parameters") do |p|
|
|
278
|
+
$options[:param] = p
|
|
279
|
+
end
|
|
280
|
+
opts.on_tail("-h", "--help", "Show this message") do
|
|
281
|
+
puts opts
|
|
282
|
+
exit
|
|
283
|
+
end
|
|
284
|
+
opts.separator ""
|
|
285
|
+
opts.separator "Notice:"
|
|
286
|
+
opts.separator "* If no output option is given, simply checks the input file"
|
|
287
|
+
opts.separator "* If no output file is given, the result is given through the standard output."
|
|
288
|
+
opts.separator "* If no top system is given, it will be automatically searched in the input file."
|
|
289
|
+
opts.separator ""
|
|
290
|
+
opts.separator "Examples:"
|
|
291
|
+
opts.separator "* Compile system named `adder` from `adder.rb` input file and generate `adder.yaml` low-level YAML description:"
|
|
292
|
+
opts.separator " hdrcc.rb --yaml --top adder adder.rb adder.yaml"
|
|
293
|
+
opts.separator "* Compile `adder.rb` input file and generate `adder.vhd` low-level VHDL description:"
|
|
294
|
+
opts.separator " hdrcc.rb --vhdl adder.rb adder.vhd"
|
|
295
|
+
opts.separator "* Check the validity of `adder.rb` input file:"
|
|
296
|
+
opts.separator " hdrcc.rb adder.rb"
|
|
297
|
+
opts.separator "* Compile system `adder` whose bit width is generic from `adder_gen.rb` input file to a 16-bit circuit whose low-level Verilog HDL description is dumped to the standard output:"
|
|
298
|
+
opts.separator " hdrcc -v -t adder --param 16 adder_gen.rb"
|
|
299
|
+
opts.separator "* Compile system `multer` with inputs and output bit width is generic from `multer_gen.rb` input file to a 16x16->32 bit cicruit whose low-level YAML description is saved to output file `multer_gen.yaml`"
|
|
300
|
+
opts.separator "hdrcc -y -t multer -p 16,16,32 multer_gen.rb multer_gen.yaml"
|
|
301
|
+
|
|
302
|
+
end
|
|
303
|
+
$optparse.parse!
|
|
304
|
+
|
|
305
|
+
# puts "options=#{$options}"
|
|
306
|
+
|
|
307
|
+
# Check the compatibility of the options
|
|
308
|
+
if $options.count {|op| [:yaml,:hdr,:verilog,:vhdl].include?(op) } > 1 then
|
|
309
|
+
warn("Please choose either YAML, HDLRuby, Verilog HDL, or VHDL output.")
|
|
310
|
+
puts $optparse.help()
|
|
311
|
+
end
|
|
312
|
+
|
|
313
|
+
# Get the the input and the output files.
|
|
314
|
+
$input,$output = $*
|
|
315
|
+
# Get the top system name if name.
|
|
316
|
+
$top = $options[:top].to_s
|
|
317
|
+
unless $top == "" || (/^[_[[:alpha:]]][_\w]*$/ =~ $top) then
|
|
318
|
+
warn("Please provide a valid top system name.")
|
|
319
|
+
exit
|
|
320
|
+
end
|
|
321
|
+
# Get the generic parameters if any.
|
|
322
|
+
$params = $options[:param].to_s.split(",")
|
|
323
|
+
|
|
324
|
+
|
|
325
|
+
if $input == nil then
|
|
326
|
+
warn("Please provide an input file (or consult the help using the --help option.)")
|
|
327
|
+
exit
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
# Open the output.
|
|
331
|
+
if $output then
|
|
332
|
+
if $options[:multiple] then
|
|
333
|
+
# Create a directory if necessary.
|
|
334
|
+
unless File.directory?($output)
|
|
335
|
+
FileUtils.mkdir_p($output)
|
|
336
|
+
end
|
|
337
|
+
else
|
|
338
|
+
# Open the file.
|
|
339
|
+
$output = File.open($output,"w")
|
|
340
|
+
end
|
|
341
|
+
else
|
|
342
|
+
if $option[:multiple] then
|
|
343
|
+
raise "Need a target directory in multiple files generation mode."
|
|
344
|
+
end
|
|
345
|
+
$output = $stdout
|
|
346
|
+
end
|
|
347
|
+
|
|
348
|
+
# Load and process the hdr files.
|
|
349
|
+
$options[:directory] ||= "./"
|
|
350
|
+
$loader = HDRLoad.new($top,$input,$options[:directory].to_s,*$params)
|
|
351
|
+
$loader.read_all
|
|
352
|
+
$loader.check_all
|
|
353
|
+
|
|
354
|
+
if $options[:syntax] then
|
|
355
|
+
if $options[:multiple] then
|
|
356
|
+
raise "Multiple files generation mode not supported for syntax tree output."
|
|
357
|
+
end
|
|
358
|
+
$output << $loader.show_all
|
|
359
|
+
exit
|
|
360
|
+
end
|
|
361
|
+
|
|
362
|
+
if $options[:debug] then
|
|
363
|
+
# Debug mode, no error management.
|
|
364
|
+
$top_instance = $loader.parse
|
|
365
|
+
else
|
|
366
|
+
# Not debug mode, use the error management.
|
|
367
|
+
error_manager($loader.requires + [$input]) { $top_instance = $loader.parse }
|
|
368
|
+
end
|
|
369
|
+
|
|
370
|
+
# Generate the result.
|
|
371
|
+
# Get the top systemT.
|
|
372
|
+
$top_system = $top_instance.to_low.systemT
|
|
373
|
+
|
|
374
|
+
# Gather the non-HDLRuby code.
|
|
375
|
+
$non_hdlruby = []
|
|
376
|
+
$top_system.each_systemT_deep do |systemT|
|
|
377
|
+
systemT.scope.each_scope_deep do |scope|
|
|
378
|
+
scope.each_code do |code|
|
|
379
|
+
$non_hdlruby << code
|
|
380
|
+
end
|
|
381
|
+
end
|
|
382
|
+
end
|
|
383
|
+
# Applies the allocators if required.
|
|
384
|
+
$allocate_range = $options[:allocate]
|
|
385
|
+
if $allocate_range then
|
|
386
|
+
# Get the allocation characteristics.
|
|
387
|
+
$allocate_range = $allocate_range.split(",")
|
|
388
|
+
$allocate_range = [$allocate_range[0]..$allocate_range[1],
|
|
389
|
+
$allocate_range[2]].compact
|
|
390
|
+
# Create the allocator.
|
|
391
|
+
allocator = HDLRuby::Low::Allocator.new(*$allocate_range)
|
|
392
|
+
$non_hdlruby.each do |code|
|
|
393
|
+
# Try the C allocator.
|
|
394
|
+
code.c_code_allocate(allocator)
|
|
395
|
+
end
|
|
396
|
+
end
|
|
397
|
+
# Generates its code.
|
|
398
|
+
$non_hdlruby.each {|code| code.to_file($output) }
|
|
399
|
+
|
|
400
|
+
# The HDLRuby code
|
|
401
|
+
if $options[:yaml] then
|
|
402
|
+
if $options[:multiple] then
|
|
403
|
+
raise "Multiple files generation mode not supported for YAML output yet."
|
|
404
|
+
end
|
|
405
|
+
# $output << $top_instance.to_low.systemT.to_yaml
|
|
406
|
+
$output << $top_system.to_yaml
|
|
407
|
+
elsif $options[:hdr] then
|
|
408
|
+
if $options[:multiple] then
|
|
409
|
+
raise "Multiple files generation mode not supported for HDLRuby output yet."
|
|
410
|
+
end
|
|
411
|
+
# $top_system.each_systemT_deep.reverse_each do |systemT|
|
|
412
|
+
# $output << systemT.to_high
|
|
413
|
+
# end
|
|
414
|
+
# $output << $top_instance.to_low.systemT.to_high
|
|
415
|
+
$output << $top_system.to_high
|
|
416
|
+
elsif $options[:clang] then
|
|
417
|
+
# top_system = $top_instance.to_low.systemT
|
|
418
|
+
top_system = $top_system
|
|
419
|
+
# Preprocess the HW description for valid C generation.
|
|
420
|
+
top_system.each_systemT_deep do |systemT|
|
|
421
|
+
# Converts the connections to behaviors.
|
|
422
|
+
systemT.connections_to_behaviors!
|
|
423
|
+
# Break the RefConcat.
|
|
424
|
+
systemT.break_concat_assigns!
|
|
425
|
+
# Explicits the types.
|
|
426
|
+
systemT.explicit_types!
|
|
427
|
+
end
|
|
428
|
+
# Generate the C.
|
|
429
|
+
if $options[:multiple] then
|
|
430
|
+
# Get the base name of the input file, it will be used for
|
|
431
|
+
# generating the main name of the multiple result files.
|
|
432
|
+
basename = File.basename($input,File.extname($input))
|
|
433
|
+
basename = $output + "/" + basename
|
|
434
|
+
# File name counter.
|
|
435
|
+
count = 0
|
|
436
|
+
|
|
437
|
+
# # Converts the connections to behaviors (C generation does not
|
|
438
|
+
# # support connections).
|
|
439
|
+
# top_system.each_systemT_deep do |systemT|
|
|
440
|
+
# systemT.connections_to_behaviors!
|
|
441
|
+
# end
|
|
442
|
+
|
|
443
|
+
# Multiple files generation mode.
|
|
444
|
+
# Generate the h file.
|
|
445
|
+
hname = $output + "/hruby_sim_gen.h"
|
|
446
|
+
hnames = [ File.basename(hname) ]
|
|
447
|
+
outfile = File.open(hname,"w")
|
|
448
|
+
# Adds the generated globals
|
|
449
|
+
top_system.each_systemT_deep do |systemT|
|
|
450
|
+
# For the h file.
|
|
451
|
+
# hname = $output + "/" +
|
|
452
|
+
# HDLRuby::Low::Low2C.c_name(systemT.name) +
|
|
453
|
+
# ".h"
|
|
454
|
+
# hnames << File.basename(hname)
|
|
455
|
+
# # Open the file for current systemT
|
|
456
|
+
# output = File.open(hname,"w")
|
|
457
|
+
# Generate the H code in to.
|
|
458
|
+
outfile << systemT.to_ch
|
|
459
|
+
# # Close the file.
|
|
460
|
+
# output.close
|
|
461
|
+
# # Clears the name.
|
|
462
|
+
# hname = nil
|
|
463
|
+
end
|
|
464
|
+
# Adds the globals from the non-HDLRuby code
|
|
465
|
+
$non_hdlruby.each do |code|
|
|
466
|
+
code.each_chunk do |chunk|
|
|
467
|
+
if chunk.name == :sim then
|
|
468
|
+
outfile << "extern " +
|
|
469
|
+
HDLRuby::Low::Low2C.prototype(chunk.to_c)
|
|
470
|
+
end
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
outfile.close
|
|
474
|
+
|
|
475
|
+
# Prepare the initial name for the main file.
|
|
476
|
+
name = basename + ".c"
|
|
477
|
+
# Generate the code for it.
|
|
478
|
+
main = File.open(name,"w")
|
|
479
|
+
|
|
480
|
+
# Generate the code of the main function.
|
|
481
|
+
# HDLRuby start code
|
|
482
|
+
main << HDLRuby::Low::Low2C.main(top_system,
|
|
483
|
+
top_system.each_systemT_deep.to_a.reverse,hnames)
|
|
484
|
+
main.close
|
|
485
|
+
|
|
486
|
+
top_system.each_systemT_deep do |systemT|
|
|
487
|
+
# For the c file.
|
|
488
|
+
name = $output + "/" +
|
|
489
|
+
HDLRuby::Low::Low2C.c_name(systemT.name) +
|
|
490
|
+
".c"
|
|
491
|
+
# Open the file for current systemT
|
|
492
|
+
outfile = File.open(name,"w")
|
|
493
|
+
# Generate the C code in to.
|
|
494
|
+
outfile << systemT.to_c(0,*hnames)
|
|
495
|
+
# Close the file.
|
|
496
|
+
outfile.close
|
|
497
|
+
# Clears the name.
|
|
498
|
+
name = nil
|
|
499
|
+
end
|
|
500
|
+
else
|
|
501
|
+
# Single file generation mode.
|
|
502
|
+
top_system.each_systemT_deep.reverse_each do |systemT|
|
|
503
|
+
$output << systemT.to_ch
|
|
504
|
+
$output << systemT.to_c
|
|
505
|
+
end
|
|
506
|
+
# Adds the main code.
|
|
507
|
+
$output << HDLRuby::Low::Low2C.main(top_system,
|
|
508
|
+
*top_system.each_systemT_deep.to_a)
|
|
509
|
+
end
|
|
510
|
+
if $options[:sim] then
|
|
511
|
+
# Simulation mode, compile and exectute.
|
|
512
|
+
# Path of the simulator core files.
|
|
513
|
+
# simdir = File.dirname(__FILE__) + "/sim/"
|
|
514
|
+
simdir = $hdr_dir + "/sim/"
|
|
515
|
+
# Generate and execute the simulation commands.
|
|
516
|
+
# Kernel.system("cp -n #{simdir}* #{$output}/; cd #{$output}/ ; make -s ; ./hruby_simulator")
|
|
517
|
+
Dir.entries(simdir).each do |filename|
|
|
518
|
+
unless File.directory?(filename) then
|
|
519
|
+
FileUtils.cp(simdir + "/" + filename,$output)
|
|
520
|
+
end
|
|
521
|
+
end
|
|
522
|
+
Dir.chdir($output)
|
|
523
|
+
Kernel.system("make -s")
|
|
524
|
+
Kernel.system("./hruby_simulator")
|
|
525
|
+
end
|
|
526
|
+
elsif $options[:verilog] then
|
|
527
|
+
# warn("Verilog HDL output is not available yet... but it will be soon, promise!")
|
|
528
|
+
# top_system = $top_instance.to_low.systemT
|
|
529
|
+
top_system = $top_system
|
|
530
|
+
# Make description compatible with verilog generation.
|
|
531
|
+
top_system.each_systemT_deep do |systemT|
|
|
532
|
+
systemT.to_upper_space!
|
|
533
|
+
systemT.to_global_systemTs!
|
|
534
|
+
systemT.break_types!
|
|
535
|
+
systemT.with_port!
|
|
536
|
+
end
|
|
537
|
+
# # Verilog generation
|
|
538
|
+
# $output << top_system.to_verilog
|
|
539
|
+
# Generate the Verilog.
|
|
540
|
+
if $options[:multiple] then
|
|
541
|
+
# Get the base name of the input file, it will be used for
|
|
542
|
+
# generating the main name of the multiple result files.
|
|
543
|
+
basename = File.basename($input,File.extname($input))
|
|
544
|
+
basename = $output + "/" + basename
|
|
545
|
+
# File name counter.
|
|
546
|
+
count = 0
|
|
547
|
+
# Prepare the initial name for the main file.
|
|
548
|
+
name = basename + ".v"
|
|
549
|
+
# Multiple files generation mode.
|
|
550
|
+
top_system.each_systemT_deep do |systemT|
|
|
551
|
+
# Generate the name if necessary.
|
|
552
|
+
unless name
|
|
553
|
+
name = $output + "/" +
|
|
554
|
+
HDLRuby::Verilog.name_to_verilog(systemT.name) +
|
|
555
|
+
".v"
|
|
556
|
+
end
|
|
557
|
+
# Open the file for current systemT
|
|
558
|
+
outfile = File.open(name,"w")
|
|
559
|
+
# Generate the VHDL code in to.
|
|
560
|
+
outfile << systemT.to_verilog
|
|
561
|
+
# Close the file.
|
|
562
|
+
outfile.close
|
|
563
|
+
# Clears the name.
|
|
564
|
+
name = nil
|
|
565
|
+
end
|
|
566
|
+
else
|
|
567
|
+
# Single file generation mode.
|
|
568
|
+
top_system.each_systemT_deep.reverse_each do |systemT|
|
|
569
|
+
$output << systemT.to_verilog
|
|
570
|
+
end
|
|
571
|
+
end
|
|
572
|
+
elsif $options[:vhdl] then
|
|
573
|
+
# top_system = $top_instance.to_low.systemT
|
|
574
|
+
top_system = $top_system
|
|
575
|
+
# Make description compatible with vhdl generation.
|
|
576
|
+
top_system.each_systemT_deep do |systemT|
|
|
577
|
+
systemT.outread2inner! unless $options[:vhdl08] || $options[:alliance]
|
|
578
|
+
systemT.with_boolean!
|
|
579
|
+
systemT.boolean_in_assign2select! unless $options[:alliance]
|
|
580
|
+
systemT.bit2vector2inner! unless $options[:vhdl08] || $options[:alliance]
|
|
581
|
+
systemT.select2case! # if $options[:alliance]
|
|
582
|
+
systemT.break_concat_assigns! # if $options[:alliance]
|
|
583
|
+
systemT.to_upper_space!
|
|
584
|
+
systemT.to_global_systemTs!
|
|
585
|
+
systemT.break_types!
|
|
586
|
+
systemT.with_port!
|
|
587
|
+
systemT.with_var!
|
|
588
|
+
systemT.cleanup!
|
|
589
|
+
end
|
|
590
|
+
# Generate the vhdl.
|
|
591
|
+
if $options[:multiple] then
|
|
592
|
+
# Get the base name of the input file, it will be used for
|
|
593
|
+
# generating the main name of the multiple result files.
|
|
594
|
+
basename = File.basename($input,File.extname($input))
|
|
595
|
+
basename = $output + "/" + basename
|
|
596
|
+
# File name counter.
|
|
597
|
+
count = 0
|
|
598
|
+
# Prepare the initial name for the main file.
|
|
599
|
+
name = basename + ".vhd"
|
|
600
|
+
# Multiple files generation mode.
|
|
601
|
+
top_system.each_systemT_deep do |systemT|
|
|
602
|
+
# Generate the name if necessary.
|
|
603
|
+
unless name
|
|
604
|
+
name = $output + "/" +
|
|
605
|
+
HDLRuby::Low::Low2VHDL.entity_name(systemT.name) +
|
|
606
|
+
".vhd"
|
|
607
|
+
end
|
|
608
|
+
# Open the file for current systemT
|
|
609
|
+
outfile = File.open(name,"w")
|
|
610
|
+
# Generate the VHDL code in to.
|
|
611
|
+
outfile << systemT.to_vhdl
|
|
612
|
+
# Close the file.
|
|
613
|
+
outfile.close
|
|
614
|
+
# Clears the name.
|
|
615
|
+
name = nil
|
|
616
|
+
end
|
|
617
|
+
else
|
|
618
|
+
# Single file generation mode.
|
|
619
|
+
top_system.each_systemT_deep.reverse_each do |systemT|
|
|
620
|
+
$output << systemT.to_vhdl
|
|
621
|
+
end
|
|
622
|
+
end
|
|
623
|
+
end
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
require 'HDLRuby'
|
|
2
|
+
|
|
3
|
+
configure_high
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
# A simple 16-bit adder with an error
|
|
7
|
+
system :adder do
|
|
8
|
+
[15..0].input :x,:y
|
|
9
|
+
[16..0].output :s
|
|
10
|
+
|
|
11
|
+
seq do
|
|
12
|
+
s = x + y
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
# Instantiate it for checking.
|
|
17
|
+
adder :adderI
|
|
18
|
+
|
|
19
|
+
# Generate the low level representation.
|
|
20
|
+
low = adderI.systemT.to_low
|
|
21
|
+
|
|
22
|
+
# Displays it
|
|
23
|
+
puts low.to_yaml
|