HDLRuby 2.11.10 → 2.11.12
Sign up to get free protection for your applications and to get access to all the features.
- 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
data/lib/HDLRuby/hruby_rcsim.rb
CHANGED
@@ -17,7 +17,6 @@ module HDLRuby::High
|
|
17
17
|
|
18
18
|
## Gives the width of an int in the current computer.
|
19
19
|
def self.int_width
|
20
|
-
# puts "int_width=#{[1.to_i].pack("i").size*8}"
|
21
20
|
return [1.to_i].pack("i").size*8
|
22
21
|
end
|
23
22
|
|
@@ -105,30 +104,18 @@ module HDLRuby::High
|
|
105
104
|
RCSim.rcsim_set_owner(@rcsystemT,rcowner)
|
106
105
|
end
|
107
106
|
# Create and add the interface signals.
|
108
|
-
# self.each_input do |sig|
|
109
|
-
# rcsig = sig.to_rcsim(@rcsystemT)
|
110
|
-
# RCSim.rcsim_add_systemT_input(@rcsystemT,rcsig)
|
111
|
-
# end
|
112
107
|
if self.each_input.any? then
|
113
108
|
RCSim.rcsim_add_systemT_inputs(@rcsystemT,
|
114
109
|
self.each_input.map do |sig|
|
115
110
|
sig.to_rcsim(@rcsystemT)
|
116
111
|
end)
|
117
112
|
end
|
118
|
-
# self.each_output do |sig|
|
119
|
-
# rcsig = sig.to_rcsim(@rcsystemT)
|
120
|
-
# RCSim.rcsim_add_systemT_output(@rcsystemT,rcsig)
|
121
|
-
# end
|
122
113
|
if self.each_output.any? then
|
123
114
|
RCSim.rcsim_add_systemT_outputs(@rcsystemT,
|
124
115
|
self.each_output.map do |sig|
|
125
116
|
sig.to_rcsim(@rcsystemT)
|
126
117
|
end)
|
127
118
|
end
|
128
|
-
# self.each_inout do |sig|
|
129
|
-
# rcsig = sig.to_rcsim(@rcsystemT)
|
130
|
-
# RCSim.rcsim_add_systemT_inout(@rcsystemT,rcsig)
|
131
|
-
# end
|
132
119
|
if self.each_inout.any? then
|
133
120
|
RCSim.rcsim_add_systemT_inouts(@rcsystemT,
|
134
121
|
self.each_inout.map do |sig|
|
@@ -174,10 +161,6 @@ module HDLRuby::High
|
|
174
161
|
subowner = self.parent.is_a?(SystemT) ? rcowner : @rcscope
|
175
162
|
|
176
163
|
# Create and add the inner signals.
|
177
|
-
# self.each_inner do |sig|
|
178
|
-
# rcsig = sig.to_rcsim(@rcscope)
|
179
|
-
# RCSim.rcsim_add_scope_inner(@rcscope,rcsig)
|
180
|
-
# end
|
181
164
|
if self.each_inner.any? then
|
182
165
|
RCSim.rcsim_add_scope_inners(@rcscope,self.each_inner.map do|sig|
|
183
166
|
# sig.to_rcsim(@rcscope)
|
@@ -186,10 +169,6 @@ module HDLRuby::High
|
|
186
169
|
end
|
187
170
|
|
188
171
|
# Create and add the system instances.
|
189
|
-
# self.each_systemI do |sys|
|
190
|
-
# rcsys = sys.to_rcsim(@rcscope)
|
191
|
-
# RCSim.rcsim_add_scope_systemI(@rcscope,rcsys)
|
192
|
-
# end
|
193
172
|
if self.each_systemI.any? then
|
194
173
|
RCSim.rcsim_add_scope_systemIs(@rcscope,
|
195
174
|
self.each_systemI.map do |sys|
|
@@ -198,32 +177,7 @@ module HDLRuby::High
|
|
198
177
|
end)
|
199
178
|
end
|
200
179
|
|
201
|
-
# Create and add the behaviors.
|
202
|
-
if self.each_behavior.any? then
|
203
|
-
RCSim.rcsim_add_scope_behaviors(@rcscope,
|
204
|
-
self.each_behavior.map do |beh|
|
205
|
-
# beh.to_rcsim(@rcscope)
|
206
|
-
beh.to_rcsim(subowner)
|
207
|
-
end)
|
208
|
-
end
|
209
|
-
|
210
|
-
# Create and add the connections.
|
211
|
-
if self.each_connection.any? then
|
212
|
-
RCSim.rcsim_add_scope_behaviors(@rcscope,
|
213
|
-
self.each_connection.map do |cxt|
|
214
|
-
# cxt.to_rcsim(@rcscope)
|
215
|
-
cxt.to_rcsim(subowner)
|
216
|
-
end)
|
217
|
-
end
|
218
|
-
|
219
|
-
# Create and add the codes.
|
220
|
-
# TODO!!
|
221
|
-
|
222
180
|
# Create and add the sub scopes.
|
223
|
-
# self.each_scope do |sub|
|
224
|
-
# rcsub = sub.to_rcsim(@rcscope)
|
225
|
-
# RCSim.rcsim_add_scope_scope(@rcscope,rcsub)
|
226
|
-
# end
|
227
181
|
if self.each_scope.any? then
|
228
182
|
RCSim.rcsim_add_scope_scopes(@rcscope,self.each_scope.map do|sub|
|
229
183
|
# sub.to_rcsim(@rcscope)
|
@@ -231,6 +185,32 @@ module HDLRuby::High
|
|
231
185
|
end)
|
232
186
|
end
|
233
187
|
|
188
|
+
# # Create and add the behaviors.
|
189
|
+
# if self.each_behavior.any? then
|
190
|
+
# RCSim.rcsim_add_scope_behaviors(@rcscope,
|
191
|
+
# self.each_behavior.map do |beh|
|
192
|
+
# # beh.to_rcsim(@rcscope)
|
193
|
+
# beh.to_rcsim(subowner)
|
194
|
+
# end)
|
195
|
+
# end
|
196
|
+
|
197
|
+
# # Create and add the connections.
|
198
|
+
# if self.each_connection.any? then
|
199
|
+
# RCSim.rcsim_add_scope_behaviors(@rcscope,
|
200
|
+
# self.each_connection.map do |cxt|
|
201
|
+
# # cxt.to_rcsim(@rcscope)
|
202
|
+
# cxt.to_rcsim(subowner)
|
203
|
+
# end)
|
204
|
+
# end
|
205
|
+
rcbehs = self.each_behavior.map {|beh| beh.to_rcsim(subowner)} +
|
206
|
+
self.each_connection.map {|cxt| cxt.to_rcsim(subowner) }
|
207
|
+
if rcbehs.any? then
|
208
|
+
RCSim.rcsim_add_scope_behaviors(@rcscope,rcbehs)
|
209
|
+
end
|
210
|
+
|
211
|
+
# Create and add the codes.
|
212
|
+
# TODO!!
|
213
|
+
|
234
214
|
return @rcscope
|
235
215
|
end
|
236
216
|
end
|
@@ -317,6 +297,20 @@ module HDLRuby::High
|
|
317
297
|
|
318
298
|
attr_reader :rcbehavior
|
319
299
|
|
300
|
+
# Add sub leaf events from +sig+ of +type+.
|
301
|
+
def add_sub_events(type,sig)
|
302
|
+
if sig.each_signal.any? then
|
303
|
+
# The event is hierarchical, recurse.
|
304
|
+
sig.each_signal do |sub|
|
305
|
+
self.add_sub_events(type,sub)
|
306
|
+
end
|
307
|
+
else
|
308
|
+
# Te event is not hierarchical, add it.
|
309
|
+
ref = RefObject.new(this,sig)
|
310
|
+
self.add_event(Event.new(type,ref))
|
311
|
+
end
|
312
|
+
end
|
313
|
+
|
320
314
|
# Generate the C description of the behavior comming from object
|
321
315
|
# whose C description is +rcowner+
|
322
316
|
def to_rcsim(rcowner)
|
@@ -345,6 +339,16 @@ module HDLRuby::High
|
|
345
339
|
events = refs.map {|ref| Event.new(:anyedge,ref.clone) }
|
346
340
|
# Add them to the behavior for further processing.
|
347
341
|
events.each {|event| self.add_event(event) }
|
342
|
+
else
|
343
|
+
# Maybe there are event on hierachical signals.
|
344
|
+
events.each do |event|
|
345
|
+
if event.ref.object.each_signal.any? then
|
346
|
+
# This is a hierarchical event, remove it.
|
347
|
+
self.delete_event!(event)
|
348
|
+
# And replace it by event of the subs of the signal.
|
349
|
+
self.add_sub_events(event.type,event.ref)
|
350
|
+
end
|
351
|
+
end
|
348
352
|
end
|
349
353
|
|
350
354
|
# Create the behavior C object.
|
@@ -355,13 +359,9 @@ module HDLRuby::High
|
|
355
359
|
RCSim.rcsim_set_owner(@rcbehavior,rcowner)
|
356
360
|
|
357
361
|
# Create and add the events.
|
358
|
-
# self.each_event do |ev|
|
359
|
-
# RCSim.rcsim_add_behavior_event(@rcbehavior,ev.to_rcsim)
|
360
|
-
# end
|
361
362
|
if self.each_event.any? then
|
362
363
|
RCSim.rcsim_add_behavior_events(@rcbehavior,
|
363
364
|
self.each_event.map do |ev|
|
364
|
-
# puts "adding event: #{ev.ref.object.name}(#{ev.type})"
|
365
365
|
ev.to_rcsim(@rcbehavior)
|
366
366
|
end)
|
367
367
|
end
|
@@ -420,6 +420,12 @@ module HDLRuby::High
|
|
420
420
|
# Set the owner.
|
421
421
|
RCSim.rcsim_set_owner(@rcsignalI,rcowner)
|
422
422
|
|
423
|
+
# Create and add the sub signals if any.
|
424
|
+
RCSim.rcsim_add_signal_signals(@rcsignalI,
|
425
|
+
self.each_signal.each.map do |sig|
|
426
|
+
sig.to_rcsim(@rcsignalI)
|
427
|
+
end)
|
428
|
+
|
423
429
|
# Set the initial value if any.
|
424
430
|
if self.value then
|
425
431
|
RCSim.rcsim_set_signal_value(@rcsignalI,self.value.to_rcsim)
|
@@ -475,10 +481,6 @@ module HDLRuby::High
|
|
475
481
|
RCSim.rcsim_set_owner(@rcsystemI,rcowner)
|
476
482
|
|
477
483
|
# Add the alternate system types.
|
478
|
-
# self.each_systemT do |systemT|
|
479
|
-
# rcsys = systemT.to_rcsim(@rcsystemI)
|
480
|
-
# RCSim.rcsim_add_systemI_systemT(@rcsystemI,rcsys)
|
481
|
-
# end
|
482
484
|
if self.each_systemI.any? then
|
483
485
|
RCSim.rcsim_add_systemI_systemTs(@rcsystemI,
|
484
486
|
self.each_systemT.select do|sys|
|
@@ -542,9 +544,6 @@ module HDLRuby::High
|
|
542
544
|
@rcstatement = RCSim.rcsim_make_print()
|
543
545
|
|
544
546
|
# Adds the arguments.
|
545
|
-
# self.each_arg do |arg|
|
546
|
-
# RCSim.rcsim_add_print_arg(@rcstatement,arg.to_rcsim)
|
547
|
-
# end
|
548
547
|
if self.each_arg.any? then
|
549
548
|
RCSim.rcsim_add_print_args(@rcstatement,
|
550
549
|
self.each_arg.map(&:to_rcsim))
|
@@ -587,9 +586,6 @@ module HDLRuby::High
|
|
587
586
|
self.no ? self.no.to_rcsim : nil)
|
588
587
|
|
589
588
|
# Add the alternate ifs if any.
|
590
|
-
# self.each_noif do |cond,stmnt|
|
591
|
-
# RCSim.rcsim_add_hif_noif(@rcstatement,cond.to_rcsim,stmnt.to_rcsim)
|
592
|
-
# end
|
593
589
|
rcsim_conds = self.each_noif.map {|cond,stmnt| cond.to_rcsim }
|
594
590
|
rcsim_stmnts = self.each_noif.map {|cond,stmnt| stmnt.to_rcsim }
|
595
591
|
if rcsim_conds.any? then
|
@@ -617,10 +613,6 @@ module HDLRuby::High
|
|
617
613
|
self.default ? self.default.to_rcsim : nil)
|
618
614
|
|
619
615
|
# Add the hardware whens.
|
620
|
-
# self.each_when do |wh|
|
621
|
-
# RCSim.rcsim_add_hcase_when(@rcstatement,
|
622
|
-
# wh.match.to_rcsim,wh.statement.to_rcsim)
|
623
|
-
# end
|
624
616
|
rcsim_matches = self.each_when.map {|wh| wh.match.to_rcsim }
|
625
617
|
rcsim_stmnts = self.each_when.map {|wh| wh.statement.to_rcsim }
|
626
618
|
if rcsim_matches.any? then
|
@@ -690,9 +682,6 @@ module HDLRuby::High
|
|
690
682
|
end
|
691
683
|
|
692
684
|
# Add the inner signals.
|
693
|
-
# self.each_inner do |inner|
|
694
|
-
# RCSim.rcsim_add_block_inner(@rcstatement,inner.to_rcsim(@rcstatement))
|
695
|
-
# end
|
696
685
|
if self.each_inner.any? then
|
697
686
|
RCSim.rcsim_add_block_inners(@rcstatement,
|
698
687
|
self.each_inner.map do |sig|
|
@@ -701,9 +690,6 @@ module HDLRuby::High
|
|
701
690
|
end
|
702
691
|
|
703
692
|
# Add the statements.
|
704
|
-
# self.each_statement do |stmnt|
|
705
|
-
# RCSim.rcsim_add_block_statement(@rcstatement,stmnt.to_rcsim)
|
706
|
-
# end
|
707
693
|
if self.each_statement.any? then
|
708
694
|
RCSim.rcsim_add_block_statements(@rcstatement,
|
709
695
|
self.each_statement.map do |stmnt|
|
@@ -730,6 +716,20 @@ module HDLRuby::High
|
|
730
716
|
class Connection
|
731
717
|
attr_reader :rcbehavior
|
732
718
|
|
719
|
+
# Add recursively any event to +rcevs+ for activativing the
|
720
|
+
# connection from signal +sig+ attached to +rcbehavior+
|
721
|
+
def self.add_rcevents(sig,rcevs,rcbehavior)
|
722
|
+
# Recurse on sub signals if any.
|
723
|
+
sig.each_signal do |sub|
|
724
|
+
Connection.add_rcevents(sub,rcevs,rcbehavior)
|
725
|
+
end
|
726
|
+
# Apply on the current node.
|
727
|
+
rcsig = sig.is_a?(SignalI) ? sig.rcsignalI : sig.rcsignalC
|
728
|
+
ev = RCSim.rcsim_make_event(:anyedge,rcsig)
|
729
|
+
RCSim.rcsim_set_owner(ev,rcbehavior)
|
730
|
+
rcevs << ev
|
731
|
+
end
|
732
|
+
|
733
733
|
# Generate the C description of the connection.
|
734
734
|
# +rcowner+ is a link to the C description of the owner scope.
|
735
735
|
def to_rcsim(rcowner)
|
@@ -744,9 +744,10 @@ module HDLRuby::High
|
|
744
744
|
rcevs = []
|
745
745
|
self.right.each_node_deep do |node|
|
746
746
|
if node.is_a?(RefObject) && !node.parent.is_a?(RefObject) then
|
747
|
-
|
748
|
-
RCSim.
|
749
|
-
|
747
|
+
Connection.add_rcevents(node.object,rcevs,@rcbehavior)
|
748
|
+
# ev = RCSim.rcsim_make_event(:anyedge,node.to_rcsim)
|
749
|
+
# RCSim.rcsim_set_owner(ev,@rcbehavior)
|
750
|
+
# rcevs << ev
|
750
751
|
end
|
751
752
|
end
|
752
753
|
if rcevs.any? then
|
@@ -755,9 +756,7 @@ module HDLRuby::High
|
|
755
756
|
|
756
757
|
# Create and set the block.
|
757
758
|
rcblock = RCSim.rcsim_make_block(:par)
|
758
|
-
|
759
|
-
# RCSim.rcsim_make_transmit(self.left.to_rcsim,
|
760
|
-
# self.right.to_rcsim))
|
759
|
+
RCSim.rcsim_set_owner(rcblock,@rcbehavior)
|
761
760
|
# puts "self.left=#{self.left} self.right=#{self.right}"
|
762
761
|
RCSim.rcsim_add_block_statements(rcblock,
|
763
762
|
[RCSim.rcsim_make_transmit(self.left.to_rcsim, self.right.to_rcsim)])
|
@@ -889,9 +888,6 @@ module HDLRuby::High
|
|
889
888
|
self.select.to_rcsim)
|
890
889
|
|
891
890
|
# Add the choice expressions. */
|
892
|
-
# self.each_choice do |choice|
|
893
|
-
# rcsim_add_select_choice(rcexpression,choice.to_rcsim)
|
894
|
-
# end
|
895
891
|
if self.each_choice.any? then
|
896
892
|
RCSim.rcsim_add_select_choices(rcexpression,
|
897
893
|
self.each_choice.map(&:to_rcsim))
|
@@ -913,9 +909,6 @@ module HDLRuby::High
|
|
913
909
|
self.type.direction)
|
914
910
|
|
915
911
|
# Add the concatenated expressions. */
|
916
|
-
# self.each_expression do |expr|
|
917
|
-
# RCSim.rcsim_add_concat_expression(rcexpression,expr.to_rcsim)
|
918
|
-
# end
|
919
912
|
if self.each_expression.any? then
|
920
913
|
RCSim.rcsim_add_concat_expressions(rcexpression,
|
921
914
|
self.each_expression.map(&:to_rcsim))
|
@@ -951,9 +944,6 @@ module HDLRuby::High
|
|
951
944
|
self.type.direction)
|
952
945
|
|
953
946
|
# Add the concatenated expressions. */
|
954
|
-
# self.each_ref do |ref|
|
955
|
-
# RCSim.rcsim_add_refConcat_ref(rcref,ref.to_rcsim)
|
956
|
-
# end
|
957
947
|
if self.each_ref.any? then
|
958
948
|
RCSim.rcsim_add_refConcat_refs(rcref,self.each_ref.map(&:to_rcsim))
|
959
949
|
end
|
@@ -1015,14 +1005,36 @@ module HDLRuby::High
|
|
1015
1005
|
class RefObject
|
1016
1006
|
# attr_reader :rcref
|
1017
1007
|
# alias_method :rcexpression, :rcref
|
1008
|
+
|
1009
|
+
# Generate the C description of the reference object with sub signals.
|
1010
|
+
def to_rcsim_subs
|
1011
|
+
# Create the reference concat C object.
|
1012
|
+
# The reference is always big endian, it is the sequence
|
1013
|
+
# of element which is reversed if necessary.
|
1014
|
+
rcref = RCSim.rcsim_make_refConcat(self.type.to_rcsim,:big)
|
1015
|
+
# self.type.direction)
|
1016
|
+
|
1017
|
+
# Add the concatenated expressions. */
|
1018
|
+
if self.object.each_signal.any? then
|
1019
|
+
iter = self.object.each_signal
|
1020
|
+
iter = iter.reverse_each if self.type.direction == :big
|
1021
|
+
RCSim.rcsim_add_refConcat_refs(rcref, iter.map do|sig|
|
1022
|
+
sig.is_a?(SignalI) ? sig.rcsignalI : sig.rcsignalC
|
1023
|
+
end)
|
1024
|
+
end
|
1025
|
+
|
1026
|
+
return rcref
|
1027
|
+
end
|
1018
1028
|
|
1019
1029
|
# Generate the C description of the reference object.
|
1020
1030
|
def to_rcsim
|
1021
1031
|
# puts "object=#{self.object.name}(#{self.object})"
|
1022
1032
|
if self.object.is_a?(SignalI)
|
1023
|
-
return self.object.
|
1033
|
+
return self.object.each_signal.any? ? self.to_rcsim_subs :
|
1034
|
+
self.object.rcsignalI
|
1024
1035
|
elsif self.object.is_a?(SignalC)
|
1025
|
-
return self.object.
|
1036
|
+
return self.object.each_signal.any? ? self.to_rcsim_subs :
|
1037
|
+
self.object.rcsignalC
|
1026
1038
|
else
|
1027
1039
|
raise "Invalid object: #{self.object}"
|
1028
1040
|
end
|
data/lib/HDLRuby/hruby_rsim.rb
CHANGED
@@ -66,7 +66,6 @@ module HDLRuby::High
|
|
66
66
|
@sig_active.each do |sig|
|
67
67
|
next if (sig.c_value.eql?(sig.f_value))
|
68
68
|
# next if (sig.c_value.to_vstr == sig.f_value.to_vstr)
|
69
|
-
# puts "sig.c_value: #{sig.c_value.to_vstr}, sig.f_value=#{sig.f_value.to_vstr}"
|
70
69
|
sig.each_anyedge { |beh| @sig_exec << beh }
|
71
70
|
if (sig.c_value.zero?) then
|
72
71
|
# puts "sig.c_value=#{sig.c_value.content}"
|
@@ -108,6 +107,8 @@ module HDLRuby::High
|
|
108
107
|
HDLRuby.show "#{Time.now}#{show_mem}"
|
109
108
|
# Merge the included.
|
110
109
|
self.merge_included!
|
110
|
+
# Process par in seq.
|
111
|
+
self.par_in_seq2seq!
|
111
112
|
# Initializes the time.
|
112
113
|
@time = 0
|
113
114
|
# Initializes the time and signals execution buffers.
|
@@ -131,6 +132,9 @@ module HDLRuby::High
|
|
131
132
|
self.init_untimeds
|
132
133
|
# puts "End of init_untimed."
|
133
134
|
|
135
|
+
# Maybe there is nothing to execute.
|
136
|
+
return if @total_timed_behaviors == 0
|
137
|
+
|
134
138
|
# Is there more than one timed behavior.
|
135
139
|
if @total_timed_behaviors <= 1 then
|
136
140
|
# No, no need of multithreading.
|
@@ -490,6 +494,12 @@ module HDLRuby::High
|
|
490
494
|
|
491
495
|
## Initialize the simulation for +systemT+
|
492
496
|
def init_sim(systemT)
|
497
|
+
# Recurse on the sub signals if any.
|
498
|
+
if self.each_signal.any? then
|
499
|
+
self.each_signal {|sig| sig.init_sim(systemT) }
|
500
|
+
return
|
501
|
+
end
|
502
|
+
# No sub signal, really initialize the current signal.
|
493
503
|
if self.value then
|
494
504
|
@c_value = self.value.execute(:par).to_value
|
495
505
|
@f_value = @c_value.to_value
|
@@ -506,18 +516,27 @@ module HDLRuby::High
|
|
506
516
|
|
507
517
|
## Adds behavior +beh+ activated on a positive edge of the signal.
|
508
518
|
def add_posedge(beh)
|
519
|
+
# Recurse on the sub signals.
|
520
|
+
self.each_signal {|sig| sig.add_posedge(beh) }
|
521
|
+
# Apply on current signal.
|
509
522
|
@posedge_behaviors ||= []
|
510
523
|
@posedge_behaviors << beh
|
511
524
|
end
|
512
525
|
|
513
526
|
## Adds behavior +beh+ activated on a negative edge of the signal.
|
514
527
|
def add_negedge(beh)
|
528
|
+
# Recurse on the sub signals.
|
529
|
+
self.each_signal {|sig| sig.add_negedge(beh) }
|
530
|
+
# Apply on current signal.
|
515
531
|
@negedge_behaviors ||= []
|
516
532
|
@negedge_behaviors << beh
|
517
533
|
end
|
518
534
|
|
519
535
|
## Adds behavior +beh+ activated on a any edge of the signal.
|
520
536
|
def add_anyedge(beh)
|
537
|
+
# Recurse on the sub signals.
|
538
|
+
self.each_signal {|sig| sig.add_anyedge(beh) }
|
539
|
+
# Apply on current signal.
|
521
540
|
@anyedge_behaviors ||= []
|
522
541
|
@anyedge_behaviors << beh
|
523
542
|
end
|
@@ -543,9 +562,9 @@ module HDLRuby::High
|
|
543
562
|
|
544
563
|
## Execute the expression.
|
545
564
|
def execute(mode)
|
546
|
-
# puts "Executing signal=#{self.fullname}"
|
547
|
-
# return mode == :par ? self.c_value : self.f_value
|
565
|
+
# puts "Executing signal=#{self.fullname} in mode=#{mode} with c_value=#{self.c_value} and f_value=#{self.f_value}"
|
548
566
|
return @mode == :seq ? self.f_value : self.c_value
|
567
|
+
# return @mode == :seq || mode == :seq ? self.f_value : self.c_value
|
549
568
|
end
|
550
569
|
|
551
570
|
## Assigns +value+ the the reference.
|
@@ -649,10 +668,12 @@ module HDLRuby::High
|
|
649
668
|
## Initialize the simulation for system +systemT+.
|
650
669
|
def init_sim(systemT)
|
651
670
|
self.left.init_sim(systemT)
|
671
|
+
self.right.init_sim(systemT)
|
652
672
|
end
|
653
673
|
|
654
674
|
## Executes the statement.
|
655
675
|
def execute(mode)
|
676
|
+
# puts "execute Transmit in mode=#{mode} for left=#{self.left.object.name}"
|
656
677
|
self.left.assign(mode,self.right.execute(mode))
|
657
678
|
end
|
658
679
|
end
|
@@ -670,6 +691,7 @@ module HDLRuby::High
|
|
670
691
|
|
671
692
|
## Executes the statement.
|
672
693
|
def execute(mode)
|
694
|
+
# puts "execute hif with mode=#{mode}"
|
673
695
|
# Check the main condition.
|
674
696
|
if !(self.condition.execute(mode).zero?) then
|
675
697
|
self.yes.execute(mode)
|
@@ -848,6 +870,7 @@ module HDLRuby::High
|
|
848
870
|
|
849
871
|
## Executes the statement.
|
850
872
|
def execute(mode)
|
873
|
+
# puts "execute block of mode=#{self.mode}"
|
851
874
|
self.each_statement { |stmnt| stmnt.execute(self.mode) }
|
852
875
|
end
|
853
876
|
|
@@ -858,6 +881,27 @@ module HDLRuby::High
|
|
858
881
|
end
|
859
882
|
end
|
860
883
|
|
884
|
+
class If
|
885
|
+
## Returns the name of the signal with its hierarchy.
|
886
|
+
def fullname
|
887
|
+
return self.parent.fullname
|
888
|
+
end
|
889
|
+
end
|
890
|
+
|
891
|
+
class When
|
892
|
+
## Returns the name of the signal with its hierarchy.
|
893
|
+
def fullname
|
894
|
+
return self.parent.fullname
|
895
|
+
end
|
896
|
+
end
|
897
|
+
|
898
|
+
class Case
|
899
|
+
## Returns the name of the signal with its hierarchy.
|
900
|
+
def fullname
|
901
|
+
return self.parent.fullname
|
902
|
+
end
|
903
|
+
end
|
904
|
+
|
861
905
|
# Describes a timed block.
|
862
906
|
#
|
863
907
|
# NOTE:
|
@@ -889,8 +933,9 @@ module HDLRuby::High
|
|
889
933
|
def init_sim(systemT)
|
890
934
|
# Add the connection to the list of untimed objets.
|
891
935
|
systemT.add_untimed(self)
|
892
|
-
# Recurse on the left.
|
936
|
+
# Recurse on the left and right.
|
893
937
|
self.left.init_sim(systemT)
|
938
|
+
self.right.init_sim(systemT)
|
894
939
|
# Process the sensitivity list.
|
895
940
|
# Is it a clocked behavior?
|
896
941
|
events = []
|
@@ -914,7 +959,7 @@ module HDLRuby::High
|
|
914
959
|
|
915
960
|
## Executes the statement.
|
916
961
|
def execute(mode)
|
917
|
-
# puts "connection
|
962
|
+
# puts "connection left=#{left} right=#{right}"
|
918
963
|
self.left.assign(mode,self.right.execute(mode))
|
919
964
|
end
|
920
965
|
end
|
@@ -926,6 +971,11 @@ module HDLRuby::High
|
|
926
971
|
#
|
927
972
|
# NOTE: this is an abstract class which is not to be used directly.
|
928
973
|
class Expression
|
974
|
+
## Initialize the simulation for system +systemT+.
|
975
|
+
def init_sim(systemT)
|
976
|
+
# By default: do nothing.
|
977
|
+
end
|
978
|
+
|
929
979
|
## Executes the expression in +mode+ (:blocking or :nonblocking)
|
930
980
|
# NOTE: to be overrided.
|
931
981
|
def execute(mode)
|
@@ -937,6 +987,11 @@ module HDLRuby::High
|
|
937
987
|
##
|
938
988
|
# Describes a value.
|
939
989
|
class Value
|
990
|
+
## Initialize the simulation for system +systemT+.
|
991
|
+
def init_sim(systemT)
|
992
|
+
# Nothing to do.
|
993
|
+
end
|
994
|
+
|
940
995
|
# include Vprocess
|
941
996
|
|
942
997
|
## Executes the expression.
|
@@ -949,10 +1004,16 @@ module HDLRuby::High
|
|
949
1004
|
##
|
950
1005
|
# Describes a cast.
|
951
1006
|
class Cast
|
1007
|
+
## Initialize the simulation for system +systemT+.
|
1008
|
+
def init_sim(systemT)
|
1009
|
+
# Recurse on the child.
|
1010
|
+
self.child.init_sim(systemT)
|
1011
|
+
end
|
1012
|
+
|
952
1013
|
## Executes the expression.
|
953
1014
|
def execute(mode)
|
954
|
-
#
|
955
|
-
#
|
1015
|
+
# puts "child=#{self.child}"
|
1016
|
+
# puts "child object=#{self.child.object}(#{self.child.object.name})" if self.child.is_a?(RefObject)
|
956
1017
|
# Shall we reverse the content of a concat.
|
957
1018
|
if self.child.is_a?(Concat) &&
|
958
1019
|
self.type.direction != self.child.type.direction then
|
@@ -961,6 +1022,7 @@ module HDLRuby::High
|
|
961
1022
|
else
|
962
1023
|
res = self.child.execute(mode)
|
963
1024
|
end
|
1025
|
+
# puts "res=#{res}"
|
964
1026
|
# Cast it.
|
965
1027
|
res = res.cast(self.type,true)
|
966
1028
|
# Returns the result.
|
@@ -981,6 +1043,12 @@ module HDLRuby::High
|
|
981
1043
|
##
|
982
1044
|
# Describes an unary operation.
|
983
1045
|
class Unary
|
1046
|
+
## Initialize the simulation for system +systemT+.
|
1047
|
+
def init_sim(systemT)
|
1048
|
+
# Recurse on the child.
|
1049
|
+
self.child.init_sim(systemT)
|
1050
|
+
end
|
1051
|
+
|
984
1052
|
## Execute the expression.
|
985
1053
|
def execute(mode)
|
986
1054
|
# puts "Unary with operator=#{self.operator}"
|
@@ -996,6 +1064,13 @@ module HDLRuby::High
|
|
996
1064
|
##
|
997
1065
|
# Describes an binary operation.
|
998
1066
|
class Binary
|
1067
|
+
## Initialize the simulation for system +systemT+.
|
1068
|
+
def init_sim(systemT)
|
1069
|
+
# Recurse on the children.
|
1070
|
+
self.left.init_sim(systemT)
|
1071
|
+
self.right.init_sim(systemT)
|
1072
|
+
end
|
1073
|
+
|
999
1074
|
## Execute the expression.
|
1000
1075
|
def execute(mode)
|
1001
1076
|
# Recurse on the children.
|
@@ -1012,6 +1087,13 @@ module HDLRuby::High
|
|
1012
1087
|
#
|
1013
1088
|
# NOTE: choice is using the value of +select+ as an index.
|
1014
1089
|
class Select
|
1090
|
+
## Initialize the simulation for system +systemT+.
|
1091
|
+
def init_sim(systemT)
|
1092
|
+
# Recurse on the children.
|
1093
|
+
self.select.init_sim(systemT)
|
1094
|
+
self.each_choice { |choice| choice.init_sim(systemT) }
|
1095
|
+
end
|
1096
|
+
|
1015
1097
|
## Execute the expression.
|
1016
1098
|
def execute(mode)
|
1017
1099
|
unless @mask then
|
@@ -1033,6 +1115,12 @@ module HDLRuby::High
|
|
1033
1115
|
##
|
1034
1116
|
# Describes a concatenation expression.
|
1035
1117
|
class Concat
|
1118
|
+
## Initialize the simulation for system +systemT+.
|
1119
|
+
def init_sim(systemT)
|
1120
|
+
# Recurse on the children.
|
1121
|
+
self.each_expression { |expr| expr.init_sim(systemT) }
|
1122
|
+
end
|
1123
|
+
|
1036
1124
|
## Execute the expression.
|
1037
1125
|
def execute(mode, reverse=false)
|
1038
1126
|
# Recurse on the children.
|
@@ -1218,7 +1306,44 @@ module HDLRuby::High
|
|
1218
1306
|
class RefObject
|
1219
1307
|
## Initialize the simulation for system +systemT+.
|
1220
1308
|
def init_sim(systemT)
|
1309
|
+
# puts "init_sim for RefObject=#{self}"
|
1221
1310
|
@sim = systemT
|
1311
|
+
|
1312
|
+
# Modify the exectute and assign methods if the object has
|
1313
|
+
# sub signals (for faster execution).
|
1314
|
+
if self.object.each_signal.any? then
|
1315
|
+
## Execute the expression.
|
1316
|
+
self.define_singleton_method(:execute) do |mode|
|
1317
|
+
# Recurse on the children.
|
1318
|
+
iter = self.object.each_signal
|
1319
|
+
iter = iter.reverse_each unless self.object.type.direction == :big
|
1320
|
+
tmpe = iter.map {|sig| sig.execute(mode) }
|
1321
|
+
# Concatenate the result.
|
1322
|
+
# return tmpe.reduce(:concat)
|
1323
|
+
return Vprocess.concat(*tmpe)
|
1324
|
+
end
|
1325
|
+
## Assigns +value+ the the reference.
|
1326
|
+
self.define_singleton_method(:assign) do |mode,value|
|
1327
|
+
# puts "RefObject #{self} assign with object=#{self.object}"
|
1328
|
+
# Flatten the value type.
|
1329
|
+
value.type = [value.type.width].to_type
|
1330
|
+
pos = 0
|
1331
|
+
width = 0
|
1332
|
+
# Recurse on the children.
|
1333
|
+
iter = self.object.each_signal
|
1334
|
+
iter = iter.reverse_each unless self.object.type.direction == :big
|
1335
|
+
iter.each do |sig|
|
1336
|
+
width = sig.type.width
|
1337
|
+
sig.assign(mode,value[(pos+width-1).to_expr..pos.to_expr])
|
1338
|
+
# Tell the signal changed.
|
1339
|
+
if !(sig.c_value.eql?(sig.f_value)) then
|
1340
|
+
@sim.add_sig_active(sig)
|
1341
|
+
end
|
1342
|
+
# Prepare for the next reference.
|
1343
|
+
pos += width
|
1344
|
+
end
|
1345
|
+
end
|
1346
|
+
end
|
1222
1347
|
end
|
1223
1348
|
|
1224
1349
|
## Execute the expression.
|