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,934 @@
|
|
1
|
+
########################################################################
|
2
|
+
## Program for testing the HDLRuby::Low module. ##
|
3
|
+
########################################################################
|
4
|
+
|
5
|
+
require "HDLRuby/hruby_low.rb"
|
6
|
+
require "HDLRuby/hruby_serializer.rb"
|
7
|
+
|
8
|
+
include HDLRuby::Low
|
9
|
+
|
10
|
+
$success = true
|
11
|
+
|
12
|
+
print "\nCreating system types... "
|
13
|
+
begin
|
14
|
+
$systemT0 = SystemT.new(:systemT0, Scope.new)
|
15
|
+
$systemT1 = SystemT.new(:systemT1, Scope.new)
|
16
|
+
if $systemT0.name == :systemT0 then
|
17
|
+
puts "Ok."
|
18
|
+
else
|
19
|
+
puts "Error: invalid name, got #{$systemT0.name} but expecting systemT0."
|
20
|
+
$success = false
|
21
|
+
end
|
22
|
+
# rescue Exception => e
|
23
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
24
|
+
# $success = false
|
25
|
+
end
|
26
|
+
|
27
|
+
|
28
|
+
print "\nCreating a bit and a 8-bit data types... "
|
29
|
+
begin
|
30
|
+
$bit = Type.new(:bit)
|
31
|
+
$bit8 = TypeVector.new(:bit8,$bit,8)
|
32
|
+
if $bit8.name != :bit8 then
|
33
|
+
puts "Error: invalid name: got #{$bit8.name} but expecting bit8."
|
34
|
+
$success = false
|
35
|
+
elsif $bit8.base != $bit then
|
36
|
+
puts "Error: invalid type: got #{$bit8.base} but expecting bit."
|
37
|
+
$success = false
|
38
|
+
elsif $bit8.range != (7..0) then
|
39
|
+
puts "Error: invalid range: got #{$bit8.range} but expecting 7..0."
|
40
|
+
$success = false
|
41
|
+
else
|
42
|
+
puts "Ok."
|
43
|
+
end
|
44
|
+
# rescue Exception => e
|
45
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
46
|
+
# $success = false
|
47
|
+
end
|
48
|
+
|
49
|
+
puts "\nCreating signals..."
|
50
|
+
$sNames = ["i0", "i1", "i2", "i3", "i4", "i5", "i6", "i7", "i8", "i9", "i10",
|
51
|
+
"clk",
|
52
|
+
"o0", "o1", "o2", "o3", "o4", "o5", "io", "s0", "s1", "s2",
|
53
|
+
]
|
54
|
+
$signals = []
|
55
|
+
$sNames.each_with_index do |name,i|
|
56
|
+
print " SignalI #{name}... "
|
57
|
+
begin
|
58
|
+
# SignalT directly used.
|
59
|
+
$signals[i] = SignalI.new(name,$bit8)
|
60
|
+
if $signals[i].name != name.to_sym then
|
61
|
+
puts "Error: invalid signal name, got #{$signalIs[i].name} " +
|
62
|
+
" but expecting #{name}"
|
63
|
+
$success = false
|
64
|
+
elsif $signals[i].type != $bit8 then
|
65
|
+
puts "Error: invalid signal type, got #{$signals[i].type} " +
|
66
|
+
" but expecting #{:bit}"
|
67
|
+
$success = false
|
68
|
+
else
|
69
|
+
puts "Ok."
|
70
|
+
end
|
71
|
+
# rescue Exception => e
|
72
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
73
|
+
# $success = false
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
puts "\nAdding them to $systemT0 as input, output or inout... "
|
78
|
+
$signals.each do |signal|
|
79
|
+
begin
|
80
|
+
name = signal.name
|
81
|
+
print " For signal instance #{name}... "
|
82
|
+
if name[0..1] == "io" then
|
83
|
+
# Inout
|
84
|
+
$systemT0.add_inout(signal)
|
85
|
+
elsif name[0] == "i" then
|
86
|
+
# Input
|
87
|
+
$systemT0.add_input(signal)
|
88
|
+
elsif name[0] == "o" then
|
89
|
+
# Output
|
90
|
+
$systemT0.add_output(signal)
|
91
|
+
elsif name[0] == "s" then
|
92
|
+
# Inner
|
93
|
+
$systemT0.add_inner(signal)
|
94
|
+
else
|
95
|
+
# Default: input (should be the clock).
|
96
|
+
$systemT0.add_input(signal)
|
97
|
+
end
|
98
|
+
puts "Ok."
|
99
|
+
# rescue Exception => e
|
100
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
101
|
+
# $success = false
|
102
|
+
end
|
103
|
+
end
|
104
|
+
|
105
|
+
print "\nCompleting $systemT1 for further use... "
|
106
|
+
begin
|
107
|
+
$systemT1.add_input(SignalI.new("i0",$bit8))
|
108
|
+
$systemT1.add_input(SignalI.new("i1",$bit8))
|
109
|
+
$systemT1.add_input(SignalI.new("i2",$bit8))
|
110
|
+
$systemT1.add_output(SignalI.new("o0",$bit8))
|
111
|
+
$systemT1.add_output(SignalI.new("o1",$bit8))
|
112
|
+
$systemT1.add_inout(SignalI.new("io",$bit8))
|
113
|
+
puts "Ok."
|
114
|
+
# rescue Exception => e
|
115
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
116
|
+
# $success = false
|
117
|
+
end
|
118
|
+
|
119
|
+
puts "\nInstantiating the systems... "
|
120
|
+
begin
|
121
|
+
print " SystemI 0... "
|
122
|
+
$systemI0 = SystemI.new("systemI0",$systemT0)
|
123
|
+
success = true
|
124
|
+
if $systemI0.name != :systemI0 then
|
125
|
+
puts "Error: invalid name, got #{$systemI0.name} but expecting systemI0."
|
126
|
+
success = false
|
127
|
+
end
|
128
|
+
if $systemI0.systemT != $systemT0 then
|
129
|
+
puts "Error: invalid system type, got #{$systemI0.systemT.name} but expecting systemT0."
|
130
|
+
success = false
|
131
|
+
end
|
132
|
+
if success then
|
133
|
+
puts "Ok."
|
134
|
+
else
|
135
|
+
$success = false
|
136
|
+
end
|
137
|
+
print " SystemI 1... "
|
138
|
+
$systemI1 = SystemI.new("systemI1",$systemT1)
|
139
|
+
if $systemI1.name != :systemI1 then
|
140
|
+
puts "Error: invalid name, got #{$systemI1.name} but expecting systemI1."
|
141
|
+
success = false
|
142
|
+
end
|
143
|
+
if $systemI1.systemT != $systemT1 then
|
144
|
+
puts "Error: invalid system type, got #{$systemI1.systemT.name} but expecting systemT1."
|
145
|
+
success = false
|
146
|
+
end
|
147
|
+
if success then
|
148
|
+
puts "Ok."
|
149
|
+
else
|
150
|
+
$success = false
|
151
|
+
end
|
152
|
+
print " SystemI 2 (SystemT designated by name)... "
|
153
|
+
$systemI2 = SystemI.new("systemI2",$systemT1)
|
154
|
+
if $systemI2.systemT != $systemT1 then
|
155
|
+
puts "Error: invalid system type, got #{$systemI2.systemT.name} but expecting systemT1."
|
156
|
+
success = false
|
157
|
+
end
|
158
|
+
if success then
|
159
|
+
puts "Ok."
|
160
|
+
else
|
161
|
+
$success = false
|
162
|
+
end
|
163
|
+
# rescue Exception => e
|
164
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
165
|
+
# $success = false
|
166
|
+
end
|
167
|
+
$systemIs = [ $systemI0, $systemI1, $systemI2 ]
|
168
|
+
|
169
|
+
puts "\nAdding systems instances to $systemT0... "
|
170
|
+
begin
|
171
|
+
print " Adding $systemI1... "
|
172
|
+
$systemT0.add_systemI($systemI1)
|
173
|
+
print "Ok.\n Adding $systemI2... "
|
174
|
+
$systemT0.add_systemI($systemI2)
|
175
|
+
puts "Ok."
|
176
|
+
# rescue Exception => e
|
177
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
178
|
+
# $success = false
|
179
|
+
end
|
180
|
+
|
181
|
+
puts "\nCreating references for further connection of the signals..."
|
182
|
+
$pNames = ["p0i0", "p0i1", "p0i2", "p0i3", "p0i4", "p0i5", "p0i6", "p0i7",
|
183
|
+
"p0i8", "p0i9", "p0i10",
|
184
|
+
"p0o0", "p0o1", "p0o2", "p0o3", "p0o4", "p0o5", "p0o6", "p0o7",
|
185
|
+
"p0o8", "p0o9",
|
186
|
+
"p0io",
|
187
|
+
"p0s0", "p0s1", "p0s2", "p0clk",
|
188
|
+
"p1i0", "p1i1", "p1i2", "p1o0", "p1o1", "p1io",
|
189
|
+
"p1s0", "p1s1", "p1s2",
|
190
|
+
"p2i0", "p2i1", "p2i2", "p2o0", "p2o1", "p2io",
|
191
|
+
"p2s0", "p2s1", "p2s2"]
|
192
|
+
$refs = []
|
193
|
+
$pNames.each_with_index do |name,i|
|
194
|
+
print " Ref #{name}... "
|
195
|
+
begin
|
196
|
+
# Create the system reference.
|
197
|
+
system_ref = RefThis.new
|
198
|
+
if name[1] != "0" then
|
199
|
+
# Sub system case.
|
200
|
+
system_ref = RefName.new(Signed,system_ref,"systemI#{name[1]}")
|
201
|
+
end
|
202
|
+
# Create the signal reference.
|
203
|
+
$refs[i] = RefName.new(Signed,system_ref,"#{name[2..-1]}")
|
204
|
+
if $refs[i].name != name[2..-1].to_sym then
|
205
|
+
puts "Error: invalid signal, got #{$refs[i].name} " +
|
206
|
+
" but expecting #{name[2..-1]}"
|
207
|
+
$success = false
|
208
|
+
else
|
209
|
+
puts "Ok."
|
210
|
+
end
|
211
|
+
# rescue Exception => e
|
212
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
213
|
+
# $success = false
|
214
|
+
end
|
215
|
+
end
|
216
|
+
|
217
|
+
puts "\nCreating reference-only connections..."
|
218
|
+
$cNames = { "p0i0" => "p1i0", "p0i1" => "p1i1",
|
219
|
+
"p0i2" => "p2i0", "p0i3" => "p2i1",
|
220
|
+
"p1o0" => "p0o0", "p1o1" => "p2i2",
|
221
|
+
"p2o0" => "p0o1", "p2o1" => "p1i2",
|
222
|
+
"p0io" => "p1io"
|
223
|
+
}
|
224
|
+
$connections = []
|
225
|
+
$cNames.each do |sName,dName|
|
226
|
+
print " Connection #{sName} => #{dName}... "
|
227
|
+
begin
|
228
|
+
left = $refs[$pNames.index(sName)]
|
229
|
+
right = $refs[$pNames.index(dName)]
|
230
|
+
connection = Connection.new(left,right)
|
231
|
+
$connections << connection
|
232
|
+
success = true
|
233
|
+
if connection.left != left then
|
234
|
+
puts "Error: invalid reference, got #{connection.keft} but expecting #{left}."
|
235
|
+
success = false
|
236
|
+
end
|
237
|
+
if connection.right != right then
|
238
|
+
puts "Error: invalid reference, got #{connection.keft} but expecting #{right}."
|
239
|
+
success = false
|
240
|
+
end
|
241
|
+
if success then
|
242
|
+
puts "Ok."
|
243
|
+
else
|
244
|
+
$success = false
|
245
|
+
end
|
246
|
+
# rescue Exception => e
|
247
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
248
|
+
# $success = false
|
249
|
+
end
|
250
|
+
end
|
251
|
+
|
252
|
+
|
253
|
+
puts "\nCreating expressions... "
|
254
|
+
eNames = [ "i4+i5", "i4&i5", "i6-i7", "i6|i7", "i4+2", "i5&7",
|
255
|
+
"i8*i9", "i8+i9", "i9-i10"]
|
256
|
+
|
257
|
+
# Generate an expression from a signal or constant name
|
258
|
+
def eName2Exp(name)
|
259
|
+
# puts "eName2Exp with name=#{name}"
|
260
|
+
ref = $refs.find do |ref|
|
261
|
+
if ref.ref.respond_to?(:name) then
|
262
|
+
ref.ref.name == name.to_sym
|
263
|
+
else
|
264
|
+
ref.name == name.to_sym
|
265
|
+
end
|
266
|
+
end
|
267
|
+
# puts "ref=#{ref}"
|
268
|
+
unless ref
|
269
|
+
return Value.new($bit8,name.to_i)
|
270
|
+
end
|
271
|
+
return ref
|
272
|
+
end
|
273
|
+
|
274
|
+
$expressions = []
|
275
|
+
eNames.each do |eName|
|
276
|
+
print " Expression #{eName}... "
|
277
|
+
begin
|
278
|
+
left = eName2Exp(eName[0..1])
|
279
|
+
# puts "left=#{left}"
|
280
|
+
operator = eName[2].to_sym
|
281
|
+
# puts "operator=#{operator}"
|
282
|
+
right = eName2Exp(eName[3..-1])
|
283
|
+
# puts "right=#{right}"
|
284
|
+
expression = Binary.new(Signed,operator,left,right)
|
285
|
+
$expressions << expression
|
286
|
+
success = true
|
287
|
+
unless expression.left == left then
|
288
|
+
puts "Error: invalid left value, got #{expression.left} but expecting #{left}."
|
289
|
+
success = false
|
290
|
+
end
|
291
|
+
unless expression.right == right then
|
292
|
+
puts "Error: invalid right value, got #{expression.right} but expecting #{right}."
|
293
|
+
success = false
|
294
|
+
end
|
295
|
+
unless expression.operator == operator then
|
296
|
+
puts "Error: invalid operator, got #{expression.operator} but expecting #{operator}."
|
297
|
+
success = false
|
298
|
+
end
|
299
|
+
all_refs = expression.each_ref_deep.to_a
|
300
|
+
# puts "all_refs=#{all_refs}"
|
301
|
+
unless all_refs[0] == expression.left then
|
302
|
+
puts "Error: invalid first result for each_ref_deep, got #{all_refs[0]} but expecting #{expression.left}."
|
303
|
+
success = false
|
304
|
+
end
|
305
|
+
if expression.right.is_a?(HDLRuby::Low::Ref) then
|
306
|
+
unless all_refs[1] == expression.right then
|
307
|
+
puts "Error: invalid second result for each_ref_deep, got #{all_refs[1]} but expecting #{expression.right}."
|
308
|
+
success = false
|
309
|
+
end
|
310
|
+
else
|
311
|
+
if all_refs.size > 1 then
|
312
|
+
puts "Error: too many signals for each_ref_deep, got #{all_refs.size} but expecting 1."
|
313
|
+
success = false
|
314
|
+
end
|
315
|
+
end
|
316
|
+
if success then
|
317
|
+
unless all_refs.size < 3 then
|
318
|
+
puts "Error: too many signals for each_ref_deep, got #{all_refs.size} but expecting 2."
|
319
|
+
sucess = false
|
320
|
+
end
|
321
|
+
end
|
322
|
+
if success then
|
323
|
+
puts "Ok."
|
324
|
+
else
|
325
|
+
$success = false
|
326
|
+
end
|
327
|
+
# Remove the parents for reusing the references (just for test purpose)
|
328
|
+
all_refs.each {|ref| ref.parent = nil }
|
329
|
+
# rescue Exception => e
|
330
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
331
|
+
# $success = false
|
332
|
+
end
|
333
|
+
end
|
334
|
+
|
335
|
+
|
336
|
+
print "\nCreating an expression connection... "
|
337
|
+
begin
|
338
|
+
|
339
|
+
ref = $refs[$pNames.index("p0o2")]
|
340
|
+
connection = Connection.new(ref,$expressions[0])
|
341
|
+
$connections << connection
|
342
|
+
puts "Ok."
|
343
|
+
# rescue Exception => e
|
344
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
345
|
+
# $success = false
|
346
|
+
end
|
347
|
+
|
348
|
+
|
349
|
+
puts "\nAdding connections to $systemT0... "
|
350
|
+
begin
|
351
|
+
$connections.each.with_index do |connection,i|
|
352
|
+
key = $cNames.keys[i]
|
353
|
+
if key then
|
354
|
+
# System connections
|
355
|
+
print " Adding connection #{key} => #{$cNames[key]}... "
|
356
|
+
else
|
357
|
+
# Expression connections
|
358
|
+
print " Adding expression connection... "
|
359
|
+
end
|
360
|
+
$systemT0.add_connection(connection)
|
361
|
+
puts "Ok."
|
362
|
+
end
|
363
|
+
# rescue Exception => e
|
364
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
365
|
+
# $success = false
|
366
|
+
end
|
367
|
+
|
368
|
+
|
369
|
+
puts "\nCreating transmit statements..."
|
370
|
+
$stNames = [ ["p0o3", $expressions[1]], ["p0o4", $expressions[2]],
|
371
|
+
["p0o5", $expressions[3]], ["p0o6", $expressions[4]],
|
372
|
+
["p0o7", $expressions[5]], ["p0o8", $expressions[6]],
|
373
|
+
["p0o9", $expressions[7]]
|
374
|
+
]
|
375
|
+
$statements = []
|
376
|
+
$stNames.each do |pName,expression|
|
377
|
+
print " Transmission to #{pName}... "
|
378
|
+
begin
|
379
|
+
ref = $refs[$pNames.index(pName)]
|
380
|
+
statement = Transmit.new(ref,expression)
|
381
|
+
$statements << statement
|
382
|
+
success = true
|
383
|
+
unless statement.left == ref then
|
384
|
+
raise "Error: invalid left value, got #{statement.left} but expecting #{ref}."
|
385
|
+
success = false
|
386
|
+
end
|
387
|
+
unless statement.right == expression then
|
388
|
+
raise "Error: invalid right value, got #{statement.right} but expecting #{expression}."
|
389
|
+
success = false
|
390
|
+
end
|
391
|
+
if success then
|
392
|
+
puts "Ok."
|
393
|
+
else
|
394
|
+
$success = false
|
395
|
+
end
|
396
|
+
# rescue Exception => e
|
397
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
398
|
+
# $success = false
|
399
|
+
end
|
400
|
+
end
|
401
|
+
|
402
|
+
puts "\nCreating an if statement..."
|
403
|
+
$yes = $statements.pop
|
404
|
+
$no = $statements.pop
|
405
|
+
$cond = $expressions[0].clone
|
406
|
+
$if = If.new($cond,$yes,$no)
|
407
|
+
unless $if.condition == $cond then
|
408
|
+
raise "Error: invalid condition for if, got #{$if.condition} but expecting #{$cond}."
|
409
|
+
$success = false
|
410
|
+
end
|
411
|
+
unless $if.yes == $yes then
|
412
|
+
raise "Error: invalid yes for if, got #{$if.yes} but expecting #{$yes}."
|
413
|
+
$success = false
|
414
|
+
end
|
415
|
+
unless $if.no == $no then
|
416
|
+
raise "Error: invalid no for if, got #{$if.no} but expecting #{$no}."
|
417
|
+
$success = false
|
418
|
+
end
|
419
|
+
|
420
|
+
|
421
|
+
puts "\nCreating case statement..."
|
422
|
+
$value = $expressions[0].clone
|
423
|
+
$default = $statements.pop
|
424
|
+
$whens = []
|
425
|
+
$whens << When.new($expressions[0].clone,$statements.pop)
|
426
|
+
$whens << When.new($expressions[1].clone,$statements.pop)
|
427
|
+
$case = Case.new($value,$default)
|
428
|
+
$case.add_when($whens[0])
|
429
|
+
$case.add_when($whens[1])
|
430
|
+
unless $case.value == $value then
|
431
|
+
raise "Error: invalid value for case, got #{$case.value} but expecting #{$value}."
|
432
|
+
$success = false
|
433
|
+
end
|
434
|
+
unless $case.default == $default then
|
435
|
+
raise "Error: invalid default for case, got #{$case.default} but expecting #{$default}."
|
436
|
+
$success = false
|
437
|
+
end
|
438
|
+
$case.each_when.with_index do |w,i|
|
439
|
+
unless w.match == $whens[i].match then
|
440
|
+
raise "Error: invalid match for when, got #{w.match} but expecting #{$whens[i].match}."
|
441
|
+
$success = false
|
442
|
+
end
|
443
|
+
unless w.statement == $whens[i].statement then
|
444
|
+
raise "Error: invalid statement for when, got #{w.statement} but expecting #{$whens[i].statement}."
|
445
|
+
$success = false
|
446
|
+
end
|
447
|
+
end
|
448
|
+
|
449
|
+
# Adds the conditional statements
|
450
|
+
$statements << $if
|
451
|
+
$statements << $case
|
452
|
+
|
453
|
+
print "\nCreating a clock event... "
|
454
|
+
begin
|
455
|
+
ref = $refs.find{|ref| ref.name == :clk}
|
456
|
+
$event = Event.new(:posedge,ref)
|
457
|
+
success = true
|
458
|
+
if $event.type != :posedge then
|
459
|
+
puts "Error: invalid type of event, got #{$event.type} but expecting :posedge."
|
460
|
+
success = false
|
461
|
+
elsif $event.ref != ref then
|
462
|
+
puts "Error: invalid reference, got #{$event.ref} but expecting #{ref}."
|
463
|
+
success = false
|
464
|
+
end
|
465
|
+
if success then
|
466
|
+
puts "Ok."
|
467
|
+
else
|
468
|
+
$success = false
|
469
|
+
end
|
470
|
+
# rescue Exception => e
|
471
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
472
|
+
# $success = false
|
473
|
+
end
|
474
|
+
|
475
|
+
|
476
|
+
print "\nCreating a block... "
|
477
|
+
begin
|
478
|
+
$block = Block.new(:seq)
|
479
|
+
if $block.mode != :seq then
|
480
|
+
puts "Error: invalid block mode, got #{$block.type} but expecting :seq."
|
481
|
+
$success = false
|
482
|
+
else
|
483
|
+
puts "Ok."
|
484
|
+
end
|
485
|
+
# rescue Exception => e
|
486
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
487
|
+
# $success = false
|
488
|
+
end
|
489
|
+
|
490
|
+
puts "\nAdding statements to $block... "
|
491
|
+
$statements[0...$statements.size/2].each.with_index do |statement,i|
|
492
|
+
begin
|
493
|
+
print " For statement #{i}... "
|
494
|
+
$block.add_statement(statement)
|
495
|
+
puts "Ok."
|
496
|
+
# rescue Exception => e
|
497
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
498
|
+
# $success = false
|
499
|
+
end
|
500
|
+
end
|
501
|
+
puts "Checking the added statements... "
|
502
|
+
$statements[0...$statements.size/2].each.with_index do |statement,i|
|
503
|
+
begin
|
504
|
+
print " For statement #{i}... "
|
505
|
+
bStatement = $block.each_statement.to_a[i]
|
506
|
+
if bStatement != statement then
|
507
|
+
puts "Error: invalid statement, got #{bStatement} but expecting #{statement}."
|
508
|
+
$success = false
|
509
|
+
else
|
510
|
+
puts "Ok."
|
511
|
+
end
|
512
|
+
# rescue Exception => e
|
513
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
514
|
+
# $success = false
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
518
|
+
print "\nCreating $blockIn, another block... "
|
519
|
+
begin
|
520
|
+
$blockIn = Block.new(:par)
|
521
|
+
if $blockIn.mode != :par then
|
522
|
+
puts "Error: invalid block mode, got #{$blockIn.type} but expecting :par."
|
523
|
+
$success = false
|
524
|
+
else
|
525
|
+
puts "Ok."
|
526
|
+
end
|
527
|
+
# rescue Exception => e
|
528
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
529
|
+
# $success = false
|
530
|
+
end
|
531
|
+
|
532
|
+
puts "\nAdding statements to $blockIn... "
|
533
|
+
$statements[$statements.size/2..-1].each.with_index do |statement,i|
|
534
|
+
begin
|
535
|
+
print " For statement #{i+$statements.size/2}... "
|
536
|
+
$blockIn.add_statement(statement)
|
537
|
+
puts "Ok."
|
538
|
+
# rescue Exception => e
|
539
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
540
|
+
# $success = false
|
541
|
+
end
|
542
|
+
end
|
543
|
+
|
544
|
+
puts "\nAdding $blockIn to $block as a statement..."
|
545
|
+
$block.add_statement($blockIn)
|
546
|
+
|
547
|
+
puts "Checking the added statements deeply... "
|
548
|
+
i = 0
|
549
|
+
$bStatements = $block.each_statement_deep.to_a
|
550
|
+
$statements.each_with_index do |statement,j|
|
551
|
+
begin
|
552
|
+
print " For statement #{j}... "
|
553
|
+
bStatement = $bStatements[i]
|
554
|
+
i += 1
|
555
|
+
if bStatement.is_a?(Block) then
|
556
|
+
# Skip Block.
|
557
|
+
bStatement = $bStatements[i]
|
558
|
+
i += 1
|
559
|
+
end
|
560
|
+
if bStatement.is_a?(If) then
|
561
|
+
# Skip the following yes.
|
562
|
+
i += 1
|
563
|
+
end
|
564
|
+
|
565
|
+
if bStatement != statement then
|
566
|
+
puts "Error: invalid statement, got #{bStatement} but expecting #{statement}."
|
567
|
+
$success = false
|
568
|
+
else
|
569
|
+
puts "Ok."
|
570
|
+
end
|
571
|
+
# rescue Exception => e
|
572
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
573
|
+
# $success = false
|
574
|
+
end
|
575
|
+
end
|
576
|
+
|
577
|
+
|
578
|
+
print "\nCreating a behavior with $block... "
|
579
|
+
begin
|
580
|
+
$behavior = Behavior.new($block)
|
581
|
+
block = $behavior.block
|
582
|
+
if block != $block then
|
583
|
+
puts "Error: invalid block, got #{block} but expecting #{$block}."
|
584
|
+
$sucess = false
|
585
|
+
else
|
586
|
+
puts "Ok."
|
587
|
+
end
|
588
|
+
# rescue Exception => e
|
589
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
590
|
+
# $success = false
|
591
|
+
end
|
592
|
+
|
593
|
+
print "\nAdding an even to $behavior... "
|
594
|
+
begin
|
595
|
+
$behavior.add_event($event)
|
596
|
+
pEvent = $behavior.each_event.first
|
597
|
+
if pEvent != $event then
|
598
|
+
puts "Error: invalid event, got #{pEvent} but expecting #{$event}."
|
599
|
+
$sucess = false
|
600
|
+
else
|
601
|
+
puts "Ok."
|
602
|
+
end
|
603
|
+
# rescue Exception => e
|
604
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
605
|
+
# $success = false
|
606
|
+
end
|
607
|
+
|
608
|
+
|
609
|
+
print "\nAdding a behavior to $systemT0... "
|
610
|
+
begin
|
611
|
+
$systemT0.add_behavior($behavior)
|
612
|
+
sBehavior = $systemT0.each_behavior.first
|
613
|
+
if sBehavior != $behavior then
|
614
|
+
puts "Error: invalid behavior, got #{sBehavior} but expecting #{$behavior}."
|
615
|
+
$sucess = false
|
616
|
+
else
|
617
|
+
puts "Ok."
|
618
|
+
end
|
619
|
+
# rescue Exception => e
|
620
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
621
|
+
# $success = false
|
622
|
+
end
|
623
|
+
|
624
|
+
#################################################################
|
625
|
+
# Final global test.
|
626
|
+
|
627
|
+
puts "\nTesting the content of $systemT0... "
|
628
|
+
begin
|
629
|
+
iCount = 0 # Input signal instances counter
|
630
|
+
oCount = 0 # Output signal instances counter
|
631
|
+
ioCount = 0 # Inout signal instances counter
|
632
|
+
puts " Inputs... "
|
633
|
+
$systemT0.each_input.with_index do |input,i|
|
634
|
+
print " Input #{i}... "
|
635
|
+
signal = $signals[i]
|
636
|
+
iCount += 1
|
637
|
+
if input == signal then
|
638
|
+
puts "Ok."
|
639
|
+
else
|
640
|
+
puts "Error: unexpected input, got #{input} but expecting #{signal}."
|
641
|
+
$success = false
|
642
|
+
end
|
643
|
+
end
|
644
|
+
puts " Inputs by name... "
|
645
|
+
$signals.each do |input|
|
646
|
+
if /i[0-9]/.match(input.name) then
|
647
|
+
print " Input #{input.name}... "
|
648
|
+
signal = $systemT0.get_input(input.name)
|
649
|
+
if input == signal then
|
650
|
+
puts "Ok."
|
651
|
+
else
|
652
|
+
puts "Error: unexpected input, got #{signal} but expecting #{input}."
|
653
|
+
$success = false
|
654
|
+
end
|
655
|
+
end
|
656
|
+
end
|
657
|
+
|
658
|
+
puts " Outputs... "
|
659
|
+
$systemT0.each_output.with_index do |output,i|
|
660
|
+
print " Output #{i}... "
|
661
|
+
signal = $signals[i+iCount]
|
662
|
+
oCount += 1
|
663
|
+
if output == signal then
|
664
|
+
puts "Ok."
|
665
|
+
else
|
666
|
+
puts "Error: unexpected output, got #{output} but expecting #{signal}."
|
667
|
+
$success = false
|
668
|
+
end
|
669
|
+
end
|
670
|
+
puts " Outputs by name... "
|
671
|
+
$signals.each do |output|
|
672
|
+
if /o[0-9]/.match(output.name) then
|
673
|
+
print " Output #{output.name}... "
|
674
|
+
signal = $systemT0.get_output(output.name)
|
675
|
+
if output == signal then
|
676
|
+
puts "Ok."
|
677
|
+
else
|
678
|
+
puts "Error: unexpected output, got #{signal} but expecting #{output}."
|
679
|
+
$success = false
|
680
|
+
end
|
681
|
+
end
|
682
|
+
end
|
683
|
+
|
684
|
+
puts " Inouts... "
|
685
|
+
$systemT0.each_inout.with_index do |inout,i|
|
686
|
+
print " Inout #{i}... "
|
687
|
+
signal = $signals[i+iCount+oCount]
|
688
|
+
ioCount += 1
|
689
|
+
if inout == signal then
|
690
|
+
puts "Ok."
|
691
|
+
else
|
692
|
+
puts "Error: unexpected output, got #{inout} but expecting #{signal}."
|
693
|
+
$success = false
|
694
|
+
end
|
695
|
+
end
|
696
|
+
puts " Inouts by name... "
|
697
|
+
$signals.each do |inout|
|
698
|
+
if /io/.match(inout.name) then
|
699
|
+
print " Inout #{inout.name}... "
|
700
|
+
signal = $systemT0.get_inout(inout.name)
|
701
|
+
if inout == signal then
|
702
|
+
puts "Ok."
|
703
|
+
else
|
704
|
+
puts "Error: unexpected inout, got #{signal} but expecting #{inout}."
|
705
|
+
$success = false
|
706
|
+
end
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
710
|
+
puts " Inners... "
|
711
|
+
$systemT0.each_inner.with_index do |inner,i|
|
712
|
+
print " Inner #{i}... "
|
713
|
+
signal = $signals[i+iCount+oCount+ioCount]
|
714
|
+
if inner == signal then
|
715
|
+
puts "Ok."
|
716
|
+
else
|
717
|
+
puts "Error: unexpected inner, got #{inner} but expecting #{signal}."
|
718
|
+
$success = false
|
719
|
+
end
|
720
|
+
end
|
721
|
+
puts " Inners by name... "
|
722
|
+
$signals.each do |inner|
|
723
|
+
if /s[0-9]/.match(inner.name) then
|
724
|
+
print " Inner #{inner.name}... "
|
725
|
+
signal = $systemT0.get_inner(inner.name)
|
726
|
+
if inner == signal then
|
727
|
+
puts "Ok."
|
728
|
+
else
|
729
|
+
puts "Error: unexpected inner, got #{signal} but expecting #{inner}."
|
730
|
+
$success = false
|
731
|
+
end
|
732
|
+
end
|
733
|
+
end
|
734
|
+
|
735
|
+
puts " All signals... "
|
736
|
+
$systemT0.each_signal.with_index do |any,i|
|
737
|
+
print " SignalI #{i}... "
|
738
|
+
signal = $signals[i]
|
739
|
+
if any == signal then
|
740
|
+
puts "Ok."
|
741
|
+
else
|
742
|
+
puts "Error: unexpected signal, got #{any} but expecting #{signal}."
|
743
|
+
$success = false
|
744
|
+
end
|
745
|
+
end
|
746
|
+
puts " All signal instances by name... "
|
747
|
+
$signals.each do |signal|
|
748
|
+
print " SignalI #{signal.name}... "
|
749
|
+
signal = $systemT0.get_signal(signal.name)
|
750
|
+
if signal == signal then
|
751
|
+
puts "Ok."
|
752
|
+
else
|
753
|
+
puts "Error: unexpected signal, got #{signal} but expecting #{signal}."
|
754
|
+
$success = false
|
755
|
+
end
|
756
|
+
end
|
757
|
+
|
758
|
+
puts " System instances... "
|
759
|
+
$systemT0.each_systemI.with_index do |any,i|
|
760
|
+
print " SystemI #{i}... "
|
761
|
+
systemI = $systemIs[i+1]
|
762
|
+
if any == systemI then
|
763
|
+
puts "Ok."
|
764
|
+
else
|
765
|
+
puts "Error: unexpected systemI, got #{any} but expecting #{systemI}."
|
766
|
+
$success = false
|
767
|
+
end
|
768
|
+
end
|
769
|
+
puts " System instances by name... "
|
770
|
+
$systemIs[1..-1].each do |system|
|
771
|
+
print " SystemI #{system.name}... "
|
772
|
+
systemI = $systemT0.get_systemI(system.name)
|
773
|
+
if system == systemI then
|
774
|
+
puts "Ok."
|
775
|
+
else
|
776
|
+
puts "Error: unexpected systemI, got #{systemI} but expecting #{system}."
|
777
|
+
$success = false
|
778
|
+
end
|
779
|
+
end
|
780
|
+
|
781
|
+
## Test temporarily disabled...
|
782
|
+
# print " All signals including system instance signal ones... "
|
783
|
+
# signals_deep = $systemT0.each_signal_deep.to_a
|
784
|
+
# exp_signals = $systemT0.each_signal.to_a + $systemI1.each_signal.to_a +
|
785
|
+
# $systemI2.each_signal.to_a
|
786
|
+
# signals_deep.sort_by! { |signal| signal.to_s }.uniq!
|
787
|
+
# exp_signals.sort_by! { |signal| signal.to_s }.uniq!
|
788
|
+
# puts "\nsignals_deep = #{signals_deep.map{|s| s.name}}"
|
789
|
+
# puts "exp_signals = #{signals_deep.map{|s| s.name}}"
|
790
|
+
# if signals_deep == exp_signals then
|
791
|
+
# puts "Ok."
|
792
|
+
# else
|
793
|
+
# puts "Error: did not get the right signals with :each_signal_deep."
|
794
|
+
# $success = false
|
795
|
+
# end
|
796
|
+
|
797
|
+
puts " Connections... "
|
798
|
+
$systemT0.each_connection.with_index do |connection,i|
|
799
|
+
print " Connection #{i}... "
|
800
|
+
if connection == $connections[i] then
|
801
|
+
puts "Ok."
|
802
|
+
else
|
803
|
+
puts "Error: unexpected systemI, got #{connection} but expecting #{$connections[i]}."
|
804
|
+
$success = false
|
805
|
+
end
|
806
|
+
end
|
807
|
+
|
808
|
+
# puts $systemT0.each_signal.to_a.size
|
809
|
+
|
810
|
+
# NOTE: The access by path is deprecated.
|
811
|
+
#
|
812
|
+
# puts " Reference path... "
|
813
|
+
# $systemT0.each_connection.with_index do |connection,i|
|
814
|
+
# unless connection.right.is_a?(HDLRuby::Low::Ref) then
|
815
|
+
# # Skip connections to expression since they are not defined through
|
816
|
+
# # $cNames
|
817
|
+
# next
|
818
|
+
# end
|
819
|
+
# # Get the path.
|
820
|
+
# path = connection.left.path_each
|
821
|
+
# print " left path[#{i}]=#{path.to_a}... "
|
822
|
+
# signal_p = $systemT0.get_signal(path)
|
823
|
+
# # And test from the refernce directly (must be identical).
|
824
|
+
# signal_r = $systemT0.get_signal(connection.left)
|
825
|
+
# print "signal #{signal_p.name}... "
|
826
|
+
# exp_left_str = $cNames.keys[i]
|
827
|
+
# case exp_left_str[1]
|
828
|
+
# when "0" then
|
829
|
+
# exp_left = $systemT0.get_signal(exp_left_str[2..-1])
|
830
|
+
# when "1" then
|
831
|
+
# exp_left = $systemI1.systemT.get_signal(exp_left_str[2..-1])
|
832
|
+
# when "2" then
|
833
|
+
# exp_left = $systemI2.systemT.get_signal(exp_left_str[2..-1])
|
834
|
+
# else
|
835
|
+
# raise "Test-internal error: could not find signal for #{exp_left_str}."
|
836
|
+
# end
|
837
|
+
# success = true
|
838
|
+
# if exp_left != signal_p then
|
839
|
+
# puts "Error: invalid signal from path #{path}, got #{signal_p.name} but expecting #{exp_left.name}."
|
840
|
+
# success = false
|
841
|
+
# end
|
842
|
+
# if exp_left != signal_r then
|
843
|
+
# puts "Error: invalid signal from reference #{path}, got #{signal_r.name} but expecting #{exp_left.name}."
|
844
|
+
# success = false
|
845
|
+
# end
|
846
|
+
# if success then
|
847
|
+
# puts "Ok."
|
848
|
+
# else
|
849
|
+
# $success = false
|
850
|
+
# end
|
851
|
+
# end
|
852
|
+
# rescue Exception => e
|
853
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
854
|
+
# $success = false
|
855
|
+
end
|
856
|
+
|
857
|
+
|
858
|
+
# Now testing the conversion to YAML.
|
859
|
+
|
860
|
+
print "\n\nConverting $systemT0 to a YAML string... "
|
861
|
+
begin
|
862
|
+
$yaml_str = $systemT0.to_yaml
|
863
|
+
puts "Ok."
|
864
|
+
# rescue Exception => e
|
865
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
866
|
+
# $success = false
|
867
|
+
end
|
868
|
+
puts "YAML result:", $yaml_str
|
869
|
+
|
870
|
+
print "\n\n Regenerating the objects from the YAML string... "
|
871
|
+
begin
|
872
|
+
$systemTx = HDLRuby.from_yaml($yaml_str)[-1]
|
873
|
+
$yaml_str2 = $systemTx.to_yaml
|
874
|
+
puts "YAML result2:", $yaml_str2
|
875
|
+
if ($yaml_str != $yaml_str2) then
|
876
|
+
puts "Error: the regenerated system type is different from the original one."
|
877
|
+
strs = $yaml_str.each_line
|
878
|
+
$yaml_str2.each_line.with_index do |line2,i|
|
879
|
+
line = strs.next
|
880
|
+
if line2 != line then
|
881
|
+
print " line ##{i} differs.\n Got #{line2} But #{line}"
|
882
|
+
end
|
883
|
+
end
|
884
|
+
$success = false
|
885
|
+
end
|
886
|
+
puts "Ok."
|
887
|
+
# rescue Exception => e
|
888
|
+
# puts "Error: unexpected exception raised #{e.inspect}\n"
|
889
|
+
# $success = false
|
890
|
+
end
|
891
|
+
|
892
|
+
# Checking low samples
|
893
|
+
print "Testing the low sample adder.yaml... "
|
894
|
+
$adder_str = File.read("./low_samples/adder.yaml")
|
895
|
+
$adder = HDLRuby.from_yaml($adder_str)[-1]
|
896
|
+
unless $adder.is_a?(SystemT) then
|
897
|
+
puts "Error: invalid class for a system: #{$adder.class}"
|
898
|
+
$success = false
|
899
|
+
end
|
900
|
+
$adder_inputs = $adder.each_input.to_a
|
901
|
+
unless $adder_inputs.size == 2 then
|
902
|
+
puts "Error: invalid number of inputs, expecting 2 but got: #{$adder_inputs.size}"
|
903
|
+
$success = false
|
904
|
+
end
|
905
|
+
unless $adder_inputs[0].name == :x then
|
906
|
+
puts "Error: invalid name for first input, expecting x but got: #{$adder_inputs[0].name}"
|
907
|
+
$success = false
|
908
|
+
end
|
909
|
+
unless $adder_inputs[0].type.is_a?(TypeVector) then
|
910
|
+
puts "Error: invalid type for first input, expecting TypeVector but got: #{$adder_inputs[0].type.class}"
|
911
|
+
$success = false
|
912
|
+
end
|
913
|
+
unless $adder_inputs[1].name == :y then
|
914
|
+
puts "Error: invalid name for second input, expecting y but got: #{$adder_inputs[1].name}"
|
915
|
+
$success = false
|
916
|
+
end
|
917
|
+
unless $adder_inputs[1].type.is_a?(TypeVector) then
|
918
|
+
puts "Error: invalid type for first input, expecting TypeVector but got: #{$adder_inputs[1].type.class}"
|
919
|
+
$success = false
|
920
|
+
end
|
921
|
+
|
922
|
+
puts "Ok." if $success
|
923
|
+
|
924
|
+
|
925
|
+
|
926
|
+
|
927
|
+
if $success then
|
928
|
+
puts "\nSuccess."
|
929
|
+
else
|
930
|
+
puts "\nFailure."
|
931
|
+
end
|
932
|
+
|
933
|
+
|
934
|
+
# puts YAML.dump($systemT0)
|