HDLRuby 2.11.2 → 2.11.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +6 -2
- data/ext/hruby_sim/hruby_rcsim_build.c +325 -73
- data/ext/hruby_sim/hruby_sim.h +11 -1
- data/ext/hruby_sim/hruby_sim_calc.c +11 -8
- data/ext/hruby_sim/hruby_sim_core.c +8 -6
- data/ext/hruby_sim/hruby_sim_tree_calc.c +14 -0
- data/ext/hruby_sim/hruby_value_pool.c +6 -4
- data/lib/HDLRuby/hdr_samples/repeat_bench.rb +48 -0
- data/lib/HDLRuby/hruby_high.rb +11 -6
- data/lib/HDLRuby/hruby_low.rb +27 -17
- data/lib/HDLRuby/hruby_low2c.rb +26 -7
- data/lib/HDLRuby/hruby_rcsim.rb +119 -74
- data/lib/HDLRuby/hruby_rsim.rb +10 -1
- data/lib/HDLRuby/hruby_rsim_vcd.rb +15 -0
- data/lib/HDLRuby/hruby_verilog.rb +71 -58
- data/lib/HDLRuby/version.rb +1 -1
- metadata +3 -2
data/lib/HDLRuby/hruby_rcsim.rb
CHANGED
@@ -107,26 +107,32 @@ module HDLRuby::High
|
|
107
107
|
# rcsig = sig.to_rcsim(@rcsystemT)
|
108
108
|
# RCSim.rcsim_add_systemT_input(@rcsystemT,rcsig)
|
109
109
|
# end
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
110
|
+
if self.each_input.any? then
|
111
|
+
RCSim.rcsim_add_systemT_inputs(@rcsystemT,
|
112
|
+
self.each_input.map do |sig|
|
113
|
+
sig.to_rcsim(@rcsystemT)
|
114
|
+
end)
|
115
|
+
end
|
114
116
|
# self.each_output do |sig|
|
115
117
|
# rcsig = sig.to_rcsim(@rcsystemT)
|
116
118
|
# RCSim.rcsim_add_systemT_output(@rcsystemT,rcsig)
|
117
119
|
# end
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
120
|
+
if self.each_output.any? then
|
121
|
+
RCSim.rcsim_add_systemT_outputs(@rcsystemT,
|
122
|
+
self.each_output.map do |sig|
|
123
|
+
sig.to_rcsim(@rcsystemT)
|
124
|
+
end)
|
125
|
+
end
|
122
126
|
# self.each_inout do |sig|
|
123
127
|
# rcsig = sig.to_rcsim(@rcsystemT)
|
124
128
|
# RCSim.rcsim_add_systemT_inout(@rcsystemT,rcsig)
|
125
129
|
# end
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
+
if self.each_inout.any? then
|
131
|
+
RCSim.rcsim_add_systemT_inouts(@rcsystemT,
|
132
|
+
self.each_inout.map do |sig|
|
133
|
+
sig.to_rcsim(@rcsystemT)
|
134
|
+
end)
|
135
|
+
end
|
130
136
|
# Create and add the scope.
|
131
137
|
RCSim.rcsim_set_systemT_scope(@rcsystemT,
|
132
138
|
self.scope.to_rcsim(@rcsystemT))
|
@@ -170,44 +176,43 @@ module HDLRuby::High
|
|
170
176
|
# rcsig = sig.to_rcsim(@rcscope)
|
171
177
|
# RCSim.rcsim_add_scope_inner(@rcscope,rcsig)
|
172
178
|
# end
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
179
|
+
if self.each_inner.any? then
|
180
|
+
RCSim.rcsim_add_scope_inners(@rcscope,self.each_inner.map do|sig|
|
181
|
+
# sig.to_rcsim(@rcscope)
|
182
|
+
sig.to_rcsim(subowner)
|
183
|
+
end)
|
184
|
+
end
|
177
185
|
|
178
186
|
# Create and add the system instances.
|
179
187
|
# self.each_systemI do |sys|
|
180
188
|
# rcsys = sys.to_rcsim(@rcscope)
|
181
189
|
# RCSim.rcsim_add_scope_systemI(@rcscope,rcsys)
|
182
190
|
# end
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
191
|
+
if self.each_systemI.any? then
|
192
|
+
RCSim.rcsim_add_scope_systemIs(@rcscope,
|
193
|
+
self.each_systemI.map do |sys|
|
194
|
+
# sys.to_rcsim(@rcscope)
|
195
|
+
sys.to_rcsim(subowner)
|
196
|
+
end)
|
197
|
+
end
|
188
198
|
|
189
199
|
# Create and add the behaviors.
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
beh.to_rcsim(subowner)
|
198
|
-
end)
|
200
|
+
if self.each_behavior.any? then
|
201
|
+
RCSim.rcsim_add_scope_behaviors(@rcscope,
|
202
|
+
self.each_behavior.map do |beh|
|
203
|
+
# beh.to_rcsim(@rcscope)
|
204
|
+
beh.to_rcsim(subowner)
|
205
|
+
end)
|
206
|
+
end
|
199
207
|
|
200
208
|
# Create and add the connections.
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
# cxt.to_rcsim(@rcscope)
|
209
|
-
cxt.to_rcsim(subowner)
|
210
|
-
end)
|
209
|
+
if self.each_connection.any? then
|
210
|
+
RCSim.rcsim_add_scope_behaviors(@rcscope,
|
211
|
+
self.each_connection.map do |cxt|
|
212
|
+
# cxt.to_rcsim(@rcscope)
|
213
|
+
cxt.to_rcsim(subowner)
|
214
|
+
end)
|
215
|
+
end
|
211
216
|
|
212
217
|
# Create and add the codes.
|
213
218
|
# TODO!!
|
@@ -217,10 +222,12 @@ module HDLRuby::High
|
|
217
222
|
# rcsub = sub.to_rcsim(@rcscope)
|
218
223
|
# RCSim.rcsim_add_scope_scope(@rcscope,rcsub)
|
219
224
|
# end
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
225
|
+
if self.each_scope.any? then
|
226
|
+
RCSim.rcsim_add_scope_scopes(@rcscope,self.each_scope.map do|sub|
|
227
|
+
# sub.to_rcsim(@rcscope)
|
228
|
+
sub.to_rcsim(subowner)
|
229
|
+
end)
|
230
|
+
end
|
224
231
|
|
225
232
|
return @rcscope
|
226
233
|
end
|
@@ -349,11 +356,13 @@ module HDLRuby::High
|
|
349
356
|
# self.each_event do |ev|
|
350
357
|
# RCSim.rcsim_add_behavior_event(@rcbehavior,ev.to_rcsim)
|
351
358
|
# end
|
352
|
-
|
353
|
-
|
354
|
-
|
355
|
-
|
356
|
-
|
359
|
+
if self.each_event.any? then
|
360
|
+
RCSim.rcsim_add_behavior_events(@rcbehavior,
|
361
|
+
self.each_event.map do |ev|
|
362
|
+
# puts "adding event: #{ev.ref.object.name}(#{ev.type})"
|
363
|
+
ev.to_rcsim(@rcbehavior)
|
364
|
+
end)
|
365
|
+
end
|
357
366
|
|
358
367
|
# Create and add the block.
|
359
368
|
RCSim.rcsim_set_behavior_block(@rcbehavior,self.block.to_rcsim)
|
@@ -468,12 +477,15 @@ module HDLRuby::High
|
|
468
477
|
# rcsys = systemT.to_rcsim(@rcsystemI)
|
469
478
|
# RCSim.rcsim_add_systemI_systemT(@rcsystemI,rcsys)
|
470
479
|
# end
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
475
|
-
sys
|
476
|
-
|
480
|
+
if self.each_systemI.any? then
|
481
|
+
RCSim.rcsim_add_systemI_systemTs(@rcsystemI,
|
482
|
+
self.each_systemT.select do|sys|
|
483
|
+
sys != self.systemT
|
484
|
+
end.map do |sys|
|
485
|
+
# sys.to_rcsim(@rcsystemI)
|
486
|
+
sys.to_rcsim(rcowner)
|
487
|
+
end)
|
488
|
+
end
|
477
489
|
|
478
490
|
return @rcsystemI
|
479
491
|
end
|
@@ -531,8 +543,10 @@ module HDLRuby::High
|
|
531
543
|
# self.each_arg do |arg|
|
532
544
|
# RCSim.rcsim_add_print_arg(@rcstatement,arg.to_rcsim)
|
533
545
|
# end
|
534
|
-
|
535
|
-
|
546
|
+
if self.each_arg.any? then
|
547
|
+
RCSim.rcsim_add_print_args(@rcstatement,
|
548
|
+
self.each_arg.map(&:to_rcsim))
|
549
|
+
end
|
536
550
|
|
537
551
|
return @rcstatement
|
538
552
|
end
|
@@ -576,7 +590,9 @@ module HDLRuby::High
|
|
576
590
|
# end
|
577
591
|
rcsim_conds = self.each_noif.map {|cond,stmnt| cond.to_rcsim }
|
578
592
|
rcsim_stmnts = self.each_noif.map {|cond,stmnt| stmnt.to_rcsim }
|
579
|
-
|
593
|
+
if rcsim_conds.any? then
|
594
|
+
RCSim.rcsim_add_hif_noifs(@rcstatement,rcsim_conds,rcsim_stmnts)
|
595
|
+
end
|
580
596
|
|
581
597
|
return @rcstatement
|
582
598
|
end
|
@@ -605,7 +621,10 @@ module HDLRuby::High
|
|
605
621
|
# end
|
606
622
|
rcsim_matches = self.each_when.map {|wh| wh.match.to_rcsim }
|
607
623
|
rcsim_stmnts = self.each_when.map {|wh| wh.statement.to_rcsim }
|
608
|
-
|
624
|
+
if rcsim_matches.any? then
|
625
|
+
RCSim.rcsim_add_hcase_whens(@rcstatement,rcsim_matches,
|
626
|
+
rcsim_stmnts)
|
627
|
+
end
|
609
628
|
|
610
629
|
return @rcstatement
|
611
630
|
end
|
@@ -635,7 +654,21 @@ module HDLRuby::High
|
|
635
654
|
## Extends the TimeRepeat class for hybrid Ruby-C simulation.
|
636
655
|
class TimeRepeat
|
637
656
|
attr_reader :rcstatement
|
638
|
-
|
657
|
+
|
658
|
+
# Generate the C description of the hardware case.
|
659
|
+
# +owner+ is a link to the C description of the owner behavior if any.
|
660
|
+
def to_rcsim(owner = nil)
|
661
|
+
# Create the timeRepeat C object.
|
662
|
+
@rcstatement = RCSim.rcsim_make_timeRepeat(self.number,
|
663
|
+
self.statement.to_rcsim)
|
664
|
+
|
665
|
+
# Sets the owner if any.
|
666
|
+
if owner then
|
667
|
+
RCSim.rcsim_set_owner(@rcstatement,owner)
|
668
|
+
end
|
669
|
+
|
670
|
+
return @rcstatement
|
671
|
+
end
|
639
672
|
end
|
640
673
|
|
641
674
|
|
@@ -651,26 +684,30 @@ module HDLRuby::High
|
|
651
684
|
|
652
685
|
# Sets the owner if any.
|
653
686
|
if owner then
|
654
|
-
RCSim.
|
687
|
+
RCSim.rcsim_set_owner(@rcstatement,owner)
|
655
688
|
end
|
656
689
|
|
657
690
|
# Add the inner signals.
|
658
691
|
# self.each_inner do |inner|
|
659
692
|
# RCSim.rcsim_add_block_inner(@rcstatement,inner.to_rcsim(@rcstatement))
|
660
693
|
# end
|
661
|
-
|
662
|
-
|
663
|
-
|
664
|
-
|
694
|
+
if self.each_inner.any? then
|
695
|
+
RCSim.rcsim_add_block_inners(@rcstatement,
|
696
|
+
self.each_inner.map do |sig|
|
697
|
+
sig.to_rcsim(@rcstatement)
|
698
|
+
end)
|
699
|
+
end
|
665
700
|
|
666
701
|
# Add the statements.
|
667
702
|
# self.each_statement do |stmnt|
|
668
703
|
# RCSim.rcsim_add_block_statement(@rcstatement,stmnt.to_rcsim)
|
669
704
|
# end
|
670
|
-
|
671
|
-
|
672
|
-
|
673
|
-
|
705
|
+
if self.each_statement.any? then
|
706
|
+
RCSim.rcsim_add_block_statements(@rcstatement,
|
707
|
+
self.each_statement.map do |stmnt|
|
708
|
+
stmnt.to_rcsim
|
709
|
+
end)
|
710
|
+
end
|
674
711
|
|
675
712
|
return @rcstatement
|
676
713
|
end
|
@@ -710,7 +747,9 @@ module HDLRuby::High
|
|
710
747
|
rcevs << ev
|
711
748
|
end
|
712
749
|
end
|
713
|
-
|
750
|
+
if rcevs.any? then
|
751
|
+
RCSim.rcsim_add_behavior_events(@rcbehavior,rcevs)
|
752
|
+
end
|
714
753
|
|
715
754
|
# Create and set the block.
|
716
755
|
rcblock = RCSim.rcsim_make_block(:par)
|
@@ -843,8 +882,10 @@ module HDLRuby::High
|
|
843
882
|
# self.each_choice do |choice|
|
844
883
|
# rcsim_add_select_choice(rcexpression,choice.to_rcsim)
|
845
884
|
# end
|
846
|
-
|
847
|
-
|
885
|
+
if self.each_choice.any? then
|
886
|
+
RCSim.rcsim_add_select_choices(rcexpression,
|
887
|
+
self.each_choice.map(&:to_rcsim))
|
888
|
+
end
|
848
889
|
|
849
890
|
return rcexpression
|
850
891
|
end
|
@@ -865,8 +906,10 @@ module HDLRuby::High
|
|
865
906
|
# self.each_expression do |expr|
|
866
907
|
# RCSim.rcsim_add_concat_expression(rcexpression,expr.to_rcsim)
|
867
908
|
# end
|
868
|
-
|
909
|
+
if self.each_expression.any? then
|
910
|
+
RCSim.rcsim_add_concat_expressions(rcexpression,
|
869
911
|
self.each_expression.map(&:to_rcsim))
|
912
|
+
end
|
870
913
|
|
871
914
|
return rcexpression
|
872
915
|
end
|
@@ -901,7 +944,9 @@ module HDLRuby::High
|
|
901
944
|
# self.each_ref do |ref|
|
902
945
|
# RCSim.rcsim_add_refConcat_ref(rcref,ref.to_rcsim)
|
903
946
|
# end
|
904
|
-
|
947
|
+
if self.each_ref.any? then
|
948
|
+
RCSim.rcsim_add_refConcat_refs(rcref,self.each_ref(&:to_rcsim))
|
949
|
+
end
|
905
950
|
|
906
951
|
return rcref
|
907
952
|
end
|
data/lib/HDLRuby/hruby_rsim.rb
CHANGED
@@ -701,7 +701,16 @@ module HDLRuby::High
|
|
701
701
|
##
|
702
702
|
# Describes a timed loop statement: not synthesizable!
|
703
703
|
class TimeRepeat
|
704
|
-
##
|
704
|
+
## Initialize the simulation for system +systemT+.
|
705
|
+
def init_sim(systemT)
|
706
|
+
# Recurde on the statement.
|
707
|
+
self.statement.init_sim(systemT)
|
708
|
+
end
|
709
|
+
|
710
|
+
## Executes the statement.
|
711
|
+
def execute(mode)
|
712
|
+
self.number.times { self.statement.execute(mode) }
|
713
|
+
end
|
705
714
|
end
|
706
715
|
|
707
716
|
|
@@ -179,6 +179,21 @@ module HDLRuby::High
|
|
179
179
|
end
|
180
180
|
end
|
181
181
|
|
182
|
+
##
|
183
|
+
# Enhance the TimeRepeat class with VCD support.
|
184
|
+
class TimeRepeat
|
185
|
+
## Shows the hierarchy of the variables.
|
186
|
+
def show_hierarchy(vcdout)
|
187
|
+
# Recurse on the statement.
|
188
|
+
self.statement.show_hierarchy(vcdout)
|
189
|
+
end
|
190
|
+
|
191
|
+
## Gets the VCD variables with their long name.
|
192
|
+
def get_vars_with_fullname(vars_with_fullname = {})
|
193
|
+
# By default: nothing to do
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
182
197
|
##
|
183
198
|
# Enhance the TimeWait class with VCD support.
|
184
199
|
class TimeWait
|
@@ -254,60 +254,62 @@ module HDLRuby::Low
|
|
254
254
|
|
255
255
|
|
256
256
|
|
257
|
-
#
|
258
|
-
#
|
259
|
-
#
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
287
|
-
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
|
302
|
-
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
end
|
257
|
+
# Deprecated with new TimeRepeat!
|
258
|
+
#
|
259
|
+
# # Extract and convert to verilog the TimeRepeat statements.
|
260
|
+
# # NOTE: work only on the current level of the block (should be called
|
261
|
+
# # through each_block_deep).
|
262
|
+
# def repeat_to_verilog!
|
263
|
+
# code = ""
|
264
|
+
# # Gather the TimeRepeat statements.
|
265
|
+
# repeats = self.each_statement.find_all { |st| st.is_a?(TimeRepeat) }
|
266
|
+
# # Remove them from the block.
|
267
|
+
# repeats.each { |st| self.delete_statement!(st) }
|
268
|
+
# # Generate them separately in timed always processes.
|
269
|
+
# repeats.each do |st|
|
270
|
+
# code << " always #{st.delay.to_verilog} begin\n"
|
271
|
+
|
272
|
+
# # Perform "scheduling" using the method "flatten".
|
273
|
+
# block = st.statement.flatten(st.statement.mode.to_s)
|
274
|
+
|
275
|
+
# # Declaration of "inner" part within "always".
|
276
|
+
# block.each_inner do |inner|
|
277
|
+
# # if regs.include?(inner.name) then
|
278
|
+
# if HDLRuby::Low::VERILOG_REGS.include?(inner.to_verilog) then
|
279
|
+
# code << " reg"
|
280
|
+
# else
|
281
|
+
# code << " wire"
|
282
|
+
# end
|
283
|
+
|
284
|
+
# # Variable has "base", but if there is width etc, it is not in "base".
|
285
|
+
# # It is determined by an if.
|
286
|
+
# if inner.type.base?
|
287
|
+
# if inner.type.base.base?
|
288
|
+
# code << "#{inner.type.base.to_verilog} #{inner.to_verilog} #{inner.type.to_verilog}"
|
289
|
+
# else
|
290
|
+
# code << "#{inner.type.to_verilog} #{inner.to_verilog}"
|
291
|
+
# end
|
292
|
+
# else
|
293
|
+
# code << " #{inner.type.to_verilog}#{inner.to_verilog}"
|
294
|
+
# end
|
295
|
+
# if inner.value then
|
296
|
+
# # There is an initial value.
|
297
|
+
# code << " = #{inner.value.to_verilog}"
|
298
|
+
# end
|
299
|
+
# code << ";\n"
|
300
|
+
# end
|
301
|
+
|
302
|
+
# # Translate the block that finished scheduling.
|
303
|
+
# block.each_statement do |statement|
|
304
|
+
# code << "\n #{statement.to_verilog(block.mode.to_s)}"
|
305
|
+
# end
|
306
|
+
|
307
|
+
# FmI.fm_par.clear()
|
308
|
+
|
309
|
+
# code << "\n end\n\n"
|
310
|
+
# end
|
311
|
+
# return code
|
312
|
+
# end
|
311
313
|
|
312
314
|
|
313
315
|
# Process top layer of Block.
|
@@ -1814,6 +1816,15 @@ module HDLRuby::Low
|
|
1814
1816
|
end
|
1815
1817
|
end
|
1816
1818
|
|
1819
|
+
|
1820
|
+
# Generate verilog code for the TimeRepeat.
|
1821
|
+
class TimeRepeat
|
1822
|
+
def to_verilog(spc = 3)
|
1823
|
+
result = (" " * spc) + "repeat(#{self.number})" + "\n"
|
1824
|
+
result << self.statement.to_verilog(spc+3)
|
1825
|
+
end
|
1826
|
+
end
|
1827
|
+
|
1817
1828
|
# Those who disappeared.
|
1818
1829
|
#class SystemI
|
1819
1830
|
#class TypeTuple
|
@@ -2137,10 +2148,12 @@ module HDLRuby::Low
|
|
2137
2148
|
if behavior.block.is_a?(TimeBlock) then
|
2138
2149
|
# Tell it is a time behavior for further processing.
|
2139
2150
|
timebeh = true
|
2140
|
-
#
|
2141
|
-
|
2142
|
-
|
2143
|
-
|
2151
|
+
# Deprecated with new TimeRepeat.
|
2152
|
+
#
|
2153
|
+
# # Extract and translate the TimeRepeat separately.
|
2154
|
+
# behavior.each_block_deep do |blk|
|
2155
|
+
# codeC << blk.repeat_to_verilog!
|
2156
|
+
# end
|
2144
2157
|
# And generate an initial block.
|
2145
2158
|
codeC << " initial "
|
2146
2159
|
else
|
data/lib/HDLRuby/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: HDLRuby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.11.
|
4
|
+
version: 2.11.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lovic Gauthier
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-10-
|
11
|
+
date: 2022-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- lib/HDLRuby/hdr_samples/ram.rb
|
149
149
|
- lib/HDLRuby/hdr_samples/range_bench.rb
|
150
150
|
- lib/HDLRuby/hdr_samples/register_with_code_bench.rb
|
151
|
+
- lib/HDLRuby/hdr_samples/repeat_bench.rb
|
151
152
|
- lib/HDLRuby/hdr_samples/rom.rb
|
152
153
|
- lib/HDLRuby/hdr_samples/rom_nest.rb
|
153
154
|
- lib/HDLRuby/hdr_samples/ruby_fir_hw.rb
|