HDLRuby 2.11.10 → 2.11.12
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/README.md +55 -18
- data/ext/hruby_sim/hruby_rcsim_build.c +110 -83
- data/ext/hruby_sim/hruby_sim.h +3 -0
- data/ext/hruby_sim/hruby_sim_calc.c +14 -6
- data/ext/hruby_sim/hruby_sim_core.c +20 -7
- data/ext/hruby_sim/hruby_sim_list.c +1 -1
- data/ext/hruby_sim/hruby_sim_stack_calc.c +3 -2
- data/ext/hruby_sim/hruby_sim_tree_calc.c +8 -1
- data/ext/hruby_sim/hruby_sim_vcd.c +24 -7
- data/ext/hruby_sim/hruby_sim_vizualize.c +9 -1
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +3 -1
- data/lib/HDLRuby/hdr_samples/counter_dff_bench.rb +3 -1
- data/lib/HDLRuby/hdr_samples/huge_rom.rb +1 -1
- data/lib/HDLRuby/hdr_samples/mei8.rb +11 -11
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +11 -11
- data/lib/HDLRuby/hdr_samples/neg_arith_bench.rb +4 -4
- data/lib/HDLRuby/hdr_samples/rom_nest.rb +1 -1
- data/lib/HDLRuby/hdr_samples/ruby_fir_hw.rb +4 -4
- data/lib/HDLRuby/hdr_samples/struct.rb +44 -10
- data/lib/HDLRuby/hdr_samples/with_bram.rb +45 -0
- data/lib/HDLRuby/hdr_samples/with_casts.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_concat.rb +6 -6
- data/lib/HDLRuby/hdr_samples/with_connector_memory.rb +2 -2
- data/lib/HDLRuby/hdr_samples/with_def.rb +10 -3
- data/lib/HDLRuby/hdr_samples/with_define_operator.rb +44 -0
- data/lib/HDLRuby/hdr_samples/with_fixpoint.rb +12 -12
- data/lib/HDLRuby/hdr_samples/with_init.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_leftright.rb +21 -0
- data/lib/HDLRuby/hdr_samples/with_reduce.rb +13 -13
- data/lib/HDLRuby/hdr_samples/with_ref_array.rb +6 -6
- data/lib/HDLRuby/hdr_samples/with_subsums.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_terminate.rb +3 -3
- data/lib/HDLRuby/hdr_samples/with_to_a.rb +10 -10
- data/lib/HDLRuby/hdr_samples/with_values.rb +3 -3
- data/lib/HDLRuby/hdrcc.rb +14 -1
- data/lib/HDLRuby/hruby_bstr.rb +10 -5
- data/lib/HDLRuby/hruby_high.rb +114 -27
- data/lib/HDLRuby/hruby_low.rb +187 -16
- data/lib/HDLRuby/hruby_low2c.rb +71 -11
- data/lib/HDLRuby/hruby_low2vhd.rb +2 -1
- data/lib/HDLRuby/hruby_low_fix_types.rb +1 -0
- data/lib/HDLRuby/hruby_low_mutable.rb +30 -1
- data/lib/HDLRuby/hruby_low_resolve.rb +15 -2
- data/lib/HDLRuby/hruby_low_without_concat.rb +28 -8
- data/lib/HDLRuby/hruby_low_without_parinseq.rb +14 -4
- data/lib/HDLRuby/hruby_low_without_select.rb +2 -2
- data/lib/HDLRuby/hruby_low_without_subsignals.rb +279 -0
- data/lib/HDLRuby/hruby_rcsim.rb +99 -87
- data/lib/HDLRuby/hruby_rsim.rb +132 -7
- data/lib/HDLRuby/hruby_rsim_vcd.rb +99 -27
- data/lib/HDLRuby/hruby_values.rb +35 -31
- data/lib/HDLRuby/std/bram.rb +22 -0
- data/lib/HDLRuby/std/fixpoint.rb +2 -2
- data/lib/HDLRuby/std/fsm.rb +20 -3
- data/lib/HDLRuby/std/function_generator.rb +2 -2
- data/lib/HDLRuby/version.rb +1 -1
- metadata +7 -3
- data/lib/HDLRuby/hdr_samples/sumprod.rb +0 -29
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# A benchmark for the cases where a left value is also a right value
|
|
2
|
+
# in a block without sensitivity list.
|
|
3
|
+
system :leftright_bench do
|
|
4
|
+
[8].inner :l,:r0,:r1,:lr
|
|
5
|
+
|
|
6
|
+
par do
|
|
7
|
+
lr <= r0*2
|
|
8
|
+
l <= [lr[7],lr[6..0]].to_expr + r1
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
timed do
|
|
12
|
+
!10.ns
|
|
13
|
+
r0 <= 1
|
|
14
|
+
!10.ns
|
|
15
|
+
r1 <= 2
|
|
16
|
+
!10.ns
|
|
17
|
+
r0 <= 3
|
|
18
|
+
r1 <= 4
|
|
19
|
+
!10.ns
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -6,33 +6,33 @@ system :with_reduce_bench do
|
|
|
6
6
|
[64].inner :val64
|
|
7
7
|
|
|
8
8
|
timed do
|
|
9
|
-
val <=
|
|
10
|
-
res <= val.reduce(
|
|
9
|
+
val <= _b01101010
|
|
10
|
+
res <= val.reduce(_b00000000,:+)
|
|
11
11
|
!10.ns
|
|
12
12
|
val <= _01010010
|
|
13
|
-
res <= val.reduce(
|
|
13
|
+
res <= val.reduce(_b00000000,:+)
|
|
14
14
|
!10.ns
|
|
15
15
|
val <= _01101111
|
|
16
|
-
res <= val.reduce(
|
|
16
|
+
res <= val.reduce(_b00000000,:+)
|
|
17
17
|
!10.ns
|
|
18
|
-
val64 <=
|
|
19
|
-
res <= val64.reduce(
|
|
18
|
+
val64 <= _b0110101001101010011010100110101001101010011010100110101001101010
|
|
19
|
+
res <= val64.reduce(_b00000000,:+)
|
|
20
20
|
!10.ns
|
|
21
21
|
res <= val64[7..0]
|
|
22
22
|
!10.ns
|
|
23
|
-
res <= res.reduce(
|
|
23
|
+
res <= res.reduce(_b00000000,:+)
|
|
24
24
|
!10.ns
|
|
25
25
|
res <= val64[63..60]
|
|
26
26
|
!10.ns
|
|
27
|
-
res <= res.reduce(
|
|
27
|
+
res <= res.reduce(_b00000000,:+)
|
|
28
28
|
!10.ns
|
|
29
29
|
val64 <= ~(val64 ^ val64)
|
|
30
|
-
res <= val64.reduce(
|
|
30
|
+
res <= val64.reduce(_b00000000,:+)
|
|
31
31
|
!10.ns
|
|
32
|
-
val64[0] <=
|
|
33
|
-
val64[3] <=
|
|
34
|
-
val64[63] <=
|
|
35
|
-
res <= val64.reduce(
|
|
32
|
+
val64[0] <= _b0
|
|
33
|
+
val64[3] <= _b0
|
|
34
|
+
val64[63] <= _b0
|
|
35
|
+
res <= val64.reduce(_b00000000,:+)
|
|
36
36
|
!10.ns
|
|
37
37
|
end
|
|
38
38
|
end
|
|
@@ -10,16 +10,16 @@ system :with_concat do
|
|
|
10
10
|
val3[6..3] <= val1[7..4]
|
|
11
11
|
|
|
12
12
|
timed do
|
|
13
|
-
val0 <=
|
|
14
|
-
val1 <=
|
|
13
|
+
val0 <= _b00001111
|
|
14
|
+
val1 <= _b11000011
|
|
15
15
|
count <= 0
|
|
16
16
|
!10.ns
|
|
17
|
-
val0 <=
|
|
18
|
-
val1 <=
|
|
17
|
+
val0 <= _b11110000
|
|
18
|
+
val1 <= _b00111100
|
|
19
19
|
count <= 1
|
|
20
20
|
!10.ns
|
|
21
|
-
val0 <=
|
|
22
|
-
val1 <=
|
|
21
|
+
val0 <= _b10101010
|
|
22
|
+
val1 <= _b01010101
|
|
23
23
|
count <= 2
|
|
24
24
|
!10.ns
|
|
25
25
|
end
|
|
@@ -20,13 +20,13 @@ system :with_concat do
|
|
|
20
20
|
val6 <= bs.reduce(:+)
|
|
21
21
|
|
|
22
22
|
timed do
|
|
23
|
-
val0 <=
|
|
23
|
+
val0 <= _b1111000011110000
|
|
24
24
|
count <= 0
|
|
25
25
|
!10.ns
|
|
26
|
-
val0 <=
|
|
26
|
+
val0 <= _b0000111100001111
|
|
27
27
|
count <= 1
|
|
28
28
|
!10.ns
|
|
29
|
-
val0 <=
|
|
29
|
+
val0 <= _b1010101010101010
|
|
30
30
|
count <= 2
|
|
31
31
|
!10.ns
|
|
32
32
|
end
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
# A benchmark for testing the terminate statement.
|
|
3
3
|
system :with_terminate do
|
|
4
4
|
[8].constant cst0: 127
|
|
5
|
-
constant cst1:
|
|
6
|
-
[8].inner sig0:
|
|
7
|
-
inner sig1:
|
|
5
|
+
constant cst1: _b1
|
|
6
|
+
[8].inner sig0: _b10000000
|
|
7
|
+
inner sig1: _b1
|
|
8
8
|
[8].inner :sig2
|
|
9
9
|
[8].inner count: 0
|
|
10
10
|
|
|
@@ -52,26 +52,26 @@ system :with_to_a_bench do
|
|
|
52
52
|
four2sixfour(:my_four2sixfour).(four,*(sixfour.to_a.reverse))
|
|
53
53
|
|
|
54
54
|
timed do
|
|
55
|
-
val <=
|
|
55
|
+
val <= _b01101010
|
|
56
56
|
res <= vals.reverse
|
|
57
57
|
!10.ns
|
|
58
|
-
val64 <=
|
|
58
|
+
val64 <= _b0110101001101010011010100110101001101010011010100110101001101010
|
|
59
59
|
res64 <= val64s.reverse
|
|
60
60
|
!10.ns
|
|
61
|
-
val <=
|
|
62
|
-
val64 <=
|
|
61
|
+
val <= _b00000000
|
|
62
|
+
val64 <= _b0000000000000000000000000000000000000000000000000000000000000000
|
|
63
63
|
!10.ns
|
|
64
64
|
vals.each.with_index do |v,i|
|
|
65
|
-
v <= (i/2) &
|
|
65
|
+
v <= (i/2) & _b1
|
|
66
66
|
end
|
|
67
67
|
res <= val
|
|
68
68
|
!10.ns
|
|
69
69
|
val64s.each.with_index do |v,i|
|
|
70
|
-
v <= (i/2) &
|
|
70
|
+
v <= (i/2) & _b1
|
|
71
71
|
end
|
|
72
72
|
res64 <= val64
|
|
73
73
|
!10.ns
|
|
74
|
-
val <=
|
|
74
|
+
val <= _b01010011
|
|
75
75
|
!10.ns
|
|
76
76
|
8.times do |i|
|
|
77
77
|
val64s[i] <= val[i]
|
|
@@ -80,11 +80,11 @@ system :with_to_a_bench do
|
|
|
80
80
|
end
|
|
81
81
|
res64 <= val64
|
|
82
82
|
!10.ns
|
|
83
|
-
four <=
|
|
83
|
+
four <= _b0000
|
|
84
84
|
!10.ns
|
|
85
|
-
four <=
|
|
85
|
+
four <= _b0001
|
|
86
86
|
!10.ns
|
|
87
|
-
four <=
|
|
87
|
+
four <= _b1100
|
|
88
88
|
!10.ns
|
|
89
89
|
end
|
|
90
90
|
end
|
|
@@ -11,7 +11,7 @@ system :with_values do
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
timed do
|
|
14
|
-
v1 <=
|
|
14
|
+
v1 <= _b0
|
|
15
15
|
v8 <= 0
|
|
16
16
|
v16 <= 0
|
|
17
17
|
v32 <= 0
|
|
@@ -19,7 +19,7 @@ system :with_values do
|
|
|
19
19
|
v64 <= 0
|
|
20
20
|
v96 <= 0
|
|
21
21
|
!10.ns
|
|
22
|
-
v1 <=
|
|
22
|
+
v1 <= _b1
|
|
23
23
|
v8 <= 1
|
|
24
24
|
v16 <= 1
|
|
25
25
|
v32 <= 1
|
|
@@ -27,7 +27,7 @@ system :with_values do
|
|
|
27
27
|
v64 <= 1
|
|
28
28
|
v96 <= 1
|
|
29
29
|
!10.ns
|
|
30
|
-
v1 <=
|
|
30
|
+
v1 <= _b1010[2]
|
|
31
31
|
v8 <= _uhFF00[12..4]
|
|
32
32
|
!10.ns
|
|
33
33
|
v8 <= 128
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
|
@@ -60,6 +60,7 @@ require 'HDLRuby/hruby_check.rb'
|
|
|
60
60
|
require 'HDLRuby/hruby_low2hdr'
|
|
61
61
|
require 'HDLRuby/hruby_low2c'
|
|
62
62
|
require 'HDLRuby/hruby_low2vhd'
|
|
63
|
+
require 'HDLRuby/hruby_low_without_subsignals'
|
|
63
64
|
require 'HDLRuby/hruby_low_fix_types'
|
|
64
65
|
# require 'HDLRuby/hruby_low_expand_types' # For now dormant
|
|
65
66
|
require 'HDLRuby/hruby_low_without_outread'
|
|
@@ -641,8 +642,12 @@ elsif $options[:clang] then
|
|
|
641
642
|
# top_system = $top_system
|
|
642
643
|
# Preprocess the HW description for valid C generation.
|
|
643
644
|
$top_system.each_systemT_deep do |systemT|
|
|
645
|
+
HDLRuby.show? "signal2subs step..."
|
|
646
|
+
# Ensure there is not implicit assign to sub signals.
|
|
647
|
+
systemT.signal2subs!
|
|
648
|
+
HDLRuby.show? "#{Time.now}#{show_mem}"
|
|
644
649
|
HDLRuby.show? "seq2seq step..."
|
|
645
|
-
#
|
|
650
|
+
# Converts the par blocks in seq blocks to seq blocks to match
|
|
646
651
|
# the simulation engine.
|
|
647
652
|
systemT.par_in_seq2seq!
|
|
648
653
|
HDLRuby.show? "#{Time.now}#{show_mem}"
|
|
@@ -801,6 +806,9 @@ elsif $options[:verilog] then
|
|
|
801
806
|
# top_system = $top_system
|
|
802
807
|
# Make description compatible with verilog generation.
|
|
803
808
|
$top_system.each_systemT_deep do |systemT|
|
|
809
|
+
HDLRuby.show? "signal2subs step..."
|
|
810
|
+
# Ensure there is not implicit assign to sub signals.
|
|
811
|
+
systemT.signal2subs!
|
|
804
812
|
# HDLRuby.show "casts_without_expression! step..."
|
|
805
813
|
# systemT.casts_without_expression!
|
|
806
814
|
# HDLRuby.show Time.now
|
|
@@ -889,6 +897,8 @@ elsif $options[:rcsim] then
|
|
|
889
897
|
require 'HDLRuby/hruby_rcsim.rb'
|
|
890
898
|
# Merge the included from the top system.
|
|
891
899
|
$top_system.merge_included!
|
|
900
|
+
# Process par in seq.
|
|
901
|
+
$top_system.par_in_seq2seq!
|
|
892
902
|
# Generate the C data structures.
|
|
893
903
|
$top_system.to_rcsim
|
|
894
904
|
HDLRuby.show "Executing the hybrid C-Ruby-level simulator..."
|
|
@@ -902,6 +912,9 @@ elsif $options[:vhdl] then
|
|
|
902
912
|
# top_system = $top_system
|
|
903
913
|
# Make description compatible with vhdl generation.
|
|
904
914
|
$top_system.each_systemT_deep do |systemT|
|
|
915
|
+
HDLRuby.show? "signal2subs step..."
|
|
916
|
+
# Ensure there is not implicit assign to sub signals.
|
|
917
|
+
systemT.signal2subs!
|
|
905
918
|
systemT.outread2inner! unless $options[:vhdl08] || $options[:alliance]
|
|
906
919
|
systemT.with_boolean!
|
|
907
920
|
systemT.boolean_in_assign2select! unless $options[:alliance]
|
data/lib/HDLRuby/hruby_bstr.rb
CHANGED
|
@@ -225,6 +225,7 @@ module HDLRuby
|
|
|
225
225
|
# * when index is larger than the bit width, the bit string is
|
|
226
226
|
# X extended accordingly.
|
|
227
227
|
def []=(index,value)
|
|
228
|
+
# puts "first @content=#{@content}"
|
|
228
229
|
# Change inside the bit string, it is not know any longer if it
|
|
229
230
|
# is specified or not
|
|
230
231
|
@specified = nil
|
|
@@ -250,8 +251,8 @@ module HDLRuby
|
|
|
250
251
|
sign = @content[-1]
|
|
251
252
|
@content.concat([sign] * (right-@content.size+1))
|
|
252
253
|
end
|
|
254
|
+
# puts "left=#{left} right=#{right} sign=#{sign} @content=#{@content}"
|
|
253
255
|
if right >= left then
|
|
254
|
-
# puts "left=#{left} right=#{right} value=#{value} (#{value.class})"
|
|
255
256
|
# Sets the value to a copy of the bit string.
|
|
256
257
|
@content[left..right] = value.is_a?(BitString) ?
|
|
257
258
|
value.raw_content[0..right-left] :
|
|
@@ -412,10 +413,14 @@ module HDLRuby
|
|
|
412
413
|
return @specified
|
|
413
414
|
end
|
|
414
415
|
|
|
415
|
-
#
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
416
|
+
# Coerces.
|
|
417
|
+
def coerce(other)
|
|
418
|
+
if other.is_a?(Numeric) && self.specified? then
|
|
419
|
+
return [other,self.to_i]
|
|
420
|
+
else
|
|
421
|
+
return [BitString.new(other),self]
|
|
422
|
+
end
|
|
423
|
+
end
|
|
419
424
|
|
|
420
425
|
# String conversion table.
|
|
421
426
|
B2S_T = [ "0", "1", "z", "x" ]
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
|
@@ -26,6 +26,14 @@ module HDLRuby::High
|
|
|
26
26
|
return HDLRuby::Infinity
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
# Reimplementation of the Proc's curry that transmit the context for
|
|
30
|
+
# execution.
|
|
31
|
+
def curry_with_context(*args,&ruby_block)
|
|
32
|
+
return proc do |cxt,*new_args|
|
|
33
|
+
cxt.instance_exec(*(args+new_args),&ruby_block)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
29
37
|
|
|
30
38
|
|
|
31
39
|
##
|
|
@@ -38,7 +46,7 @@ module HDLRuby::High
|
|
|
38
46
|
# puts "eigen_extend for #{self} class=#{self.class}"
|
|
39
47
|
obj.singleton_methods.each do |name|
|
|
40
48
|
next if name == :yaml_tag # Do not know why we need to skip
|
|
41
|
-
puts "name=#{name}"
|
|
49
|
+
# puts "name=#{name}"
|
|
42
50
|
self.define_singleton_method(name, &obj.singleton_method(name))
|
|
43
51
|
end
|
|
44
52
|
end
|
|
@@ -403,6 +411,11 @@ module HDLRuby::High
|
|
|
403
411
|
return @scope
|
|
404
412
|
end
|
|
405
413
|
|
|
414
|
+
# Converts to a new reference.
|
|
415
|
+
def to_ref
|
|
416
|
+
return RefObject.new(this,self)
|
|
417
|
+
end
|
|
418
|
+
|
|
406
419
|
# Creates and adds a set of inputs typed +type+ from a list of +names+.
|
|
407
420
|
#
|
|
408
421
|
# NOTE: a name can also be a signal, is which case it is duplicated.
|
|
@@ -1397,6 +1410,7 @@ module HDLRuby::High
|
|
|
1397
1410
|
# Merge the included systems interface in +systemT+
|
|
1398
1411
|
# NOTE: incompatible with further to_low transformation.
|
|
1399
1412
|
def merge_included(systemT)
|
|
1413
|
+
# puts "merge_included for scope=#{self.name} with behaviors=#{self.each_behavior.count}"
|
|
1400
1414
|
# Recurse on the sub.
|
|
1401
1415
|
self.each_scope {|scope| scope.merge_included(systemT) }
|
|
1402
1416
|
# Include for current scope.
|
|
@@ -1437,6 +1451,8 @@ module HDLRuby::High
|
|
|
1437
1451
|
end
|
|
1438
1452
|
# Adds its subscopes.
|
|
1439
1453
|
included.scope.each_scope do |scope|
|
|
1454
|
+
# Do not override scopes with same name since it is prioritary!
|
|
1455
|
+
next if !scope.name.empty? && systemT.scope.each_scope.find {|sc| sc.name == scope.name}
|
|
1440
1456
|
scope.no_parent!
|
|
1441
1457
|
systemT.scope.add_scope(scope)
|
|
1442
1458
|
end
|
|
@@ -1709,10 +1725,27 @@ module HDLRuby::High
|
|
|
1709
1725
|
# Set the new method for the operator.
|
|
1710
1726
|
self.define_singleton_method(comp_operator(operator)) do |*args|
|
|
1711
1727
|
# puts "Top user=#{HDLRuby::High.top_user}"
|
|
1712
|
-
HDLRuby::High.top_user.
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1728
|
+
HDLRuby::High.top_user.sub(HDLRuby.uniq_name) do
|
|
1729
|
+
ruby_block.call(*args)
|
|
1730
|
+
end
|
|
1731
|
+
end
|
|
1732
|
+
end
|
|
1733
|
+
|
|
1734
|
+
# Redefinition of +operator+ when requiring the context to be passed
|
|
1735
|
+
# as argument (normally only used internally).
|
|
1736
|
+
def define_operator_with_context(operator,&ruby_block)
|
|
1737
|
+
# Ensure there is a block.
|
|
1738
|
+
ruby_block = proc {} unless block_given?
|
|
1739
|
+
# Register the operator as overloaded.
|
|
1740
|
+
@overloads ||= {}
|
|
1741
|
+
@overloads[operator] = ruby_block
|
|
1742
|
+
# Set the new method for the operator.
|
|
1743
|
+
self.define_singleton_method(comp_operator(operator)) do |*args|
|
|
1744
|
+
# puts "Top user=#{HDLRuby::High.top_user}"
|
|
1745
|
+
HDLRuby::High.top_user.sub(HDLRuby.uniq_name) do
|
|
1746
|
+
# It is assumed that the first argument of the ruby_block
|
|
1747
|
+
# is the context in which it must be executed.
|
|
1748
|
+
ruby_block.call(self,*args)
|
|
1716
1749
|
end
|
|
1717
1750
|
end
|
|
1718
1751
|
end
|
|
@@ -1945,7 +1978,8 @@ module HDLRuby::High
|
|
|
1945
1978
|
gtype)
|
|
1946
1979
|
# Adds the possible overloaded operators.
|
|
1947
1980
|
self.each_overload do |op,ruby_block|
|
|
1948
|
-
gtype.define_operator(op,&(ruby_block.curry[*args]))
|
|
1981
|
+
# gtype.define_operator(op,&(ruby_block.curry[*args]))
|
|
1982
|
+
gtype.define_operator_with_context(op,&(High.curry_with_context(*args,&ruby_block)))
|
|
1949
1983
|
end
|
|
1950
1984
|
# Returns the resulting type
|
|
1951
1985
|
return gtype
|
|
@@ -2051,10 +2085,10 @@ module HDLRuby::High
|
|
|
2051
2085
|
|
|
2052
2086
|
# Converts the type to HDLRuby::Low and set its +name+.
|
|
2053
2087
|
def to_low(name = self.name)
|
|
2054
|
-
#
|
|
2055
|
-
# *@types.map
|
|
2056
|
-
typeTupleL = HDLRuby::Low::TypeTuple.new(name,self.direction
|
|
2057
|
-
|
|
2088
|
+
# typeTupleL = HDLRuby::Low::TypeTuple.new(name,self.direction,
|
|
2089
|
+
# *@types.map do |typ| typ.to_low )
|
|
2090
|
+
typeTupleL = HDLRuby::Low::TypeTuple.new(name,self.direction)
|
|
2091
|
+
@types.each { |typ| typeTupleL.add_type(typ.to_low) }
|
|
2058
2092
|
# # For debugging: set the source high object
|
|
2059
2093
|
# typeTupleL.properties[:low2high] = self.hdr_id
|
|
2060
2094
|
# self.properties[:high2low] = typeTupleL
|
|
@@ -2116,6 +2150,7 @@ module HDLRuby::High
|
|
|
2116
2150
|
gtype = type.generate(*args)
|
|
2117
2151
|
# And add it as a local type of the system.
|
|
2118
2152
|
HDLRuby::High.top_user.add_type(gtype)
|
|
2153
|
+
gtype
|
|
2119
2154
|
end
|
|
2120
2155
|
end
|
|
2121
2156
|
else
|
|
@@ -3208,6 +3243,7 @@ module HDLRuby::High
|
|
|
3208
3243
|
# expr.to_low
|
|
3209
3244
|
# end
|
|
3210
3245
|
# )
|
|
3246
|
+
i = 0
|
|
3211
3247
|
concatL = HDLRuby::Low::Concat.new(self.type.to_low,
|
|
3212
3248
|
self.each_expression.map do |expr|
|
|
3213
3249
|
expr.to_low
|
|
@@ -3292,7 +3328,8 @@ module HDLRuby::High
|
|
|
3292
3328
|
|
|
3293
3329
|
# Converts to a new event.
|
|
3294
3330
|
def to_event
|
|
3295
|
-
return Event.new(:change,self.to_ref)
|
|
3331
|
+
# return Event.new(:change,self.to_ref)
|
|
3332
|
+
return Event.new(:anyedge,self.to_ref)
|
|
3296
3333
|
end
|
|
3297
3334
|
|
|
3298
3335
|
# Iterate over the elements.
|
|
@@ -3370,8 +3407,19 @@ module HDLRuby::High
|
|
|
3370
3407
|
def to_low
|
|
3371
3408
|
# puts "to_low with base=#{@base} @object=#{@object}"
|
|
3372
3409
|
# puts "@object.name=#{@object.name}"
|
|
3373
|
-
|
|
3410
|
+
if @base.is_a?(RefThis) &&
|
|
3411
|
+
(@object.parent != High.top_user) &&
|
|
3412
|
+
(@object.parent != High.cur_system) &&
|
|
3413
|
+
(!@object.parent.name.empty?) then
|
|
3414
|
+
# Need to have a hierachical access.
|
|
3415
|
+
# puts "Indirect access for #{self.object.name}: #{self.object.parent.name}(#{self.object.parent.class}) != #{High.cur_system.name}(#{High.top_user.class})"
|
|
3416
|
+
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
|
3417
|
+
@object.parent.to_ref.to_low,@object.name)
|
|
3418
|
+
else
|
|
3419
|
+
# Direct access is enough.
|
|
3420
|
+
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
|
3374
3421
|
@base.to_ref.to_low,@object.name)
|
|
3422
|
+
end
|
|
3375
3423
|
# # For debugging: set the source high object
|
|
3376
3424
|
# refNameL.properties[:low2high] = self.hdr_id
|
|
3377
3425
|
# self.properties[:high2low] = refNameL
|
|
@@ -3801,11 +3849,15 @@ module HDLRuby::High
|
|
|
3801
3849
|
|
|
3802
3850
|
# Hierarchical type allows access to sub references, so generate
|
|
3803
3851
|
# the corresponding methods.
|
|
3852
|
+
# For that first get the real type.
|
|
3853
|
+
type = type.def while type.is_a?(TypeDef)
|
|
3854
|
+
# Now process it if it is a structured type.
|
|
3804
3855
|
if type.struct? then
|
|
3805
3856
|
type.each_name do |name|
|
|
3857
|
+
sig = SignalI.new(name,type.get_type(name),dir)
|
|
3858
|
+
self.add_signal(sig)
|
|
3806
3859
|
self.define_singleton_method(name) do
|
|
3807
|
-
RefObject.new(self.to_ref,
|
|
3808
|
-
SignalI.new(name,type.get_type(name),dir))
|
|
3860
|
+
RefObject.new(self.to_ref,sig)
|
|
3809
3861
|
end
|
|
3810
3862
|
end
|
|
3811
3863
|
end
|
|
@@ -3838,17 +3890,41 @@ module HDLRuby::High
|
|
|
3838
3890
|
|
|
3839
3891
|
# Creates a positive edge event from the signal.
|
|
3840
3892
|
def posedge
|
|
3841
|
-
return Event.new(:posedge,self.to_ref)
|
|
3893
|
+
# return Event.new(:posedge,self.to_ref)
|
|
3894
|
+
# Is there any sub signals?
|
|
3895
|
+
if self.each_signal.any? then
|
|
3896
|
+
# Yes, make events with them instead.
|
|
3897
|
+
return self.each_signal.map { |sig| sig.posedge }
|
|
3898
|
+
else
|
|
3899
|
+
# No, create a single event.
|
|
3900
|
+
return Event.new(:posedge,self.to_ref)
|
|
3901
|
+
end
|
|
3842
3902
|
end
|
|
3843
3903
|
|
|
3844
3904
|
# Creates a negative edge event from the signal.
|
|
3845
3905
|
def negedge
|
|
3846
|
-
return Event.new(:negedge,self.to_ref)
|
|
3906
|
+
# return Event.new(:negedge,self.to_ref)
|
|
3907
|
+
# Is there any sub signals?
|
|
3908
|
+
if self.each_signal.any? then
|
|
3909
|
+
# Yes, make events with them instead.
|
|
3910
|
+
return self.each_signal.map { |sig| sig.negedge }
|
|
3911
|
+
else
|
|
3912
|
+
# No, create a single event.
|
|
3913
|
+
return Event.new(:negedge,self.to_ref)
|
|
3914
|
+
end
|
|
3847
3915
|
end
|
|
3848
3916
|
|
|
3849
3917
|
# Creates an edge event from the signal.
|
|
3850
|
-
def
|
|
3851
|
-
return Event.new(:edge,self.to_ref)
|
|
3918
|
+
def anyedge
|
|
3919
|
+
# return Event.new(:edge,self.to_ref)
|
|
3920
|
+
# Is there any sub signals?
|
|
3921
|
+
if self.each_signal.any? then
|
|
3922
|
+
# Yes, make events with them instead.
|
|
3923
|
+
return self.each_signal.map { |sig| sig.anyedge }
|
|
3924
|
+
else
|
|
3925
|
+
# No, create a single event.
|
|
3926
|
+
return Event.new(:anyedge,self.to_ref)
|
|
3927
|
+
end
|
|
3852
3928
|
end
|
|
3853
3929
|
|
|
3854
3930
|
# Converts to a new reference.
|
|
@@ -3871,6 +3947,10 @@ module HDLRuby::High
|
|
|
3871
3947
|
# return HDLRuby::Low::SignalI.new(name,self.type.to_low)
|
|
3872
3948
|
valueL = self.value ? self.value.to_low : nil
|
|
3873
3949
|
signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low,valueL)
|
|
3950
|
+
# Recurse on the sub signals if any.
|
|
3951
|
+
self.each_signal do |sig|
|
|
3952
|
+
signalIL.add_signal(sig.to_low)
|
|
3953
|
+
end
|
|
3874
3954
|
# # For debugging: set the source high object
|
|
3875
3955
|
# signalIL.properties[:low2high] = self.hdr_id
|
|
3876
3956
|
# self.properties[:high2low] = signalIL
|
|
@@ -3937,6 +4017,10 @@ module HDLRuby::High
|
|
|
3937
4017
|
# self.value.to_low)
|
|
3938
4018
|
signalCL = HDLRuby::Low::SignalC.new(name,self.type.to_low,
|
|
3939
4019
|
self.value.to_low)
|
|
4020
|
+
# Recurse on the sub signals if any.
|
|
4021
|
+
self.each_signal do |sig|
|
|
4022
|
+
signalCL.add_signal(sig.to_low)
|
|
4023
|
+
end
|
|
3940
4024
|
# # For debugging: set the source high object
|
|
3941
4025
|
# signalCL.properties[:low2high] = self.hdr_id
|
|
3942
4026
|
# self.properties[:high2low] = signalCL
|
|
@@ -4062,7 +4146,8 @@ module HDLRuby::High
|
|
|
4062
4146
|
# +ruby_block+.
|
|
4063
4147
|
#
|
|
4064
4148
|
# NOTE: the else part is defined through the helse method.
|
|
4065
|
-
def hif(condition, mode = nil, &ruby_block)
|
|
4149
|
+
# def hif(condition, mode = nil, &ruby_block)
|
|
4150
|
+
def hif(condition, mode = self.mode, &ruby_block)
|
|
4066
4151
|
# Ensure there is a block.
|
|
4067
4152
|
ruby_block = proc {} unless block_given?
|
|
4068
4153
|
# Creates the if statement.
|
|
@@ -4327,8 +4412,8 @@ module HDLRuby::High
|
|
|
4327
4412
|
# @location = caller_locations
|
|
4328
4413
|
# Sets the current behavior
|
|
4329
4414
|
@@cur_behavior = self
|
|
4330
|
-
# Add the events
|
|
4331
|
-
events.each { |event| self.add_event(event) }
|
|
4415
|
+
# Add the events (they may be hierarchical to flatten)
|
|
4416
|
+
events.flatten.each { |event| self.add_event(event) }
|
|
4332
4417
|
# Create and add the block.
|
|
4333
4418
|
self.block = High.make_block(mode,&ruby_block)
|
|
4334
4419
|
# Unset the current behavior
|
|
@@ -4982,19 +5067,21 @@ module HDLRuby::High
|
|
|
4982
5067
|
def to_value
|
|
4983
5068
|
str = self.to_s
|
|
4984
5069
|
return nil if str[0] != "_" # Bit string are prefixed by "_"
|
|
4985
|
-
# Remove the "_" not needed any longer.
|
|
4986
|
-
str = str[1..-1]
|
|
4987
5070
|
# Get and check the type
|
|
4988
|
-
type = str[0]
|
|
4989
|
-
|
|
5071
|
+
# type = str[0]
|
|
5072
|
+
type = str[1]
|
|
5073
|
+
if ["0", "1", "z", "Z", "o", "d", "h"].include?(type) then
|
|
4990
5074
|
# Default binary
|
|
4991
5075
|
type = "b"
|
|
4992
5076
|
else
|
|
4993
5077
|
# Not a default type
|
|
4994
|
-
str = str[1..-1]
|
|
5078
|
+
# str = str[1..-1]
|
|
5079
|
+
str = str[2..-1]
|
|
4995
5080
|
end
|
|
4996
|
-
return nil if str.empty?
|
|
4997
5081
|
return nil unless ["b","u","s"].include?(type)
|
|
5082
|
+
# Remove the "_"
|
|
5083
|
+
str = str.delete("_")
|
|
5084
|
+
return nil if str.empty?
|
|
4998
5085
|
# Get the width if any.
|
|
4999
5086
|
if str[0].match(/[0-9]/) then
|
|
5000
5087
|
width = str.scan(/[0-9]*/)[0]
|