HDLRuby 2.0.8
Sign up to get free protection for your applications and to get access to all the features.
- 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,107 @@
|
|
1
|
+
require "HDLRuby/hruby_error"
|
2
|
+
require "HDLRuby/hruby_low_mutable"
|
3
|
+
|
4
|
+
|
5
|
+
##
|
6
|
+
# Ensures that there is no read on output port by adding intermediate
|
7
|
+
# inner signal.
|
8
|
+
#
|
9
|
+
#
|
10
|
+
# NOTE: Used for instance for converting to old versions of VHDL that
|
11
|
+
#
|
12
|
+
########################################################################
|
13
|
+
module HDLRuby::Low
|
14
|
+
|
15
|
+
|
16
|
+
|
17
|
+
## Extends the SystemT class for remove read of output signal.
|
18
|
+
class SystemT
|
19
|
+
# Replace read of output signal to read of intermediate inner
|
20
|
+
# signal.
|
21
|
+
#
|
22
|
+
# NOTE: the result is the same systemT.
|
23
|
+
def outread2inner!
|
24
|
+
# puts "For system: #{self.name}"
|
25
|
+
# First gather the read on output signals.
|
26
|
+
outreads = {}
|
27
|
+
gather_outreads = proc do |node|
|
28
|
+
# puts "node=#{node.name}" if node.is_a?(RefName)
|
29
|
+
if node.is_a?(RefName) && !node.leftvalue? then
|
30
|
+
name = node.name
|
31
|
+
# puts "name=#{name}"
|
32
|
+
sig = self.get_output(name)
|
33
|
+
outreads[node.name] = node if sig
|
34
|
+
end
|
35
|
+
end
|
36
|
+
# Apply the procedure for gathering the read on outputs signals.
|
37
|
+
self.scope.each_scope_deep do |scope|
|
38
|
+
scope.each_connection do |connection|
|
39
|
+
connection.each_node_deep(&gather_outreads)
|
40
|
+
end
|
41
|
+
scope.each_behavior do |behavior|
|
42
|
+
behavior.each_event do |event|
|
43
|
+
gather_outreads.(event.ref)
|
44
|
+
end
|
45
|
+
behavior.each_statement do |statement|
|
46
|
+
# puts "statement=#{statement.class}"
|
47
|
+
statement.each_node_deep(&gather_outreads)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
# puts "outreads=#{outreads.keys}"
|
52
|
+
|
53
|
+
# Generate one inner signal per read output.
|
54
|
+
out2inner = {}
|
55
|
+
outreads.each do |name,node|
|
56
|
+
# Generate the inner variable.
|
57
|
+
out2inner[name] =
|
58
|
+
self.scope.add_inner(SignalI.new(HDLRuby::uniq_name,node.type))
|
59
|
+
# puts "new inner=#{out2inner[name].name}"
|
60
|
+
end
|
61
|
+
|
62
|
+
# Replace the output by the corresponding inner in the
|
63
|
+
# expressions.
|
64
|
+
replace_name = proc do |node| # The replacement procedure.
|
65
|
+
# Only single name reference are to be replaced, the others
|
66
|
+
# cannot correspond to output signal.
|
67
|
+
if node.is_a?(RefName) && node.ref.is_a?(RefThis) &&
|
68
|
+
!node.parent.is_a?(RefName) then
|
69
|
+
inner = out2inner[node.name]
|
70
|
+
# puts "node=#{node.name} inner=#{inner}"
|
71
|
+
# puts "Replace name: #{node.name} by #{inner.name}" if inner
|
72
|
+
node.set_name!(inner.name) if inner
|
73
|
+
end
|
74
|
+
end
|
75
|
+
# Apply the replacement procedure on the code
|
76
|
+
self.scope.each_scope_deep do |scope|
|
77
|
+
scope.each_connection do |connection|
|
78
|
+
connection.each_node_deep do |node|
|
79
|
+
replace_name.(node)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
scope.each_behavior do |behavior|
|
83
|
+
behavior.each_event do |event|
|
84
|
+
event.ref.each_node_deep do |node|
|
85
|
+
replace_name.(node)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
behavior.each_statement do |statement|
|
89
|
+
statement.each_node_deep do |node|
|
90
|
+
replace_name.(node)
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Finally connect the inner to the output.
|
97
|
+
out2inner.each do |out,inner|
|
98
|
+
self.scope.add_connection(
|
99
|
+
Connection.new(RefName.new(inner.type,RefThis.new,out),
|
100
|
+
RefName.new(inner.type,RefThis.new,inner.name)))
|
101
|
+
end
|
102
|
+
|
103
|
+
return self
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
@@ -0,0 +1,206 @@
|
|
1
|
+
require 'HDLRuby'
|
2
|
+
require 'HDLRuby/hruby_tools'
|
3
|
+
require 'HDLRuby/hruby_low_mutable'
|
4
|
+
|
5
|
+
|
6
|
+
module HDLRuby::Low
|
7
|
+
|
8
|
+
|
9
|
+
##
|
10
|
+
# Converts the select expression to case statements.
|
11
|
+
# Makes handling by some synthesis tools easier.
|
12
|
+
#
|
13
|
+
########################################################################
|
14
|
+
|
15
|
+
|
16
|
+
## Module containing helping methods for converting Select expressions
|
17
|
+
# to Case.
|
18
|
+
module LowWithoutSelect
|
19
|
+
|
20
|
+
# Generate a block with Cases from a list of Select objects.
|
21
|
+
def self.selects2block(selects)
|
22
|
+
blk = Block.new(:seq)
|
23
|
+
selects.each do |select,sig|
|
24
|
+
# puts "for select=#{select.to_high} with sig=#{sig.name}(#{sig.type.name})"
|
25
|
+
# Create the case.
|
26
|
+
cas = Case.new(select.select.clone)
|
27
|
+
# Get the type for the matches.
|
28
|
+
type = select.select.type
|
29
|
+
# Create and add the whens.
|
30
|
+
size = select.each_choice.count
|
31
|
+
select.each_choice.with_index do |choice,i|
|
32
|
+
# Create the transmission statements of the when.
|
33
|
+
left = RefName.new(sig.type,RefThis.new,sig.name)
|
34
|
+
trans = Transmit.new(left,choice.clone)
|
35
|
+
# Put it into a block for the when.
|
36
|
+
tb = Block.new(:par)
|
37
|
+
tb.add_statement(trans)
|
38
|
+
if i < size-1 then
|
39
|
+
# Create and add the when.
|
40
|
+
cas.add_when( When.new(Value.new(type,i), tb) )
|
41
|
+
else
|
42
|
+
# Last choice, add a default/
|
43
|
+
cas.default = tb
|
44
|
+
end
|
45
|
+
end
|
46
|
+
# puts "Resulting case: #{cas.to_high}"
|
47
|
+
# Adds the case to the block.
|
48
|
+
blk.add_statement(cas)
|
49
|
+
end
|
50
|
+
return blk
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
## Extends the SystemT class with functionality for converting select
|
56
|
+
# expressions to case statements.
|
57
|
+
class SystemT
|
58
|
+
|
59
|
+
# Converts the Select expressions to Case statements.
|
60
|
+
def select2case!
|
61
|
+
self.scope.select2case!
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
|
66
|
+
## Extends the Scope class with functionality for converting select
|
67
|
+
# expressions to case statements.
|
68
|
+
class Scope
|
69
|
+
|
70
|
+
# Converts the Select expressions to Case statements.
|
71
|
+
def select2case!
|
72
|
+
# Recruse on the sub scopes.
|
73
|
+
self.each_scope(&:select2case!)
|
74
|
+
|
75
|
+
# Recurse on the blocks.
|
76
|
+
self.each_behavior do |behavior|
|
77
|
+
behavior.block.each_block_deep(&:select2case!)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Work on the connections.
|
81
|
+
self.each_connection.to_a.each do |connection|
|
82
|
+
selects = connection.extract_selects!
|
83
|
+
if selects.any? then
|
84
|
+
# Selects have been extract, replace the connection
|
85
|
+
# be y behavior.
|
86
|
+
# Generate the block with cases.
|
87
|
+
blk = LowWithoutSelect.selects2block(selects)
|
88
|
+
# Add a transmit replacing the connection.
|
89
|
+
blk.add_statement(
|
90
|
+
Transmit.new(self.left.clone,self.right.clone))
|
91
|
+
# Remove the connection and add a behavior instead.
|
92
|
+
self.remove_connection(connection)
|
93
|
+
self.add_behavior(Behavior.new(blk))
|
94
|
+
end
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
## Extends the Block class with functionality for converting select
|
100
|
+
# expressions to case statements.
|
101
|
+
class Block
|
102
|
+
|
103
|
+
# Breaks the assignments to concats.
|
104
|
+
#
|
105
|
+
# NOTE: work on the direct sub statement only, not deeply.
|
106
|
+
def select2case!
|
107
|
+
# Check each statement.
|
108
|
+
self.map_statements! do |stmnt|
|
109
|
+
# Skip blocks that are treated through recursion.
|
110
|
+
next stmnt if stmnt.is_a?(Block)
|
111
|
+
# Work on the statement.
|
112
|
+
# Extract the Select expressions.
|
113
|
+
selects = stmnt.extract_selects!
|
114
|
+
if selects.any? then
|
115
|
+
# Generate a sequential block containing the cases.
|
116
|
+
blk = LowWithoutSelect.selects2block(selects)
|
117
|
+
# Adds the statement to the block.
|
118
|
+
blk.add_statement(stmnt.clone)
|
119
|
+
stmnt = blk
|
120
|
+
end
|
121
|
+
stmnt
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
## Extends the Transmit class with functionality for converting select
|
127
|
+
# expressions to case statements.
|
128
|
+
class Transmit
|
129
|
+
# Extract the Select expressions.
|
130
|
+
def extract_selects!
|
131
|
+
selects = []
|
132
|
+
self.set_left!(self.left.extract_selects_to!(selects))
|
133
|
+
self.set_right!(self.right.extract_selects_to!(selects))
|
134
|
+
return selects
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
## Extends the If class with functionality for converting select
|
139
|
+
# expressions to case statements.
|
140
|
+
class If
|
141
|
+
|
142
|
+
# Extract the Select expressions.
|
143
|
+
#
|
144
|
+
# NOTE: work on the condition only.
|
145
|
+
def extract_selects!
|
146
|
+
selects = []
|
147
|
+
self.set_condition!(self.condition.extract_selects_to!(selects))
|
148
|
+
return selects
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
## Extends the If class with functionality for converting select
|
153
|
+
# expressions to case statements.
|
154
|
+
class When
|
155
|
+
|
156
|
+
# Extract the Select expressions.
|
157
|
+
#
|
158
|
+
# NOTE: work on the match only.
|
159
|
+
def extract_selects!
|
160
|
+
selects = []
|
161
|
+
self.set_match!(self.match.extract_selects_to!(selects))
|
162
|
+
return selects
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
166
|
+
## Extends the If class with functionality for converting select
|
167
|
+
# expressions to case statements.
|
168
|
+
class Case
|
169
|
+
|
170
|
+
# Extract the Select expressions.
|
171
|
+
#
|
172
|
+
# Note: the default is not treated.
|
173
|
+
def extract_selects!
|
174
|
+
selects = []
|
175
|
+
# Work on the value.
|
176
|
+
self.set_value!(self.value.extract_selects_to!(selects))
|
177
|
+
# Work on the whens.
|
178
|
+
selects += self.each_when.map(&:extract_selects!).reduce(:+)
|
179
|
+
return selects
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
## Extends the Expression class with functionality for converting select
|
184
|
+
# expressions to ase statements.
|
185
|
+
class Expression
|
186
|
+
|
187
|
+
# Extract the Select expressions and put them into +selects+
|
188
|
+
def extract_selects_to!(selects)
|
189
|
+
# Recurse on the sub expressions.
|
190
|
+
self.map_expressions! {|expr| expr.extract_selects_to!(selects) }
|
191
|
+
# Treat case of select.
|
192
|
+
if self.is_a?(Select) then
|
193
|
+
# Create the signal replacing self.
|
194
|
+
sig = SignalI.new(HDLRuby.uniq_name,self.type)
|
195
|
+
# Add the self with replacing sig to the extracted selects
|
196
|
+
selects << [self,sig]
|
197
|
+
# Create the signal replacing self.
|
198
|
+
blk = self.statement.block
|
199
|
+
blk.add_inner(sig)
|
200
|
+
# And return a reference to it.
|
201
|
+
return RefName.new(sig.type,RefThis.new,sig.name)
|
202
|
+
end
|
203
|
+
return self
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|