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
data/lib/HDLRuby/hruby_low.rb
CHANGED
|
@@ -79,6 +79,24 @@ module HDLRuby::Low
|
|
|
79
79
|
end
|
|
80
80
|
return res
|
|
81
81
|
end
|
|
82
|
+
|
|
83
|
+
# Get an absolute reference to the object.
|
|
84
|
+
def absolute_ref
|
|
85
|
+
# Get the full hierarchy up to the object.
|
|
86
|
+
path = self.hierarchy
|
|
87
|
+
# Create the reference.
|
|
88
|
+
# return path.reduce(RefThis.new) do |ref,node|
|
|
89
|
+
return path.reverse_each.reduce(RefThis.new) do |ref,node|
|
|
90
|
+
# puts "node=#{node}"
|
|
91
|
+
# puts "name=#{node.name}" if node.respond_to?(:name)
|
|
92
|
+
if node.respond_to?(:name) then
|
|
93
|
+
typ = node.respond_to?(:type) ? node.type : void
|
|
94
|
+
RefName.new(typ,ref,node.name)
|
|
95
|
+
else
|
|
96
|
+
ref
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
end
|
|
82
100
|
end
|
|
83
101
|
|
|
84
102
|
|
|
@@ -98,7 +116,8 @@ module HDLRuby::Low
|
|
|
98
116
|
attr_reader :scope
|
|
99
117
|
|
|
100
118
|
# Creates a new system type named +name+ with +scope+.
|
|
101
|
-
def initialize(name,scope)
|
|
119
|
+
# def initialize(name,scope)
|
|
120
|
+
def initialize(name,scope = nil)
|
|
102
121
|
# Set the name as a symbol.
|
|
103
122
|
@name = name.to_sym
|
|
104
123
|
|
|
@@ -109,6 +128,13 @@ module HDLRuby::Low
|
|
|
109
128
|
@interface = [] # The interface signals in order of
|
|
110
129
|
# declaration
|
|
111
130
|
|
|
131
|
+
# self.set_scope(scope) if scope
|
|
132
|
+
# end
|
|
133
|
+
|
|
134
|
+
# # Set the scope of the systemT to +scope+.
|
|
135
|
+
# # Note: cannot override an existing scope.
|
|
136
|
+
# def set_scope(scope)
|
|
137
|
+
# raise(AnyError,"Scope already present") if @scope
|
|
112
138
|
# Check the scope
|
|
113
139
|
unless scope.is_a?(Scope)
|
|
114
140
|
raise AnyError,
|
|
@@ -313,7 +339,7 @@ module HDLRuby::Low
|
|
|
313
339
|
# Returns an enumerator if no ruby block is given.
|
|
314
340
|
def each_signal_all(&ruby_block)
|
|
315
341
|
# No ruby block? Return an enumerator.
|
|
316
|
-
return to_enum(:
|
|
342
|
+
return to_enum(:each_signal_all) unless ruby_block
|
|
317
343
|
# A ruby block? Apply it on each signal instance.
|
|
318
344
|
@inputs.each(&ruby_block)
|
|
319
345
|
@outputs.each(&ruby_block)
|
|
@@ -526,6 +552,8 @@ module HDLRuby::Low
|
|
|
526
552
|
@inners = HashName.new
|
|
527
553
|
# Initialize the system instances list.
|
|
528
554
|
@systemIs = HashName.new
|
|
555
|
+
# Initialize the programs list.
|
|
556
|
+
@programs = []
|
|
529
557
|
# Initialize the non-HDLRuby code chunks list.
|
|
530
558
|
@codes = []
|
|
531
559
|
# Initialize the connections list.
|
|
@@ -804,7 +832,40 @@ module HDLRuby::Low
|
|
|
804
832
|
# end
|
|
805
833
|
# systemI
|
|
806
834
|
# end
|
|
835
|
+
|
|
836
|
+
|
|
837
|
+
# Handling the programs.
|
|
838
|
+
|
|
839
|
+
# Adds program +prog+.
|
|
840
|
+
def add_program(prog)
|
|
841
|
+
# Check and add the program.
|
|
842
|
+
unless prog.is_a?(Program)
|
|
843
|
+
raise AnyError,
|
|
844
|
+
"Invalid class for a program: #{prog.class}"
|
|
845
|
+
end
|
|
846
|
+
# Set the parent of the program.
|
|
847
|
+
program.parent = self
|
|
848
|
+
# Add the program.
|
|
849
|
+
@programs << program
|
|
850
|
+
program
|
|
851
|
+
end
|
|
852
|
+
|
|
853
|
+
# Iterates over the programs.
|
|
807
854
|
#
|
|
855
|
+
# Returns an enumerator if no ruby block is given.
|
|
856
|
+
def each_program(&ruby_block)
|
|
857
|
+
# puts "each_program from scope=#{self}"
|
|
858
|
+
# No ruby block? Return an enumerator.
|
|
859
|
+
return to_enum(:each_program) unless ruby_block
|
|
860
|
+
# A ruby block? Apply it on each program.
|
|
861
|
+
@programs.each(&ruby_block)
|
|
862
|
+
end
|
|
863
|
+
|
|
864
|
+
# Tells if there is any program.
|
|
865
|
+
def has_program?
|
|
866
|
+
return !@programs.empty?
|
|
867
|
+
end
|
|
868
|
+
|
|
808
869
|
# Handling the non-HDLRuby code chunks.
|
|
809
870
|
|
|
810
871
|
# Adds code chunk +code+.
|
|
@@ -832,7 +893,7 @@ module HDLRuby::Low
|
|
|
832
893
|
# puts "each_code from scope=#{self}"
|
|
833
894
|
# No ruby block? Return an enumerator.
|
|
834
895
|
return to_enum(:each_code) unless ruby_block
|
|
835
|
-
# A ruby block? Apply it on each
|
|
896
|
+
# A ruby block? Apply it on each code.
|
|
836
897
|
@codes.each(&ruby_block)
|
|
837
898
|
end
|
|
838
899
|
|
|
@@ -2936,6 +2997,69 @@ module HDLRuby::Low
|
|
|
2936
2997
|
end
|
|
2937
2998
|
|
|
2938
2999
|
|
|
3000
|
+
##
|
|
3001
|
+
# Describes a program.
|
|
3002
|
+
class Program
|
|
3003
|
+
|
|
3004
|
+
include Hparent
|
|
3005
|
+
|
|
3006
|
+
attr_reader :language, :function
|
|
3007
|
+
|
|
3008
|
+
# Creates a new program in language +lang+ with start function
|
|
3009
|
+
# named +func+ accessed expressions, events and code files given in
|
|
3010
|
+
# +args+.
|
|
3011
|
+
def initialize(lang,func,*args)
|
|
3012
|
+
# Sets the language.
|
|
3013
|
+
@language = lang.to_sym
|
|
3014
|
+
# Sets the start function.
|
|
3015
|
+
@function = func.to_s
|
|
3016
|
+
# Process the expressions and code files arguments.
|
|
3017
|
+
@exprs = []
|
|
3018
|
+
@events = []
|
|
3019
|
+
@codes = []
|
|
3020
|
+
args.each do |arg|
|
|
3021
|
+
if arg.is_a?(String) then
|
|
3022
|
+
@codes << arg
|
|
3023
|
+
elsif arg.is_a?(Event) then
|
|
3024
|
+
@events << arg
|
|
3025
|
+
else
|
|
3026
|
+
@exprs << arg.to_expr
|
|
3027
|
+
end
|
|
3028
|
+
end
|
|
3029
|
+
end
|
|
3030
|
+
|
|
3031
|
+
# Iterates over each accessed expression.
|
|
3032
|
+
#
|
|
3033
|
+
# Returns an enumerator if no ruby block is given.
|
|
3034
|
+
def each_expression(&ruby_block)
|
|
3035
|
+
# No block? Return an enumerator.
|
|
3036
|
+
return to_enum(:each_expression) unless ruby_block
|
|
3037
|
+
# A block is given, apply it.
|
|
3038
|
+
@exprs.each(&ruby_block)
|
|
3039
|
+
end
|
|
3040
|
+
|
|
3041
|
+
# Iterates over each accessed event.
|
|
3042
|
+
#
|
|
3043
|
+
# Returns an enumerator if no ruby block is given.
|
|
3044
|
+
def each_event(&ruby_block)
|
|
3045
|
+
# No block? Return an enumerator.
|
|
3046
|
+
return to_enum(:each_event) unless ruby_block
|
|
3047
|
+
# A block is given, apply it.
|
|
3048
|
+
@events.each(&ruby_block)
|
|
3049
|
+
end
|
|
3050
|
+
|
|
3051
|
+
# Iterates over each code files.
|
|
3052
|
+
#
|
|
3053
|
+
# Returns an enumerator if no ruby block is given.
|
|
3054
|
+
def each_code(&ruby_block)
|
|
3055
|
+
# No block? Return an enumerator.
|
|
3056
|
+
return to_enum(:each_code) unless ruby_block
|
|
3057
|
+
# A block is given, apply it.
|
|
3058
|
+
@codes.each(&ruby_block)
|
|
3059
|
+
end
|
|
3060
|
+
end
|
|
3061
|
+
|
|
3062
|
+
|
|
2939
3063
|
##
|
|
2940
3064
|
# Decribes a set of non-HDLRuby code chunks.
|
|
2941
3065
|
class Code
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
require 'HDLRuby'
|
|
2
|
+
require 'HDLRuby/hruby_low_with_bool'
|
|
3
|
+
require 'HDLRuby/hruby_low_without_namespace'
|
|
4
|
+
require 'HDLRuby/hruby_low_with_var'
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module HDLRuby::Low
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
##
|
|
11
|
+
# Converts a HDLRuby::Low description to descriptions of software programs.
|
|
12
|
+
#
|
|
13
|
+
########################################################################
|
|
14
|
+
|
|
15
|
+
## Provides tools for extracting software from HDLRuby description.
|
|
16
|
+
module Low2Programs
|
|
17
|
+
|
|
18
|
+
class SystemT
|
|
19
|
+
## Extends the SystemT class with extraction of software.
|
|
20
|
+
|
|
21
|
+
# Extract the information about the software in the system and put it
|
|
22
|
+
# into +target+ directory.
|
|
23
|
+
def extract_programs(target)
|
|
24
|
+
# Gather the programs descriptions.
|
|
25
|
+
programs = self.scope.each_scope_deep.map do |scope|
|
|
26
|
+
scope.each_program.to_a
|
|
27
|
+
end
|
|
28
|
+
programs.flatten!
|
|
29
|
+
# Sort the programs by language.
|
|
30
|
+
lang2prog = Hash.new([])
|
|
31
|
+
programs.each { |prog| lang2prog[prog.language] << prog }
|
|
32
|
+
# Copy the programs in the corresponding subdirectories.
|
|
33
|
+
lang2prog.each do |lang,progs|
|
|
34
|
+
dir = target + "/" + lang
|
|
35
|
+
Dir.mkdir(dir)
|
|
36
|
+
progs.each do |prog|
|
|
37
|
+
prog.each_code { |code| FileUtils.cp(code,dir) }
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class Scope
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
@@ -233,6 +233,7 @@ module HDLRuby::Low
|
|
|
233
233
|
if self.ref.is_a?(RefName) then
|
|
234
234
|
obj = self.ref.resolve
|
|
235
235
|
# puts "obj=#{obj}"
|
|
236
|
+
return obj if obj.name == self.name
|
|
236
237
|
# Look into the object for the name.
|
|
237
238
|
return obj.get_by_name(self.name)
|
|
238
239
|
else
|
|
@@ -242,9 +243,9 @@ module HDLRuby::Low
|
|
|
242
243
|
while parent
|
|
243
244
|
# puts "parent=#{parent}"
|
|
244
245
|
if parent.respond_to?(:get_by_name) then
|
|
245
|
-
# puts "get_by_name"
|
|
246
|
+
# puts "Going get_by_name with name=#{self.name}"
|
|
246
247
|
found = parent.get_by_name(self.name)
|
|
247
|
-
# puts "found" if found
|
|
248
|
+
# puts "found=#{found}" if found
|
|
248
249
|
return found if found
|
|
249
250
|
end
|
|
250
251
|
parent = parent.parent
|
|
@@ -122,10 +122,17 @@ module HDLRuby::Low
|
|
|
122
122
|
# Extract the connections of the sub scopes.
|
|
123
123
|
cnxs = self.each_scope.map(&:extract_connections!).flatten
|
|
124
124
|
# Reinsert them to self.
|
|
125
|
-
cnxs.each { |
|
|
125
|
+
cnxs.each { |cnx| self.add_connection(cnx) }
|
|
126
|
+
|
|
127
|
+
# The fix the RefName using sub scopes since their target have
|
|
128
|
+
# been deplaced to current scope and renamed.
|
|
129
|
+
self_scopes = self.each_scope.to_a
|
|
130
|
+
self.each_behavior { |beh| beh.fix_scope_refnames!(self_scopes) }
|
|
131
|
+
self.each_connection { |cnx| cnx.fix_scope_refnames!(self_scopes) }
|
|
126
132
|
|
|
127
133
|
# Now can delete the sub scopes since they are empty.
|
|
128
|
-
self.each_scope.to_a.each { |scope| self.delete_scope!(scope) }
|
|
134
|
+
# self.each_scope.to_a.each { |scope| self.delete_scope!(scope) }
|
|
135
|
+
self_scopes.each { |scope| self.delete_scope!(scope) }
|
|
129
136
|
end
|
|
130
137
|
|
|
131
138
|
# Extract the behaviors from the scope and returns them into an array.
|
|
@@ -219,9 +226,10 @@ module HDLRuby::Low
|
|
|
219
226
|
# in the internals.
|
|
220
227
|
def replace_names_subs!(former,nname)
|
|
221
228
|
# puts "replace_names_subs! for #{self} with former=#{former} and nname=#{nname}"
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
229
|
+
# No need?
|
|
230
|
+
# self.each_type do |type|
|
|
231
|
+
# type.replace_names!(former,nname)
|
|
232
|
+
# end
|
|
225
233
|
self.each_systemT do |systemT|
|
|
226
234
|
systemT.replace_names!(former,nname)
|
|
227
235
|
end
|
|
@@ -460,6 +468,13 @@ module HDLRuby::Low
|
|
|
460
468
|
# Recurse on the block.
|
|
461
469
|
self.block.replace_names!(former,nname)
|
|
462
470
|
end
|
|
471
|
+
|
|
472
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
473
|
+
# are marked to be deleted).
|
|
474
|
+
def fix_scope_refnames!(scopes)
|
|
475
|
+
self.block.fix_scope_refnames!(scopes)
|
|
476
|
+
return self
|
|
477
|
+
end
|
|
463
478
|
end
|
|
464
479
|
|
|
465
480
|
|
|
@@ -498,6 +513,34 @@ module HDLRuby::Low
|
|
|
498
513
|
node.break_types!(types)
|
|
499
514
|
end
|
|
500
515
|
end
|
|
516
|
+
|
|
517
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
518
|
+
# are marked to be deleted).
|
|
519
|
+
def fix_scope_refnames!(scopes)
|
|
520
|
+
# By default, does nothing.
|
|
521
|
+
return self
|
|
522
|
+
end
|
|
523
|
+
end
|
|
524
|
+
|
|
525
|
+
|
|
526
|
+
class Transmit
|
|
527
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
528
|
+
# are marked to be deleted).
|
|
529
|
+
def fix_scope_refnames!(scopes)
|
|
530
|
+
self.set_left!(self.left.fix_scope_refnames!(scopes))
|
|
531
|
+
self.set_right!(self.right.fix_scope_refnames!(scopes))
|
|
532
|
+
return self
|
|
533
|
+
end
|
|
534
|
+
end
|
|
535
|
+
|
|
536
|
+
class Connection
|
|
537
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
538
|
+
# are marked to be deleted).
|
|
539
|
+
def fix_scope_refnames!(scopes)
|
|
540
|
+
self.set_left!(self.left.fix_scope_refnames!(scopes))
|
|
541
|
+
self.set_right!(self.right.fix_scope_refnames!(scopes))
|
|
542
|
+
return self
|
|
543
|
+
end
|
|
501
544
|
end
|
|
502
545
|
|
|
503
546
|
|
|
@@ -527,6 +570,16 @@ module HDLRuby::Low
|
|
|
527
570
|
end
|
|
528
571
|
end
|
|
529
572
|
end
|
|
573
|
+
|
|
574
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
575
|
+
# are marked to be deleted).
|
|
576
|
+
def fix_scope_refnames!(scopes)
|
|
577
|
+
# By default: recurse.
|
|
578
|
+
self.map_nodes! do |node|
|
|
579
|
+
node.fix_scope_refnames!(scopes)
|
|
580
|
+
end
|
|
581
|
+
return self
|
|
582
|
+
end
|
|
530
583
|
end
|
|
531
584
|
|
|
532
585
|
|
|
@@ -578,6 +631,24 @@ module HDLRuby::Low
|
|
|
578
631
|
# Recurse on the no if any.
|
|
579
632
|
self.no.replace_names!(former,nname) if self.no
|
|
580
633
|
end
|
|
634
|
+
|
|
635
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
636
|
+
# are marked to be deleted).
|
|
637
|
+
def fix_scope_refnames!(scopes)
|
|
638
|
+
# Fix the condition.
|
|
639
|
+
self.set_condition!(self.condition.fix_scope_refnames!(scopes))
|
|
640
|
+
# Recurse on the yes.
|
|
641
|
+
self.yes.fix_scope_refnames!(scopes)
|
|
642
|
+
# Recurse on the alternate ifs.
|
|
643
|
+
self.map_noifs! do |cond,stmnt|
|
|
644
|
+
cond = cond.fix_scope_refnames!(scopes)
|
|
645
|
+
stmnt = stmnt.fix_scope_refnames!(scopes)
|
|
646
|
+
[cond,stmnt]
|
|
647
|
+
end
|
|
648
|
+
# Recruse on the no if any.
|
|
649
|
+
self.no.fix_scope_refnames!(scopes) if self.no
|
|
650
|
+
return self
|
|
651
|
+
end
|
|
581
652
|
end
|
|
582
653
|
|
|
583
654
|
|
|
@@ -618,6 +689,16 @@ module HDLRuby::Low
|
|
|
618
689
|
end
|
|
619
690
|
end
|
|
620
691
|
end
|
|
692
|
+
|
|
693
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
694
|
+
# are marked to be deleted).
|
|
695
|
+
def fix_scope_refnames!(scopes)
|
|
696
|
+
# Fix the match.
|
|
697
|
+
self.set_match!(self.match.fix_scope_refnames!(scopes))
|
|
698
|
+
# Recurse on the statement.
|
|
699
|
+
self.statement.fix_scope_refnames!(scopes)
|
|
700
|
+
return self
|
|
701
|
+
end
|
|
621
702
|
end
|
|
622
703
|
|
|
623
704
|
|
|
@@ -655,6 +736,18 @@ module HDLRuby::Low
|
|
|
655
736
|
# Recurse on the default.
|
|
656
737
|
self.default.replace_names!(former,nname) if self.default
|
|
657
738
|
end
|
|
739
|
+
|
|
740
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
741
|
+
# are marked to be deleted).
|
|
742
|
+
def fix_scope_refnames!(scopes)
|
|
743
|
+
# Fix the value.
|
|
744
|
+
self.set_value!(self.value.fix_scope_refnames!(scopes))
|
|
745
|
+
# Recurse on the whens.
|
|
746
|
+
self.each_when {|w| w.fix_scope_refnames!(scopes) }
|
|
747
|
+
# Recurse on the default.
|
|
748
|
+
self.default.fix_scope_refnames!(scopes) if self.default
|
|
749
|
+
return self
|
|
750
|
+
end
|
|
658
751
|
end
|
|
659
752
|
|
|
660
753
|
|
|
@@ -681,6 +774,14 @@ module HDLRuby::Low
|
|
|
681
774
|
# Recurse on the statement.
|
|
682
775
|
self.statement.replace_names!(former,nname)
|
|
683
776
|
end
|
|
777
|
+
|
|
778
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
779
|
+
# are marked to be deleted).
|
|
780
|
+
def fix_scope_refnames!(scopes)
|
|
781
|
+
# Recurse on the statement.
|
|
782
|
+
self.statement.fix_scope_refnames!(scopes)
|
|
783
|
+
return self
|
|
784
|
+
end
|
|
684
785
|
end
|
|
685
786
|
|
|
686
787
|
|
|
@@ -738,6 +839,33 @@ module HDLRuby::Low
|
|
|
738
839
|
# Recurse on the sub scopes and behaviors.
|
|
739
840
|
replace_names_subs!(former,nname)
|
|
740
841
|
end
|
|
842
|
+
|
|
843
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
844
|
+
# are marked to be deleted).
|
|
845
|
+
def fix_scope_refnames!(scopes)
|
|
846
|
+
self.each_statement {|stmnt| stmnt.fix_scope_refnames!(scopes) }
|
|
847
|
+
return self
|
|
848
|
+
end
|
|
849
|
+
end
|
|
850
|
+
|
|
851
|
+
|
|
852
|
+
class RefName
|
|
853
|
+
include ForceName
|
|
854
|
+
|
|
855
|
+
# Fix the references names using scopes given in +scopes + list (they
|
|
856
|
+
# are marked to be deleted).
|
|
857
|
+
def fix_scope_refnames!(scopes)
|
|
858
|
+
return self unless self.ref.is_a?(RefName)
|
|
859
|
+
# puts "fix_scope_refnames! with self.name=#{name} and self.ref=#{self.ref}"
|
|
860
|
+
# Recurse on the ref.
|
|
861
|
+
self.set_ref!(self.ref.fix_scope_refnames!(scopes))
|
|
862
|
+
# Rename and curt the subref if referening to one of the scopes.
|
|
863
|
+
if scopes.find {|scope| scope.name == self.ref.name } then
|
|
864
|
+
self.ref.extend_name!(self)
|
|
865
|
+
self.set_ref!(RefThis.new)
|
|
866
|
+
end
|
|
867
|
+
return self
|
|
868
|
+
end
|
|
741
869
|
end
|
|
742
870
|
|
|
743
871
|
end
|
|
@@ -243,7 +243,6 @@ module HDLRuby::Low
|
|
|
243
243
|
# Flatten a reference to a list of reference to leaf signals
|
|
244
244
|
# from signal +sig+ and add to result to +subrefs+
|
|
245
245
|
def flatten_to(sig,subrefs)
|
|
246
|
-
# puts "flatten_to with sig name=#{sig.name}"
|
|
247
246
|
# Shall we decompose 2d vectors, and is the current signal
|
|
248
247
|
# for one of them?
|
|
249
248
|
if SystemT.decompose_vec2d? and sig.type.is_a?(TypeVector) and
|
|
@@ -294,6 +293,7 @@ module HDLRuby::Low
|
|
|
294
293
|
# Decompose the hierarchical signals in the statements.
|
|
295
294
|
def signal2subs!
|
|
296
295
|
# puts "signal2subs! for RefName: #{self.name}"
|
|
296
|
+
return self if self.type == void # Not a singal anyway.
|
|
297
297
|
# Decompose it to a list of reference to each leaf sub signal.
|
|
298
298
|
subrefs = []
|
|
299
299
|
self.flatten_to(self.resolve,subrefs)
|
data/lib/HDLRuby/hruby_rcsim.rb
CHANGED
|
@@ -1000,7 +1000,30 @@ module HDLRuby::High
|
|
|
1000
1000
|
|
|
1001
1001
|
class RefName
|
|
1002
1002
|
## Extends the RefName class for hybrid Ruby-C simulation.
|
|
1003
|
-
#
|
|
1003
|
+
# Converted to RefRange.
|
|
1004
|
+
|
|
1005
|
+
# Generate the C description of the reference range (not ref name!).
|
|
1006
|
+
def to_rcsim
|
|
1007
|
+
# Convert the base to a bit vector.
|
|
1008
|
+
type_base = Bit[self.ref.type.width]
|
|
1009
|
+
# self.ref.parent = nil
|
|
1010
|
+
# bit_base = Cast.new(type_base,self.ref)
|
|
1011
|
+
bit_base = RCSim.rcsim_make_cast(type_base.to_rcsim,self.ref.to_rcsim)
|
|
1012
|
+
# Compute range in bits of the field.
|
|
1013
|
+
last = 0
|
|
1014
|
+
self.ref.type.each.detect do |name,typ|
|
|
1015
|
+
last += typ.width
|
|
1016
|
+
name == self.name
|
|
1017
|
+
end
|
|
1018
|
+
first = last-self.type.width
|
|
1019
|
+
last -= 1
|
|
1020
|
+
# puts "name=#{self.name} first=#{first} last=#{last}"
|
|
1021
|
+
type_int = Bit[type_base.width.width]
|
|
1022
|
+
return RCSim.rcsim_make_refRange(self.type.to_rcsim,
|
|
1023
|
+
Value.new(type_int,last).to_rcsim,
|
|
1024
|
+
Value.new(type_int,first).to_rcsim,
|
|
1025
|
+
bit_base)
|
|
1026
|
+
end
|
|
1004
1027
|
end
|
|
1005
1028
|
|
|
1006
1029
|
|
|
@@ -23,7 +23,8 @@ module HDLRuby
|
|
|
23
23
|
Low::TypeSigned, Low::TypeUnsigned, Low::TypeFloat,
|
|
24
24
|
Low::TypeTuple, Low::TypeStruct,
|
|
25
25
|
Low::Behavior, Low::TimeBehavior,
|
|
26
|
-
Low::Event, Low::Block, Low::TimeBlock,
|
|
26
|
+
Low::Event, Low::Block, Low::TimeBlock,
|
|
27
|
+
Low::Program, Low::Code,
|
|
27
28
|
Low::SignalI, Low::SignalC,
|
|
28
29
|
Low::SystemI, Low::Connection,
|
|
29
30
|
Low::Transmit, Low::If, Low::Case, Low::When, Low::Cast,
|