HDLRuby 3.1.0 → 3.2.0
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 +4 -4
- data/HDLRuby.gemspec +1 -0
- data/README.md +10 -0
- data/ext/hruby_sim/hruby_rcsim_build.c +2 -0
- data/ext/hruby_sim/hruby_sim_calc.c +33 -6
- data/ext/hruby_sim/hruby_sim_tree_calc.c +111 -22
- data/lib/HDLRuby/hdr_samples/comparison_bench.rb +2 -2
- data/lib/HDLRuby/hdr_samples/counter_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +8 -7
- data/lib/HDLRuby/hdr_samples/dff_properties.rb +2 -0
- data/lib/HDLRuby/hdr_samples/enum_as_param.rb +52 -0
- data/lib/HDLRuby/hdr_samples/linear_test.rb +2 -0
- data/lib/HDLRuby/hdr_samples/logic_bench.rb +6 -0
- data/lib/HDLRuby/hdr_samples/mei8.rb +6 -6
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +6 -6
- data/lib/HDLRuby/hdr_samples/memory_test.rb +2 -0
- data/lib/HDLRuby/hdr_samples/named_sub.rb +9 -5
- data/lib/HDLRuby/hdr_samples/ram.rb +7 -6
- data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +2 -0
- data/lib/HDLRuby/hdr_samples/struct.rb +15 -3
- data/lib/HDLRuby/hdr_samples/with_bram.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_bram_frame_stack.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_channel.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_channel_other.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_class.rb +3 -1
- data/lib/HDLRuby/hdr_samples/with_connector.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +6 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint_adv.rb +73 -0
- data/lib/HDLRuby/hdr_samples/with_leftright.rb +1 -1
- data/lib/HDLRuby/hdr_samples/with_sequencer.rb +17 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_channel.rb +58 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +10 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +18 -4
- data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +2 -1
- data/lib/HDLRuby/hdrcc.rb +12 -0
- data/lib/HDLRuby/hruby_high.rb +82 -26
- data/lib/HDLRuby/hruby_low.rb +127 -3
- data/lib/HDLRuby/hruby_low2programs.rb +47 -0
- data/lib/HDLRuby/hruby_low_resolve.rb +3 -2
- data/lib/HDLRuby/hruby_low_without_namespace.rb +133 -5
- data/lib/HDLRuby/hruby_low_without_subsignals.rb +1 -1
- data/lib/HDLRuby/hruby_rcsim.rb +24 -1
- data/lib/HDLRuby/hruby_serializer.rb +2 -1
- data/lib/HDLRuby/hruby_verilog.rb +94 -20
- data/lib/HDLRuby/hruby_verilog_name.rb +3 -17
- data/lib/HDLRuby/std/fixpoint.rb +2 -2
- data/lib/HDLRuby/std/function_generator.rb +1 -1
- data/lib/HDLRuby/std/linear.rb +7 -7
- data/lib/HDLRuby/std/sequencer.rb +263 -13
- data/lib/HDLRuby/std/sequencer_channel.rb +90 -0
- data/lib/HDLRuby/std/sequencer_func.rb +28 -15
- data/lib/HDLRuby/std/std.rb +1 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +22 -3
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# A class for a handshake transmission.
|
|
2
2
|
|
|
3
|
+
raise "Deprecated code."
|
|
4
|
+
|
|
3
5
|
class Handshaker
|
|
4
6
|
|
|
5
7
|
## Create a new handshaker for transmitting +type+ data.
|
|
@@ -179,7 +181,7 @@ end
|
|
|
179
181
|
|
|
180
182
|
# A system testing the producer/consumer.
|
|
181
183
|
system :hs_test do
|
|
182
|
-
|
|
184
|
+
inner :clk,:rst
|
|
183
185
|
|
|
184
186
|
# Declares the handshaker
|
|
185
187
|
hs = Handshaker.new([8])
|
|
@@ -11,6 +11,12 @@ system :fix_test do
|
|
|
11
11
|
bit[3..0,3..0].inner :x,:y,:z
|
|
12
12
|
# Declare three 8-bit integer part 8-bit fractional part
|
|
13
13
|
signed[3..0,3..0].inner :a,:b,:c,:d
|
|
14
|
+
# Declare the comparison results.
|
|
15
|
+
bit.inner :cmpU, :cmpS
|
|
16
|
+
|
|
17
|
+
cmpU <= (x >= y)
|
|
18
|
+
cmpS <= (a >= b)
|
|
19
|
+
|
|
14
20
|
|
|
15
21
|
# Performs calculation between then
|
|
16
22
|
timed do
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Sample for testing advanced expressions with fixpoint.
|
|
2
|
+
|
|
3
|
+
system :with_fixpoint_adv do
|
|
4
|
+
inner :clk,:rst
|
|
5
|
+
signed[8,8].inner :x,:y,:z,:u,:v,:w,:a,:b,:c,:d
|
|
6
|
+
bit.inner :cmp
|
|
7
|
+
|
|
8
|
+
cmp <= (x >= y)
|
|
9
|
+
u <= (x >= y)
|
|
10
|
+
|
|
11
|
+
sequencer(clk,rst) do
|
|
12
|
+
hif(5>4) { w <= _hFFFF }
|
|
13
|
+
helse { w <= _h0000 }
|
|
14
|
+
swhile(w<_h0000) do
|
|
15
|
+
hif(5>6) { w <= _hFFFF }
|
|
16
|
+
helse { w <= _h0000 }
|
|
17
|
+
end
|
|
18
|
+
5.stimes do
|
|
19
|
+
x <= _h0100
|
|
20
|
+
y <= _hFF34
|
|
21
|
+
a <= _h0100
|
|
22
|
+
b <= _h0100
|
|
23
|
+
c <= _h0100
|
|
24
|
+
step
|
|
25
|
+
x <= x*a
|
|
26
|
+
hif(x>=y) { z <= _hFFFF }
|
|
27
|
+
helse { z <= _h0000 }
|
|
28
|
+
v <= mux(x>=y,_h0000,_hFFFF)
|
|
29
|
+
hif(10>0) { w <= _hFFFF }
|
|
30
|
+
helse { w <= _h0000 }
|
|
31
|
+
d <= a*b*c
|
|
32
|
+
step
|
|
33
|
+
x <= _h0000
|
|
34
|
+
x <= x*a
|
|
35
|
+
y <= _hFE68
|
|
36
|
+
hif(x>=y) { z <= _hFFFF }
|
|
37
|
+
helse { z <= _h0000 }
|
|
38
|
+
v <= mux(x>=y,_h0000,_hFFFF)
|
|
39
|
+
hif(1>20) { w <= _hFFFF }
|
|
40
|
+
helse { w <= _h0000 }
|
|
41
|
+
a <= _h0200
|
|
42
|
+
d <= a*b*c
|
|
43
|
+
step
|
|
44
|
+
x <= _hFE00
|
|
45
|
+
x <= x*a
|
|
46
|
+
y <= _hFE02
|
|
47
|
+
hif(x>=y) { z <= _hFFFF }
|
|
48
|
+
helse { z <= _h0000 }
|
|
49
|
+
v <= mux(x>=y,_h0000,_hFFFF)
|
|
50
|
+
b <= _h0200
|
|
51
|
+
d <= a*b*c
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def cstep(n=1)
|
|
56
|
+
n.times do
|
|
57
|
+
clk <= ~clk
|
|
58
|
+
!10.ns
|
|
59
|
+
end
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
timed do
|
|
63
|
+
clk <= 0
|
|
64
|
+
rst <= 0
|
|
65
|
+
!10.ns
|
|
66
|
+
cstep(2)
|
|
67
|
+
rst <= 1
|
|
68
|
+
cstep(2)
|
|
69
|
+
rst <= 0
|
|
70
|
+
cstep(40)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
@@ -16,6 +16,7 @@ include HDLRuby::High::Std
|
|
|
16
16
|
# - One sequencer puts the sum of two arrays in a third one.
|
|
17
17
|
# - One sequencer iterates over two arrays.
|
|
18
18
|
# - One sequencer iterates downward.
|
|
19
|
+
# - One sequencer checks sub iterators (HDLRuby special).
|
|
19
20
|
system :my_seqencer do
|
|
20
21
|
|
|
21
22
|
inner :clk,:rst
|
|
@@ -161,6 +162,22 @@ system :my_seqencer do
|
|
|
161
162
|
# hprint(")2 res6=",res6,"\n")
|
|
162
163
|
end
|
|
163
164
|
|
|
165
|
+
[8].inner :res7,:res8
|
|
166
|
+
|
|
167
|
+
sequencer(clk.posedge,rst) do
|
|
168
|
+
res7 <= 0
|
|
169
|
+
res8 <= 0
|
|
170
|
+
ar0.seach_range(0..3) do |elem|
|
|
171
|
+
res7 <= elem
|
|
172
|
+
end
|
|
173
|
+
ar0.seach_range(4..9) do |elem|
|
|
174
|
+
res7 <= elem
|
|
175
|
+
end
|
|
176
|
+
(_h00.._h07).seach_range(1..4) do |elem|
|
|
177
|
+
res8 <= elem
|
|
178
|
+
end
|
|
179
|
+
end
|
|
180
|
+
|
|
164
181
|
|
|
165
182
|
timed do
|
|
166
183
|
clk <= 0
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
require 'std/sequencer.rb'
|
|
2
|
+
|
|
3
|
+
include HDLRuby::High::Std
|
|
4
|
+
|
|
5
|
+
# Checking the usage of sequencers' channels.
|
|
6
|
+
system :my_seqencer do
|
|
7
|
+
|
|
8
|
+
inner :clk,:rst,filled: 0
|
|
9
|
+
bit[16][-16].inner :mem
|
|
10
|
+
[16].inner :res0, :res1, :res2, :res3
|
|
11
|
+
|
|
12
|
+
ch_read = schannel(bit[16],16) do |i|
|
|
13
|
+
mem[i]
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
ch_write = schannel(bit[16],16) do |i,val|
|
|
17
|
+
mem[i] <= val
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
sequencer(clk.posedge,rst) do
|
|
21
|
+
16.stimes { |i| ch_write.snext!(i) }
|
|
22
|
+
filled <= 1
|
|
23
|
+
16.stimes do |i|
|
|
24
|
+
res0 <= ch_read.snext
|
|
25
|
+
res1 <= ch_read[15-i]
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
sequencer(clk.posedge,rst) do
|
|
30
|
+
swhile(~filled);
|
|
31
|
+
16.stimes do |i|
|
|
32
|
+
res2 <= ch_read.snext
|
|
33
|
+
res3 <= ch_read[15-i]
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
timed do
|
|
39
|
+
clk <= 0
|
|
40
|
+
rst <= 0
|
|
41
|
+
!10.ns
|
|
42
|
+
clk <= 1
|
|
43
|
+
!10.ns
|
|
44
|
+
clk <= 0
|
|
45
|
+
rst <= 1
|
|
46
|
+
!10.ns
|
|
47
|
+
clk <= 1
|
|
48
|
+
!10.ns
|
|
49
|
+
clk <= 0
|
|
50
|
+
rst <= 0
|
|
51
|
+
!10.ns
|
|
52
|
+
clk <= 1
|
|
53
|
+
repeat(100) do
|
|
54
|
+
!10.ns
|
|
55
|
+
clk <= ~clk
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
end
|
|
@@ -34,6 +34,7 @@ include HDLRuby::High::Std
|
|
|
34
34
|
# - The twenty nineth sequencer checks stake and stake_while
|
|
35
35
|
# - The thirtieth sequencer checks suniq
|
|
36
36
|
# - The thirty first sequencer checks szip
|
|
37
|
+
# - The thirty second sequnecer checks seach_nexts (HDLRuby special)
|
|
37
38
|
#
|
|
38
39
|
# __WARNING__: All the operations on enumerators generate their own result
|
|
39
40
|
# signal. Therefore, in a real circuit, there is no need to
|
|
@@ -414,6 +415,15 @@ system :my_seqencer do
|
|
|
414
415
|
# hprint("}1 res52=",res52," res53=",res53,"\n")
|
|
415
416
|
end
|
|
416
417
|
|
|
418
|
+
[8].inner :res54,:res55
|
|
419
|
+
|
|
420
|
+
sequencer(clk.posedge,rst) do
|
|
421
|
+
res54 <= 0
|
|
422
|
+
res55 <= 0
|
|
423
|
+
vals.seach_nexts(6) { |i| res54 <= i }
|
|
424
|
+
res55 <= vals.seach_nexts(4).ssum
|
|
425
|
+
end
|
|
426
|
+
|
|
417
427
|
|
|
418
428
|
|
|
419
429
|
timed do
|
|
@@ -52,16 +52,30 @@ system :my_seqencer do
|
|
|
52
52
|
|
|
53
53
|
data <= mem[addr]
|
|
54
54
|
|
|
55
|
-
mem_enum = senumerator(bit[8],8) do |i|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
mem_enum = senumerator(bit[8],8) do |i,val|
|
|
56
|
+
if val then
|
|
57
|
+
# Write
|
|
58
|
+
mem[i] <= val
|
|
59
|
+
step
|
|
60
|
+
val
|
|
61
|
+
else
|
|
62
|
+
# Read
|
|
63
|
+
addr <= i
|
|
64
|
+
step
|
|
65
|
+
data
|
|
66
|
+
end
|
|
59
67
|
end
|
|
60
68
|
|
|
61
69
|
sequencer(clk.posedge,rst) do
|
|
62
70
|
# hprint("~0\n")
|
|
63
71
|
res6 <= 0
|
|
64
72
|
res6 <= mem_enum.ssum
|
|
73
|
+
mem_enum.srewind
|
|
74
|
+
mem_enum.snext!(_hAA)
|
|
75
|
+
mem_enum.snext!(_hBB)
|
|
76
|
+
mem_enum.srewind
|
|
77
|
+
res6 <= mem_enum.snext
|
|
78
|
+
res6 <= mem_enum.snext
|
|
65
79
|
# hprint("~1 res6=",res6,"\n")
|
|
66
80
|
end
|
|
67
81
|
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
|
@@ -84,6 +84,10 @@ require 'HDLRuby/backend/hruby_c_allocator'
|
|
|
84
84
|
|
|
85
85
|
require 'HDLRuby/version.rb'
|
|
86
86
|
|
|
87
|
+
# Global flags
|
|
88
|
+
$sim = false # Tells if hdrcc is in simulation mode
|
|
89
|
+
$gen = false # Tells if hdrcc is in hardware generation mode
|
|
90
|
+
|
|
87
91
|
|
|
88
92
|
##
|
|
89
93
|
# HDLRuby compiler interface program
|
|
@@ -373,19 +377,23 @@ $optparse = OptionParser.new do |opts|
|
|
|
373
377
|
opts.on("-S","--sim","Default simulator (hybrid C-Ruby)") do |v|
|
|
374
378
|
$options[:rcsim] = v
|
|
375
379
|
$options[:multiple] = v
|
|
380
|
+
$sim = true
|
|
376
381
|
end
|
|
377
382
|
opts.on("--csim","Standalone C-based simulator") do |v|
|
|
378
383
|
$options[:clang] = v
|
|
379
384
|
$options[:multiple] = v
|
|
380
385
|
$options[:csim] = v
|
|
386
|
+
$sim = true
|
|
381
387
|
end
|
|
382
388
|
opts.on("--rsim","Ruby-based simulator") do |v|
|
|
383
389
|
$options[:rsim] = v
|
|
384
390
|
$options[:multiple] = v
|
|
391
|
+
$sim = true
|
|
385
392
|
end
|
|
386
393
|
opts.on("--rcsim","Hybrid C-Ruby-based simulator") do |v|
|
|
387
394
|
$options[:rcsim] = v
|
|
388
395
|
$options[:multiple] = v
|
|
396
|
+
$sim = true
|
|
389
397
|
end
|
|
390
398
|
opts.on("--mute", "The simulator will not generate any output") do |v|
|
|
391
399
|
$options[:mute] = v
|
|
@@ -396,12 +404,14 @@ $optparse = OptionParser.new do |opts|
|
|
|
396
404
|
opts.on("-v", "--verilog","Output in Verlog HDL format") do |v|
|
|
397
405
|
$options[:verilog] = v
|
|
398
406
|
$options[:multiple] = v
|
|
407
|
+
$gen = true
|
|
399
408
|
end
|
|
400
409
|
opts.on("-V", "--vhdl","Output in VHDL format") do |v|
|
|
401
410
|
HDLRuby::Low::Low2VHDL.vhdl08 = false
|
|
402
411
|
$options[:vhdl] = v
|
|
403
412
|
$options[:multiple] = v
|
|
404
413
|
$options[:vhdl08] = false
|
|
414
|
+
$gen = true
|
|
405
415
|
end
|
|
406
416
|
opts.on("-A", "--alliance","Output in Alliance-compatible VHDL format") do |v|
|
|
407
417
|
HDLRuby::Low::Low2VHDL.vhdl08 = false
|
|
@@ -410,12 +420,14 @@ $optparse = OptionParser.new do |opts|
|
|
|
410
420
|
$options[:alliance] = v
|
|
411
421
|
$options[:multiple] = v
|
|
412
422
|
$options[:vhdl08] = false
|
|
423
|
+
$gen = true
|
|
413
424
|
end
|
|
414
425
|
opts.on("-U", "--vhdl08","Output in VHDL'08 format") do |v|
|
|
415
426
|
HDLRuby::Low::Low2VHDL.vhdl08 = true
|
|
416
427
|
$options[:vhdl] = v
|
|
417
428
|
$options[:multiple] = v
|
|
418
429
|
$options[:vhdl08] = true
|
|
430
|
+
$gen = true
|
|
419
431
|
end
|
|
420
432
|
opts.on("-s", "--syntax","Output the Ruby syntax tree") do |s|
|
|
421
433
|
$options[:syntax] = s
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
|
@@ -880,9 +880,11 @@ module HDLRuby::High
|
|
|
880
880
|
"Cannot convert a system without a name to HDLRuby::Low."
|
|
881
881
|
end
|
|
882
882
|
# Create the resulting low system type.
|
|
883
|
-
# systemTL = HDLRuby::Low::SystemT.new(
|
|
884
|
-
|
|
885
|
-
|
|
883
|
+
# systemTL = HDLRuby::Low::SystemT.new(HDLRuby.uniq_name(name),
|
|
884
|
+
# self.scope.to_low)
|
|
885
|
+
systemTLN = HDLRuby.uniq_name(name)
|
|
886
|
+
systemTL = HDLRuby::Low::SystemT.new(systemTLN,
|
|
887
|
+
self.scope.to_low(systemTLN))
|
|
886
888
|
# puts "New low from system #{self.name}: #{systemTL.name}"
|
|
887
889
|
# # For debugging: set the source high object
|
|
888
890
|
# systemTL.properties[:low2high] = self.hdr_id
|
|
@@ -1168,6 +1170,17 @@ module HDLRuby::High
|
|
|
1168
1170
|
self.parent.inout(*names)
|
|
1169
1171
|
end
|
|
1170
1172
|
|
|
1173
|
+
# Declares a program in language +lang+ with start function named +func+
|
|
1174
|
+
# and accessed expressions an code given in +args+.
|
|
1175
|
+
def program(lang, func, *args)
|
|
1176
|
+
# Create the program.
|
|
1177
|
+
prog = Program.new(lang, func, *args)
|
|
1178
|
+
# Adds the resulting program to the current scope.
|
|
1179
|
+
HDLRuby::High.top_user.add_program(prog)
|
|
1180
|
+
# Return the resulting program
|
|
1181
|
+
return prog
|
|
1182
|
+
end
|
|
1183
|
+
|
|
1171
1184
|
# Declares a non-HDLRuby set of code chunks described by +content+ and
|
|
1172
1185
|
# completed from +ruby_block+ execution result.
|
|
1173
1186
|
# NOTE: content includes the events to activate the code on and
|
|
@@ -1512,6 +1525,8 @@ module HDLRuby::High
|
|
|
1512
1525
|
scopeL.add_systemT(systemI_low.systemT)
|
|
1513
1526
|
}
|
|
1514
1527
|
end
|
|
1528
|
+
# Adds the programs.
|
|
1529
|
+
self.each_program { |prog| scopeL.add_program(prog.to_low) }
|
|
1515
1530
|
# Adds the code chunks.
|
|
1516
1531
|
self.each_code { |code| scopeL.add_code(code.to_low) }
|
|
1517
1532
|
# Adds the connections.
|
|
@@ -1526,10 +1541,15 @@ module HDLRuby::High
|
|
|
1526
1541
|
end
|
|
1527
1542
|
|
|
1528
1543
|
# Converts the scope to HDLRuby::Low.
|
|
1529
|
-
|
|
1544
|
+
# +name+ is the name of the system containing the new low scope in case
|
|
1545
|
+
# of top scope, should be used as name for it.
|
|
1546
|
+
# NOTE: by convention, the name of the top scope is the name of the
|
|
1547
|
+
# system.
|
|
1548
|
+
def to_low(low_name = nil)
|
|
1530
1549
|
# Create the resulting low scope.
|
|
1531
1550
|
# scopeL = HDLRuby::Low::Scope.new()
|
|
1532
|
-
|
|
1551
|
+
low_name = self.name unless low_name
|
|
1552
|
+
scopeL = HDLRuby::Low::Scope.new(low_name)
|
|
1533
1553
|
# # For debugging: set the source high object
|
|
1534
1554
|
# scopeL.properties[:low2high] = self.hdr_id
|
|
1535
1555
|
# self.properties[:high2low] = scopeL
|
|
@@ -1974,7 +1994,7 @@ module HDLRuby::High
|
|
|
1974
1994
|
raise AnyError, "Generic type #{self.name} did not produce a valid type: #{gtype.class}"
|
|
1975
1995
|
end
|
|
1976
1996
|
# Create a new type definition from it.
|
|
1977
|
-
gtype = TypeDef.new(self.name.to_s + "_#{args.join(
|
|
1997
|
+
gtype = TypeDef.new(self.name.to_s + "_#{args.join(':')}",
|
|
1978
1998
|
gtype)
|
|
1979
1999
|
# Adds the possible overloaded operators.
|
|
1980
2000
|
self.each_overload do |op,ruby_block|
|
|
@@ -2168,6 +2188,7 @@ module HDLRuby::High
|
|
|
2168
2188
|
|
|
2169
2189
|
# Methods for declaring systems
|
|
2170
2190
|
|
|
2191
|
+
|
|
2171
2192
|
# Declares a high-level system type named +name+, with +includes+ mixins
|
|
2172
2193
|
# system types and using +ruby_block+ for instantiating.
|
|
2173
2194
|
def system(name = :"", *includes, &ruby_block)
|
|
@@ -2294,24 +2315,8 @@ module HDLRuby::High
|
|
|
2294
2315
|
# Performs the connections.
|
|
2295
2316
|
connects.each do |key,value|
|
|
2296
2317
|
# Gets the signal corresponding to connect.
|
|
2297
|
-
# signal = self.get_signal(key)
|
|
2298
|
-
# unless signal then
|
|
2299
|
-
# # Look into the included systems.
|
|
2300
|
-
# self.systemT.scope.each_included do |included|
|
|
2301
|
-
# signal = included.get_signal(key)
|
|
2302
|
-
# break if signal
|
|
2303
|
-
# end
|
|
2304
|
-
# end
|
|
2305
2318
|
signal = self.systemT.get_signal_with_included(key)
|
|
2306
2319
|
# Check if it is an output.
|
|
2307
|
-
# isout = self.get_output(key)
|
|
2308
|
-
# unless isout then
|
|
2309
|
-
# # Look into the inlucded systems.
|
|
2310
|
-
# self.systemT.scope.each_included do |included|
|
|
2311
|
-
# isout = included.get_output(key)
|
|
2312
|
-
# break if isout
|
|
2313
|
-
# end
|
|
2314
|
-
# end
|
|
2315
2320
|
isout = self.systemT.get_output_with_included(key)
|
|
2316
2321
|
# Convert it to a reference.
|
|
2317
2322
|
# puts "key=#{key} value=#{value} signal=#{signal}"
|
|
@@ -2441,7 +2446,6 @@ module HDLRuby::High
|
|
|
2441
2446
|
|
|
2442
2447
|
# Gets the private namespace.
|
|
2443
2448
|
def namespace
|
|
2444
|
-
# self.systemT.scope.namespace
|
|
2445
2449
|
self.systemT.namespace
|
|
2446
2450
|
end
|
|
2447
2451
|
|
|
@@ -2492,6 +2496,25 @@ module HDLRuby::High
|
|
|
2492
2496
|
end
|
|
2493
2497
|
end
|
|
2494
2498
|
|
|
2499
|
+
|
|
2500
|
+
|
|
2501
|
+
|
|
2502
|
+
##
|
|
2503
|
+
# Describes a program.
|
|
2504
|
+
class Program < HDLRuby::Low::Program
|
|
2505
|
+
# Converts the if to HDLRuby::Low.
|
|
2506
|
+
def to_low
|
|
2507
|
+
# Create the resulting program.
|
|
2508
|
+
progL = HDLRuby::Low::Program.new(self.lang,self.function,
|
|
2509
|
+
*self.each_expression.map(&:to_low),
|
|
2510
|
+
*self.each_event.map(&:to_low),
|
|
2511
|
+
*self.each_code)
|
|
2512
|
+
# Return the resulting program.
|
|
2513
|
+
return progL
|
|
2514
|
+
end
|
|
2515
|
+
end
|
|
2516
|
+
|
|
2517
|
+
|
|
2495
2518
|
##
|
|
2496
2519
|
# Decribes a set of non-HDLRuby code chunks.
|
|
2497
2520
|
class Code < HDLRuby::Low::Code
|
|
@@ -3336,6 +3359,24 @@ module HDLRuby::High
|
|
|
3336
3359
|
include HExpression
|
|
3337
3360
|
include HArrow
|
|
3338
3361
|
|
|
3362
|
+
# Update the initialize to handle struct types accesses if
|
|
3363
|
+
# it is not a RefObject, this latter being a proxy to a
|
|
3364
|
+
# real component.
|
|
3365
|
+
if klass != RefObject then
|
|
3366
|
+
original_initialize = instance_method(:initialize)
|
|
3367
|
+
define_method(:initialize) do |*args, &block|
|
|
3368
|
+
original_initialize.bind(self).call(*args,&block)
|
|
3369
|
+
# Now process it if it is a structured type.
|
|
3370
|
+
if self.type.struct? then
|
|
3371
|
+
self.type.each do |name,typ|
|
|
3372
|
+
self.define_singleton_method(name) do
|
|
3373
|
+
RefName.new(typ,self,name)
|
|
3374
|
+
end
|
|
3375
|
+
end
|
|
3376
|
+
end
|
|
3377
|
+
end
|
|
3378
|
+
end
|
|
3379
|
+
|
|
3339
3380
|
# Converts to a new expression.
|
|
3340
3381
|
def to_expr
|
|
3341
3382
|
self.to_ref
|
|
@@ -3436,15 +3477,22 @@ module HDLRuby::High
|
|
|
3436
3477
|
# Converts the name reference to a HDLRuby::Low::RefName.
|
|
3437
3478
|
def to_low
|
|
3438
3479
|
# puts "to_low with base=#{@base} @object=#{@object}"
|
|
3439
|
-
# puts "@object.name=#{@object.name}"
|
|
3480
|
+
# puts "@object.name=#{@object.name} @object.parent=#{@object.parent.name}"
|
|
3440
3481
|
if @base.is_a?(RefThis) &&
|
|
3441
3482
|
(@object.parent != High.top_user) &&
|
|
3442
3483
|
(@object.parent != High.cur_system) &&
|
|
3484
|
+
(@object.parent != High.cur_system.scope) &&
|
|
3443
3485
|
(!@object.parent.name.empty?) then
|
|
3444
3486
|
# Need to have a hierachical access.
|
|
3445
|
-
|
|
3446
|
-
|
|
3487
|
+
if @object.respond_to?(:low_object) && @object.low_object then
|
|
3488
|
+
# There where already a low object, create the ref from it.
|
|
3489
|
+
# puts "absolute ref!"
|
|
3490
|
+
refNameL = @object.low_object.absolute_ref
|
|
3491
|
+
else
|
|
3492
|
+
# No create the indirect reference.
|
|
3493
|
+
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
|
3447
3494
|
@object.parent.to_ref.to_low,@object.name)
|
|
3495
|
+
end
|
|
3448
3496
|
else
|
|
3449
3497
|
# Direct access is enough.
|
|
3450
3498
|
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
|
@@ -3972,11 +4020,19 @@ module HDLRuby::High
|
|
|
3972
4020
|
return [obj,self.to_expr]
|
|
3973
4021
|
end
|
|
3974
4022
|
|
|
4023
|
+
# Get the low version off the object.
|
|
4024
|
+
# NOTE: only useful for Signals and SystemIs since they can be accessed
|
|
4025
|
+
# from outside the module they have been defined in.
|
|
4026
|
+
def low_object
|
|
4027
|
+
return @low_object
|
|
4028
|
+
end
|
|
4029
|
+
|
|
3975
4030
|
# Converts the system to HDLRuby::Low and set its +name+.
|
|
3976
4031
|
def to_low(name = self.name)
|
|
3977
4032
|
# return HDLRuby::Low::SignalI.new(name,self.type.to_low)
|
|
3978
4033
|
valueL = self.value ? self.value.to_low : nil
|
|
3979
4034
|
signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low,valueL)
|
|
4035
|
+
@low_object = signalIL
|
|
3980
4036
|
# Recurse on the sub signals if any.
|
|
3981
4037
|
self.each_signal do |sig|
|
|
3982
4038
|
signalIL.add_signal(sig.to_low)
|