HDLRuby 2.11.11 → 3.0.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/README.html +3274 -0
- data/README.md +608 -99
- data/ext/hruby_sim/hruby_rcsim_build.c +27 -0
- data/ext/hruby_sim/hruby_sim.h +3 -0
- data/ext/hruby_sim/hruby_sim_calc.c +2 -0
- data/ext/hruby_sim/hruby_sim_core.c +17 -5
- data/ext/hruby_sim/hruby_sim_stack_calc.c +1 -1
- 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/backend/hruby_allocator.rb +2 -2
- data/lib/HDLRuby/backend/hruby_c_allocator.rb +7 -7
- 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 +12 -12
- 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_bram_frame_stack.rb +105 -0
- data/lib/HDLRuby/hdr_samples/with_bram_stack.rb +69 -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_register_stack.rb +150 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer.rb +190 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_deep.rb +91 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +405 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerator.rb +89 -0
- data/lib/HDLRuby/hdr_samples/with_sequencer_sync.rb +120 -0
- 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 +29 -3
- data/lib/HDLRuby/hdrlib.rb +1 -1
- data/lib/HDLRuby/hruby_bstr.rb +10 -5
- data/lib/HDLRuby/hruby_db.rb +2 -2
- data/lib/HDLRuby/hruby_high.rb +152 -47
- data/lib/HDLRuby/hruby_high_fullname.rb +3 -1
- data/lib/HDLRuby/hruby_low.rb +189 -18
- data/lib/HDLRuby/hruby_low2c.rb +129 -54
- data/lib/HDLRuby/hruby_low2hdr.rb +66 -40
- data/lib/HDLRuby/hruby_low2high.rb +86 -44
- data/lib/HDLRuby/hruby_low2seq.rb +26 -18
- data/lib/HDLRuby/hruby_low2sym.rb +14 -13
- data/lib/HDLRuby/hruby_low2vhd.rb +80 -44
- data/lib/HDLRuby/hruby_low_bool2select.rb +61 -46
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +56 -44
- data/lib/HDLRuby/hruby_low_cleanup.rb +18 -16
- data/lib/HDLRuby/hruby_low_fix_types.rb +65 -32
- data/lib/HDLRuby/hruby_low_mutable.rb +83 -119
- data/lib/HDLRuby/hruby_low_resolve.rb +38 -30
- data/lib/HDLRuby/hruby_low_with_bool.rb +33 -16
- data/lib/HDLRuby/hruby_low_with_port.rb +3 -3
- data/lib/HDLRuby/hruby_low_with_var.rb +23 -9
- data/lib/HDLRuby/hruby_low_without_concat.rb +45 -19
- data/lib/HDLRuby/hruby_low_without_namespace.rb +47 -32
- data/lib/HDLRuby/hruby_low_without_parinseq.rb +32 -16
- data/lib/HDLRuby/hruby_low_without_select.rb +37 -24
- data/lib/HDLRuby/hruby_low_without_subsignals.rb +280 -0
- data/lib/HDLRuby/hruby_rcsim.rb +158 -134
- data/lib/HDLRuby/hruby_rsim.rb +194 -20
- data/lib/HDLRuby/hruby_rsim_mute.rb +2 -3
- data/lib/HDLRuby/hruby_rsim_vcd.rb +125 -50
- data/lib/HDLRuby/hruby_values.rb +48 -33
- data/lib/HDLRuby/hruby_verilog.rb +90 -48
- data/lib/HDLRuby/soft/stacks.rb +219 -0
- data/lib/HDLRuby/std/bram.rb +26 -0
- data/lib/HDLRuby/std/clocks.rb +1 -1
- data/lib/HDLRuby/std/fixpoint.rb +2 -2
- data/lib/HDLRuby/std/fsm.rb +48 -11
- data/lib/HDLRuby/std/function_generator.rb +2 -2
- data/lib/HDLRuby/std/sequencer.rb +1857 -0
- data/lib/HDLRuby/std/sequencer_sync.rb +400 -0
- data/lib/HDLRuby/std/std.rb +12 -0
- data/lib/HDLRuby/version.rb +1 -1
- data/tuto/adder_sat_flags_vcd.png +0 -0
- data/tuto/addsub_vcd.png +0 -0
- data/tuto/alu_vcd.png +0 -0
- data/tuto/bit_pong_vcd.png +0 -0
- data/tuto/checksum_vcd.png +0 -0
- data/tuto/circuit_hdr.odg +0 -0
- data/tuto/circuit_hdr.png +0 -0
- data/tuto/circuit_hie.odg +0 -0
- data/tuto/circuit_hie.png +0 -0
- data/tuto/circuit_view.odg +0 -0
- data/tuto/circuit_view.png +0 -0
- data/tuto/clock_counter_vcd.png +0 -0
- data/tuto/counter_ext_vcd.png +0 -0
- data/tuto/fact_vcd.png +0 -0
- data/tuto/hw_flow.odg +0 -0
- data/tuto/hw_flow.png +0 -0
- data/tuto/maxxer_vcd.png +0 -0
- data/tuto/pingpong0_vcd.png +0 -0
- data/tuto/pingpong1_vcd.png +0 -0
- data/tuto/pingpong2_vcd.png +0 -0
- data/tuto/ram_vcd.png +0 -0
- data/tuto/serializer_vcd.png +0 -0
- data/tuto/sw_flow.odg +0 -0
- data/tuto/sw_flow.png +0 -0
- data/tuto/the_counter_vcd.png +0 -0
- data/tuto/tutorial_sw.html +2359 -0
- data/tuto/tutorial_sw.md +2684 -0
- data/tuto/tutorial_sw.pdf +0 -0
- data/tuto/tutorial_sw_jp.md +417 -0
- metadata +49 -3
- data/lib/HDLRuby/hdr_samples/sumprod.rb +0 -29
data/lib/HDLRuby/hruby_rsim.rb
CHANGED
@@ -12,13 +12,17 @@ module HDLRuby::High
|
|
12
12
|
#
|
13
13
|
########################################################################
|
14
14
|
|
15
|
-
|
16
|
-
|
15
|
+
|
16
|
+
|
17
17
|
class SystemT
|
18
|
+
## Enhance a system type with Ruby simulation.
|
18
19
|
|
19
20
|
# Tell if the simulation is in multithread mode or not.
|
20
21
|
attr_reader :multithread
|
21
22
|
|
23
|
+
# The current global time.
|
24
|
+
attr_reader :time
|
25
|
+
|
22
26
|
## Add untimed objet +obj+
|
23
27
|
def add_untimed(obj)
|
24
28
|
@untimeds << obj
|
@@ -66,7 +70,7 @@ module HDLRuby::High
|
|
66
70
|
@sig_active.each do |sig|
|
67
71
|
next if (sig.c_value.eql?(sig.f_value))
|
68
72
|
# next if (sig.c_value.to_vstr == sig.f_value.to_vstr)
|
69
|
-
# puts "
|
73
|
+
# puts "for sig=#{sig.fullname}"
|
70
74
|
sig.each_anyedge { |beh| @sig_exec << beh }
|
71
75
|
if (sig.c_value.zero?) then
|
72
76
|
# puts "sig.c_value=#{sig.c_value.content}"
|
@@ -79,6 +83,7 @@ module HDLRuby::High
|
|
79
83
|
@sig_active.each { |sig| sig.c_value = sig.f_value }
|
80
84
|
# puts "first @sig_exec.size=#{@sig_exec.size}"
|
81
85
|
@sig_exec.uniq! {|beh| beh.object_id }
|
86
|
+
# puts "now @sig_exec.size=#{@sig_exec.size}"
|
82
87
|
# Display the activated signals.
|
83
88
|
@sig_active.each do |sig|
|
84
89
|
if !shown_values[sig].eql?(sig.f_value) then
|
@@ -94,9 +99,10 @@ module HDLRuby::High
|
|
94
99
|
@sig_exec.clear
|
95
100
|
@sig_active.uniq! {|sig| sig.object_id }
|
96
101
|
# puts "@sig_active.size=#{@sig_active.size}"
|
97
|
-
#
|
102
|
+
# Compute the nearest next time stamp.
|
98
103
|
@time = (@timed_behaviors.min {|b0,b1| b0.time <=> b1.time }).time
|
99
104
|
end
|
105
|
+
# puts "@time=#{@time}"
|
100
106
|
# Display the time
|
101
107
|
self.show_time
|
102
108
|
end
|
@@ -108,6 +114,8 @@ module HDLRuby::High
|
|
108
114
|
HDLRuby.show "#{Time.now}#{show_mem}"
|
109
115
|
# Merge the included.
|
110
116
|
self.merge_included!
|
117
|
+
# Process par in seq.
|
118
|
+
self.par_in_seq2seq!
|
111
119
|
# Initializes the time.
|
112
120
|
@time = 0
|
113
121
|
# Initializes the time and signals execution buffers.
|
@@ -131,6 +139,9 @@ module HDLRuby::High
|
|
131
139
|
self.init_untimeds
|
132
140
|
# puts "End of init_untimed."
|
133
141
|
|
142
|
+
# Maybe there is nothing to execute.
|
143
|
+
return if @total_timed_behaviors == 0
|
144
|
+
|
134
145
|
# Is there more than one timed behavior.
|
135
146
|
if @total_timed_behaviors <= 1 then
|
136
147
|
# No, no need of multithreading.
|
@@ -318,9 +329,8 @@ module HDLRuby::High
|
|
318
329
|
end
|
319
330
|
|
320
331
|
|
321
|
-
##
|
322
|
-
# Describes scopes of system types.
|
323
332
|
class Scope
|
333
|
+
## Enhance a scope with Ruby simulation.
|
324
334
|
|
325
335
|
## Initialize the simulation for system +systemT+.
|
326
336
|
def init_sim(systemT)
|
@@ -331,7 +341,26 @@ module HDLRuby::High
|
|
331
341
|
# Recurse on the systemI.
|
332
342
|
self.each_systemI { |sys| sys.init_sim(systemT) }
|
333
343
|
# Recurse on the connections.
|
334
|
-
self.each_connection { |cnx| cnx.init_sim(systemT) }
|
344
|
+
# self.each_connection { |cnx| cnx.init_sim(systemT) }
|
345
|
+
self.each_connection do |cnx|
|
346
|
+
# Connection to a real expression?
|
347
|
+
if !cnx.right.is_a?(RefObject) then
|
348
|
+
# Yes.
|
349
|
+
cnx.init_sim(systemT)
|
350
|
+
else
|
351
|
+
# No, maybe the reverse connection is also required.
|
352
|
+
# puts "cnx.left.object=#{cnx.left.object.fullname} cnx.right.object=#{cnx.right.object.fullname}"
|
353
|
+
cnx.init_sim(systemT)
|
354
|
+
if cnx.left.is_a?(RefObject) then
|
355
|
+
sigL = cnx.left.object
|
356
|
+
prtL = sigL.parent
|
357
|
+
if prtL.is_a?(SystemT) and prtL.each_inout.any?{|e| e.object_id == sigL.object_id} then
|
358
|
+
# puts "write to right with sigL=#{sigL.fullname}."
|
359
|
+
Connection.new(cnx.right.clone,cnx.left.clone).init_sim(systemT)
|
360
|
+
end
|
361
|
+
end
|
362
|
+
end
|
363
|
+
end
|
335
364
|
# Recurse on the sub scopes.
|
336
365
|
self.each_scope { |sco| sco.init_sim(systemT) }
|
337
366
|
end
|
@@ -389,9 +418,21 @@ module HDLRuby::High
|
|
389
418
|
# Keep only one ref per signal.
|
390
419
|
refs.uniq! { |node| node.fullname }
|
391
420
|
# puts "refs=#{refs.map {|node| node.fullname}}"
|
421
|
+
# The get the left references: the will be removed from the
|
422
|
+
# events.
|
423
|
+
left_refs = self.block.each_node_deep.select do |node|
|
424
|
+
node.is_a?(RefObject) && node.leftvalue? &&
|
425
|
+
!node.parent.is_a?(RefObject)
|
426
|
+
end.to_a
|
427
|
+
# Keep only one left ref per signal.
|
428
|
+
left_refs.uniq! { |node| node.fullname }
|
392
429
|
# Remove the inner signals from the list.
|
393
430
|
self.block.each_inner do |inner|
|
394
|
-
refs.delete_if {|r| r.
|
431
|
+
refs.delete_if {|r| r.fullname == inner.fullname }
|
432
|
+
end
|
433
|
+
# Remove the left refs.
|
434
|
+
left_refs.each do |l|
|
435
|
+
refs.delete_if {|r| r.fullname == l.fullname }
|
395
436
|
end
|
396
437
|
# Generate the event.
|
397
438
|
events = refs.map {|ref| Event.new(:anyedge,ref.clone) }
|
@@ -490,6 +531,15 @@ module HDLRuby::High
|
|
490
531
|
|
491
532
|
## Initialize the simulation for +systemT+
|
492
533
|
def init_sim(systemT)
|
534
|
+
# Initialize the local time to -1
|
535
|
+
@time = -1
|
536
|
+
@sim = systemT
|
537
|
+
# Recurse on the sub signals if any.
|
538
|
+
if self.each_signal.any? then
|
539
|
+
self.each_signal {|sig| sig.init_sim(systemT) }
|
540
|
+
return
|
541
|
+
end
|
542
|
+
# No sub signal, really initialize the current signal.
|
493
543
|
if self.value then
|
494
544
|
@c_value = self.value.execute(:par).to_value
|
495
545
|
@f_value = @c_value.to_value
|
@@ -506,18 +556,27 @@ module HDLRuby::High
|
|
506
556
|
|
507
557
|
## Adds behavior +beh+ activated on a positive edge of the signal.
|
508
558
|
def add_posedge(beh)
|
559
|
+
# Recurse on the sub signals.
|
560
|
+
self.each_signal {|sig| sig.add_posedge(beh) }
|
561
|
+
# Apply on current signal.
|
509
562
|
@posedge_behaviors ||= []
|
510
563
|
@posedge_behaviors << beh
|
511
564
|
end
|
512
565
|
|
513
566
|
## Adds behavior +beh+ activated on a negative edge of the signal.
|
514
567
|
def add_negedge(beh)
|
568
|
+
# Recurse on the sub signals.
|
569
|
+
self.each_signal {|sig| sig.add_negedge(beh) }
|
570
|
+
# Apply on current signal.
|
515
571
|
@negedge_behaviors ||= []
|
516
572
|
@negedge_behaviors << beh
|
517
573
|
end
|
518
574
|
|
519
575
|
## Adds behavior +beh+ activated on a any edge of the signal.
|
520
576
|
def add_anyedge(beh)
|
577
|
+
# Recurse on the sub signals.
|
578
|
+
self.each_signal {|sig| sig.add_anyedge(beh) }
|
579
|
+
# Apply on current signal.
|
521
580
|
@anyedge_behaviors ||= []
|
522
581
|
@anyedge_behaviors << beh
|
523
582
|
end
|
@@ -543,19 +602,23 @@ module HDLRuby::High
|
|
543
602
|
|
544
603
|
## Execute the expression.
|
545
604
|
def execute(mode)
|
546
|
-
# puts "Executing signal=#{self.fullname}"
|
547
|
-
# return mode == :par ? self.c_value : self.f_value
|
605
|
+
# puts "Executing signal=#{self.fullname} in mode=#{mode} with c_value=#{self.c_value} and f_value=#{self.f_value}"
|
548
606
|
return @mode == :seq ? self.f_value : self.c_value
|
607
|
+
# return @mode == :seq || mode == :seq ? self.f_value : self.c_value
|
549
608
|
end
|
550
609
|
|
551
610
|
## Assigns +value+ the the reference.
|
552
611
|
def assign(mode,value)
|
553
|
-
# Set the next value.
|
554
|
-
@f_value = value
|
612
|
+
# # Set the next value.
|
613
|
+
# @f_value = value
|
555
614
|
# Set the mode.
|
556
615
|
@mode = mode
|
557
|
-
#
|
558
|
-
@
|
616
|
+
# @f_value = value.cast(self.type) # Cast not always inserted by HDLRuby normally
|
617
|
+
if @sim.time > @time or !value.impedence? then
|
618
|
+
# puts "assign #{value.content} to #{self.fullname}"
|
619
|
+
@f_value = value.cast(self.type) # Cast not always inserted by HDLRuby normally
|
620
|
+
@time = @sim.time
|
621
|
+
end
|
559
622
|
end
|
560
623
|
|
561
624
|
## Assigns +value+ at +index+ (integer or range).
|
@@ -649,10 +712,12 @@ module HDLRuby::High
|
|
649
712
|
## Initialize the simulation for system +systemT+.
|
650
713
|
def init_sim(systemT)
|
651
714
|
self.left.init_sim(systemT)
|
715
|
+
self.right.init_sim(systemT)
|
652
716
|
end
|
653
717
|
|
654
718
|
## Executes the statement.
|
655
719
|
def execute(mode)
|
720
|
+
# puts "execute Transmit in mode=#{mode} for left=#{self.left.object.fullname}" if left.is_a?(RefObject)
|
656
721
|
self.left.assign(mode,self.right.execute(mode))
|
657
722
|
end
|
658
723
|
end
|
@@ -664,12 +729,17 @@ module HDLRuby::High
|
|
664
729
|
## Initialize the simulation for system +systemT+.
|
665
730
|
def init_sim(systemT)
|
666
731
|
self.yes.init_sim(systemT)
|
667
|
-
self.each_noif { |cond,stmnt| stmnt.init_sim(systemT) }
|
732
|
+
# self.each_noif { |cond,stmnt| stmnt.init_sim(systemT) }
|
733
|
+
self.each_noif do |cond,stmnt|
|
734
|
+
cond.init_sim(systemT)
|
735
|
+
stmnt.init_sim(systemT)
|
736
|
+
end
|
668
737
|
self.no.init_sim(systemT) if self.no
|
669
738
|
end
|
670
739
|
|
671
740
|
## Executes the statement.
|
672
741
|
def execute(mode)
|
742
|
+
# puts "execute hif with mode=#{mode}"
|
673
743
|
# Check the main condition.
|
674
744
|
if !(self.condition.execute(mode).zero?) then
|
675
745
|
self.yes.execute(mode)
|
@@ -848,6 +918,7 @@ module HDLRuby::High
|
|
848
918
|
|
849
919
|
## Executes the statement.
|
850
920
|
def execute(mode)
|
921
|
+
# puts "execute block of mode=#{self.mode}"
|
851
922
|
self.each_statement { |stmnt| stmnt.execute(self.mode) }
|
852
923
|
end
|
853
924
|
|
@@ -858,6 +929,27 @@ module HDLRuby::High
|
|
858
929
|
end
|
859
930
|
end
|
860
931
|
|
932
|
+
class If
|
933
|
+
## Returns the name of the signal with its hierarchy.
|
934
|
+
def fullname
|
935
|
+
return self.parent.fullname
|
936
|
+
end
|
937
|
+
end
|
938
|
+
|
939
|
+
class When
|
940
|
+
## Returns the name of the signal with its hierarchy.
|
941
|
+
def fullname
|
942
|
+
return self.parent.fullname
|
943
|
+
end
|
944
|
+
end
|
945
|
+
|
946
|
+
class Case
|
947
|
+
## Returns the name of the signal with its hierarchy.
|
948
|
+
def fullname
|
949
|
+
return self.parent.fullname
|
950
|
+
end
|
951
|
+
end
|
952
|
+
|
861
953
|
# Describes a timed block.
|
862
954
|
#
|
863
955
|
# NOTE:
|
@@ -889,8 +981,9 @@ module HDLRuby::High
|
|
889
981
|
def init_sim(systemT)
|
890
982
|
# Add the connection to the list of untimed objets.
|
891
983
|
systemT.add_untimed(self)
|
892
|
-
# Recurse on the left.
|
984
|
+
# Recurse on the left and right.
|
893
985
|
self.left.init_sim(systemT)
|
986
|
+
self.right.init_sim(systemT)
|
894
987
|
# Process the sensitivity list.
|
895
988
|
# Is it a clocked behavior?
|
896
989
|
events = []
|
@@ -914,8 +1007,9 @@ module HDLRuby::High
|
|
914
1007
|
|
915
1008
|
## Executes the statement.
|
916
1009
|
def execute(mode)
|
917
|
-
# puts "connection
|
918
|
-
self.left.assign(mode,self.right.execute(mode))
|
1010
|
+
# puts "connection left=#{left.object.fullname}"
|
1011
|
+
# self.left.assign(mode,self.right.execute(mode))
|
1012
|
+
self.left.assign(:seq,self.right.execute(mode))
|
919
1013
|
end
|
920
1014
|
end
|
921
1015
|
|
@@ -926,6 +1020,11 @@ module HDLRuby::High
|
|
926
1020
|
#
|
927
1021
|
# NOTE: this is an abstract class which is not to be used directly.
|
928
1022
|
class Expression
|
1023
|
+
## Initialize the simulation for system +systemT+.
|
1024
|
+
def init_sim(systemT)
|
1025
|
+
# By default: do nothing.
|
1026
|
+
end
|
1027
|
+
|
929
1028
|
## Executes the expression in +mode+ (:blocking or :nonblocking)
|
930
1029
|
# NOTE: to be overrided.
|
931
1030
|
def execute(mode)
|
@@ -937,6 +1036,11 @@ module HDLRuby::High
|
|
937
1036
|
##
|
938
1037
|
# Describes a value.
|
939
1038
|
class Value
|
1039
|
+
## Initialize the simulation for system +systemT+.
|
1040
|
+
def init_sim(systemT)
|
1041
|
+
# Nothing to do.
|
1042
|
+
end
|
1043
|
+
|
940
1044
|
# include Vprocess
|
941
1045
|
|
942
1046
|
## Executes the expression.
|
@@ -949,10 +1053,16 @@ module HDLRuby::High
|
|
949
1053
|
##
|
950
1054
|
# Describes a cast.
|
951
1055
|
class Cast
|
1056
|
+
## Initialize the simulation for system +systemT+.
|
1057
|
+
def init_sim(systemT)
|
1058
|
+
# Recurse on the child.
|
1059
|
+
self.child.init_sim(systemT)
|
1060
|
+
end
|
1061
|
+
|
952
1062
|
## Executes the expression.
|
953
1063
|
def execute(mode)
|
954
|
-
#
|
955
|
-
#
|
1064
|
+
# puts "child=#{self.child}"
|
1065
|
+
# puts "child object=#{self.child.object}(#{self.child.object.name})" if self.child.is_a?(RefObject)
|
956
1066
|
# Shall we reverse the content of a concat.
|
957
1067
|
if self.child.is_a?(Concat) &&
|
958
1068
|
self.type.direction != self.child.type.direction then
|
@@ -961,6 +1071,7 @@ module HDLRuby::High
|
|
961
1071
|
else
|
962
1072
|
res = self.child.execute(mode)
|
963
1073
|
end
|
1074
|
+
# puts "res=#{res}"
|
964
1075
|
# Cast it.
|
965
1076
|
res = res.cast(self.type,true)
|
966
1077
|
# Returns the result.
|
@@ -981,6 +1092,12 @@ module HDLRuby::High
|
|
981
1092
|
##
|
982
1093
|
# Describes an unary operation.
|
983
1094
|
class Unary
|
1095
|
+
## Initialize the simulation for system +systemT+.
|
1096
|
+
def init_sim(systemT)
|
1097
|
+
# Recurse on the child.
|
1098
|
+
self.child.init_sim(systemT)
|
1099
|
+
end
|
1100
|
+
|
984
1101
|
## Execute the expression.
|
985
1102
|
def execute(mode)
|
986
1103
|
# puts "Unary with operator=#{self.operator}"
|
@@ -996,6 +1113,13 @@ module HDLRuby::High
|
|
996
1113
|
##
|
997
1114
|
# Describes an binary operation.
|
998
1115
|
class Binary
|
1116
|
+
## Initialize the simulation for system +systemT+.
|
1117
|
+
def init_sim(systemT)
|
1118
|
+
# Recurse on the children.
|
1119
|
+
self.left.init_sim(systemT)
|
1120
|
+
self.right.init_sim(systemT)
|
1121
|
+
end
|
1122
|
+
|
999
1123
|
## Execute the expression.
|
1000
1124
|
def execute(mode)
|
1001
1125
|
# Recurse on the children.
|
@@ -1012,6 +1136,13 @@ module HDLRuby::High
|
|
1012
1136
|
#
|
1013
1137
|
# NOTE: choice is using the value of +select+ as an index.
|
1014
1138
|
class Select
|
1139
|
+
## Initialize the simulation for system +systemT+.
|
1140
|
+
def init_sim(systemT)
|
1141
|
+
# Recurse on the children.
|
1142
|
+
self.select.init_sim(systemT)
|
1143
|
+
self.each_choice { |choice| choice.init_sim(systemT) }
|
1144
|
+
end
|
1145
|
+
|
1015
1146
|
## Execute the expression.
|
1016
1147
|
def execute(mode)
|
1017
1148
|
unless @mask then
|
@@ -1033,6 +1164,12 @@ module HDLRuby::High
|
|
1033
1164
|
##
|
1034
1165
|
# Describes a concatenation expression.
|
1035
1166
|
class Concat
|
1167
|
+
## Initialize the simulation for system +systemT+.
|
1168
|
+
def init_sim(systemT)
|
1169
|
+
# Recurse on the children.
|
1170
|
+
self.each_expression { |expr| expr.init_sim(systemT) }
|
1171
|
+
end
|
1172
|
+
|
1036
1173
|
## Execute the expression.
|
1037
1174
|
def execute(mode, reverse=false)
|
1038
1175
|
# Recurse on the children.
|
@@ -1218,7 +1355,44 @@ module HDLRuby::High
|
|
1218
1355
|
class RefObject
|
1219
1356
|
## Initialize the simulation for system +systemT+.
|
1220
1357
|
def init_sim(systemT)
|
1358
|
+
# puts "init_sim for RefObject=#{self}"
|
1221
1359
|
@sim = systemT
|
1360
|
+
|
1361
|
+
# Modify the exectute and assign methods if the object has
|
1362
|
+
# sub signals (for faster execution).
|
1363
|
+
if self.object.each_signal.any? then
|
1364
|
+
## Execute the expression.
|
1365
|
+
self.define_singleton_method(:execute) do |mode|
|
1366
|
+
# Recurse on the children.
|
1367
|
+
iter = self.object.each_signal
|
1368
|
+
iter = iter.reverse_each unless self.object.type.direction == :big
|
1369
|
+
tmpe = iter.map {|sig| sig.execute(mode) }
|
1370
|
+
# Concatenate the result.
|
1371
|
+
# return tmpe.reduce(:concat)
|
1372
|
+
return Vprocess.concat(*tmpe)
|
1373
|
+
end
|
1374
|
+
## Assigns +value+ the the reference.
|
1375
|
+
self.define_singleton_method(:assign) do |mode,value|
|
1376
|
+
# puts "RefObject #{self} assign with object=#{self.object}"
|
1377
|
+
# Flatten the value type.
|
1378
|
+
value.type = [value.type.width].to_type
|
1379
|
+
pos = 0
|
1380
|
+
width = 0
|
1381
|
+
# Recurse on the children.
|
1382
|
+
iter = self.object.each_signal
|
1383
|
+
iter = iter.reverse_each unless self.object.type.direction == :big
|
1384
|
+
iter.each do |sig|
|
1385
|
+
width = sig.type.width
|
1386
|
+
sig.assign(mode,value[(pos+width-1).to_expr..pos.to_expr])
|
1387
|
+
# Tell the signal changed.
|
1388
|
+
if !(sig.c_value.eql?(sig.f_value)) then
|
1389
|
+
@sim.add_sig_active(sig)
|
1390
|
+
end
|
1391
|
+
# Prepare for the next reference.
|
1392
|
+
pos += width
|
1393
|
+
end
|
1394
|
+
end
|
1395
|
+
end
|
1222
1396
|
end
|
1223
1397
|
|
1224
1398
|
## Execute the expression.
|
@@ -1,14 +1,13 @@
|
|
1
1
|
require "HDLRuby/hruby_rsim"
|
2
2
|
|
3
3
|
##
|
4
|
-
# Library for enhancing the Ruby simulator with
|
4
|
+
# Library for enhancing the Ruby simulator with muted output support
|
5
5
|
#
|
6
6
|
########################################################################
|
7
7
|
module HDLRuby::High
|
8
8
|
|
9
|
-
##
|
10
|
-
# Enhance the system type class with VCD support.
|
11
9
|
class SystemT
|
10
|
+
# Enhance the system type class with mute support.
|
12
11
|
|
13
12
|
## Initializes the displayer for generating a vcd on +vcdout+
|
14
13
|
def show_init(vcdout)
|