HDLRuby 2.10.3 → 2.10.5
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/lib/HDLRuby/hdr_samples/dff_bench.rb +4 -1
- data/lib/HDLRuby/hdr_samples/dff_override.rb +76 -0
- data/lib/HDLRuby/hdr_samples/with_values.rb +14 -0
- data/lib/HDLRuby/hdrcc.rb +30 -13
- data/lib/HDLRuby/hruby_high.rb +67 -7
- data/lib/HDLRuby/hruby_low.rb +69 -48
- data/lib/HDLRuby/hruby_low_mutable.rb +1 -1
- data/lib/HDLRuby/hruby_low_without_namespace.rb +2 -1
- data/lib/HDLRuby/std/handshakes.rb +1 -1
- data/lib/HDLRuby/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 57f711573af1646f1dc678be203b16a119744cc09f5e1d2a3e7adce5b8363579
|
4
|
+
data.tar.gz: b5880098c778a28c820c879a77be3730c945fb2efb8d2771e787c0377184a1a2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f19830b5bccdebeb4359d09be4e5222d7b0a39fccaa6a346ead07b1b62e21bf4195dda796d4237cf56aaa8ca41f0a8bb1e2b67b12e945e2647922d8e966861e1
|
7
|
+
data.tar.gz: ebc946677fd8c44d00374f62bcc55b7146fa5f84a0f15e32478a7fa2aa4cfc61ab108ea2da07668acad4534bdae6655a042d16237d3275296b07b12e64b59918
|
@@ -0,0 +1,76 @@
|
|
1
|
+
# A simple D-FF with overridable part.
|
2
|
+
system :dff do
|
3
|
+
input :d, :clk, :rst
|
4
|
+
output :q
|
5
|
+
|
6
|
+
sub(:process) do
|
7
|
+
(q <= d & ~rst).at(clk.posedge)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
# A new dff overriding process.
|
12
|
+
system :dff_neg, dff do
|
13
|
+
sub(:process) do
|
14
|
+
(q <= d & ~rst).at(clk.negedge)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
# A benchmark for the dff.
|
19
|
+
system :dff_bench do
|
20
|
+
inner :d, :clk, :rst
|
21
|
+
inner :q
|
22
|
+
|
23
|
+
dff_neg(:my_dff).(d,clk,rst,q)
|
24
|
+
# dff(:my_dff).(d,clk,rst,q)
|
25
|
+
|
26
|
+
timed do
|
27
|
+
clk <= 1
|
28
|
+
rst <= 0
|
29
|
+
d <= _z
|
30
|
+
!10.ns
|
31
|
+
clk <= 0
|
32
|
+
rst <= 0
|
33
|
+
d <= _z
|
34
|
+
!10.ns
|
35
|
+
clk <= 1
|
36
|
+
rst <= 1
|
37
|
+
d <= _z
|
38
|
+
!10.ns
|
39
|
+
clk <= 0
|
40
|
+
rst <= 1
|
41
|
+
d <= _z
|
42
|
+
!10.ns
|
43
|
+
clk <= 1
|
44
|
+
rst <= 0
|
45
|
+
d <= 1
|
46
|
+
!10.ns
|
47
|
+
clk <= 0
|
48
|
+
rst <= 0
|
49
|
+
d <= 1
|
50
|
+
!10.ns
|
51
|
+
clk <= 1
|
52
|
+
rst <= 0
|
53
|
+
d <= 1
|
54
|
+
!10.ns
|
55
|
+
clk <= 0
|
56
|
+
rst <= 0
|
57
|
+
d <= 1
|
58
|
+
!10.ns
|
59
|
+
clk <= 1
|
60
|
+
rst <= 0
|
61
|
+
d <= 0
|
62
|
+
!10.ns
|
63
|
+
clk <= 0
|
64
|
+
rst <= 0
|
65
|
+
d <= 0
|
66
|
+
!10.ns
|
67
|
+
clk <= 1
|
68
|
+
rst <= 0
|
69
|
+
d <= 0
|
70
|
+
!10.ns
|
71
|
+
clk <= 0
|
72
|
+
rst <= 0
|
73
|
+
d <= 0
|
74
|
+
!10.ns
|
75
|
+
end
|
76
|
+
end
|
@@ -37,6 +37,20 @@ system :with_values do
|
|
37
37
|
v64 <= 128
|
38
38
|
v96 <= 128
|
39
39
|
!10.ns
|
40
|
+
v8 <= -1
|
41
|
+
v16 <= -1
|
42
|
+
v32 <= -1
|
43
|
+
v56 <= -1
|
44
|
+
v64 <= -1
|
45
|
+
v96 <= -1
|
46
|
+
!10.ns
|
47
|
+
v8 <= -2
|
48
|
+
v16 <= -2
|
49
|
+
v32 <= -2
|
50
|
+
v56 <= -2
|
51
|
+
v64 <= -2
|
52
|
+
v96 <= -2
|
53
|
+
!10.ns
|
40
54
|
v16 <= 0x1000
|
41
55
|
v32 <= 0x1000
|
42
56
|
v56 <= 0x1000
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
@@ -36,6 +36,22 @@ if ARGV.include?("-I") || ARGV.include?("--interactive") then
|
|
36
36
|
abort
|
37
37
|
end
|
38
38
|
|
39
|
+
|
40
|
+
begin
|
41
|
+
# We can check the memory.
|
42
|
+
require 'get_process_mem'
|
43
|
+
$memory_check = GetProcessMem.new
|
44
|
+
def show_mem
|
45
|
+
" | "+$memory_check.bytes.to_s+"B"
|
46
|
+
end
|
47
|
+
rescue LoadError
|
48
|
+
# We cannot check the memory.
|
49
|
+
def show_mem
|
50
|
+
""
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
39
55
|
require 'fileutils'
|
40
56
|
require 'tempfile'
|
41
57
|
require 'HDLRuby'
|
@@ -67,6 +83,7 @@ require 'HDLRuby/backend/hruby_c_allocator'
|
|
67
83
|
|
68
84
|
require 'HDLRuby/version.rb'
|
69
85
|
|
86
|
+
|
70
87
|
##
|
71
88
|
# HDLRuby compiler interface program
|
72
89
|
#####################################
|
@@ -525,7 +542,7 @@ if $options[:syntax] then
|
|
525
542
|
$output << $loader.show_all
|
526
543
|
exit
|
527
544
|
end
|
528
|
-
HDLRuby.show Time.now
|
545
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
529
546
|
HDLRuby.show "##### Starting parser #####"
|
530
547
|
|
531
548
|
if $options[:debug] then
|
@@ -538,11 +555,11 @@ end
|
|
538
555
|
|
539
556
|
# Generate the result.
|
540
557
|
# Get the top systemT.
|
541
|
-
HDLRuby.show Time.now
|
558
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
542
559
|
$top_system = $top_instance.to_low.systemT
|
543
560
|
$top_intance = nil # Free as much memory as possible.
|
544
561
|
HDLRuby.show "##### Top system built #####"
|
545
|
-
HDLRuby.show Time.now
|
562
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
546
563
|
|
547
564
|
|
548
565
|
# # Apply the pre drivers if any.
|
@@ -613,19 +630,19 @@ elsif $options[:clang] then
|
|
613
630
|
# Coverts the par blocks in seq blocks to seq blocks to match
|
614
631
|
# the simulation engine.
|
615
632
|
systemT.par_in_seq2seq!
|
616
|
-
HDLRuby.show Time.now
|
633
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
617
634
|
HDLRuby.show "connections_to_behaviors step..."
|
618
635
|
# Converts the connections to behaviors.
|
619
636
|
systemT.connections_to_behaviors!
|
620
|
-
HDLRuby.show Time.now
|
637
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
621
638
|
# Break the RefConcat.
|
622
639
|
HDLRuby.show "concat_assigns step..."
|
623
640
|
systemT.break_concat_assigns!
|
624
|
-
HDLRuby.show Time.now
|
641
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
625
642
|
# Explicits the types.
|
626
643
|
HDLRuby.show "explicit_types step..."
|
627
644
|
systemT.explicit_types!
|
628
|
-
HDLRuby.show Time.now
|
645
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
629
646
|
end
|
630
647
|
# Generate the C.
|
631
648
|
if $options[:multiple] then
|
@@ -768,23 +785,23 @@ elsif $options[:verilog] then
|
|
768
785
|
# HDLRuby.show Time.now
|
769
786
|
HDLRuby.show "to_upper_space! step..."
|
770
787
|
systemT.to_upper_space!
|
771
|
-
HDLRuby.show Time.now
|
788
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
772
789
|
end
|
773
790
|
HDLRuby.show "to_global_space! step (global)..."
|
774
791
|
$top_system.to_global_systemTs!
|
775
|
-
HDLRuby.show Time.now
|
792
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
776
793
|
$top_system.each_systemT_deep do |systemT|
|
777
794
|
## systemT.break_types!
|
778
795
|
## systemT.expand_types!
|
779
796
|
HDLRuby.show "par_in_seq2seq! step..."
|
780
797
|
systemT.par_in_seq2seq!
|
781
|
-
HDLRuby.show Time.now
|
798
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
782
799
|
HDLRuby.show "initial_concat_to_timed! step..."
|
783
800
|
systemT.initial_concat_to_timed!
|
784
|
-
HDLRuby.show Time.now
|
801
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
785
802
|
HDLRuby.show "with_port! step..."
|
786
803
|
systemT.with_port!
|
787
|
-
HDLRuby.show Time.now
|
804
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
788
805
|
end
|
789
806
|
# # Verilog generation
|
790
807
|
# $output << top_system.to_verilog
|
@@ -875,7 +892,7 @@ elsif $options[:vhdl] then
|
|
875
892
|
end
|
876
893
|
|
877
894
|
HDLRuby.show "##### Code generated #####"
|
878
|
-
HDLRuby.show Time.now
|
895
|
+
HDLRuby.show "#{Time.now}#{show_mem}"
|
879
896
|
|
880
897
|
# # Apply the post drivers if any.
|
881
898
|
# Hdecorator.each_with_property(:post_driver) do |obj, value|
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -38,7 +38,7 @@ module HDLRuby::High
|
|
38
38
|
# puts "eigen_extend for #{self} class=#{self.class}"
|
39
39
|
obj.singleton_methods.each do |name|
|
40
40
|
next if name == :yaml_tag # Do not know why we need to skip
|
41
|
-
|
41
|
+
puts "name=#{name}"
|
42
42
|
self.define_singleton_method(name, &obj.singleton_method(name))
|
43
43
|
end
|
44
44
|
end
|
@@ -87,10 +87,11 @@ module HDLRuby::High
|
|
87
87
|
raise AnyError,
|
88
88
|
"Resevered name #{name} cannot be overridden."
|
89
89
|
end
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
90
|
+
# Deactivated: overriding is now accepted.
|
91
|
+
# if self.respond_to?(name) then
|
92
|
+
# raise AnyError,
|
93
|
+
# "Symbol #{name} is already defined."
|
94
|
+
# end
|
94
95
|
define_singleton_method(name,&ruby_block)
|
95
96
|
end
|
96
97
|
end
|
@@ -669,7 +670,6 @@ module HDLRuby::High
|
|
669
670
|
# Fill the public namespace
|
670
671
|
space = self.public_namespace
|
671
672
|
# Interface signals
|
672
|
-
# puts "i_name=#{i_name} @to_includes=#{@to_includes.size}"
|
673
673
|
self.each_signal do |signal|
|
674
674
|
# puts "signal=#{signal.name}"
|
675
675
|
space.send(:define_singleton_method,signal.name) do
|
@@ -1181,6 +1181,8 @@ module HDLRuby::High
|
|
1181
1181
|
|
1182
1182
|
# Declares a sub scope with possible +name+ and built from +ruby_block+.
|
1183
1183
|
def sub(name = :"", &ruby_block)
|
1184
|
+
# Ensure there is a block.
|
1185
|
+
ruby_block = proc {} unless block_given?
|
1184
1186
|
# Creates the new scope.
|
1185
1187
|
# scope = Scope.new(name,&ruby_block)
|
1186
1188
|
scope = Scope.new(name)
|
@@ -1197,6 +1199,8 @@ module HDLRuby::High
|
|
1197
1199
|
# Declares a high-level sequential behavior activated on a list of
|
1198
1200
|
# +events+, and built by executing +ruby_block+.
|
1199
1201
|
def seq(*events, &ruby_block)
|
1202
|
+
# Ensure there is a block.
|
1203
|
+
ruby_block = proc {} unless block_given?
|
1200
1204
|
# Preprocess the events.
|
1201
1205
|
events.map! do |event|
|
1202
1206
|
event.respond_to?(:to_event) ? event.to_event : event
|
@@ -1208,6 +1212,8 @@ module HDLRuby::High
|
|
1208
1212
|
# Declares a high-level parallel behavior activated on a list of
|
1209
1213
|
# +events+, and built by executing +ruby_block+.
|
1210
1214
|
def par(*events, &ruby_block)
|
1215
|
+
# Ensure there is a block.
|
1216
|
+
ruby_block = proc {} unless block_given?
|
1211
1217
|
# Preprocess the events.
|
1212
1218
|
events.map! do |event|
|
1213
1219
|
event.respond_to?(:to_event) ? event.to_event : event
|
@@ -1219,6 +1225,8 @@ module HDLRuby::High
|
|
1219
1225
|
# Declares a high-level timed behavior built by executing +ruby_block+.
|
1220
1226
|
# By default, timed behavior are sequential.
|
1221
1227
|
def timed(&ruby_block)
|
1228
|
+
# Ensure there is a block.
|
1229
|
+
ruby_block = proc {} unless block_given?
|
1222
1230
|
# Create and add the resulting behavior.
|
1223
1231
|
self.add_behavior(TimeBehavior.new(:seq,&ruby_block))
|
1224
1232
|
end
|
@@ -1232,6 +1240,8 @@ module HDLRuby::High
|
|
1232
1240
|
# * the else part is defined through the helse method.
|
1233
1241
|
# * a behavior is created to enclose the hif.
|
1234
1242
|
def hif(condition, mode = nil, &ruby_block)
|
1243
|
+
# Ensure there is a block.
|
1244
|
+
ruby_block = proc {} unless block_given?
|
1235
1245
|
self.par do
|
1236
1246
|
hif(condition,mode,&ruby_block)
|
1237
1247
|
end
|
@@ -1244,6 +1254,8 @@ module HDLRuby::High
|
|
1244
1254
|
#
|
1245
1255
|
# NOTE: added to the hif of the last behavior.
|
1246
1256
|
def helse(mode = nil, &ruby_block)
|
1257
|
+
# Ensure there is a block.
|
1258
|
+
ruby_block = proc {} unless block_given?
|
1247
1259
|
# There is a ruby_block: the helse is assumed to be with
|
1248
1260
|
# the last statement of the last behavior.
|
1249
1261
|
statement = self.last_behavior.last_statement
|
@@ -1258,6 +1270,8 @@ module HDLRuby::High
|
|
1258
1270
|
# with a +condition+ that when met lead
|
1259
1271
|
# to the execution of the block in +mode+ generated by the +ruby_block+.
|
1260
1272
|
def helsif(condition, mode = nil, &ruby_block)
|
1273
|
+
# Ensure there is a block.
|
1274
|
+
ruby_block = proc {} unless block_given?
|
1261
1275
|
# There is a ruby_block: the helse is assumed to be with
|
1262
1276
|
# the last statement of the last behavior.
|
1263
1277
|
statement = self.last_behavior.last_statement
|
@@ -1285,6 +1299,8 @@ module HDLRuby::High
|
|
1285
1299
|
#
|
1286
1300
|
# Can only be used once.
|
1287
1301
|
def hwhen(match, mode = nil, &ruby_block)
|
1302
|
+
# Ensure there is a block.
|
1303
|
+
ruby_block = proc {} unless block_given?
|
1288
1304
|
# There is a ruby_block: the helse is assumed to be with
|
1289
1305
|
# the last statement of the last behavior.
|
1290
1306
|
statement = @behaviors.last.last_statement
|
@@ -1607,6 +1623,8 @@ module HDLRuby::High
|
|
1607
1623
|
|
1608
1624
|
# Redefinition of +operator+.
|
1609
1625
|
def define_operator(operator,&ruby_block)
|
1626
|
+
# Ensure there is a block.
|
1627
|
+
ruby_block = proc {} unless block_given?
|
1610
1628
|
# Register the operator as overloaded.
|
1611
1629
|
@overloads ||= {}
|
1612
1630
|
@overloads[operator] = ruby_block
|
@@ -2003,6 +2021,8 @@ module HDLRuby::High
|
|
2003
2021
|
# Declares a high-level generic type named +name+, and using +ruby_block+
|
2004
2022
|
# for construction.
|
2005
2023
|
def typedef(name, &ruby_block)
|
2024
|
+
# Ensure there is a block.
|
2025
|
+
ruby_block = proc {} unless block_given?
|
2006
2026
|
type = TypeGen.new(name,&ruby_block)
|
2007
2027
|
if HDLRuby::High.in_system? then
|
2008
2028
|
# Must be inside a scope.
|
@@ -2038,6 +2058,8 @@ module HDLRuby::High
|
|
2038
2058
|
# Declares a high-level system type named +name+, with +includes+ mixins
|
2039
2059
|
# system types and using +ruby_block+ for instantiating.
|
2040
2060
|
def system(name = :"", *includes, &ruby_block)
|
2061
|
+
# Ensure there is a block.
|
2062
|
+
ruby_block = proc {} unless block_given?
|
2041
2063
|
# print "system ruby_block=#{ruby_block}\n"
|
2042
2064
|
# Creates the resulting system.
|
2043
2065
|
return SystemT.new(name,*includes,&ruby_block)
|
@@ -2049,6 +2071,8 @@ module HDLRuby::High
|
|
2049
2071
|
# NOTE: this is for generating directly an instance without declaring
|
2050
2072
|
# it system type.
|
2051
2073
|
def instance(name, *includes, &ruby_block)
|
2074
|
+
# Ensure there is a block.
|
2075
|
+
ruby_block = proc {} unless block_given?
|
2052
2076
|
# Creates the system type.
|
2053
2077
|
systemT = system(:"",*includes,&ruby_block)
|
2054
2078
|
# Instantiate it with +name+.
|
@@ -2061,6 +2085,8 @@ module HDLRuby::High
|
|
2061
2085
|
#
|
2062
2086
|
# NOTE: a function is a short-cut for a method that creates a scope.
|
2063
2087
|
def function(name, &ruby_block)
|
2088
|
+
# Ensure there is a block.
|
2089
|
+
ruby_block = proc {} unless block_given?
|
2064
2090
|
if HDLRuby::High.in_system? then
|
2065
2091
|
define_singleton_method(name.to_sym) do |*args,&other_block|
|
2066
2092
|
# sub do
|
@@ -2199,6 +2225,8 @@ module HDLRuby::High
|
|
2199
2225
|
# NOTE: actually executes +ruby_block+ in the context of the
|
2200
2226
|
# systemT.
|
2201
2227
|
def open(&ruby_block)
|
2228
|
+
# Ensure there is a block.
|
2229
|
+
ruby_block = proc {} unless block_given?
|
2202
2230
|
# Extend the eigen system.
|
2203
2231
|
@systemT.run(&ruby_block)
|
2204
2232
|
# Update the methods.
|
@@ -2260,7 +2288,15 @@ module HDLRuby::High
|
|
2260
2288
|
# system type.
|
2261
2289
|
def method_missing(m, *args, &ruby_block)
|
2262
2290
|
# print "method_missing in class=#{self.class} with m=#{m}\n"
|
2263
|
-
|
2291
|
+
# Maybe its a signal reference.
|
2292
|
+
signal = self.systemT.get_signal_with_included(m)
|
2293
|
+
if signal then
|
2294
|
+
# Yes, create the reference.
|
2295
|
+
return RefObject.new(self.to_ref,signal)
|
2296
|
+
else
|
2297
|
+
# No try elsewhere
|
2298
|
+
self.public_namespace.send(m,*args,&ruby_block)
|
2299
|
+
end
|
2264
2300
|
end
|
2265
2301
|
|
2266
2302
|
|
@@ -2395,6 +2431,8 @@ module HDLRuby::High
|
|
2395
2431
|
#
|
2396
2432
|
# Can only be used once.
|
2397
2433
|
def helse(mode = nil, &ruby_block)
|
2434
|
+
# Ensure there is a block.
|
2435
|
+
ruby_block = proc {} unless block_given?
|
2398
2436
|
# If there is a no block, it is an error.
|
2399
2437
|
raise AnyError, "Cannot have two helse for a single if statement." if self.no
|
2400
2438
|
# Create the no block if required
|
@@ -2409,6 +2447,8 @@ module HDLRuby::High
|
|
2409
2447
|
#
|
2410
2448
|
# Can only be used if the no-block is not set yet.
|
2411
2449
|
def helsif(next_cond, mode = nil, &ruby_block)
|
2450
|
+
# Ensure there is a block.
|
2451
|
+
ruby_block = proc {} unless block_given?
|
2412
2452
|
# If there is a no block, it is an error.
|
2413
2453
|
raise AnyError, "Cannot have an helsif after an helse." if self.no
|
2414
2454
|
# Create the noif block if required
|
@@ -2477,6 +2517,8 @@ module HDLRuby::High
|
|
2477
2517
|
#
|
2478
2518
|
# Can only be used once for the given +match+.
|
2479
2519
|
def hwhen(match, mode = nil, &ruby_block)
|
2520
|
+
# Ensure there is a block.
|
2521
|
+
ruby_block = proc {} unless block_given?
|
2480
2522
|
# Create the nu block if required
|
2481
2523
|
when_block = High.make_block(mode,&ruby_block)
|
2482
2524
|
# Adds the case.
|
@@ -2488,6 +2530,8 @@ module HDLRuby::High
|
|
2488
2530
|
#
|
2489
2531
|
# Can only be used once.
|
2490
2532
|
def helse(mode = nil, &ruby_block)
|
2533
|
+
# Ensure there is a block.
|
2534
|
+
ruby_block = proc {} unless block_given?
|
2491
2535
|
# Create the nu block if required
|
2492
2536
|
default_block = High.make_block(mode,&ruby_block)
|
2493
2537
|
# Sets the default block.
|
@@ -3859,11 +3903,15 @@ module HDLRuby::High
|
|
3859
3903
|
# Creates a new block with the current mode with possible +name+ and
|
3860
3904
|
# built from +ruby_block+.
|
3861
3905
|
def sub(name = :"", &ruby_block)
|
3906
|
+
# Ensure there is a block.
|
3907
|
+
ruby_block = proc {} unless block_given?
|
3862
3908
|
self.add_block(self.mode,name,&ruby_block)
|
3863
3909
|
end
|
3864
3910
|
|
3865
3911
|
# Adds statements at the top of the block.
|
3866
3912
|
def unshift(&ruby_block)
|
3913
|
+
# Ensure there is a block.
|
3914
|
+
ruby_block = proc {} unless block_given?
|
3867
3915
|
# Create a sub block for the statements.
|
3868
3916
|
block = High.make_block(self.mode,:"",&ruby_block)
|
3869
3917
|
# Unshifts it.
|
@@ -3908,6 +3956,8 @@ module HDLRuby::High
|
|
3908
3956
|
#
|
3909
3957
|
# NOTE: the else part is defined through the helse method.
|
3910
3958
|
def hif(condition, mode = nil, &ruby_block)
|
3959
|
+
# Ensure there is a block.
|
3960
|
+
ruby_block = proc {} unless block_given?
|
3911
3961
|
# Creates the if statement.
|
3912
3962
|
self.add_statement(If.new(condition,mode,&ruby_block))
|
3913
3963
|
end
|
@@ -3917,6 +3967,8 @@ module HDLRuby::High
|
|
3917
3967
|
#
|
3918
3968
|
# Can only be used once.
|
3919
3969
|
def helse(mode = nil, &ruby_block)
|
3970
|
+
# Ensure there is a block.
|
3971
|
+
ruby_block = proc {} unless block_given?
|
3920
3972
|
# There is a ruby_block: the helse is assumed to be with
|
3921
3973
|
# the hif in the same block.
|
3922
3974
|
# Completes the hif or the hcase statement.
|
@@ -3931,6 +3983,8 @@ module HDLRuby::High
|
|
3931
3983
|
# with a +condition+ that when met lead
|
3932
3984
|
# to the execution of the block in +mode+ generated by the +ruby_block+.
|
3933
3985
|
def helsif(condition, mode = nil, &ruby_block)
|
3986
|
+
# Ensure there is a block.
|
3987
|
+
ruby_block = proc {} unless block_given?
|
3934
3988
|
# There is a ruby_block: the helse is assumed to be with
|
3935
3989
|
# the hif in the same block.
|
3936
3990
|
# Completes the hif statement.
|
@@ -3958,6 +4012,8 @@ module HDLRuby::High
|
|
3958
4012
|
#
|
3959
4013
|
# Can only be used once.
|
3960
4014
|
def hwhen(match, mode = nil, &ruby_block)
|
4015
|
+
# Ensure there is a block.
|
4016
|
+
ruby_block = proc {} unless block_given?
|
3961
4017
|
# There is a ruby_block: the helse is assumed to be with
|
3962
4018
|
# the hif in the same block.
|
3963
4019
|
# Completes the hcase statement.
|
@@ -4073,6 +4129,8 @@ module HDLRuby::High
|
|
4073
4129
|
# Adds a loop until +delay+ statement in the block in +mode+ whose
|
4074
4130
|
# loop content is built using +ruby_block+.
|
4075
4131
|
def repeat(delay, mode = nil, &ruby_block)
|
4132
|
+
# Ensure there is a block.
|
4133
|
+
ruby_block = proc {} unless block_given?
|
4076
4134
|
# Build the content block.
|
4077
4135
|
content = High.make_block(mode,&ruby_block)
|
4078
4136
|
# Create and add the statement.
|
@@ -4731,6 +4789,8 @@ module HDLRuby::High
|
|
4731
4789
|
# Creates a hcase statement executing +ruby_block+ on the element of
|
4732
4790
|
# the array selected by +value+
|
4733
4791
|
def hcase(value,&ruby_block)
|
4792
|
+
# Ensure there is a block.
|
4793
|
+
ruby_block = proc {} unless block_given?
|
4734
4794
|
High.cur_block.hcase(value)
|
4735
4795
|
self.each.with_index do |elem,i|
|
4736
4796
|
High.cur_block.hwhen(i) { ruby_block.call(elem) }
|
data/lib/HDLRuby/hruby_low.rb
CHANGED
@@ -190,14 +190,22 @@ module HDLRuby::Low
|
|
190
190
|
raise AnyError,
|
191
191
|
"Invalid class for a signal instance: #{signal.class}"
|
192
192
|
end
|
193
|
+
# if @inputs.include?(signal) then
|
194
|
+
# raise AnyError, "SignalI #{signal.name} already present."
|
195
|
+
# end
|
193
196
|
if @inputs.include?(signal) then
|
194
|
-
|
197
|
+
signal.parent = self
|
198
|
+
# Replace the signal.
|
199
|
+
old_signal = @inputs[signal.name]
|
200
|
+
@inputs.add(signal)
|
201
|
+
@interface[@interface.index(old_signal)] = signal
|
202
|
+
else
|
203
|
+
# Set the parent of the signal.
|
204
|
+
signal.parent = self
|
205
|
+
# And add the signal.
|
206
|
+
@inputs.add(signal)
|
207
|
+
@interface << signal
|
195
208
|
end
|
196
|
-
# Set the parent of the signal.
|
197
|
-
signal.parent = self
|
198
|
-
# And add the signal.
|
199
|
-
@inputs.add(signal)
|
200
|
-
@interface << signal
|
201
209
|
return signal
|
202
210
|
end
|
203
211
|
|
@@ -208,14 +216,22 @@ module HDLRuby::Low
|
|
208
216
|
raise AnyError,
|
209
217
|
"Invalid class for a signal instance: #{signal.class}"
|
210
218
|
end
|
219
|
+
# if @outputs.include?(signal) then
|
220
|
+
# raise AnyError, "SignalI #{signal.name} already present."
|
221
|
+
# end
|
211
222
|
if @outputs.include?(signal) then
|
212
|
-
|
223
|
+
signal.parent = self
|
224
|
+
# Replace the signal.
|
225
|
+
old_signal = @outputs[signal.name]
|
226
|
+
@outputs.add(signal)
|
227
|
+
@interface[@interface.index(old_signal)] = signal
|
228
|
+
else
|
229
|
+
# Set the parent of the signal.
|
230
|
+
signal.parent = self
|
231
|
+
# And add the signal.
|
232
|
+
@outputs.add(signal)
|
233
|
+
@interface << signal
|
213
234
|
end
|
214
|
-
# Set the parent of the signal.
|
215
|
-
signal.parent = self
|
216
|
-
# And add the signal.
|
217
|
-
@outputs.add(signal)
|
218
|
-
@interface << signal
|
219
235
|
return signal
|
220
236
|
end
|
221
237
|
|
@@ -226,14 +242,22 @@ module HDLRuby::Low
|
|
226
242
|
raise AnyError,
|
227
243
|
"Invalid class for a signal instance: #{signal.class}"
|
228
244
|
end
|
245
|
+
# if @inouts.include?(signal) then
|
246
|
+
# raise AnyError, "SignalI #{signal.name} already present."
|
247
|
+
# end
|
229
248
|
if @inouts.include?(signal) then
|
230
|
-
|
249
|
+
signal.parent = self
|
250
|
+
# Replace the signal.
|
251
|
+
old_signal = @inouts[signal.name]
|
252
|
+
@inouts.add(signal)
|
253
|
+
@interface[@interface.index(old_signal)] = signal
|
254
|
+
else
|
255
|
+
# Set the parent of the signal.
|
256
|
+
signal.parent = self
|
257
|
+
# And add the signal.
|
258
|
+
@inouts.add(signal)
|
259
|
+
@interface << signal
|
231
260
|
end
|
232
|
-
# Set the parent of the signal.
|
233
|
-
signal.parent = self
|
234
|
-
# And add the signal.
|
235
|
-
@inouts.add(signal)
|
236
|
-
@interface << signal
|
237
261
|
return signal
|
238
262
|
end
|
239
263
|
|
@@ -571,9 +595,9 @@ module HDLRuby::Low
|
|
571
595
|
raise AnyError,
|
572
596
|
"Invalid class for a system type: #{systemT.class}"
|
573
597
|
end
|
574
|
-
if @systemTs.include?(systemT) then
|
575
|
-
|
576
|
-
end
|
598
|
+
# if @systemTs.include?(systemT) then
|
599
|
+
# raise AnyError, "SystemT #{systemT.name} already present."
|
600
|
+
# end
|
577
601
|
# Set the parent of the instance
|
578
602
|
systemT.parent = self
|
579
603
|
# puts "systemT = #{systemT}, parent=#{self}"
|
@@ -623,9 +647,9 @@ module HDLRuby::Low
|
|
623
647
|
raise AnyError,
|
624
648
|
"Invalid class for a type: #{type.class}"
|
625
649
|
end
|
626
|
-
if @types.include?(type) then
|
627
|
-
|
628
|
-
end
|
650
|
+
# if @types.include?(type) then
|
651
|
+
# raise AnyError, "Type #{type.name} already present."
|
652
|
+
# end
|
629
653
|
# Set the parent of the instance
|
630
654
|
type.parent = self
|
631
655
|
# puts "type = #{type}, parent=#{self}"
|
@@ -676,12 +700,14 @@ module HDLRuby::Low
|
|
676
700
|
raise AnyError,
|
677
701
|
"Invalid class for a system instance: #{scope.class}"
|
678
702
|
end
|
679
|
-
if @scopes.include?(scope) then
|
680
|
-
|
681
|
-
end
|
703
|
+
# if @scopes.include?(scope) then
|
704
|
+
# raise AnyError, "Scope #{scope} already present."
|
705
|
+
# end
|
682
706
|
# Set the parent of the scope
|
683
707
|
scope.parent = self
|
684
|
-
#
|
708
|
+
# Remove a former scope with same name if present (override)
|
709
|
+
@scopes.delete_if { |sc| sc.name && sc.name == scope.name }
|
710
|
+
# Add the scope
|
685
711
|
@scopes << scope
|
686
712
|
end
|
687
713
|
|
@@ -732,9 +758,9 @@ module HDLRuby::Low
|
|
732
758
|
raise AnyError,
|
733
759
|
"Invalid class for a system instance: #{systemI.class}"
|
734
760
|
end
|
735
|
-
if @systemIs.include?(systemI) then
|
736
|
-
|
737
|
-
end
|
761
|
+
# if @systemIs.include?(systemI) then
|
762
|
+
# raise AnyError, "SystemI #{systemI.name} already present."
|
763
|
+
# end
|
738
764
|
# Set the parent of the instance
|
739
765
|
systemI.parent = self
|
740
766
|
# puts "systemI = #{systemI}, parent=#{self}"
|
@@ -783,9 +809,9 @@ module HDLRuby::Low
|
|
783
809
|
raise AnyError,
|
784
810
|
"Invalid class for a non-hDLRuby code chunk: #{code.class}"
|
785
811
|
end
|
786
|
-
if @codes.include?(code) then
|
787
|
-
|
788
|
-
end
|
812
|
+
# if @codes.include?(code) then
|
813
|
+
# raise AnyError, "Code #{code.name} already present."
|
814
|
+
# end
|
789
815
|
# Set the parent of the code chunk.
|
790
816
|
code.parent = self
|
791
817
|
# puts "code = #{code}, parent=#{self}"
|
@@ -824,11 +850,9 @@ module HDLRuby::Low
|
|
824
850
|
raise AnyError,
|
825
851
|
"Invalid class for a signal instance: #{signal.class}"
|
826
852
|
end
|
827
|
-
# if @inners.
|
828
|
-
|
829
|
-
|
830
|
-
end
|
831
|
-
# @inners[signal.name] = signal
|
853
|
+
# if @inners.include?(signal) then
|
854
|
+
# raise AnyError, "SignalI #{signal.name} already present."
|
855
|
+
# end
|
832
856
|
# Set the parent of the signal.
|
833
857
|
signal.parent = self
|
834
858
|
# And add the signal.
|
@@ -2761,10 +2785,9 @@ module HDLRuby::Low
|
|
2761
2785
|
raise AnyError,
|
2762
2786
|
"Invalid class for a code chunk: #{chunk.class}"
|
2763
2787
|
end
|
2764
|
-
# if @chunks.
|
2765
|
-
|
2766
|
-
|
2767
|
-
end
|
2788
|
+
# if @chunks.include?(chunk) then
|
2789
|
+
# raise AnyError, "Code chunk #{chunk.name} already present."
|
2790
|
+
# end
|
2768
2791
|
# Set its parent.
|
2769
2792
|
chunk.parent = self
|
2770
2793
|
# And add it
|
@@ -4269,11 +4292,9 @@ module HDLRuby::Low
|
|
4269
4292
|
raise AnyError,
|
4270
4293
|
"Invalid class for a signal instance: #{signal.class}"
|
4271
4294
|
end
|
4272
|
-
# if @inners.
|
4273
|
-
|
4274
|
-
|
4275
|
-
end
|
4276
|
-
# @inners[signal.name] = signal
|
4295
|
+
# if @inners.include?(signal) then
|
4296
|
+
# raise AnyError, "SignalI #{signal.name} already present."
|
4297
|
+
# end
|
4277
4298
|
# Set its parent.
|
4278
4299
|
signal.parent = self
|
4279
4300
|
# And add it
|
@@ -147,7 +147,8 @@ module HDLRuby::Low
|
|
147
147
|
cnxs = self.each_connection.to_a
|
148
148
|
# Remove them from the scope.
|
149
149
|
# cnxs.each { |cnx| self.delete_connection!(cnx) }
|
150
|
-
cnxs.delete_all_connections!
|
150
|
+
# cnxs.delete_all_connections!
|
151
|
+
self.delete_all_connections!
|
151
152
|
# Return the connections.
|
152
153
|
return cnxs
|
153
154
|
end
|
@@ -47,7 +47,7 @@ module HDLRuby::High::Std
|
|
47
47
|
end
|
48
48
|
|
49
49
|
|
50
|
-
## Module describing a
|
50
|
+
## Module describing a pipe with handshakes.
|
51
51
|
# @param event the event to synchronize the handshakes.
|
52
52
|
# @param read the signal telling there is a request from the client side
|
53
53
|
# @param write the signal used for asking the server to issue a request
|
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.10.
|
4
|
+
version: 2.10.5
|
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-
|
11
|
+
date: 2022-07-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/HDLRuby/hdr_samples/dff.rb
|
92
92
|
- lib/HDLRuby/hdr_samples/dff_bench.rb
|
93
93
|
- lib/HDLRuby/hdr_samples/dff_counter.rb
|
94
|
+
- lib/HDLRuby/hdr_samples/dff_override.rb
|
94
95
|
- lib/HDLRuby/hdr_samples/dff_properties.rb
|
95
96
|
- lib/HDLRuby/hdr_samples/dff_unit.rb
|
96
97
|
- lib/HDLRuby/hdr_samples/huge_rom.rb
|