HDLRuby 3.8.2 → 3.9.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.md +2229 -1314
- data/ext/hruby_sim/hruby_sim_calc.c +23 -16
- data/lib/HDLRuby/hdr_samples/comparison_bench.rb +36 -0
- data/lib/HDLRuby/hdr_samples/with_henumerable.rb +5 -1
- data/lib/HDLRuby/hdr_samples/with_reduce.rb +10 -10
- data/lib/HDLRuby/hdr_samples/with_sequencer_enumerable.rb +4 -1
- data/lib/HDLRuby/hdrlib.rb +291 -209
- data/lib/HDLRuby/hruby_high.rb +51 -32
- data/lib/HDLRuby/hruby_low2hdr.rb +9 -8
- data/lib/HDLRuby/hruby_low2vhd.rb +1 -1
- data/lib/HDLRuby/std/hruby_enum.rb +26 -5
- data/lib/HDLRuby/std/sequencer.rb +12 -2
- data/lib/HDLRuby/std/sequencer_sw.rb +812 -72
- data/lib/HDLRuby/version.rb +1 -1
- metadata +1 -1
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -61,8 +61,12 @@ module HDLRuby::High
|
|
61
61
|
include SingletonExtend
|
62
62
|
|
63
63
|
# The reserved names
|
64
|
-
RESERVED =
|
65
|
-
|
64
|
+
RESERVED = Set.new(
|
65
|
+
[ :user, :initialize, :add_method, :concat_namespace,
|
66
|
+
:to_namespace, :user?, :user_deep?,
|
67
|
+
|
68
|
+
:sub, :seq, :par, :hif, :helse, :hcase, :hwhen, :mux, :timed
|
69
|
+
])
|
66
70
|
|
67
71
|
# The construct using the namespace.
|
68
72
|
attr_reader :user
|
@@ -423,6 +427,19 @@ module HDLRuby::High
|
|
423
427
|
return RefObject.new(this,self)
|
424
428
|
end
|
425
429
|
|
430
|
+
def [](num,name)
|
431
|
+
name = name.to_sym
|
432
|
+
this = self
|
433
|
+
res = []
|
434
|
+
num.to_i.times do |i|
|
435
|
+
High.top_user.instance_eval do
|
436
|
+
res << send(this.name,HDLRuby.uniq_name(name.to_s + "_#{i}"))
|
437
|
+
end
|
438
|
+
end
|
439
|
+
High.space_reg(name) { res }
|
440
|
+
res
|
441
|
+
end
|
442
|
+
|
426
443
|
# Creates and adds a set of inputs typed +type+ from a list of +names+.
|
427
444
|
#
|
428
445
|
# NOTE: a name can also be a signal, is which case it is duplicated.
|
@@ -970,7 +987,7 @@ module HDLRuby::High
|
|
970
987
|
@metacond ||= nil
|
971
988
|
@metavalue ||= nil
|
972
989
|
match = match ? 1 : 0 if [true,false,nil].include?(match)
|
973
|
-
if match.respond_to?(:to_i) then
|
990
|
+
if @metavalue and match.respond_to?(:to_i) then
|
974
991
|
# The hwen can be evaluate straight away. Do metaprograming.
|
975
992
|
if @metavalue == match.to_i then
|
976
993
|
HDLRuby::High.top_user.sub do
|
@@ -1391,7 +1408,7 @@ module HDLRuby::High
|
|
1391
1408
|
# * the else part is defined through the helse method.
|
1392
1409
|
# * a behavior is created to enclose the hif.
|
1393
1410
|
def hif(condition, mode = nil, &ruby_block)
|
1394
|
-
|
1411
|
+
return if self.metaif(condition,&ruby_block)
|
1395
1412
|
# Ensure there is a block.
|
1396
1413
|
ruby_block = proc {} unless block_given?
|
1397
1414
|
self.par do
|
@@ -1406,7 +1423,7 @@ module HDLRuby::High
|
|
1406
1423
|
#
|
1407
1424
|
# NOTE: added to the hif of the last behavior.
|
1408
1425
|
def helse(mode = nil, &ruby_block)
|
1409
|
-
|
1426
|
+
return if self.metaelse(&ruby_block)
|
1410
1427
|
# Ensure there is a block.
|
1411
1428
|
ruby_block = proc {} unless block_given?
|
1412
1429
|
# There is a ruby_block: the helse is assumed to be with
|
@@ -1423,13 +1440,13 @@ module HDLRuby::High
|
|
1423
1440
|
# with a +condition+ that when met lead
|
1424
1441
|
# to the execution of the block in +mode+ generated by the +ruby_block+.
|
1425
1442
|
def helsif(condition, mode = nil, &ruby_block)
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
1432
|
-
|
1443
|
+
meta = self.metaelsif(condition,&ruby_block)
|
1444
|
+
if meta == :toif then
|
1445
|
+
# Must be converted to hif.
|
1446
|
+
return self.hif(condition,mode, &ruby_block)
|
1447
|
+
elsif meta then
|
1448
|
+
return
|
1449
|
+
end
|
1433
1450
|
# Ensure there is a block.
|
1434
1451
|
ruby_block = proc {} unless block_given?
|
1435
1452
|
# There is a ruby_block: the helse is assumed to be with
|
@@ -1449,7 +1466,7 @@ module HDLRuby::High
|
|
1449
1466
|
# * the when part is defined through the hwhen method.
|
1450
1467
|
# * a new behavior is created to enclose the hcase.
|
1451
1468
|
def hcase(value)
|
1452
|
-
|
1469
|
+
return if self.metacase(value)
|
1453
1470
|
self.par do
|
1454
1471
|
hcase(value)
|
1455
1472
|
end
|
@@ -1460,7 +1477,7 @@ module HDLRuby::High
|
|
1460
1477
|
#
|
1461
1478
|
# Can only be used once.
|
1462
1479
|
def hwhen(match, mode = nil, &ruby_block)
|
1463
|
-
|
1480
|
+
return if self.metawhen(match,&ruby_block)
|
1464
1481
|
# Ensure there is a block.
|
1465
1482
|
ruby_block = proc {} unless block_given?
|
1466
1483
|
# There is a ruby_block: the helse is assumed to be with
|
@@ -2785,7 +2802,7 @@ module HDLRuby::High
|
|
2785
2802
|
obj = self
|
2786
2803
|
::HDLRuby::High.cur_block.delete_statement!(obj)
|
2787
2804
|
# Handles the metaprogramming.
|
2788
|
-
|
2805
|
+
return obj if self.metaif(condition,proc { add_statement(obj) })
|
2789
2806
|
# Creates the if statement.
|
2790
2807
|
stmnt = If.new(condition) { add_statement(obj) }
|
2791
2808
|
# Add it to the current block.
|
@@ -4099,9 +4116,11 @@ module HDLRuby::High
|
|
4099
4116
|
# default produces a Transmit or a Connection.
|
4100
4117
|
def to_expr
|
4101
4118
|
# Remove the connection from the system type.
|
4102
|
-
High.top_user.delete_connection(self)
|
4119
|
+
High.top_user.delete_connection!(self)
|
4120
|
+
self.left.no_parent!
|
4121
|
+
self.right.no_parent!
|
4103
4122
|
# Generate an expression.
|
4104
|
-
return Binary.new(
|
4123
|
+
return Binary.new(self.left.type,:<=,self.left,self.right)
|
4105
4124
|
end
|
4106
4125
|
|
4107
4126
|
# Creates a new behavior sensitive to +event+ including the connection
|
@@ -4134,10 +4153,10 @@ module HDLRuby::High
|
|
4134
4153
|
# NOTE: the else part is defined through the helse method.
|
4135
4154
|
def hif(condition)
|
4136
4155
|
# Handles the metaprogramming.
|
4137
|
-
|
4138
|
-
|
4139
|
-
|
4140
|
-
|
4156
|
+
if self.metaif(condition,proc { left <= right }) then
|
4157
|
+
High.top_user.delete_connection!(self)
|
4158
|
+
return
|
4159
|
+
end
|
4141
4160
|
|
4142
4161
|
# Creates the behavior.
|
4143
4162
|
left, right = self.left, self.right
|
@@ -4528,7 +4547,7 @@ module HDLRuby::High
|
|
4528
4547
|
# NOTE: the else part is defined through the helse method.
|
4529
4548
|
# def hif(condition, mode = nil, &ruby_block)
|
4530
4549
|
def hif(condition, mode = self.mode, &ruby_block)
|
4531
|
-
|
4550
|
+
return if self.metaif(condition,&ruby_block)
|
4532
4551
|
# Ensure there is a block.
|
4533
4552
|
ruby_block = proc {} unless block_given?
|
4534
4553
|
# Creates the if statement.
|
@@ -4540,7 +4559,7 @@ module HDLRuby::High
|
|
4540
4559
|
#
|
4541
4560
|
# Can only be used once.
|
4542
4561
|
def helse(mode = nil, &ruby_block)
|
4543
|
-
|
4562
|
+
return if self.metaelse(&ruby_block)
|
4544
4563
|
# Ensure there is a block.
|
4545
4564
|
ruby_block = proc {} unless block_given?
|
4546
4565
|
# There is a ruby_block: the helse is assumed to be with
|
@@ -4557,13 +4576,13 @@ module HDLRuby::High
|
|
4557
4576
|
# with a +condition+ that when met lead
|
4558
4577
|
# to the execution of the block in +mode+ generated by the +ruby_block+.
|
4559
4578
|
def helsif(condition, mode = nil, &ruby_block)
|
4560
|
-
|
4561
|
-
|
4562
|
-
|
4563
|
-
|
4564
|
-
|
4565
|
-
|
4566
|
-
|
4579
|
+
meta = self.metaelsif(condition,&ruby_block)
|
4580
|
+
if meta == :toif then
|
4581
|
+
# Must be converted to hif.
|
4582
|
+
return self.hif(condition,mode, &ruby_block)
|
4583
|
+
elsif meta then
|
4584
|
+
return
|
4585
|
+
end
|
4567
4586
|
# Ensure there is a block.
|
4568
4587
|
ruby_block = proc {} unless block_given?
|
4569
4588
|
# There is a ruby_block: the helse is assumed to be with
|
@@ -4584,7 +4603,7 @@ module HDLRuby::High
|
|
4584
4603
|
#
|
4585
4604
|
# NOTE: the when part is defined through the hwhen method.
|
4586
4605
|
def hcase(value)
|
4587
|
-
|
4606
|
+
return if self.metacase(value)
|
4588
4607
|
# Creates the case statement.
|
4589
4608
|
self.add_statement(Case.new(value))
|
4590
4609
|
end
|
@@ -4594,7 +4613,7 @@ module HDLRuby::High
|
|
4594
4613
|
#
|
4595
4614
|
# Can only be used once.
|
4596
4615
|
def hwhen(match, mode = nil, &ruby_block)
|
4597
|
-
|
4616
|
+
return if self.metawhen(match,&ruby_block)
|
4598
4617
|
# Ensure there is a block.
|
4599
4618
|
ruby_block = proc {} unless block_given?
|
4600
4619
|
# There is a ruby_block: the helse is assumed to be with
|
@@ -133,7 +133,7 @@ module HDLRuby::Low
|
|
133
133
|
# Generate the inners declaration.
|
134
134
|
self.each_inner do |inner|
|
135
135
|
res << " " * (level*3)
|
136
|
-
res << inner.type.
|
136
|
+
res << inner.type.to_hdr(level)
|
137
137
|
res << ".inner :" << Low2HDR.hdr_decl_name(inner.name) << "\n"
|
138
138
|
end
|
139
139
|
# Generate the instances.
|
@@ -331,7 +331,7 @@ module HDLRuby::Low
|
|
331
331
|
# +level+ is the hierachical level of the object.
|
332
332
|
def to_hdr(level = 0)
|
333
333
|
# Should never be here.
|
334
|
-
raise AnyError, "Internal error:
|
334
|
+
raise AnyError, "Internal error: to_hdr should be implemented in class :#{self.class}"
|
335
335
|
end
|
336
336
|
end
|
337
337
|
|
@@ -449,7 +449,7 @@ module HDLRuby::Low
|
|
449
449
|
# The resulting string.
|
450
450
|
res = " " * (level*3)
|
451
451
|
# Generate the wait.
|
452
|
-
res << "
|
452
|
+
res << "!" << self.delay.to_hdr(level) << "\n"
|
453
453
|
# Return the resulting string.
|
454
454
|
return res
|
455
455
|
end
|
@@ -465,7 +465,8 @@ module HDLRuby::Low
|
|
465
465
|
# The resulting string.
|
466
466
|
res = " " * (level*3)
|
467
467
|
# Generate the header.
|
468
|
-
res << "repeat " << self.delay.to_hdr(level) << " do\n"
|
468
|
+
# res << "repeat " << self.delay.to_hdr(level) << " do\n"
|
469
|
+
res << "repeat " << self.number.to_hdr(level) << " do\n"
|
469
470
|
# Generate the statement to repeat.
|
470
471
|
res << self.statement.to_hdr(level+1)
|
471
472
|
# Close the repeat.
|
@@ -554,7 +555,7 @@ module HDLRuby::Low
|
|
554
555
|
# +level+ is the hierachical level of the object.
|
555
556
|
def to_hdr(level = 0)
|
556
557
|
# Should never be here.
|
557
|
-
raise AnyError, "Internal error:
|
558
|
+
raise AnyError, "Internal error: to_hdr should be implemented in class :#{self.class}"
|
558
559
|
end
|
559
560
|
end
|
560
561
|
|
@@ -566,7 +567,7 @@ module HDLRuby::Low
|
|
566
567
|
# +level+ is the hierachical level of the object.
|
567
568
|
def to_hdr(level = 0)
|
568
569
|
if self.content.is_a?(HDLRuby::BitString) then
|
569
|
-
return "
|
570
|
+
return "_b#{self.content}"
|
570
571
|
else
|
571
572
|
return self.content.to_s
|
572
573
|
end
|
@@ -593,7 +594,7 @@ module HDLRuby::Low
|
|
593
594
|
# +level+ is the hierachical level of the object.
|
594
595
|
def to_hdr(level = 0)
|
595
596
|
# Should never be here.
|
596
|
-
raise AnyError, "Internal error:
|
597
|
+
raise AnyError, "Internal error: to_hdr should be implemented in class :#{self.class}"
|
597
598
|
end
|
598
599
|
end
|
599
600
|
|
@@ -672,7 +673,7 @@ module HDLRuby::Low
|
|
672
673
|
# +level+ is the hierachical level of the object.
|
673
674
|
def to_hdr(level = 0)
|
674
675
|
# Should never be here.
|
675
|
-
raise AnyError, "Internal error:
|
676
|
+
raise AnyError, "Internal error: to_hdr should be implemented in class :#{self.class}"
|
676
677
|
end
|
677
678
|
end
|
678
679
|
|
@@ -1100,7 +1100,7 @@ module HDLRuby::Low
|
|
1100
1100
|
res << "begin\n"
|
1101
1101
|
# Adds the wait.
|
1102
1102
|
res << " " * ((level+1)*3)
|
1103
|
-
res << "wait for " << self.
|
1103
|
+
res << "wait for " << self.number.to_vhdl(level) << ";\n"
|
1104
1104
|
# Generate the remaining of the body.
|
1105
1105
|
res << self.statement.to_vhdl(vars,level+1)
|
1106
1106
|
# Close the process.
|
@@ -331,14 +331,35 @@ module HDLRuby::High::Std
|
|
331
331
|
if ruby_block then
|
332
332
|
# Case when a block is given.
|
333
333
|
res = args[0]
|
334
|
-
|
335
|
-
|
334
|
+
# HDLRuby special: the argument can also be the type.
|
335
|
+
if res.respond_to?(:to_type) then
|
336
|
+
typ = res.to_type
|
337
|
+
res = nil
|
338
|
+
self.heach do |e|
|
339
|
+
res = res ? ruby_block.call(res,e.as(typ)) : e.as(typ)
|
340
|
+
end
|
341
|
+
else
|
342
|
+
self.heach do |e|
|
343
|
+
res = res ? ruby_block.call(res,e) : e
|
344
|
+
end
|
336
345
|
end
|
337
346
|
else
|
338
347
|
# Case when a symbol is given.
|
339
|
-
|
340
|
-
|
341
|
-
|
348
|
+
res, sym = args[0], args[1]
|
349
|
+
if res.is_a?(::Symbol) then
|
350
|
+
sym = res
|
351
|
+
res = nil
|
352
|
+
end
|
353
|
+
if res.respond_to?(:to_type) then
|
354
|
+
typ = res.to_type
|
355
|
+
res = nil
|
356
|
+
self.heach do |e|
|
357
|
+
res = res ? res.send(sym,e.as(typ)) : e.as(typ)
|
358
|
+
end
|
359
|
+
else
|
360
|
+
self.heach do |e|
|
361
|
+
res = res ? res.send(sym,e) : e
|
362
|
+
end
|
342
363
|
end
|
343
364
|
end
|
344
365
|
return res
|
@@ -947,7 +947,12 @@ module HDLRuby::High::Std
|
|
947
947
|
enum = self.seach
|
948
948
|
# Define the computation type: from the initial value if any,
|
949
949
|
# otherwise from the enum.
|
950
|
-
|
950
|
+
if init.respond_to?(:to_type) then
|
951
|
+
typ = init.to_type
|
952
|
+
init = nil
|
953
|
+
else
|
954
|
+
typ = init ? init.to_expr.type : enum.type
|
955
|
+
end
|
951
956
|
# Generate the result signal.
|
952
957
|
res = nil
|
953
958
|
HDLRuby::High.cur_system.open do
|
@@ -2155,7 +2160,9 @@ module HDLRuby::High::Std
|
|
2155
2160
|
|
2156
2161
|
# HW times iteration.
|
2157
2162
|
def stimes(&ruby_block)
|
2158
|
-
#
|
2163
|
+
# Ensures there is a ruby block. This allows to use empty while
|
2164
|
+
# statement.
|
2165
|
+
ruby_block = proc { } unless ruby_block
|
2159
2166
|
return AnyRange.new(0,self-1).seach(&ruby_block)
|
2160
2167
|
end
|
2161
2168
|
|
@@ -2320,6 +2327,9 @@ module HDLRuby::High::Std
|
|
2320
2327
|
|
2321
2328
|
# HW times iteration.
|
2322
2329
|
def stimes(&ruby_block)
|
2330
|
+
# Ensures there is a ruby block. This allows to use empty while
|
2331
|
+
# statement.
|
2332
|
+
ruby_block = proc { } unless ruby_block
|
2323
2333
|
return (0..self-1).seach(&ruby_block)
|
2324
2334
|
end
|
2325
2335
|
|