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,295 @@
|
|
|
1
|
+
require 'HDLRuby'
|
|
2
|
+
require 'HDLRuby/hruby_tools'
|
|
3
|
+
require 'HDLRuby/hruby_low_mutable'
|
|
4
|
+
require 'HDLRuby/hruby_low_with_bool'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module HDLRuby::Low
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
# Converts booleans in assignments to select operators.
|
|
12
|
+
# Use for generating VHDL code without type compatibility troubles.
|
|
13
|
+
#
|
|
14
|
+
########################################################################
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Extends the SystemT class with functionality for converting booleans
|
|
18
|
+
# in assignments to select operators.
|
|
19
|
+
class SystemT
|
|
20
|
+
|
|
21
|
+
# Converts booleans in assignments to select operators.
|
|
22
|
+
def boolean_in_assign2select!
|
|
23
|
+
self.scope.boolean_in_assign2select!
|
|
24
|
+
return self
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
## Extends the Scope class with functionality for converting booleans
|
|
31
|
+
# in assignments to select operators.
|
|
32
|
+
class Scope
|
|
33
|
+
|
|
34
|
+
# Converts booleans in assignments to select operators.
|
|
35
|
+
def boolean_in_assign2select!
|
|
36
|
+
# Recurse on the sub scopes.
|
|
37
|
+
self.each_scope(&:boolean_in_assign2select!)
|
|
38
|
+
|
|
39
|
+
# Apply on the connections.
|
|
40
|
+
self.each_connection(&:boolean_in_assign2select!)
|
|
41
|
+
|
|
42
|
+
# Apply on the behaviors.
|
|
43
|
+
self.each_behavior do |behavior|
|
|
44
|
+
behavior.block.boolean_in_assign2select!
|
|
45
|
+
end
|
|
46
|
+
return self
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
## Extends the Transmit class with functionality for converting booleans
|
|
52
|
+
# in assignments to select operators.
|
|
53
|
+
class Transmit
|
|
54
|
+
|
|
55
|
+
# Converts booleans in assignments to select operators.
|
|
56
|
+
def boolean_in_assign2select!
|
|
57
|
+
# Apply on the left value.
|
|
58
|
+
self.set_left!(self.left.boolean_in_assign2select)
|
|
59
|
+
# Apply on the right value.
|
|
60
|
+
self.set_right!(self.right.boolean_in_assign2select)
|
|
61
|
+
return self
|
|
62
|
+
end
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
## Extends the If class with functionality for converting booleans
|
|
66
|
+
# in assignments to select operators.
|
|
67
|
+
class If
|
|
68
|
+
|
|
69
|
+
# Converts booleans in assignments to select operators.
|
|
70
|
+
def boolean_in_assign2select!
|
|
71
|
+
# No need to apply on condition!
|
|
72
|
+
# # Apply on the condition.
|
|
73
|
+
# self.set_condition!(self.condition.boolean_in_assign2select)
|
|
74
|
+
# Apply on the yes.
|
|
75
|
+
self.yes.boolean_in_assign2select!
|
|
76
|
+
# Apply on the noifs.
|
|
77
|
+
@noifs.map! do |cond,stmnt|
|
|
78
|
+
# No need to apply on condition!
|
|
79
|
+
# [cond.boolean_in_assign2select,stmnt.boolean_in_assign2select!]
|
|
80
|
+
[cond,stmnt.boolean_in_assign2select!]
|
|
81
|
+
end
|
|
82
|
+
# Apply on the no if any.
|
|
83
|
+
self.no.boolean_in_assign2select! if self.no
|
|
84
|
+
return self
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
## Extends the When class with functionality for converting booleans
|
|
89
|
+
# in assignments to select operators.
|
|
90
|
+
class When
|
|
91
|
+
|
|
92
|
+
# Converts booleans in assignments to select operators.
|
|
93
|
+
def boolean_in_assign2select!
|
|
94
|
+
# No need to apply on the match!
|
|
95
|
+
# # Apply on the match.
|
|
96
|
+
# self.set_match!(self.match.boolean_in_assign2select)
|
|
97
|
+
# Apply on the statement.
|
|
98
|
+
self.statement.boolean_in_assign2select!
|
|
99
|
+
return self
|
|
100
|
+
end
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
|
|
104
|
+
## Extends the Case class with functionality for converting booleans
|
|
105
|
+
# in assignments to select operators.
|
|
106
|
+
class Case
|
|
107
|
+
|
|
108
|
+
# Converts booleans in assignments to select operators.
|
|
109
|
+
def boolean_in_assign2select!
|
|
110
|
+
# No need to apply on the value!
|
|
111
|
+
# # Apply on the value.
|
|
112
|
+
# self.set_value!(self.value.boolean_in_assign2select)
|
|
113
|
+
# Apply on the whens.
|
|
114
|
+
self.each_when(&:boolean_in_assign2select!)
|
|
115
|
+
# Apply on the default if any.
|
|
116
|
+
self.default.boolean_in_assign2select! if self.default
|
|
117
|
+
return self
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## Extends the Block class with functionality for converting booleans
|
|
123
|
+
# in assignments to select operators.
|
|
124
|
+
class Block
|
|
125
|
+
|
|
126
|
+
# Converts booleans in assignments to select operators.
|
|
127
|
+
def boolean_in_assign2select!
|
|
128
|
+
# Apply on each statement.
|
|
129
|
+
self.each_statement(&:boolean_in_assign2select!)
|
|
130
|
+
return self
|
|
131
|
+
end
|
|
132
|
+
end
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
## Extends the Value class with functionality for converting booleans
|
|
136
|
+
# in assignments to select operators.
|
|
137
|
+
class Value
|
|
138
|
+
# Converts booleans in assignments to select operators.
|
|
139
|
+
def boolean_in_assign2select
|
|
140
|
+
# Simple clones.
|
|
141
|
+
return self.clone
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
|
|
146
|
+
## Extends the Cast class with functionality for converting booleans
|
|
147
|
+
# in assignments to select operators.
|
|
148
|
+
class Cast
|
|
149
|
+
# Converts booleans in assignments to select operators.
|
|
150
|
+
def boolean_in_assign2select
|
|
151
|
+
# Recurse on the child.
|
|
152
|
+
return Cast.new(self.type,self.child.boolean_in_assign2select)
|
|
153
|
+
end
|
|
154
|
+
end
|
|
155
|
+
|
|
156
|
+
## Extends the Unary class with functionality for converting booleans
|
|
157
|
+
# in assignments to select operators.
|
|
158
|
+
class Unary
|
|
159
|
+
|
|
160
|
+
# Converts booleans in assignments to select operators.
|
|
161
|
+
def boolean_in_assign2select
|
|
162
|
+
# Recurse on the sub node.
|
|
163
|
+
return Unary.new(self.type,self.operator,
|
|
164
|
+
self.child.boolean_in_assign2select)
|
|
165
|
+
return self
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
## Extends the Binary class with functionality for converting booleans
|
|
171
|
+
# in assignments to select operators.
|
|
172
|
+
class Binary
|
|
173
|
+
|
|
174
|
+
# Converts booleans in assignments to select operators.
|
|
175
|
+
def boolean_in_assign2select
|
|
176
|
+
# Recurse on the sub nodes.
|
|
177
|
+
nleft = self.left.boolean_in_assign2select
|
|
178
|
+
nright = self.right.boolean_in_assign2select
|
|
179
|
+
# Is it a comparison but the parent is not a boolean?
|
|
180
|
+
# or a transmit to a boolean.
|
|
181
|
+
if [:==,:>,:<,:>=,:<=].include?(self.operator) &&
|
|
182
|
+
( (self.parent.is_a?(Expression) && !self.parent.type.boolean?) ||
|
|
183
|
+
(self.parent.is_a?(Transmit) && !self.parent.left.type.boolean?)) then
|
|
184
|
+
# Yes, create a select.
|
|
185
|
+
nself = Binary.new(self.type,self.operator,nleft,nright)
|
|
186
|
+
# return Select.new(self.type, "?", nself,
|
|
187
|
+
return Select.new(HDLRuby::Low::Bit, "?", nself,
|
|
188
|
+
# Value.new(self.type,1), Value.new(self.type,0) )
|
|
189
|
+
Value.new(HDLRuby::Low::Bit,0),
|
|
190
|
+
Value.new(HDLRuby::Low::Bit,1) )
|
|
191
|
+
# Value.new(HDLRuby::Low::Boolean,0),
|
|
192
|
+
# Value.new(HDLRuby::Low::Boolean,1) )
|
|
193
|
+
else
|
|
194
|
+
# No return it as is.
|
|
195
|
+
self.set_left!(nleft)
|
|
196
|
+
self.set_right!(nright)
|
|
197
|
+
return self
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
|
|
202
|
+
|
|
203
|
+
## Extends the Select class with functionality for converting booleans
|
|
204
|
+
# in assignments to select operators.
|
|
205
|
+
class Select
|
|
206
|
+
|
|
207
|
+
# Converts booleans in assignments to select operators.
|
|
208
|
+
def boolean_in_assign2select
|
|
209
|
+
# Recurse on the sub node.
|
|
210
|
+
return Select.new(self.type,"?",
|
|
211
|
+
self.select.boolean_in_assign2select,
|
|
212
|
+
*self.each_choice.map do |choice|
|
|
213
|
+
choice.boolean_in_assign2select
|
|
214
|
+
end )
|
|
215
|
+
return self
|
|
216
|
+
end
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
|
|
220
|
+
## Extends the Concat class with functionality for converting booleans
|
|
221
|
+
# in assignments to select operators.
|
|
222
|
+
class Concat
|
|
223
|
+
# Converts booleans in assignments to select operators.
|
|
224
|
+
def boolean_in_assign2select
|
|
225
|
+
# Recurse on the sub expressions.
|
|
226
|
+
return Concat.new(self.type,self.each_expression.map do |expr|
|
|
227
|
+
expr.boolean_in_assign2select
|
|
228
|
+
end )
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
|
|
233
|
+
## Extends the Ref class with functionality for converting booleans
|
|
234
|
+
# in assignments to select operators.
|
|
235
|
+
class RefConcat
|
|
236
|
+
# Converts booleans in assignments to select operators.
|
|
237
|
+
def boolean_in_assign2select
|
|
238
|
+
# Recurse on the sub references.
|
|
239
|
+
return RefConcat.new(self.type,self.each_expression.map do |expr|
|
|
240
|
+
expr.boolean_in_assign2select
|
|
241
|
+
end )
|
|
242
|
+
end
|
|
243
|
+
end
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
## Extends the RefIndex class with functionality for converting booleans
|
|
247
|
+
# in assignments to select operators.
|
|
248
|
+
class RefIndex
|
|
249
|
+
# Converts booleans in assignments to select operators.
|
|
250
|
+
def boolean_in_assign2select
|
|
251
|
+
# Recurse on the sub references.
|
|
252
|
+
return RefIndex.new(self.type,
|
|
253
|
+
self.ref.boolean_in_assign2select,
|
|
254
|
+
self.index.boolean_in_assign2select)
|
|
255
|
+
end
|
|
256
|
+
end
|
|
257
|
+
|
|
258
|
+
|
|
259
|
+
## Extends the RefRange class with functionality for converting booleans
|
|
260
|
+
# in assignments to select operators.
|
|
261
|
+
class RefRange
|
|
262
|
+
# Converts booleans in assignments to select operators.
|
|
263
|
+
def boolean_in_assign2select
|
|
264
|
+
# Recurse on the sub references.
|
|
265
|
+
return RefRange.new(self.type,
|
|
266
|
+
self.ref.boolean_in_assign2select,
|
|
267
|
+
self.range.first.boolean_in_assign2select ..
|
|
268
|
+
self.range.last.boolean_in_assign2select)
|
|
269
|
+
end
|
|
270
|
+
end
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
## Extends the RefName class with functionality for converting booleans
|
|
274
|
+
# in assignments to select operators.
|
|
275
|
+
class RefName
|
|
276
|
+
# Converts booleans in assignments to select operators.
|
|
277
|
+
def boolean_in_assign2select
|
|
278
|
+
# Recurse on the sub references.
|
|
279
|
+
return RefName.new(self.type,
|
|
280
|
+
self.ref.boolean_in_assign2select,
|
|
281
|
+
self.name)
|
|
282
|
+
end
|
|
283
|
+
end
|
|
284
|
+
|
|
285
|
+
|
|
286
|
+
## Extends the RefName class with functionality for converting booleans
|
|
287
|
+
# in assignments to select operators.
|
|
288
|
+
class RefThis
|
|
289
|
+
# Converts booleans in assignments to select operators.
|
|
290
|
+
def boolean_in_assign2select
|
|
291
|
+
# Simply clone.
|
|
292
|
+
return self.clone
|
|
293
|
+
end
|
|
294
|
+
end
|
|
295
|
+
end
|
|
@@ -0,0 +1,193 @@
|
|
|
1
|
+
require 'HDLRuby'
|
|
2
|
+
require 'HDLRuby/hruby_tools'
|
|
3
|
+
require 'HDLRuby/hruby_low_mutable'
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
module HDLRuby::Low
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
##
|
|
10
|
+
# Cleans up the HDLRuby::Low description.
|
|
11
|
+
#
|
|
12
|
+
# NOTE: Assume each name is uniq.
|
|
13
|
+
#
|
|
14
|
+
########################################################################
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
## Extends the SystemT class with functionality for cleaning up the
|
|
18
|
+
# structure.
|
|
19
|
+
class SystemT
|
|
20
|
+
|
|
21
|
+
# Cleans up.
|
|
22
|
+
def cleanup!
|
|
23
|
+
# Gather the output and inout signals' names, they are used to
|
|
24
|
+
# identify the signals that can be removed.
|
|
25
|
+
keep = self.each_output.map {|sig| sig.name } +
|
|
26
|
+
self.each_inout.map {|sig| sig.name }
|
|
27
|
+
self.scope.cleanup!(keep)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
## Extends the Scope class with functionality for cleaning up the
|
|
33
|
+
# structure.
|
|
34
|
+
class Scope
|
|
35
|
+
|
|
36
|
+
# Cleans up.
|
|
37
|
+
# +keep+ includes the list of names to be kept.
|
|
38
|
+
def cleanup!(keep)
|
|
39
|
+
# Complete the list of signals to keep with the signals parts
|
|
40
|
+
# of the right values of connections and statements or
|
|
41
|
+
# instance interface.
|
|
42
|
+
self.each_scope_deep do |scope|
|
|
43
|
+
# Connections.
|
|
44
|
+
scope.each_connection do |connection|
|
|
45
|
+
connection.right.each_node_deep do |node|
|
|
46
|
+
# Leaf right value references are to keep.
|
|
47
|
+
# They are either signal of current system or
|
|
48
|
+
# system instance names.
|
|
49
|
+
if node.is_a?(RefName) && !node.ref.is_a?(RefName) then
|
|
50
|
+
keep << node.name
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
# System instances.
|
|
55
|
+
scope.each_systemI do |systemI|
|
|
56
|
+
keep << systemI.name
|
|
57
|
+
end
|
|
58
|
+
# Behaviors.
|
|
59
|
+
scope.each_behavior do |behavior|
|
|
60
|
+
behavior.block.each_node_deep do |node|
|
|
61
|
+
# Skip left values.
|
|
62
|
+
next if node.respond_to?(:leftvalue?) && node.leftvalue?
|
|
63
|
+
# Leaf right value references are to keep.
|
|
64
|
+
# They are either signal of current system or
|
|
65
|
+
# system instance names.
|
|
66
|
+
if node.is_a?(RefName) && !node.ref.is_a?(RefName) then
|
|
67
|
+
keep << node.name
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Remove the signals and correspondong assignments that are not
|
|
74
|
+
# to keep.
|
|
75
|
+
self.delete_unless!(keep)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# Removes the signals and corresponding assignments whose name is not
|
|
79
|
+
# in +keep+.
|
|
80
|
+
def delete_unless!(keep)
|
|
81
|
+
# Recurse on the sub scopes.
|
|
82
|
+
self.each_scope { |scope| scope.delete_unless!(keep) }
|
|
83
|
+
|
|
84
|
+
# Remove the unessary inner signals.
|
|
85
|
+
self.each_inner.to_a.each do |inner|
|
|
86
|
+
unless keep.include?(inner.name) then
|
|
87
|
+
self.delete_inner!(inner)
|
|
88
|
+
end
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# Remove the unessary connections.
|
|
92
|
+
self.each_connection.to_a.each do |connection|
|
|
93
|
+
# puts "connection with left=#{connection.left.name}"
|
|
94
|
+
unless connection.left.each_node_deep.any? { |node|
|
|
95
|
+
node.is_a?(RefName) && keep.include?(node.name)
|
|
96
|
+
}
|
|
97
|
+
self.delete_connection!(connection)
|
|
98
|
+
end
|
|
99
|
+
end
|
|
100
|
+
|
|
101
|
+
# Recurse on the blocks.
|
|
102
|
+
self.each_behavior do |behavior|
|
|
103
|
+
behavior.block.delete_unless!(keep)
|
|
104
|
+
end
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
## Extends the Statement class with functionality for breaking assingments
|
|
111
|
+
# to concats.
|
|
112
|
+
class Statement
|
|
113
|
+
|
|
114
|
+
# Removes the signals and corresponding assignments whose name is not
|
|
115
|
+
# in +keep+.
|
|
116
|
+
def delete_unless!(keep)
|
|
117
|
+
# By default nothing to do.
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
|
|
122
|
+
## Extends the If class with functionality for breaking assingments
|
|
123
|
+
# to concats.
|
|
124
|
+
class If
|
|
125
|
+
|
|
126
|
+
# Removes the signals and corresponding assignments whose name is not
|
|
127
|
+
# in +keep+.
|
|
128
|
+
def delete_unless!(keep)
|
|
129
|
+
# Recurse on the sub statements.
|
|
130
|
+
# Yes.
|
|
131
|
+
self.yes.delete_unless!(keep)
|
|
132
|
+
# Noifs.
|
|
133
|
+
self.each_noif { |cond,stmnt| stmnt.delete_unless!(keep) }
|
|
134
|
+
# No if any.
|
|
135
|
+
self.no.delete_unless!(keep) if self.no
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
139
|
+
## Extends the When class with functionality for breaking assingments
|
|
140
|
+
# to concats.
|
|
141
|
+
class When
|
|
142
|
+
|
|
143
|
+
# Removes the signals and corresponding assignments whose name is not
|
|
144
|
+
# in +keep+.
|
|
145
|
+
def delete_unless!(keep)
|
|
146
|
+
# Recurse on the statement.
|
|
147
|
+
self.statement.delete_unless!(keep)
|
|
148
|
+
end
|
|
149
|
+
end
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
## Extends the Case class with functionality for breaking assingments
|
|
153
|
+
# to concats.
|
|
154
|
+
class Case
|
|
155
|
+
# Removes the signals and corresponding assignments whose name is not
|
|
156
|
+
# in +keep+.
|
|
157
|
+
def delete_unless!(keep)
|
|
158
|
+
# Recurse on the whens.
|
|
159
|
+
self.each_when {|w| w.delete_unless!(keep) }
|
|
160
|
+
# Recurse on the default if any.
|
|
161
|
+
self.default.delete_unless!(keep) if self.default
|
|
162
|
+
end
|
|
163
|
+
end
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
## Extends the Block class with functionality for breaking assingments
|
|
167
|
+
# to concats.
|
|
168
|
+
class Block
|
|
169
|
+
|
|
170
|
+
# Removes the signals and corresponding assignments whose name is not
|
|
171
|
+
# in +keep+.
|
|
172
|
+
def delete_unless!(keep)
|
|
173
|
+
# Delete the unecessary inner signals.
|
|
174
|
+
self.each_inner.to_a.each do |inner|
|
|
175
|
+
self.delete_inner!(inner) unless keep.include?(inner.name)
|
|
176
|
+
end
|
|
177
|
+
|
|
178
|
+
# Recurse on the sub statements.
|
|
179
|
+
self.each_statement {|stmnt| stmnt.delete_unless!(keep) }
|
|
180
|
+
|
|
181
|
+
# Delete the unecessary assignments.
|
|
182
|
+
self.each_statement.to_a.each do |stmnt|
|
|
183
|
+
if stmnt.is_a?(Transmit) &&
|
|
184
|
+
!stmnt.left.each_node_deep.any? { |node|
|
|
185
|
+
node.is_a?(RefName) && keep.include?(node.name) } then
|
|
186
|
+
self.delete_statement!(stmnt)
|
|
187
|
+
end
|
|
188
|
+
end
|
|
189
|
+
end
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
|
|
193
|
+
end
|