HDLRuby 3.4.0 → 3.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HDLRuby.gemspec +1 -0
- data/README.md +14 -6
- data/lib/HDLRuby/hdr_samples/hard_to_route.rb +30 -0
- data/lib/HDLRuby/hdr_samples/with_generic_in_generic.rb +31 -0
- data/lib/HDLRuby/hdr_samples/with_seq_case.rb +28 -0
- data/lib/HDLRuby/hdr_samples/with_seq_if.rb +25 -0
- data/lib/HDLRuby/hdr_samples/with_seq_if_succ.rb +27 -0
- data/lib/HDLRuby/hdr_samples/with_verilog.rb +1 -1
- data/lib/HDLRuby/hdrcc.rb +84 -27
- data/lib/HDLRuby/hruby_bstr.rb +2 -2
- data/lib/HDLRuby/hruby_high.rb +40 -11
- data/lib/HDLRuby/hruby_low.rb +4 -0
- data/lib/HDLRuby/hruby_viz.rb +5060 -0
- data/lib/HDLRuby/std/sequencer.rb +28 -13
- data/lib/HDLRuby/version.rb +1 -1
- data/tuto/tutorial_sw.html +2772 -4079
- data/tuto/tutorial_sw.md +16 -3
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ddf985a2c95d278dd5267350cb09cf3310d29a21ede26b0dea69381ae0cd8ed8
|
4
|
+
data.tar.gz: 0b38f0e98fdc47a7a0ba692777957a76cc239fc22d5ae4eb9c4b979df88fa186
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbe2f1ecba2cbd9fe06e1707479b5024a4b21a839f857a357b2ea4880ecb90dd1a48a91c8e32b45ea5f1b670d52b1e3fdb6297f71cd2dd05cc013447fd0151ad
|
7
|
+
data.tar.gz: 16cde53ba9e257f76c60f7ce1b75fda7b416433668d07fe0f696fcdeff000e921777e142cb09140930ccf65de48dea8f4565d0831c896bc7304d59d0bc64f5d2
|
data/HDLRuby.gemspec
CHANGED
@@ -8,6 +8,7 @@ Gem::Specification.new do |spec|
|
|
8
8
|
spec.version = HDLRuby::VERSION
|
9
9
|
spec.authors = ["Lovic Gauthier"]
|
10
10
|
spec.email = ["lovic@ariake-nct.ac.jp"]
|
11
|
+
spec.platform = "ruby"
|
11
12
|
|
12
13
|
spec.summary = %q{HDLRuby is a library for describing and simulating digital electronic systems.}
|
13
14
|
spec.description = %q{HDLRuby is a library for describing and simulating digital electronic systems. With this library it will possible to describe synthesizable hardware using all the features of the Ruby language, e.g., object orientation, duck typing, closure. This library is also usable through irb for interactive design and simulation.}
|
data/README.md
CHANGED
@@ -17,6 +17,13 @@ hdrcc --get-tuto
|
|
17
17
|
|
18
18
|
__What's new__
|
19
19
|
|
20
|
+
For HDLRuby version 3.5.0:
|
21
|
+
|
22
|
+
* Added direct support for Verilog HDL files as input to 'hdrcc'.
|
23
|
+
|
24
|
+
* Added the ability to generate a graphical representation of the RTL code in SVG format using the '--svg' option for 'hdrcc'.
|
25
|
+
|
26
|
+
|
20
27
|
For HDLRuby version 3.4.0:
|
21
28
|
|
22
29
|
* Improved synchronization of the browser-base graphical interface with the HDLRuby simulator.
|
@@ -106,14 +113,14 @@ __Warning__:
|
|
106
113
|
__Usage__:
|
107
114
|
|
108
115
|
```
|
109
|
-
hdrcc [options] <input file> <output directory>
|
116
|
+
hdrcc [options] <input file> <output/working directory>
|
110
117
|
```
|
111
118
|
|
112
119
|
Where:
|
113
120
|
|
114
121
|
* `options` is a list of options
|
115
122
|
* `<input file>` is the initial file to compile (mandatory)
|
116
|
-
* `<output directory>` is the directory where the
|
123
|
+
* `<output/working directory>` is the directory where the output and temporary files will be put
|
117
124
|
|
118
125
|
| Options | |
|
119
126
|
|:------------------|:-----------------------------------------------------|
|
@@ -128,6 +135,7 @@ Where:
|
|
128
135
|
| `--rsim` | Perform the simulation with the Ruby engine |
|
129
136
|
| `--rcsim` | Perform the simulation with the Hybrid engine |
|
130
137
|
| `--vcd` | Make the simulator generate a VCD file |
|
138
|
+
| `--svg` | Output a graphical representation of the RTL (SVG format) |
|
131
139
|
| `-d, --directory` | Specify the base directory for loading the HDLRuby files |
|
132
140
|
| `-D, --debug` | Set the HDLRuby debug mode |
|
133
141
|
| `-t, --top system`| Specify the top system describing the circuit to compile |
|
@@ -151,16 +159,16 @@ __Notes__:
|
|
151
159
|
|
152
160
|
__Examples__:
|
153
161
|
|
154
|
-
* Compile
|
162
|
+
* Compile `adder.rb` input file and generate a low-level Verilog HDL description into the directory `adder`:
|
155
163
|
|
156
164
|
```bash
|
157
|
-
hdrcc
|
165
|
+
hdrcc -v adder.rb adder
|
158
166
|
```
|
159
167
|
|
160
|
-
* Compile `
|
168
|
+
* Compile `adder8.v` input Verilog HDL file with `adder8` as top module, and generate a graphical representation of its RTL in the `view` directory:
|
161
169
|
|
162
170
|
```bash
|
163
|
-
hdrcc
|
171
|
+
hdrcc adder8.v -t adder8 --svg view
|
164
172
|
```
|
165
173
|
|
166
174
|
* Compile system `adder` whose bit width is generic from `adder_gen.rb` input file to a 16-bit circuit low-level VHDL description into directory `adder`:
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# A benchmark for testing the router of SVG generation with hard to
|
2
|
+
# handle patterns.
|
3
|
+
# Note that the circuit is not synthesizable here, it is just for
|
4
|
+
# testing difficult routing patterns, even if they are illegal in practice.
|
5
|
+
|
6
|
+
system :adder do |typ|
|
7
|
+
typ.input :x, :y
|
8
|
+
typ.output :z
|
9
|
+
|
10
|
+
z <= x + y
|
11
|
+
end
|
12
|
+
|
13
|
+
|
14
|
+
system :hard_to_route do
|
15
|
+
|
16
|
+
[8].inner :x, :y, :z, :c
|
17
|
+
|
18
|
+
adder(bit[8]).(:adderI0).(x,y,z)
|
19
|
+
adder(bit[8]).(:adderI1).(x: x, y: y, z: z)
|
20
|
+
|
21
|
+
timed do
|
22
|
+
!10.ns
|
23
|
+
x <= 0
|
24
|
+
y <= 0
|
25
|
+
!10.ns
|
26
|
+
x <= 1
|
27
|
+
y <= 1
|
28
|
+
!10.ns
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# Samples for testing instantiation of generic system within generic system.
|
2
|
+
|
3
|
+
|
4
|
+
system :inner_generic do |typeI, typeO|
|
5
|
+
typeI.input :din
|
6
|
+
typeO.output :dout
|
7
|
+
|
8
|
+
dout <= din * 2
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
system :outer_generic do |typeI, typeO|
|
13
|
+
typeI.input :din_
|
14
|
+
typeO.output :dout_
|
15
|
+
|
16
|
+
inner_generic(typeI,typeO).(:my_inner_generic).(din_,dout_)
|
17
|
+
end
|
18
|
+
|
19
|
+
|
20
|
+
system :test_generic_in_generic do
|
21
|
+
[8].inner :x, :y
|
22
|
+
|
23
|
+
outer_generic(bit[8],bit[16]).(:my_outer_generic).(x,y)
|
24
|
+
|
25
|
+
timed do
|
26
|
+
x <= 0
|
27
|
+
!10.ns
|
28
|
+
x <= 1
|
29
|
+
!10.ns
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# A benchmark for testing case in seq blocks.
|
4
|
+
system :with_seq_case_bench do
|
5
|
+
[2].inner :s
|
6
|
+
[8].inner :z
|
7
|
+
|
8
|
+
seq do
|
9
|
+
z <= 4
|
10
|
+
hcase(s)
|
11
|
+
hwhen(0) { z <= 0 }
|
12
|
+
hwhen(1) { z <= 1 }
|
13
|
+
hwhen(2) { } # Intentionally left blank
|
14
|
+
helse { z <= 3 }
|
15
|
+
z <= z+1
|
16
|
+
end
|
17
|
+
|
18
|
+
timed do
|
19
|
+
s <= 0
|
20
|
+
!10.ns
|
21
|
+
s <= 1
|
22
|
+
!10.ns
|
23
|
+
s <= 2
|
24
|
+
!10.ns
|
25
|
+
s <= 3
|
26
|
+
!10.ns
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# A benchmark for testing if in seq blocks.
|
4
|
+
system :with_seq_if_bench do
|
5
|
+
[2].inner :s
|
6
|
+
[8].inner :z
|
7
|
+
|
8
|
+
seq do
|
9
|
+
hif(s==0) { z <= 0 }
|
10
|
+
helsif(s==1) { z <= 1 }
|
11
|
+
helsif(s==2) { z <= 2 }
|
12
|
+
helse { z <= 3 }
|
13
|
+
end
|
14
|
+
|
15
|
+
timed do
|
16
|
+
s <= 0
|
17
|
+
!10.ns
|
18
|
+
s <= 1
|
19
|
+
!10.ns
|
20
|
+
s <= 2
|
21
|
+
!10.ns
|
22
|
+
s <= 3
|
23
|
+
!10.ns
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
# A benchmark for testing if in seq blocks.
|
4
|
+
system :with_seq_if_bench do
|
5
|
+
[2].inner :s
|
6
|
+
[8].inner :u, :v
|
7
|
+
|
8
|
+
seq do
|
9
|
+
hif(s==0) { u <= 0; v <= 3 }
|
10
|
+
helsif(s==1) { u <= 1; v <= 2 }
|
11
|
+
helsif(s==2) { u <= 2; v <= 1 }
|
12
|
+
helse { u <= 3; v <= 0 }
|
13
|
+
u <= u + 1
|
14
|
+
v <= v + 2
|
15
|
+
end
|
16
|
+
|
17
|
+
timed do
|
18
|
+
s <= 0
|
19
|
+
!10.ns
|
20
|
+
s <= 1
|
21
|
+
!10.ns
|
22
|
+
s <= 2
|
23
|
+
!10.ns
|
24
|
+
s <= 3
|
25
|
+
!10.ns
|
26
|
+
end
|
27
|
+
end
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
@@ -254,15 +254,15 @@ module HDLRuby
|
|
254
254
|
# No, look for it.
|
255
255
|
@top_system = get_top
|
256
256
|
# show? "@top_system=#{@top_system}"
|
257
|
-
unless @top_system then
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
end
|
257
|
+
# unless @top_system then
|
258
|
+
# # Not found? Error.
|
259
|
+
# # Maybe it is a parse error, look for it.
|
260
|
+
# bind = TOPLEVEL_BINDING.clone
|
261
|
+
# eval("require 'HDLRuby'\n\nconfigure_high\n\n",bind)
|
262
|
+
# eval(@texts[0],bind,@top_file_name,1)
|
263
|
+
# # No parse error found.
|
264
|
+
# raise "Cannot find a top system." unless @top_system
|
265
|
+
# end
|
266
266
|
end
|
267
267
|
# Initialize the environment for processing the hdr file.
|
268
268
|
bind = TOPLEVEL_BINDING.clone
|
@@ -272,16 +272,20 @@ module HDLRuby
|
|
272
272
|
end
|
273
273
|
# Process it.
|
274
274
|
eval(@texts[0],bind,@top_file_name,1)
|
275
|
-
# Get the resulting instance
|
276
|
-
if @
|
275
|
+
# Get the resulting instance if any.
|
276
|
+
if @top_system then
|
277
|
+
if @params.empty? then
|
277
278
|
# There is no generic parameter
|
278
279
|
@top_instance =
|
279
|
-
|
280
|
-
|
280
|
+
eval("#{@top_system} :#{@top_name}\n#{@top_name}",bind)
|
281
|
+
else
|
281
282
|
# There are generic parameters
|
282
283
|
@top_instance =
|
283
|
-
|
284
|
-
|
284
|
+
eval("#{@top_system}(#{@params.join(",")}).(:#{@top_name})\n#{@top_name}",bind)
|
285
|
+
end
|
286
|
+
else
|
287
|
+
# No top instance.
|
288
|
+
@top_instance = nil
|
285
289
|
end
|
286
290
|
end
|
287
291
|
end
|
@@ -348,13 +352,15 @@ $options = {}
|
|
348
352
|
$options[:std] = true
|
349
353
|
# Parse the options
|
350
354
|
$optparse = OptionParser.new do |opts|
|
351
|
-
opts.banner = "Usage: hdrcc.rb [options] <input file> [<output directory
|
355
|
+
opts.banner = "Usage: hdrcc.rb [options] [<input file>] [<output/working directory>]"
|
352
356
|
|
353
357
|
opts.separator ""
|
354
358
|
opts.separator "Where:"
|
355
359
|
opts.separator "* `options` is a list of options"
|
356
|
-
opts.separator "* `<input file>` is the initial file to compile
|
357
|
-
opts.separator "
|
360
|
+
opts.separator "* `<input file>` is the initial file to compile."
|
361
|
+
opts.separator " This input can either be HDLRuby (.rb) or Verilog HDL (.v),"
|
362
|
+
opts.separator " however, for the latter the top module must be specified using --top"
|
363
|
+
opts.separator "* `<output/working directory>` is the directory where to put temporary and output files"
|
358
364
|
opts.separator ""
|
359
365
|
opts.separator "Options:"
|
360
366
|
|
@@ -456,6 +462,11 @@ $optparse = OptionParser.new do |opts|
|
|
456
462
|
$options[:vhdl08] = true
|
457
463
|
$gen = true
|
458
464
|
end
|
465
|
+
opts.on("--svg","Output a graphical representation of the RTL (SVG format)") do |v|
|
466
|
+
$options[:svg] = v
|
467
|
+
$options[:multiple] = v
|
468
|
+
$gen = true
|
469
|
+
end
|
459
470
|
opts.on("-s", "--syntax","Output the Ruby syntax tree") do |s|
|
460
471
|
$options[:syntax] = s
|
461
472
|
end
|
@@ -541,15 +552,15 @@ $optparse.parse!
|
|
541
552
|
# show? "options=#{$options}"
|
542
553
|
|
543
554
|
# Check the compatibility of the options
|
544
|
-
if $options.count {|op| [:yaml,:hdr,:verilog,:vhdl].include?(op) } > 1 then
|
545
|
-
warn("Please choose either YAML, HDLRuby, Verilog HDL,
|
555
|
+
if $options.count {|op| [:yaml,:hdr,:verilog,:vhdl,:svg].include?(op) } > 1 then
|
556
|
+
warn("Please choose either YAML, HDLRuby, Verilog HDL, VHDL, SVG (visualize) output.")
|
546
557
|
puts $optparse.help()
|
547
558
|
end
|
548
559
|
|
549
560
|
# Get the the input and the output files.
|
550
561
|
$input,$output = $*
|
551
|
-
|
552
|
-
|
562
|
+
# Get the top system name if name.
|
563
|
+
$top = $options[:top].to_s
|
553
564
|
unless $top == "" || (/^[_[[:alpha:]]][_\w]*$/ =~ $top) then
|
554
565
|
warn("Please provide a valid top system name.")
|
555
566
|
exit
|
@@ -593,17 +604,42 @@ if $output then
|
|
593
604
|
FileUtils.mkdir_p($output)
|
594
605
|
end
|
595
606
|
else
|
596
|
-
#
|
597
|
-
|
607
|
+
# Now, nothing to do: specified output files are not to be
|
608
|
+
# handled by hdrcc directly with handles output directories only.
|
609
|
+
#
|
610
|
+
# # Open the file if it is one, otherwise use a string.
|
611
|
+
# if File.file?($output) then
|
612
|
+
# $output = File.open($output,"w")
|
613
|
+
# else
|
614
|
+
# $output = StringIO.new
|
615
|
+
# end
|
598
616
|
end
|
599
617
|
else
|
600
618
|
if $options[:multiple] then
|
601
|
-
raise "Need a target directory in multiple files generation mode."
|
619
|
+
# raise "Need a target directory in multiple files generation mode."
|
620
|
+
warn("Need a output/working directory.")
|
621
|
+
warn($optparse.banner)
|
622
|
+
exit
|
602
623
|
end
|
603
624
|
$output = $stdout
|
604
625
|
end
|
605
626
|
|
606
|
-
#
|
627
|
+
# Process non-HDLRuby files.
|
628
|
+
if $input.end_with?(".v") then
|
629
|
+
if $top.empty? then
|
630
|
+
warn("The top module must be specified using \"--top <top module>\".")
|
631
|
+
exit
|
632
|
+
end
|
633
|
+
# Processing a Verilog HDL file, embed it into regular HDLRuby
|
634
|
+
# Generate a temporary HDLRuby file to process it.
|
635
|
+
rinput = $output+"/"+$input.chomp(".v")+".rb"
|
636
|
+
File.open(rinput,"w") do |f|
|
637
|
+
f << "require_verilog '#{$input}'\n"
|
638
|
+
end
|
639
|
+
$input = rinput
|
640
|
+
end
|
641
|
+
|
642
|
+
# Load and process the HDLRuby files.
|
607
643
|
$options[:directory] ||= "./"
|
608
644
|
$loader = HDRLoad.new($top,$input,$options[:directory].to_s,*$params)
|
609
645
|
$loader.read_all
|
@@ -637,7 +673,13 @@ end
|
|
637
673
|
# Get the top systemT.
|
638
674
|
HDLRuby.show "#{Time.now}#{show_mem}"
|
639
675
|
# Ruby simulation uses the HDLRuby::High tree, other the HDLRuby::Lowais used
|
640
|
-
|
676
|
+
if $top_instance then
|
677
|
+
$top_system = ($options[:rsim] || $options[:rcsim]) ? $top_instance.systemT : $top_instance.to_low.systemT
|
678
|
+
else
|
679
|
+
# No top system, end here.
|
680
|
+
HDLRuby.show "##### End here since not top system #####"
|
681
|
+
exit
|
682
|
+
end
|
641
683
|
$top_intance = nil # Free as much memory as possible.
|
642
684
|
HDLRuby.show "##### Top system built #####"
|
643
685
|
HDLRuby.show "#{Time.now}#{show_mem}"
|
@@ -1025,6 +1067,21 @@ elsif $options[:vhdl] then
|
|
1025
1067
|
$output << systemT.to_vhdl
|
1026
1068
|
end
|
1027
1069
|
end
|
1070
|
+
elsif $options[:svg] then
|
1071
|
+
# Requires the viz library.
|
1072
|
+
require "HDLRuby/hruby_viz.rb"
|
1073
|
+
# Generate the viz structure.
|
1074
|
+
viz = $top_system.to_viz
|
1075
|
+
# Do the place and route.
|
1076
|
+
viz.place_and_route_deep
|
1077
|
+
viz.scale = 30.0
|
1078
|
+
# Get the base name of the input file, it will be used for
|
1079
|
+
# generating the main name of the multiple result files.
|
1080
|
+
$basename = File.basename($input,File.extname($input))
|
1081
|
+
$basename = $output + "/" + $basename
|
1082
|
+
$name = $basename + ".svg"
|
1083
|
+
# Generate the svg file.
|
1084
|
+
File.open($name,"w") { |file| file.write(viz.to_svg) }
|
1028
1085
|
end
|
1029
1086
|
|
1030
1087
|
HDLRuby.show "##### Code generated #####"
|
data/lib/HDLRuby/hruby_bstr.rb
CHANGED
@@ -70,7 +70,7 @@ module HDLRuby
|
|
70
70
|
# Content is not a numeric nor a BitString.
|
71
71
|
@content = []
|
72
72
|
# Ensure it is a string.
|
73
|
-
val = val.to_s.downcase
|
73
|
+
val = val.to_s.chomp.downcase
|
74
74
|
val.each_byte.reverse_each do |c|
|
75
75
|
case c
|
76
76
|
when 48 # "0"
|
@@ -82,7 +82,7 @@ module HDLRuby
|
|
82
82
|
when 122 # "z"
|
83
83
|
@content << 2
|
84
84
|
else
|
85
|
-
|
85
|
+
raise "Invalid bit '#{c.chr}' in #{val}"
|
86
86
|
end
|
87
87
|
end
|
88
88
|
end
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -420,6 +420,7 @@ module HDLRuby::High
|
|
420
420
|
#
|
421
421
|
# NOTE: a name can also be a signal, is which case it is duplicated.
|
422
422
|
def make_inputs(type, *names)
|
423
|
+
# puts "for inputs=#{names} top_user=#{High.top_user}(#{High.top_user.name}) @scope=#{@scope}(#{@scope.name})"
|
423
424
|
# Check if called within the top scope of the block.
|
424
425
|
if High.top_user != @scope then
|
425
426
|
# No, cannot make an input from here.
|
@@ -874,6 +875,7 @@ module HDLRuby::High
|
|
874
875
|
|
875
876
|
# Converts the system to HDLRuby::Low and set its +name+.
|
876
877
|
def to_low(name = self.name)
|
878
|
+
# puts "to_low for system=#{name}"
|
877
879
|
name = name.to_s
|
878
880
|
if name.empty? then
|
879
881
|
raise AnyError,
|
@@ -2307,6 +2309,11 @@ module HDLRuby::High
|
|
2307
2309
|
|
2308
2310
|
# Creates a new system instance of system type +systemT+ named +name+.
|
2309
2311
|
def initialize(name, systemT)
|
2312
|
+
# Check the validity of the name.
|
2313
|
+
unless name.is_a?(String) or name.is_a?(Symbol)
|
2314
|
+
raise AnyError,
|
2315
|
+
"Missing instance name for system instantiation."
|
2316
|
+
end
|
2310
2317
|
# Initialize the system instance structure.
|
2311
2318
|
super(name,systemT)
|
2312
2319
|
|
@@ -2361,7 +2368,16 @@ module HDLRuby::High
|
|
2361
2368
|
end
|
2362
2369
|
else
|
2363
2370
|
# No, perform a connection is order of declaration
|
2371
|
+
# But first check if there are not too many of them.
|
2372
|
+
if connects.size >
|
2373
|
+
self.systemT.each_signal_with_included.to_a.size then
|
2374
|
+
raise AnyError, "Too many connections to instance " +
|
2375
|
+
"#{self.name}: got #{connects.size} " +
|
2376
|
+
"but expecting at most " +
|
2377
|
+
"#{self.systemT.each_signal_with_included.to_a.size}"
|
2378
|
+
end
|
2364
2379
|
connects.each.with_index do |csig,i|
|
2380
|
+
# Now do the connection.
|
2365
2381
|
# puts "systemT inputs=#{systemT.each_input.to_a.size}"
|
2366
2382
|
# Gets i-est signal to connect
|
2367
2383
|
ssig = self.systemT.get_interface_with_included(i)
|
@@ -3563,12 +3579,21 @@ module HDLRuby::High
|
|
3563
3579
|
|
3564
3580
|
# Converts the name reference to a HDLRuby::Low::RefName.
|
3565
3581
|
def to_low
|
3566
|
-
# puts "to_low with base=#{@base} @object=#{@object}"
|
3567
|
-
# puts "@object.name=#{@object.name}
|
3582
|
+
# puts "to_low with base=#{@base} @object=#{@object} @object.parent=#{@object.parent} High.cur_system=#{High.cur_system}"
|
3583
|
+
# puts "@object.name=#{@object.name}"
|
3584
|
+
# puts "@object.parent.name=#{@object.parent.name}" if @object.parent
|
3585
|
+
# Check if a direct access is possible or not.
|
3586
|
+
# It is possible if the object parent is the top level,
|
3587
|
+
# or if it is a system or the first scope of a system.
|
3588
|
+
# (NOTE: previously we ensured that it was only for the
|
3589
|
+
# current system, however, this did not support the case
|
3590
|
+
# of object within included systems).
|
3568
3591
|
if @base.is_a?(RefThis) &&
|
3569
3592
|
(@object.parent != High.top_user) &&
|
3570
|
-
(@object.parent != High.cur_system) &&
|
3571
|
-
(
|
3593
|
+
# (@object.parent != High.cur_system) &&
|
3594
|
+
(!@object.parent.is_a?(SystemT)) &&
|
3595
|
+
# (@object.parent != High.cur_system.scope) then # &&
|
3596
|
+
(!(@object.parent.is_a?(Scope) && @object.parent.parent.is_a?(SystemT))) then
|
3572
3597
|
# (!@object.parent.name.empty?) then
|
3573
3598
|
# Need to have a hierachical access.
|
3574
3599
|
if @object.respond_to?(:low_object) && @object.low_object then
|
@@ -4497,17 +4522,16 @@ module HDLRuby::High
|
|
4497
4522
|
self.add_statement(TimeWait.new(delay))
|
4498
4523
|
end
|
4499
4524
|
|
4500
|
-
# # Adds a
|
4501
|
-
#
|
4502
|
-
#
|
4503
|
-
# Adds a +number+ times loop statement in the block in +mode+ whose
|
4525
|
+
# # Adds a +number+ times loop statement in the block in +mode+ whose
|
4526
|
+
# def repeat(number = -1, mode = nil, &ruby_block)
|
4527
|
+
# Adds a +number+ times loop statement in the block whose
|
4504
4528
|
# loop content is built using +ruby_block+.
|
4505
4529
|
# NOTE: if +number+ is negative, the number of iteration is infinite.
|
4506
|
-
def repeat(number = -1,
|
4530
|
+
def repeat(number = -1, &ruby_block)
|
4507
4531
|
# Ensure there is a block.
|
4508
4532
|
ruby_block = proc {} unless block_given?
|
4509
|
-
# Build the content block.
|
4510
|
-
content = High.make_block(
|
4533
|
+
# Build the content block: necessarily seq since timed.
|
4534
|
+
content = High.make_block(:seq,&ruby_block)
|
4511
4535
|
# Create and add the statement.
|
4512
4536
|
# self.add_statement(TimeRepeat.new(content,delay))
|
4513
4537
|
self.add_statement(TimeRepeat.new(number,content))
|
@@ -4835,6 +4859,11 @@ module HDLRuby::High
|
|
4835
4859
|
# Registers hardware referencing method +name+ to the current namespace.
|
4836
4860
|
def self.space_reg(name,&ruby_block)
|
4837
4861
|
# print "registering #{name} in #{Namespaces[-1]}\n"
|
4862
|
+
# Check the name class.
|
4863
|
+
unless name.is_a?(String) or name.is_a?(Symbol) then
|
4864
|
+
raise AnyError,
|
4865
|
+
"Invalid class for a name, string or symbol expected but got: #{name.class}"
|
4866
|
+
end
|
4838
4867
|
Namespaces[-1].add_method(name,&ruby_block)
|
4839
4868
|
end
|
4840
4869
|
|
data/lib/HDLRuby/hruby_low.rb
CHANGED
@@ -6194,6 +6194,10 @@ module HDLRuby::Low
|
|
6194
6194
|
# Create a new named reference with +type+ accessing +ref+ with +name+.
|
6195
6195
|
# def initialize(ref,name)
|
6196
6196
|
def initialize(type,ref,name)
|
6197
|
+
# puts "new RefName with name=#{name}"
|
6198
|
+
if !name or name.empty? then
|
6199
|
+
raise "Internal error: Creating a RefName without a name."
|
6200
|
+
end
|
6197
6201
|
super(type)
|
6198
6202
|
# Check and set the accessed reference.
|
6199
6203
|
unless ref.is_a?(Ref) then
|