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,165 @@
|
|
|
1
|
+
require "HDLRuby/hruby_error"
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
##
|
|
6
|
+
# Adds methods for finding objects through names.
|
|
7
|
+
#
|
|
8
|
+
# NOTE: For now only resolve name reference.
|
|
9
|
+
#
|
|
10
|
+
########################################################################
|
|
11
|
+
module HDLRuby::Low
|
|
12
|
+
|
|
13
|
+
##
|
|
14
|
+
# Extends SystemT with the capability of finding one of its inner object
|
|
15
|
+
# by name.
|
|
16
|
+
class SystemT
|
|
17
|
+
|
|
18
|
+
## Find an inner object by +name+.
|
|
19
|
+
# NOTE: return nil if not found.
|
|
20
|
+
def get_by_name(name)
|
|
21
|
+
# Ensure the name is a symbol.
|
|
22
|
+
name = name.to_sym
|
|
23
|
+
# Look in the interface.
|
|
24
|
+
found = self.get_signal(name)
|
|
25
|
+
return found if found
|
|
26
|
+
# Maybe it is the scope.
|
|
27
|
+
return self.scope if self.scope.name == name
|
|
28
|
+
# Look in the scope.
|
|
29
|
+
return self.scope.get_by_name(name)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# Extends Scope with the capability of finding one of its inner object
|
|
36
|
+
# by name.
|
|
37
|
+
class Scope
|
|
38
|
+
|
|
39
|
+
## Find an inner object by +name+.
|
|
40
|
+
# NOTE: return nil if not found.
|
|
41
|
+
def get_by_name(name)
|
|
42
|
+
# Ensure the name is a symbol.
|
|
43
|
+
name = name.to_sym
|
|
44
|
+
# Look in the signals.
|
|
45
|
+
found = self.get_inner(name)
|
|
46
|
+
return found if found
|
|
47
|
+
# Look in the instances.
|
|
48
|
+
found = self.each_systemI.find { |systemI| systemI.name == name }
|
|
49
|
+
return found if found
|
|
50
|
+
# Maybe it is a sub scope.
|
|
51
|
+
return self.each_scope.find { |scope| scope.name == name }
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
##
|
|
57
|
+
# Extends SystemI with the capability of finding one of its inner object
|
|
58
|
+
# by name.
|
|
59
|
+
class SystemI
|
|
60
|
+
|
|
61
|
+
## Find an inner object by +name+.
|
|
62
|
+
# NOTE: return nil if not found.
|
|
63
|
+
def get_by_name(name)
|
|
64
|
+
# Look into the eigen system.
|
|
65
|
+
return self.systemT.get_by_name(name)
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
|
|
70
|
+
##
|
|
71
|
+
# Extends Block with the capability of finding one of its inner object
|
|
72
|
+
# by name.
|
|
73
|
+
class Block
|
|
74
|
+
|
|
75
|
+
## Find an inner object by +name+.
|
|
76
|
+
# NOTE: return nil if not found.
|
|
77
|
+
def get_by_name(name)
|
|
78
|
+
# Ensure the name is a symbol.
|
|
79
|
+
name = name.to_sym
|
|
80
|
+
# Look in the signals.
|
|
81
|
+
return self.get_inner(name)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
##
|
|
87
|
+
# Extends RefIndex with the capability of finding the object it
|
|
88
|
+
# refered to.
|
|
89
|
+
class RefIndex
|
|
90
|
+
|
|
91
|
+
## Tells if it is a reference to a systemI signal.
|
|
92
|
+
def from_systemI?
|
|
93
|
+
return self.ref.from_systemI
|
|
94
|
+
end
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
##
|
|
99
|
+
# Extends RefRange with the capability of finding the object it
|
|
100
|
+
# refered to.
|
|
101
|
+
class RefRange
|
|
102
|
+
|
|
103
|
+
## Tells if it is a reference to a systemI signal.
|
|
104
|
+
def from_systemI?
|
|
105
|
+
return self.ref.from_systemI
|
|
106
|
+
end
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
##
|
|
111
|
+
# Extends RefName with the capability of finding the object it
|
|
112
|
+
# refered to.
|
|
113
|
+
class RefName
|
|
114
|
+
|
|
115
|
+
## Tells if it is a reference to a systemI signal.
|
|
116
|
+
def from_systemI?
|
|
117
|
+
# puts "from_systemI? for #{self.name}"
|
|
118
|
+
# Look for the owner from the name hierarchy.
|
|
119
|
+
if self.ref.is_a?(RefName) then
|
|
120
|
+
# Look in the parent hierachy for the sub reference name.
|
|
121
|
+
parent = self.parent
|
|
122
|
+
while parent
|
|
123
|
+
if parent.respond_to?(:get_by_name) then
|
|
124
|
+
found = parent.get_by_name(self.ref.name)
|
|
125
|
+
# puts "found is a :#{found.class}"
|
|
126
|
+
return found.is_a?(SystemI)
|
|
127
|
+
end
|
|
128
|
+
parent = parent.parent
|
|
129
|
+
end
|
|
130
|
+
# Not found, look further in the reference hierarchy.
|
|
131
|
+
return self.ref.from_systemI?
|
|
132
|
+
end
|
|
133
|
+
# Not from a systemI.
|
|
134
|
+
# puts "Not from systemI for #{self.name}"
|
|
135
|
+
return false
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
## Resolves the name of the reference and return the
|
|
140
|
+
# corresponding object.
|
|
141
|
+
# NOTE: return nil if could not resolve.
|
|
142
|
+
def resolve
|
|
143
|
+
# puts "Resolve with #{self} and name=#{self.name}"
|
|
144
|
+
# First resolve the sub reference if possible.
|
|
145
|
+
if self.ref.is_a?(RefName) then
|
|
146
|
+
obj = self.ref.resolve
|
|
147
|
+
# Look into the object for the name.
|
|
148
|
+
return obj.get_by_name(self.name)
|
|
149
|
+
else
|
|
150
|
+
# Look in the parent hierachy for the name.
|
|
151
|
+
parent = self.parent
|
|
152
|
+
# puts "parent=#{parent}"
|
|
153
|
+
while parent
|
|
154
|
+
if parent.respond_to?(:get_by_name) then
|
|
155
|
+
found = parent.get_by_name(self.name)
|
|
156
|
+
return found if found
|
|
157
|
+
end
|
|
158
|
+
parent = parent.parent
|
|
159
|
+
end
|
|
160
|
+
# Not found.
|
|
161
|
+
return nil
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
end
|
|
165
|
+
end
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
require 'HDLRuby'
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
module HDLRuby::Low
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
##
|
|
8
|
+
# Skeleton of the HRuby::Low class structure.
|
|
9
|
+
#
|
|
10
|
+
# Can be used as basis for extending HDLRuby::Low
|
|
11
|
+
#
|
|
12
|
+
########################################################################
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SystemT
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
class Scope
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
class Type
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
class TypeDef
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
class TypeVector
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class TypeTuple
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
class TypeStruct
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
class Behavior
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
class TimeBehavior
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
class Event
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
class SignalI
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
class SystemI
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
class Statement
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
class Transmit
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
class If
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
class When
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
class Case
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
class Delay
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
class TimeWait
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
class TimeRepeat
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
class Block
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
class TimeBlock
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
class Code
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
class Connection
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
class Expression
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
class Value
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
class Cast
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
class Operation
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
class Unary
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
class Binary
|
|
103
|
+
end
|
|
104
|
+
|
|
105
|
+
class Select
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
class Concat
|
|
109
|
+
end
|
|
110
|
+
|
|
111
|
+
class Ref
|
|
112
|
+
end
|
|
113
|
+
|
|
114
|
+
class RefConcat
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
class RefIndex
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
class RefRange
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
class RefName
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
class RefThis
|
|
127
|
+
end
|
|
128
|
+
|
|
129
|
+
end
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
require "HDLRuby/hruby_error"
|
|
2
|
+
require "HDLRuby/hruby_low_mutable"
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
##
|
|
6
|
+
# Provides a new boolean type and converts the comparison and operations
|
|
7
|
+
# on it to this new type.
|
|
8
|
+
#
|
|
9
|
+
# NOTE: * this transformation is a prerequired for supporting target
|
|
10
|
+
# language like VHDL that do not consider boolean to be identical
|
|
11
|
+
# to bit.
|
|
12
|
+
# * Boolean is weak in type promotion, e.g.: boolean & bit = bit
|
|
13
|
+
#
|
|
14
|
+
########################################################################
|
|
15
|
+
module HDLRuby::Low
|
|
16
|
+
|
|
17
|
+
# Extend Type with check telling if it is a boolean type.
|
|
18
|
+
class Type
|
|
19
|
+
# Tells if it is a boolean type.
|
|
20
|
+
def boolean?
|
|
21
|
+
return false
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
##
|
|
27
|
+
# The boolean type leaf.
|
|
28
|
+
class << ( Boolean = Type.new(:boolean) )
|
|
29
|
+
include LLeaf
|
|
30
|
+
# Tells if the type fixed point.
|
|
31
|
+
def fixed?
|
|
32
|
+
return true
|
|
33
|
+
end
|
|
34
|
+
# Gets the bitwidth of the type, nil for undefined.
|
|
35
|
+
def width
|
|
36
|
+
1
|
|
37
|
+
end
|
|
38
|
+
# Gets the range of the type.
|
|
39
|
+
def range
|
|
40
|
+
0..0
|
|
41
|
+
end
|
|
42
|
+
# Tells if it is a boolean type.
|
|
43
|
+
def boolean?
|
|
44
|
+
return true
|
|
45
|
+
end
|
|
46
|
+
# # Get the base type, actually self for leaf types.
|
|
47
|
+
# def base
|
|
48
|
+
# self
|
|
49
|
+
# end
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
## Extends the SystemT class for converting types of comparison and
|
|
54
|
+
# operations on it to boolean type.
|
|
55
|
+
class SystemT
|
|
56
|
+
# Converts to a variable-compatible system.
|
|
57
|
+
#
|
|
58
|
+
# NOTE: the result is the same systemT.
|
|
59
|
+
def with_boolean!
|
|
60
|
+
self.scope.each_scope_deep do |scope|
|
|
61
|
+
scope.each_connection { |connection| connection.with_boolean! }
|
|
62
|
+
scope.each_behavior { |behavior| behavior.with_boolean! }
|
|
63
|
+
end
|
|
64
|
+
return self
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
## Extends the Behaviour class for converting types of comparison and
|
|
69
|
+
# operations on it to boolean type.
|
|
70
|
+
class Behavior
|
|
71
|
+
# Converts to a variable-compatible system.
|
|
72
|
+
#
|
|
73
|
+
# NOTE: the result is the same Behaviour.
|
|
74
|
+
def with_boolean!
|
|
75
|
+
self.each_statement { |statement| statement.with_boolean! }
|
|
76
|
+
end
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
## Extends the Statement class for converting types of comparison and
|
|
80
|
+
# operations on it to boolean type.
|
|
81
|
+
class Statement
|
|
82
|
+
# Converts to a variable-compatible system.
|
|
83
|
+
#
|
|
84
|
+
# NOTE: the result is the same Behaviour.
|
|
85
|
+
def with_boolean!
|
|
86
|
+
self.each_node do |node|
|
|
87
|
+
if node.is_a?(Expression) && node.boolean? then
|
|
88
|
+
node.set_type!(HDLRuby::Low::Boolean)
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
end
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
## Extends the Expression class for checking if it a boolean expression
|
|
95
|
+
# or not.
|
|
96
|
+
class Expression
|
|
97
|
+
# Tells if the expression is boolean.
|
|
98
|
+
def boolean?
|
|
99
|
+
return false
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
## Extends the Unary class for checking if it is a boolean expression
|
|
104
|
+
# or not.
|
|
105
|
+
class Unary
|
|
106
|
+
# Tells if the expression is boolean.
|
|
107
|
+
def boolean?
|
|
108
|
+
return self.child.boolean?
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
## Extends the Binary class for checking if it is a boolean expression
|
|
113
|
+
# or not.
|
|
114
|
+
class Binary
|
|
115
|
+
# Tells if the expression is boolean.
|
|
116
|
+
def boolean?
|
|
117
|
+
case(self.operator)
|
|
118
|
+
when :==,:!=,:>,:<,:>=,:<= then
|
|
119
|
+
# Comparison, it is a boolean.
|
|
120
|
+
return true
|
|
121
|
+
when :&,:|,:^ then
|
|
122
|
+
# AND, OR or XOR, boolean if both subs are boolean.
|
|
123
|
+
return self.left.boolean? && self.right.boolean?
|
|
124
|
+
else
|
|
125
|
+
# Other cases: not boolean.
|
|
126
|
+
return false
|
|
127
|
+
end
|
|
128
|
+
end
|
|
129
|
+
end
|
|
130
|
+
|
|
131
|
+
## Extends the Select class for checking if it a boolean epression
|
|
132
|
+
# or not.
|
|
133
|
+
class Select
|
|
134
|
+
# Tells if the expression is boolean.
|
|
135
|
+
def boolean?
|
|
136
|
+
# Boolean if all the choices are boolean.
|
|
137
|
+
return !self.each_choice.any? {|c| !c.boolean? }
|
|
138
|
+
end
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
end
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
require "HDLRuby/hruby_error"
|
|
2
|
+
require "HDLRuby/hruby_low_mutable"
|
|
3
|
+
require "HDLRuby/hruby_low2sym"
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module HDLRuby::Low
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
# Generates port wires for each instance instead of standard signals in
|
|
12
|
+
# HDLRuby::Low description.
|
|
13
|
+
#
|
|
14
|
+
# Port wires can be directly converted to instance connection in VHDL and
|
|
15
|
+
# Verilog.
|
|
16
|
+
#
|
|
17
|
+
########################################################################
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Extends SystemT with generation of port wires.
|
|
22
|
+
class SystemT
|
|
23
|
+
|
|
24
|
+
# Converts to a port-compatible system.
|
|
25
|
+
#
|
|
26
|
+
# NOTE: the result is the same systemT.
|
|
27
|
+
def with_port!
|
|
28
|
+
self.scope.with_port!
|
|
29
|
+
return self
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
## Extends the Scope class with retrival conversion to symbol.
|
|
35
|
+
class Scope
|
|
36
|
+
|
|
37
|
+
# Converts a port wire to a reference to it.
|
|
38
|
+
def portw2ref(portw)
|
|
39
|
+
return RefName.new(portw.type,RefThis.new,portw.name)
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# Converts symbol +sym+ representing an HDLRuby reference to a
|
|
43
|
+
# instance port to a port wire.
|
|
44
|
+
def sym2portw_name(sym)
|
|
45
|
+
return ("^" + sym.to_s).to_sym
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# Converts a port wire +name+ to the symbol giving the corresponding
|
|
49
|
+
# HDLRuby reference.
|
|
50
|
+
def portw_name2sym(name)
|
|
51
|
+
return name[1..-1].to_sym
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
# Generates a port wire from a reference.
|
|
55
|
+
def make_portw(ref)
|
|
56
|
+
# First generates the name of the port.
|
|
57
|
+
name = sym2portw_name(ref.to_sym)
|
|
58
|
+
# Then generate the port wire.
|
|
59
|
+
return SignalI.new(name,ref.type)
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
# Tells if a +node+ is a reference to an instance's port.
|
|
63
|
+
def instance_port?(node)
|
|
64
|
+
# First the node must be a name reference.
|
|
65
|
+
return false unless node.is_a?(RefName)
|
|
66
|
+
# Then its sub ref must be a RefName of an instance.
|
|
67
|
+
sub = node.ref
|
|
68
|
+
return false unless sub.is_a?(RefName)
|
|
69
|
+
# puts "@systemIs.keys=#{@systemIs.keys}"
|
|
70
|
+
# System instance in current scope?
|
|
71
|
+
return true if @systemIs.key?(sub.name)
|
|
72
|
+
# if self.parent.is_a?(Scope) then
|
|
73
|
+
# # Recurse the search in the parent.
|
|
74
|
+
# return parent.instance_port?(node)
|
|
75
|
+
# else
|
|
76
|
+
# # No parent, failure.
|
|
77
|
+
# return false
|
|
78
|
+
# end
|
|
79
|
+
return false
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# Converts to a port-compatible system.
|
|
84
|
+
#
|
|
85
|
+
# NOTE: the result is the same scope.
|
|
86
|
+
def with_port!
|
|
87
|
+
# # Recurse on the sub scope.
|
|
88
|
+
# self.each_scope(&:with_port!)
|
|
89
|
+
# Gather the references to instance ports.
|
|
90
|
+
# Also remember if the references were left values or not.
|
|
91
|
+
refs = []
|
|
92
|
+
ref_sym2leftvalue = {}
|
|
93
|
+
self.each_block_deep do |block|
|
|
94
|
+
block.each_node_deep do |node|
|
|
95
|
+
if instance_port?(node) then
|
|
96
|
+
# puts "port for node: #{node.ref.name}.#{node.name}"
|
|
97
|
+
refs << node
|
|
98
|
+
ref_sym2leftvalue[node.to_sym] = node.leftvalue?
|
|
99
|
+
end
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
self.each_connection do |connection|
|
|
103
|
+
connection.each_node_deep do |node|
|
|
104
|
+
if instance_port?(node) then
|
|
105
|
+
refs << node
|
|
106
|
+
ref_sym2leftvalue[node.to_sym] = node.leftvalue?
|
|
107
|
+
end
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
# Generate the port wire from the refs.
|
|
111
|
+
ref_sym2portw = {}
|
|
112
|
+
refs.each { |ref| ref_sym2portw[ref.to_sym] = make_portw(ref) }
|
|
113
|
+
# Declare the port wires.
|
|
114
|
+
ref_sym2portw.each_value { |portw| self.add_inner(portw.clone) }
|
|
115
|
+
# Replace the references by their corresponding port wires.
|
|
116
|
+
self.each_block_deep do |block|
|
|
117
|
+
block.each_node_deep do |node|
|
|
118
|
+
node.map_nodes! do |expr|
|
|
119
|
+
portw = ref_sym2portw[expr.to_sym]
|
|
120
|
+
portw ? portw2ref(portw) : expr
|
|
121
|
+
end
|
|
122
|
+
end
|
|
123
|
+
end
|
|
124
|
+
self.each_connection do |connection|
|
|
125
|
+
connection.each_node_deep do |node|
|
|
126
|
+
node.map_nodes! do |expr|
|
|
127
|
+
portw = ref_sym2portw[expr.to_sym]
|
|
128
|
+
portw ? portw2ref(portw) : expr
|
|
129
|
+
end
|
|
130
|
+
end
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Finally adds the connections with the port wires.
|
|
134
|
+
ref_sym2portw.each do |sym,portw|
|
|
135
|
+
ref = sym.to_hdr
|
|
136
|
+
if ref_sym2leftvalue[sym] then
|
|
137
|
+
# The reference was a left value, assign the port wire
|
|
138
|
+
# to the ref.
|
|
139
|
+
self.add_connection(
|
|
140
|
+
Connection.new(ref.clone,portw2ref(portw)) )
|
|
141
|
+
else
|
|
142
|
+
# The reference was a right value, assign it to the
|
|
143
|
+
# port wire.
|
|
144
|
+
self.add_connection(
|
|
145
|
+
Connection.new(portw2ref(portw),ref.clone) )
|
|
146
|
+
end
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
|
|
150
|
+
return self
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
## Extends SystemT with generation of port wires.
|
|
157
|
+
class SystemI
|
|
158
|
+
|
|
159
|
+
def with_port!
|
|
160
|
+
self.systemT.with_port!
|
|
161
|
+
return self
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
end
|