HDLRuby 2.5.1 → 2.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/HDLRuby/hdr_samples/adder.rb +1 -1
- data/lib/HDLRuby/hdr_samples/adder_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/adder_gen.rb +1 -1
- data/lib/HDLRuby/hdr_samples/constant_in_function.rb +27 -0
- data/lib/HDLRuby/hdr_samples/dff_unit.rb +3 -3
- data/lib/HDLRuby/hdr_samples/huge_rom.rb +25 -0
- data/lib/HDLRuby/hdr_samples/logic_bench.rb +21 -0
- data/lib/HDLRuby/hdr_samples/mei8_bench.rb +1 -1
- data/lib/HDLRuby/hdr_samples/music.rb +79 -0
- data/lib/HDLRuby/hdr_samples/named_sub.rb +42 -0
- data/lib/HDLRuby/hdr_samples/rom.rb +16 -0
- data/lib/HDLRuby/hdr_samples/with_function_generator.rb +25 -0
- data/lib/HDLRuby/hdrcc.rb +41 -7
- data/lib/HDLRuby/hruby_decorator.rb +3 -1
- data/lib/HDLRuby/hruby_high.rb +214 -26
- data/lib/HDLRuby/hruby_low.rb +402 -45
- data/lib/HDLRuby/hruby_low2c.rb +122 -168
- data/lib/HDLRuby/hruby_low2hdr.rb +738 -0
- data/lib/HDLRuby/hruby_low2high.rb +331 -549
- data/lib/HDLRuby/hruby_low2vhd.rb +39 -2
- data/lib/HDLRuby/hruby_low_bool2select.rb +29 -0
- data/lib/HDLRuby/hruby_low_casts_without_expression.rb +27 -0
- data/lib/HDLRuby/hruby_low_fix_types.rb +25 -0
- data/lib/HDLRuby/hruby_low_mutable.rb +70 -0
- data/lib/HDLRuby/hruby_low_resolve.rb +28 -0
- data/lib/HDLRuby/hruby_low_without_connection.rb +6 -3
- data/lib/HDLRuby/hruby_low_without_namespace.rb +7 -4
- data/lib/HDLRuby/hruby_low_without_select.rb +13 -0
- data/lib/HDLRuby/hruby_tools.rb +11 -1
- data/lib/HDLRuby/hruby_verilog.rb +1572 -1723
- data/lib/HDLRuby/sim/hruby_sim.h +25 -2
- data/lib/HDLRuby/sim/hruby_sim_calc.c +63 -6
- data/lib/HDLRuby/sim/hruby_sim_vcd.c +5 -1
- data/lib/HDLRuby/sim/hruby_sim_vizualize.c +22 -6
- data/lib/HDLRuby/std/fixpoint.rb +9 -0
- data/lib/HDLRuby/std/function_generator.rb +139 -0
- data/lib/HDLRuby/std/hruby_unit.rb +75 -0
- data/lib/HDLRuby/version.rb +1 -1
- metadata +14 -6
- data/lib/HDLRuby/hruby_unit.rb +0 -43
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8611332c824fad3b8ad75436070b940389c1d8cf75c66be0842cd5f4efd22340
|
4
|
+
data.tar.gz: 71f3633a674d50a2b4014654d6af82066bc9e8e399e6cdddb733827411ea2787
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8316f77bab49fc0899074915a18292f357b45c5e5415b3045f74b80f67260566797e8ffc0edf8b6eaca86340c32adfde49650edddfaa91cad03efd1e6e9f729c
|
7
|
+
data.tar.gz: 117236582bbca17d1ee75a2e3fb4c601ef53b1988f4175a7f77632f9c85a79e5af3e3474463f654c05a48ecdcabd73967d447b90f7640451f1bc3a24d99fd2ec
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# Sample for testing constant declaration in function.
|
2
|
+
|
3
|
+
|
4
|
+
function :func do |addr|
|
5
|
+
bit[4][-4].constant tbl: [ _0000, _0001, _0010, _0011 ]
|
6
|
+
|
7
|
+
tbl[addr]
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
system :with_func do
|
12
|
+
[4].inner :addr, :val
|
13
|
+
|
14
|
+
val <= func(addr)
|
15
|
+
# val <= 1
|
16
|
+
|
17
|
+
timed do
|
18
|
+
addr <= 0
|
19
|
+
!10.ns
|
20
|
+
addr <= 1
|
21
|
+
!10.ns
|
22
|
+
addr <= 2
|
23
|
+
!10.ns
|
24
|
+
addr <= 3
|
25
|
+
!10.ns
|
26
|
+
end
|
27
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
# Testing HDLRuby unit test.
|
2
|
-
# require 'hruby_unit.rb'
|
2
|
+
# require 'std/hruby_unit.rb'
|
3
3
|
|
4
4
|
# Declare multiple simple dff-systems and their corresponding test.
|
5
5
|
|
6
|
-
|
6
|
+
3.times do |i|
|
7
7
|
|
8
8
|
# A simple D-FF
|
9
9
|
system:"dff#{i}" do
|
@@ -21,7 +21,7 @@
|
|
21
21
|
|
22
22
|
send(:"dff#{i}",:dffI).(clk,rst,d,q,qb)
|
23
23
|
|
24
|
-
|
24
|
+
test do
|
25
25
|
clk <= 0
|
26
26
|
rst <= 0
|
27
27
|
d <= 0
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# Describes an 8-bit data 16-bit address ROM.
|
2
|
+
system :huge_rom do
|
3
|
+
[15..0].input :addr
|
4
|
+
[7..0].output :data
|
5
|
+
|
6
|
+
bit[7..0][-65536].constant content: 65536.times.to_a
|
7
|
+
|
8
|
+
data <= content[addr]
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
|
13
|
+
system :test_rom do
|
14
|
+
[15..0].inner :addr
|
15
|
+
[7..0].inner :data
|
16
|
+
|
17
|
+
huge_rom(:my_rom).(addr,data)
|
18
|
+
|
19
|
+
timed do
|
20
|
+
8.times do |i|
|
21
|
+
addr <= i
|
22
|
+
!10.ns
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
|
2
|
+
# A benchmark for the logic operations.
|
3
|
+
system :logic_bench do
|
4
|
+
[3].inner :x,:y
|
5
|
+
[3].inner :s_not, :s_and, :s_or, :s_xor, :s_nxor
|
6
|
+
|
7
|
+
timed do
|
8
|
+
8.times do |i|
|
9
|
+
8.times do |j|
|
10
|
+
x <= i
|
11
|
+
y <= j
|
12
|
+
s_not <= ~x
|
13
|
+
s_and <= x & y
|
14
|
+
s_or <= x | y
|
15
|
+
s_xor <= x ^ y
|
16
|
+
s_nxor <= (x == y)
|
17
|
+
!10.ns
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -28,7 +28,7 @@ system :mei8 do |prog_file = "./prog.obj"|
|
|
28
28
|
bit[7..0][-256].constant mem: # The content of the memory
|
29
29
|
( File.readlines(prog_file).map {|l| l.split[0] }.select do |l|
|
30
30
|
["0","1"].include?(l[2])
|
31
|
-
end.map {|l| l[2..9] } )
|
31
|
+
end.map {|l| l[2..9].to_i(2) } )
|
32
32
|
instr <= mem[addr] # The access procedure
|
33
33
|
end
|
34
34
|
|
@@ -0,0 +1,79 @@
|
|
1
|
+
# require "std/fixpoint.rb"
|
2
|
+
# require_relative "activation_function.rb"
|
3
|
+
require 'std/function_generator.rb'
|
4
|
+
|
5
|
+
include HDLRuby::High::Std
|
6
|
+
|
7
|
+
system :music do
|
8
|
+
|
9
|
+
input :clk, :rst
|
10
|
+
[24].output :sound
|
11
|
+
|
12
|
+
# func_sin = proc { |i| Math.sin(i) }
|
13
|
+
# More efficient:
|
14
|
+
func_sin = Math.method(:sin)
|
15
|
+
|
16
|
+
# bit[8,8].inner :time
|
17
|
+
# signed[2,22].inner :sin_val0
|
18
|
+
# signed[2,22].inner :sin_val1
|
19
|
+
bit[8].inner :time
|
20
|
+
signed[24].inner :sin_val0
|
21
|
+
signed[24].inner :sin_val1
|
22
|
+
|
23
|
+
# activation_function(func_sin,signed[2,22],8,8,16).(:func_sin0_generator).(time,sin_val0)
|
24
|
+
# activation_function(func_sin,signed[2,22],8,8,16).(:func_sin1_generator).(time/2,sin_val1)
|
25
|
+
function_generator(func_sin,bit[8],signed[24],4,-Math::PI..Math::PI,-2..2).(:func_sin0_generator).(time,sin_val0)
|
26
|
+
function_generator(func_sin,bit[8],signed[24],4,-Math::PI*2..Math::PI*2,-2..2).(:func_sin1_generator).(time/2,sin_val1)
|
27
|
+
|
28
|
+
# signed[2,22].inner :sound0
|
29
|
+
signed[48].inner :sound0
|
30
|
+
|
31
|
+
sound0 <= sin_val0.as(signed[24]) * sin_val1
|
32
|
+
|
33
|
+
sound <= sound0[47..24]
|
34
|
+
|
35
|
+
par(clk.posedge) do
|
36
|
+
hif(rst) { time <= 0 }
|
37
|
+
helse do
|
38
|
+
# time <= time + _0000000000000001
|
39
|
+
time <= time + _00000001
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
|
47
|
+
|
48
|
+
system :music_test do
|
49
|
+
|
50
|
+
inner :clk,:rst
|
51
|
+
[24].inner :sound
|
52
|
+
|
53
|
+
music(:my_music).(clk,rst,sound)
|
54
|
+
|
55
|
+
timed do
|
56
|
+
clk <= 0
|
57
|
+
rst <= 0
|
58
|
+
!10.ns
|
59
|
+
clk <= 1
|
60
|
+
!10.ns
|
61
|
+
clk <= 0
|
62
|
+
rst <= 1
|
63
|
+
!10.ns
|
64
|
+
clk <= 1
|
65
|
+
!10.ns
|
66
|
+
clk <= 0
|
67
|
+
!10.ns
|
68
|
+
clk <= 1
|
69
|
+
!10.ns
|
70
|
+
clk <= 0
|
71
|
+
rst <= 0
|
72
|
+
256.times do
|
73
|
+
!10.ns
|
74
|
+
clk <= 1
|
75
|
+
!10.ns
|
76
|
+
clk <= 0
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
##
|
2
|
+
# Sample testing named sub
|
3
|
+
#######################################
|
4
|
+
|
5
|
+
|
6
|
+
# A simple circuit with named sub
|
7
|
+
system :named_sub do
|
8
|
+
input :x, :y
|
9
|
+
output :s
|
10
|
+
|
11
|
+
sub :somesub do
|
12
|
+
inner :sig
|
13
|
+
end
|
14
|
+
|
15
|
+
seq do
|
16
|
+
somesub.sig <= x | y
|
17
|
+
s <= ~somesub.sig
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
# A benchmark for the circuit.
|
23
|
+
system :named_sub_bench do
|
24
|
+
inner :x, :y, :s
|
25
|
+
|
26
|
+
named_sub(:my_named_sub).(x,y,s)
|
27
|
+
|
28
|
+
timed do
|
29
|
+
x <= 0
|
30
|
+
y <= 0
|
31
|
+
!10.ns
|
32
|
+
x <= 1
|
33
|
+
y <= 0
|
34
|
+
!10.ns
|
35
|
+
x <= 0
|
36
|
+
y <= 1
|
37
|
+
!10.ns
|
38
|
+
x <= 1
|
39
|
+
y <= 1
|
40
|
+
!10.ns
|
41
|
+
end
|
42
|
+
end
|
@@ -14,3 +14,19 @@ system :rom4_8 do
|
|
14
14
|
data1 <= content1[addr]
|
15
15
|
data2 <= content2[addr]
|
16
16
|
end
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
system :test_rom do
|
21
|
+
[2..0].inner :addr
|
22
|
+
[7..0].inner :data0,:data1,:data2
|
23
|
+
|
24
|
+
rom4_8(:my_rom).(addr,data0,data1,data2)
|
25
|
+
|
26
|
+
timed do
|
27
|
+
8.times do |i|
|
28
|
+
addr <= i
|
29
|
+
!10.ns
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'std/function_generator.rb'
|
2
|
+
|
3
|
+
include HDLRuby::High::Std
|
4
|
+
|
5
|
+
# System for testing the function generator standard library.
|
6
|
+
system :with_function_generator do
|
7
|
+
# signed[8].inner :x
|
8
|
+
# signed[32].inner :y
|
9
|
+
bit[8].inner :x
|
10
|
+
signed[8].inner :y
|
11
|
+
|
12
|
+
# function_generator(Math.method(:sin).to_proc,
|
13
|
+
# signed[8],signed[32],4,-Math::PI..Math::PI,-2..2).
|
14
|
+
function_generator(Math.method(:sin).to_proc,
|
15
|
+
bit[8],signed[8],4,-Math::PI..Math::PI,-2..2).
|
16
|
+
(:my_sin).(x,y)
|
17
|
+
|
18
|
+
timed do
|
19
|
+
# (-128..127).each do |i|
|
20
|
+
(0..255).each do |i|
|
21
|
+
x <= i
|
22
|
+
!10.ns
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/lib/HDLRuby/hdrcc.rb
CHANGED
@@ -5,7 +5,7 @@ require 'tempfile'
|
|
5
5
|
require 'HDLRuby'
|
6
6
|
require 'HDLRuby/hruby_check.rb'
|
7
7
|
# require 'ripper'
|
8
|
-
require 'HDLRuby/
|
8
|
+
require 'HDLRuby/hruby_low2hdr'
|
9
9
|
require 'HDLRuby/hruby_low2c'
|
10
10
|
require 'HDLRuby/hruby_low2vhd'
|
11
11
|
require 'HDLRuby/hruby_low_fix_types'
|
@@ -337,9 +337,12 @@ $optparse = OptionParser.new do |opts|
|
|
337
337
|
opts.on("-D", "--debug","Set the HDLRuby debug mode") do |d|
|
338
338
|
$options[:debug] = d
|
339
339
|
end
|
340
|
-
opts.on("-T","--test","Compile the unit tests
|
340
|
+
opts.on("-T","--test t0,t1,t2","Compile the unit tests named t0,t1,...") do |t|
|
341
341
|
$options[:test] = t
|
342
342
|
end
|
343
|
+
opts.on("--testall","Compile all the available unit tests.") do |t|
|
344
|
+
$options[:testall] = t
|
345
|
+
end
|
343
346
|
opts.on("-t", "--top system", "Specify the top system to process") do|t|
|
344
347
|
$options[:top] = t
|
345
348
|
end
|
@@ -350,6 +353,10 @@ $optparse = OptionParser.new do |opts|
|
|
350
353
|
$options[:dump] = v
|
351
354
|
$options[:multiple] = v
|
352
355
|
end
|
356
|
+
opts.on("--version", "Shows the version of HDLRuby.") do |v|
|
357
|
+
puts VERSION
|
358
|
+
exit
|
359
|
+
end
|
353
360
|
# opts.on_tail("-h", "--help", "Show this message") do
|
354
361
|
opts.on("-h", "--help", "Show this message") do
|
355
362
|
puts opts
|
@@ -400,14 +407,23 @@ if $input == nil then
|
|
400
407
|
exit
|
401
408
|
end
|
402
409
|
|
403
|
-
if ($options[:test]) then
|
410
|
+
if ($options[:test] || $options[:testall]) then
|
404
411
|
$top = "__test__"
|
412
|
+
tests = $options[:test]
|
413
|
+
if tests then
|
414
|
+
tests = tests.to_s.split(",")
|
415
|
+
tests.map! {|test| ":\"#{test}\"" }
|
416
|
+
tests = ", #{tests.join(",")}"
|
417
|
+
else
|
418
|
+
tests = ""
|
419
|
+
end
|
405
420
|
# Generate the unit test file.
|
406
421
|
$test_file = Tempfile.new('tester.rb',Dir.getwd)
|
407
|
-
$test_file.write("require 'hruby_unit.rb'\nrequire_relative '#{$input}'\n\n" +
|
408
|
-
|
422
|
+
$test_file.write("require 'std/hruby_unit.rb'\nrequire_relative '#{$input}'\n\n" +
|
423
|
+
"HDLRuby::Unit.test(:\"#{$top}\"#{tests})\n")
|
409
424
|
# $test_file.rewind
|
410
425
|
# puts $test_file.read
|
426
|
+
# exit
|
411
427
|
$test_file.rewind
|
412
428
|
# It is the new input file.
|
413
429
|
$input = $test_file
|
@@ -425,7 +441,7 @@ if $output then
|
|
425
441
|
$output = File.open($output,"w")
|
426
442
|
end
|
427
443
|
else
|
428
|
-
if $
|
444
|
+
if $options[:multiple] then
|
429
445
|
raise "Need a target directory in multiple files generation mode."
|
430
446
|
end
|
431
447
|
$output = $stdout
|
@@ -463,6 +479,24 @@ end
|
|
463
479
|
# Get the top systemT.
|
464
480
|
$top_system = $top_instance.to_low.systemT
|
465
481
|
|
482
|
+
|
483
|
+
# Apply the pre drivers if any.
|
484
|
+
Hdecorator.each_with_property(:pre_driver) do |obj, value|
|
485
|
+
unless value.is_a?(Array) && value.size == 2 then
|
486
|
+
raise "pre_driver requires a driver file name command name."
|
487
|
+
end
|
488
|
+
# Load the driver.
|
489
|
+
require_relative(value[0].to_s)
|
490
|
+
# Ensure obj is the low version.
|
491
|
+
if obj.properties.key?(:high2low) then
|
492
|
+
# obj is high, get the corresponding low.
|
493
|
+
obj = obj.properties[:high2low][0]
|
494
|
+
end
|
495
|
+
# Execute it.
|
496
|
+
send(value[1].to_sym,obj,*value[2..-1])
|
497
|
+
end
|
498
|
+
|
499
|
+
|
466
500
|
# Gather the non-HDLRuby code.
|
467
501
|
$non_hdlruby = []
|
468
502
|
$top_system.each_systemT_deep do |systemT|
|
@@ -504,7 +538,7 @@ elsif $options[:hdr] then
|
|
504
538
|
# $output << systemT.to_high
|
505
539
|
# end
|
506
540
|
# $output << $top_instance.to_low.systemT.to_high
|
507
|
-
$output << $top_system.
|
541
|
+
$output << $top_system.to_hdr
|
508
542
|
elsif $options[:clang] then
|
509
543
|
# top_system = $top_instance.to_low.systemT
|
510
544
|
# top_system = $top_system
|
@@ -46,11 +46,13 @@ module HDLRuby
|
|
46
46
|
# Iterate over all the id with their object.
|
47
47
|
#
|
48
48
|
# Returns an enumerator if no ruby block is given.
|
49
|
+
#
|
50
|
+
# NOTE: converts the hash to an array to allow on-the-fly modification.
|
49
51
|
def self.each(&ruby_block)
|
50
52
|
# No ruby block? Return an enumerator.
|
51
53
|
return to_enum(:each) unless ruby_block
|
52
54
|
# A ruby block? Apply it on each object.
|
53
|
-
@@id_map.each(&ruby_block)
|
55
|
+
@@id_map.to_a.each(&ruby_block)
|
54
56
|
end
|
55
57
|
|
56
58
|
# The decorator also need to add properties to the HDLRuby objects.
|
data/lib/HDLRuby/hruby_high.rb
CHANGED
@@ -620,8 +620,8 @@ module HDLRuby::High
|
|
620
620
|
# Extend the instance.
|
621
621
|
instance.eigen_extend(@singleton_instanceO)
|
622
622
|
# puts "instance scope= #{instance.systemT.scope}"
|
623
|
-
# Add the instance.
|
624
|
-
High.top_user.send(:add_systemI,instance)
|
623
|
+
# Add the instance if instantiating within another system.
|
624
|
+
High.top_user.send(:add_systemI,instance) if High.top_user
|
625
625
|
|
626
626
|
# Execute the post instantiation tasks.
|
627
627
|
eigen.each_on_instance { |task| task.(instance) }
|
@@ -762,6 +762,7 @@ module HDLRuby::High
|
|
762
762
|
self.scope.to_low)
|
763
763
|
# For debugging: set the source high object
|
764
764
|
systemTL.properties[:low2high] = self.hdr_id
|
765
|
+
self.properties[:high2low] = systemTL
|
765
766
|
|
766
767
|
# Fills the interface of the new system
|
767
768
|
# from the included systems.
|
@@ -936,8 +937,19 @@ module HDLRuby::High
|
|
936
937
|
# Set the namespace for buidling the scope.
|
937
938
|
High.space_push(@namespace)
|
938
939
|
# Build the scope.
|
939
|
-
@return_value = High.top_user.instance_eval(&ruby_block)
|
940
|
+
# @return_value = High.top_user.instance_eval(&ruby_block)
|
941
|
+
res = High.top_user.instance_eval(&ruby_block)
|
940
942
|
High.space_pop
|
943
|
+
# Now gain access to the result within the sub scope.
|
944
|
+
if (res.is_a?(HRef)) then
|
945
|
+
@return_value = res.type.inner(HDLRuby.uniq_name)
|
946
|
+
High.space_push(@namespace)
|
947
|
+
@return_value <= res
|
948
|
+
High.space_pop
|
949
|
+
else
|
950
|
+
@return_value = res
|
951
|
+
end
|
952
|
+
# This will be the return value.
|
941
953
|
@return_value
|
942
954
|
end
|
943
955
|
|
@@ -1298,6 +1310,7 @@ module HDLRuby::High
|
|
1298
1310
|
scopeL = HDLRuby::Low::Scope.new(self.name)
|
1299
1311
|
# For debugging: set the source high object
|
1300
1312
|
scopeL.properties[:low2high] = self.hdr_id
|
1313
|
+
self.properties[:high2low] = scopeL
|
1301
1314
|
|
1302
1315
|
# Push the private namespace for the low generation.
|
1303
1316
|
High.space_push(@namespace)
|
@@ -1531,6 +1544,7 @@ module HDLRuby::High
|
|
1531
1544
|
typeL = HDLRuby::Low::Type.new(name)
|
1532
1545
|
# For debugging: set the source high object
|
1533
1546
|
typeL.properties[:low2high] = self.hdr_id
|
1547
|
+
self.properties[:high2low] = typeL
|
1534
1548
|
return typeL
|
1535
1549
|
end
|
1536
1550
|
end
|
@@ -1616,6 +1630,18 @@ module HDLRuby::High
|
|
1616
1630
|
include HbasicType
|
1617
1631
|
end
|
1618
1632
|
|
1633
|
+
# The string type
|
1634
|
+
StringT = define_type(:string)
|
1635
|
+
class << StringT
|
1636
|
+
# Converts the type to HDLRuby::Low.
|
1637
|
+
def to_low
|
1638
|
+
return Low::StringT
|
1639
|
+
end
|
1640
|
+
|
1641
|
+
include HbasicType
|
1642
|
+
end
|
1643
|
+
|
1644
|
+
|
1619
1645
|
# # The infer type.
|
1620
1646
|
# # Unspecified, but automatically infered when connected.
|
1621
1647
|
# Infer = define_type(:infer)
|
@@ -1672,6 +1698,7 @@ module HDLRuby::High
|
|
1672
1698
|
typeDefL = HDLRuby::Low::TypeDef.new(name,self.def.to_low)
|
1673
1699
|
# For debugging: set the source high object
|
1674
1700
|
typeDefL.properties[:low2high] = self.hdr_id
|
1701
|
+
self.properties[:high2low] = typeDefL
|
1675
1702
|
return typeDefL
|
1676
1703
|
end
|
1677
1704
|
end
|
@@ -1724,6 +1751,7 @@ module HDLRuby::High
|
|
1724
1751
|
typeDefL = HDLRuby::Low::TypeDef.new(name,self.def.to_low)
|
1725
1752
|
# For debugging: set the source high object
|
1726
1753
|
typeDefL.properties[:low2high] = self.hdr_id
|
1754
|
+
self.properties[:high2low] = typeDefL
|
1727
1755
|
return typeDefL
|
1728
1756
|
end
|
1729
1757
|
end
|
@@ -1741,6 +1769,7 @@ module HDLRuby::High
|
|
1741
1769
|
self.range.to_low)
|
1742
1770
|
# For debugging: set the source high object
|
1743
1771
|
typeVectorL.properties[:low2high] = self.hdr_id
|
1772
|
+
self.properties[:high2low] = typeVectorL
|
1744
1773
|
return typeVectorL
|
1745
1774
|
end
|
1746
1775
|
end
|
@@ -1820,6 +1849,7 @@ module HDLRuby::High
|
|
1820
1849
|
*@types.map { |type| type.to_low } )
|
1821
1850
|
# For debugging: set the source high object
|
1822
1851
|
typeTupleL.properties[:low2high] = self.hdr_id
|
1852
|
+
self.properties[:high2low] = typeTupleL
|
1823
1853
|
return typeTupleL
|
1824
1854
|
end
|
1825
1855
|
end
|
@@ -1840,6 +1870,7 @@ module HDLRuby::High
|
|
1840
1870
|
@types.map { |name,type| [name,type.to_low] } )
|
1841
1871
|
# For debugging: set the source high object
|
1842
1872
|
typeStructL.properties[:low2high] = self.hdr_id
|
1873
|
+
self.properties[:high2low] = typeStructL
|
1843
1874
|
return typeStructL
|
1844
1875
|
end
|
1845
1876
|
end
|
@@ -2007,7 +2038,8 @@ module HDLRuby::High
|
|
2007
2038
|
else
|
2008
2039
|
# No, perform a connection is order of declaration
|
2009
2040
|
connects.each.with_index do |csig,i|
|
2010
|
-
|
2041
|
+
csig = csig.to_expr
|
2042
|
+
# puts "csig=#{csig} i=#{i}"
|
2011
2043
|
# puts "systemT inputs=#{systemT.each_input.to_a.size}"
|
2012
2044
|
# Gets i-est signal to connect
|
2013
2045
|
ssig = self.systemT.get_interface_with_included(i)
|
@@ -2078,6 +2110,7 @@ module HDLRuby::High
|
|
2078
2110
|
systemTL)
|
2079
2111
|
# For debugging: set the source high object
|
2080
2112
|
systemIL.properties[:low2high] = self.hdr_id
|
2113
|
+
self.properties[:high2low] = systemIL
|
2081
2114
|
# Adds the other systemTs.
|
2082
2115
|
self.each_systemT do |systemT|
|
2083
2116
|
systemIL.add_systemT(systemT.to_low) unless systemT == self.systemT
|
@@ -2105,6 +2138,7 @@ module HDLRuby::High
|
|
2105
2138
|
end)
|
2106
2139
|
# For debugging: set the source high object
|
2107
2140
|
chunkL.properties[:low2high] = self.hdr_id
|
2141
|
+
self.properties[:high2low] = chunkL
|
2108
2142
|
return chunkL
|
2109
2143
|
end
|
2110
2144
|
end
|
@@ -2118,6 +2152,7 @@ module HDLRuby::High
|
|
2118
2152
|
codeL = HDLRuby::Low::Code.new
|
2119
2153
|
# For debugging: set the source high object
|
2120
2154
|
codeL.properties[:low2high] = self.hdr_id
|
2155
|
+
self.properties[:high2low] = codeL
|
2121
2156
|
# Add the low-level events.
|
2122
2157
|
self.each_event { |event| codeL.add_event(event.to_low) }
|
2123
2158
|
# Add the low-level code chunks.
|
@@ -2211,6 +2246,7 @@ module HDLRuby::High
|
|
2211
2246
|
self.each_noif {|cond,block| ifL.add_noif(cond.to_low,block.to_low)}
|
2212
2247
|
# For debugging: set the source high object
|
2213
2248
|
ifL.properties[:low2high] = self.hdr_id
|
2249
|
+
self.properties[:high2low] = ifL
|
2214
2250
|
return ifL
|
2215
2251
|
end
|
2216
2252
|
end
|
@@ -2235,6 +2271,7 @@ module HDLRuby::High
|
|
2235
2271
|
self.statement.to_low)
|
2236
2272
|
# For debugging: set the source high object
|
2237
2273
|
whenL.properties[:low2high] = self.hdr_id
|
2274
|
+
self.properties[:high2low] = whenL
|
2238
2275
|
return whenL
|
2239
2276
|
end
|
2240
2277
|
end
|
@@ -2282,6 +2319,7 @@ module HDLRuby::High
|
|
2282
2319
|
caseL = HDLRuby::Low::Case.new(@value.to_low)
|
2283
2320
|
# For debugging: set the source high object
|
2284
2321
|
caseL.properties[:low2high] = self.hdr_id
|
2322
|
+
self.properties[:high2low] = caseL
|
2285
2323
|
# Add each when case.
|
2286
2324
|
self.each_when do |w|
|
2287
2325
|
caseL.add_when(w.to_low)
|
@@ -2312,6 +2350,7 @@ module HDLRuby::High
|
|
2312
2350
|
delayL = HDLRuby::Low::Delay.new(self.value, self.unit)
|
2313
2351
|
# For debugging: set the source high object
|
2314
2352
|
delayL.properties[:low2high] = self.hdr_id
|
2353
|
+
self.properties[:high2low] = delayL
|
2315
2354
|
return delayL
|
2316
2355
|
end
|
2317
2356
|
end
|
@@ -2327,6 +2366,7 @@ module HDLRuby::High
|
|
2327
2366
|
timeWaitL = HDLRuby::Low::TimeWait.new(self.delay.to_low)
|
2328
2367
|
# For debugging: set the source high object
|
2329
2368
|
timeWaitL.properties[:low2high] = self.hdr_id
|
2369
|
+
self.properties[:high2low] = timeWaitL
|
2330
2370
|
return timeWaitL
|
2331
2371
|
end
|
2332
2372
|
end
|
@@ -2345,6 +2385,7 @@ module HDLRuby::High
|
|
2345
2385
|
self.delay.to_low)
|
2346
2386
|
# For debugging: set the source high object
|
2347
2387
|
timeRepeatL.properties[:low2high] = self.hdr_id
|
2388
|
+
self.properties[:high2low] = timeRepeatL
|
2348
2389
|
return timeRepeatL
|
2349
2390
|
end
|
2350
2391
|
end
|
@@ -2493,6 +2534,35 @@ module HDLRuby::High
|
|
2493
2534
|
return self.ljust(self[-1])
|
2494
2535
|
end
|
2495
2536
|
|
2537
|
+
# Match the type with +typ+:
|
2538
|
+
# - Recurse on the sub expr if hierachical type, raising an arror
|
2539
|
+
# if the expression is not hierarchical.
|
2540
|
+
# - Directly cast otherwise.
|
2541
|
+
def match_type(typ)
|
2542
|
+
# Has the type sub types?
|
2543
|
+
if typ.types? then
|
2544
|
+
unless self.is_a?(Concat) then
|
2545
|
+
raise AnyError,
|
2546
|
+
"Invalid class for assignment to hierarchical: #{self.class}."
|
2547
|
+
end
|
2548
|
+
return Concat.new(typ,
|
2549
|
+
self.each_expression.zip(typ.each_type).map do |e,t|
|
2550
|
+
e.match_type(t)
|
2551
|
+
end)
|
2552
|
+
elsif typ.vector? && typ.base.hierarchical? then
|
2553
|
+
unless self.is_a?(Concat) then
|
2554
|
+
raise AnyError,
|
2555
|
+
"Invalid class for assignment to hierarchical: #{self.class}."
|
2556
|
+
end
|
2557
|
+
return Concat.new(typ,
|
2558
|
+
self.each_expression.map do |e|
|
2559
|
+
e.match_type(typ.base)
|
2560
|
+
end)
|
2561
|
+
else
|
2562
|
+
return self.as(typ)
|
2563
|
+
end
|
2564
|
+
end
|
2565
|
+
|
2496
2566
|
# Gets the origin method for operation +op+.
|
2497
2567
|
def self.orig_operator(op)
|
2498
2568
|
return (op.to_s + "_orig").to_sym
|
@@ -2641,14 +2711,19 @@ module HDLRuby::High
|
|
2641
2711
|
#
|
2642
2712
|
# NOTE: it is converted afterward to an expression if required.
|
2643
2713
|
def <=(expr)
|
2714
|
+
# Cast expr to self if required.
|
2715
|
+
expr = expr.to_expr.match_type(self.type)
|
2716
|
+
# Generate the transmit.
|
2644
2717
|
if High.top_user.is_a?(HDLRuby::Low::Block) then
|
2645
2718
|
# We are in a block, so generate and add a Transmit.
|
2646
2719
|
High.top_user.
|
2647
|
-
add_statement(Transmit.new(self.to_ref,expr.to_expr))
|
2720
|
+
# add_statement(Transmit.new(self.to_ref,expr.to_expr))
|
2721
|
+
add_statement(Transmit.new(self.to_ref,expr))
|
2648
2722
|
else
|
2649
2723
|
# We are in a system type, so generate and add a Connection.
|
2650
2724
|
High.top_user.
|
2651
|
-
add_connection(Connection.new(self.to_ref,expr.to_expr))
|
2725
|
+
# add_connection(Connection.new(self.to_ref,expr.to_expr))
|
2726
|
+
add_connection(Connection.new(self.to_ref,expr))
|
2652
2727
|
end
|
2653
2728
|
end
|
2654
2729
|
end
|
@@ -2670,6 +2745,7 @@ module HDLRuby::High
|
|
2670
2745
|
castL =HDLRuby::Low::Cast.new(self.type.to_low,self.child.to_low)
|
2671
2746
|
# For debugging: set the source high object
|
2672
2747
|
castL.properties[:low2high] = self.hdr_id
|
2748
|
+
self.properties[:high2low] = castL
|
2673
2749
|
return castL
|
2674
2750
|
end
|
2675
2751
|
end
|
@@ -2693,6 +2769,7 @@ module HDLRuby::High
|
|
2693
2769
|
self.child.to_low)
|
2694
2770
|
# For debugging: set the source high object
|
2695
2771
|
unaryL.properties[:low2high] = self.hdr_id
|
2772
|
+
self.properties[:high2low] = unaryL
|
2696
2773
|
return unaryL
|
2697
2774
|
end
|
2698
2775
|
end
|
@@ -2717,6 +2794,7 @@ module HDLRuby::High
|
|
2717
2794
|
self.left.to_low, self.right.to_low)
|
2718
2795
|
# For debugging: set the source high object
|
2719
2796
|
binaryL.properties[:low2high] = self.hdr_id
|
2797
|
+
self.properties[:high2low] = binaryL
|
2720
2798
|
return binaryL
|
2721
2799
|
end
|
2722
2800
|
end
|
@@ -2751,6 +2829,7 @@ module HDLRuby::High
|
|
2751
2829
|
end)
|
2752
2830
|
# For debugging: set the source high object
|
2753
2831
|
selectL.properties[:low2high] = self.hdr_id
|
2832
|
+
self.properties[:high2low] = selectL
|
2754
2833
|
return selectL
|
2755
2834
|
end
|
2756
2835
|
end
|
@@ -2784,6 +2863,7 @@ module HDLRuby::High
|
|
2784
2863
|
)
|
2785
2864
|
# For debugging: set the source high object
|
2786
2865
|
concatL.properties[:low2high] = self.hdr_id
|
2866
|
+
self.properties[:high2low] = concatL
|
2787
2867
|
return concatL
|
2788
2868
|
end
|
2789
2869
|
end
|
@@ -2827,6 +2907,7 @@ module HDLRuby::High
|
|
2827
2907
|
valueL = HDLRuby::Low::Value.new(self.type.to_low,self.content)
|
2828
2908
|
# For debugging: set the source high object
|
2829
2909
|
valueL.properties[:low2high] = self.hdr_id
|
2910
|
+
self.properties[:high2low] = valueL
|
2830
2911
|
return valueL
|
2831
2912
|
end
|
2832
2913
|
|
@@ -2929,12 +3010,12 @@ module HDLRuby::High
|
|
2929
3010
|
|
2930
3011
|
# Converts the name reference to a HDLRuby::Low::RefName.
|
2931
3012
|
def to_low
|
2932
|
-
#
|
2933
|
-
# @base.to_ref.to_low,@object.name)
|
3013
|
+
# puts "to_low with base=#{@base} @object=#{@object}"
|
2934
3014
|
refNameL = HDLRuby::Low::RefName.new(self.type.to_low,
|
2935
3015
|
@base.to_ref.to_low,@object.name)
|
2936
3016
|
# For debugging: set the source high object
|
2937
3017
|
refNameL.properties[:low2high] = self.hdr_id
|
3018
|
+
self.properties[:high2low] = refNameL
|
2938
3019
|
return refNameL
|
2939
3020
|
end
|
2940
3021
|
|
@@ -2974,6 +3055,7 @@ module HDLRuby::High
|
|
2974
3055
|
)
|
2975
3056
|
# For debugging: set the source high object
|
2976
3057
|
refConcatL.properties[:low2high] = self.hdr_id
|
3058
|
+
self.properties[:high2low] = refConcatL
|
2977
3059
|
return refConcatL
|
2978
3060
|
end
|
2979
3061
|
end
|
@@ -2997,6 +3079,7 @@ module HDLRuby::High
|
|
2997
3079
|
self.ref.to_low,self.index.to_low)
|
2998
3080
|
# For debugging: set the source high object
|
2999
3081
|
refIndexL.properties[:low2high] = self.hdr_id
|
3082
|
+
self.properties[:high2low] = refIndexL
|
3000
3083
|
return refIndexL
|
3001
3084
|
end
|
3002
3085
|
end
|
@@ -3020,6 +3103,7 @@ module HDLRuby::High
|
|
3020
3103
|
self.ref.to_low,self.range.to_low)
|
3021
3104
|
# For debugging: set the source high object
|
3022
3105
|
refRangeL.properties[:low2high] = self.hdr_id
|
3106
|
+
self.properties[:high2low] = refRangeL
|
3023
3107
|
return refRangeL
|
3024
3108
|
end
|
3025
3109
|
end
|
@@ -3031,7 +3115,7 @@ module HDLRuby::High
|
|
3031
3115
|
|
3032
3116
|
# Converts to a new reference.
|
3033
3117
|
def to_ref
|
3034
|
-
return RefName.new(self.ref.to_ref,self.name)
|
3118
|
+
return RefName.new(self.type,self.ref.to_ref,self.name)
|
3035
3119
|
end
|
3036
3120
|
|
3037
3121
|
# Converts the name reference to HDLRuby::Low.
|
@@ -3042,6 +3126,7 @@ module HDLRuby::High
|
|
3042
3126
|
self.ref.to_low,self.name)
|
3043
3127
|
# For debugging: set the source high object
|
3044
3128
|
refNameL.properties[:low2high] = self.hdr_id
|
3129
|
+
self.properties[:high2low] = refNameL
|
3045
3130
|
return refNameL
|
3046
3131
|
end
|
3047
3132
|
end
|
@@ -3078,14 +3163,49 @@ module HDLRuby::High
|
|
3078
3163
|
refThisL = HDLRuby::Low::RefThis.new
|
3079
3164
|
# For debugging: set the source high object
|
3080
3165
|
refThisL.properties[:low2high] = self.hdr_id
|
3166
|
+
self.properties[:high2low] = refThisL
|
3081
3167
|
return refThisL
|
3082
3168
|
end
|
3083
3169
|
end
|
3084
3170
|
|
3171
|
+
##
|
3172
|
+
# Describes a string.
|
3173
|
+
#
|
3174
|
+
# NOTE: This is not synthesizable!
|
3175
|
+
class StringE < Low::StringE
|
3176
|
+
include HExpression
|
3177
|
+
|
3178
|
+
# Converts to an expression.
|
3179
|
+
def to_expr
|
3180
|
+
return StringE.new(self.content,*self.each_arg.map(&:to_expr))
|
3181
|
+
end
|
3182
|
+
|
3183
|
+
# Converts the connection to HDLRuby::Low.
|
3184
|
+
def to_low
|
3185
|
+
return HDLRuby::Low::StringE.new(self.content,
|
3186
|
+
*self.each_arg.map(&:to_low))
|
3187
|
+
end
|
3188
|
+
end
|
3189
|
+
|
3190
|
+
|
3191
|
+
|
3192
|
+
|
3193
|
+
# Sets the current this to +obj+.
|
3194
|
+
#
|
3195
|
+
# NOTE: do not use a this= style to avoid confusion.
|
3196
|
+
def set_this(obj = proc { RefThis.new })
|
3197
|
+
if (obj.is_a?(Proc)) then
|
3198
|
+
@@this = obj
|
3199
|
+
else
|
3200
|
+
@@this = proc { RefObject.new(RefThis.new,obj) }
|
3201
|
+
end
|
3202
|
+
end
|
3203
|
+
|
3085
3204
|
|
3086
3205
|
# Gives access to the *this* reference.
|
3087
3206
|
def this
|
3088
|
-
RefThis.new
|
3207
|
+
# RefThis.new
|
3208
|
+
@@this.call
|
3089
3209
|
end
|
3090
3210
|
|
3091
3211
|
|
@@ -3116,6 +3236,7 @@ module HDLRuby::High
|
|
3116
3236
|
eventL = HDLRuby::Low::Event.new(self.type,self.ref.to_low)
|
3117
3237
|
# For debugging: set the source high object
|
3118
3238
|
eventL.properties[:low2high] = self.hdr_id
|
3239
|
+
self.properties[:high2low] = eventL
|
3119
3240
|
return eventL
|
3120
3241
|
end
|
3121
3242
|
end
|
@@ -3158,10 +3279,33 @@ module HDLRuby::High
|
|
3158
3279
|
self.right.to_low)
|
3159
3280
|
# For debugging: set the source high object
|
3160
3281
|
transmitL.properties[:low2high] = self.hdr_id
|
3282
|
+
self.properties[:high2low] = transmitL
|
3161
3283
|
return transmitL
|
3162
3284
|
end
|
3163
3285
|
end
|
3164
3286
|
|
3287
|
+
|
3288
|
+
##
|
3289
|
+
# Describes a print statement: not synthesizable!
|
3290
|
+
class Print < Low::Print
|
3291
|
+
High = HDLRuby::High
|
3292
|
+
|
3293
|
+
include HStatement
|
3294
|
+
|
3295
|
+
# Creates a new statement for printing +args+.
|
3296
|
+
def initialize(*args)
|
3297
|
+
# Process the arguments.
|
3298
|
+
super(*args.map(&:to_expr))
|
3299
|
+
end
|
3300
|
+
|
3301
|
+
# Converts the connection to HDLRuby::Low.
|
3302
|
+
def to_low
|
3303
|
+
return HDLRuby::Low::Print.new(*self.each_arg.map(&:to_low))
|
3304
|
+
end
|
3305
|
+
|
3306
|
+
end
|
3307
|
+
|
3308
|
+
|
3165
3309
|
##
|
3166
3310
|
# Describes a connection.
|
3167
3311
|
class Connection < Low::Connection
|
@@ -3228,6 +3372,7 @@ module HDLRuby::High
|
|
3228
3372
|
self.right.to_low)
|
3229
3373
|
# For debugging: set the source high object
|
3230
3374
|
connectionL.properties[:low2high] = self.hdr_id
|
3375
|
+
self.properties[:high2low] = connectionL
|
3231
3376
|
return connectionL
|
3232
3377
|
end
|
3233
3378
|
end
|
@@ -3258,7 +3403,7 @@ module HDLRuby::High
|
|
3258
3403
|
# NOTE: +dir+ can be :input, :output, :inout or :inner
|
3259
3404
|
def initialize(name,type,dir,value = nil)
|
3260
3405
|
# Check the value.
|
3261
|
-
value = value.to_expr if value
|
3406
|
+
value = value.to_expr.match_type(type) if value
|
3262
3407
|
# Initialize the type structure.
|
3263
3408
|
super(name,type,value)
|
3264
3409
|
|
@@ -3341,6 +3486,7 @@ module HDLRuby::High
|
|
3341
3486
|
signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low)
|
3342
3487
|
# For debugging: set the source high object
|
3343
3488
|
signalIL.properties[:low2high] = self.hdr_id
|
3489
|
+
self.properties[:high2low] = signalIL
|
3344
3490
|
return signalIL
|
3345
3491
|
end
|
3346
3492
|
end
|
@@ -3357,7 +3503,7 @@ module HDLRuby::High
|
|
3357
3503
|
# and +value+.
|
3358
3504
|
def initialize(name,type,value)
|
3359
3505
|
# Check the value is a constant.
|
3360
|
-
value = value.to_expr
|
3506
|
+
value = value.to_expr.match_type(type)
|
3361
3507
|
unless value.constant? then
|
3362
3508
|
raise AnyError,"Non-constant value assignment to constant."
|
3363
3509
|
end
|
@@ -3406,6 +3552,7 @@ module HDLRuby::High
|
|
3406
3552
|
self.value.to_low)
|
3407
3553
|
# For debugging: set the source high object
|
3408
3554
|
signalCL.properties[:low2high] = self.hdr_id
|
3555
|
+
self.properties[:high2low] = signalCL
|
3409
3556
|
return signalCL
|
3410
3557
|
end
|
3411
3558
|
end
|
@@ -3479,13 +3626,6 @@ module HDLRuby::High
|
|
3479
3626
|
# Use its return value.
|
3480
3627
|
return block.return_value
|
3481
3628
|
end
|
3482
|
-
|
3483
|
-
# # Get the current mode of the block.
|
3484
|
-
# #
|
3485
|
-
# # NOTE: for name coherency purpose only.
|
3486
|
-
# def block
|
3487
|
-
# return self.mode
|
3488
|
-
# end
|
3489
3629
|
|
3490
3630
|
# Gets the current block.
|
3491
3631
|
def cur_block
|
@@ -3583,6 +3723,12 @@ module HDLRuby::High
|
|
3583
3723
|
end
|
3584
3724
|
statement.hwhen(match, mode, &ruby_block)
|
3585
3725
|
end
|
3726
|
+
|
3727
|
+
|
3728
|
+
# Prints.
|
3729
|
+
def hprint(*args)
|
3730
|
+
self.add_statement(Print.new(*args))
|
3731
|
+
end
|
3586
3732
|
end
|
3587
3733
|
|
3588
3734
|
|
@@ -3619,6 +3765,7 @@ module HDLRuby::High
|
|
3619
3765
|
blockL = HDLRuby::Low::Block.new(self.mode)
|
3620
3766
|
# For debugging: set the source high object
|
3621
3767
|
blockL.properties[:low2high] = self.hdr_id
|
3768
|
+
self.properties[:high2low] = blockL
|
3622
3769
|
# Push the namespace for the low generation.
|
3623
3770
|
High.space_push(@namespace)
|
3624
3771
|
# Pushes on the name stack for converting the internals of
|
@@ -3688,6 +3835,7 @@ module HDLRuby::High
|
|
3688
3835
|
blockL = HDLRuby::Low::TimeBlock.new(self.mode)
|
3689
3836
|
# For debugging: set the source high object
|
3690
3837
|
blockL.properties[:low2high] = self.hdr_id
|
3838
|
+
self.properties[:high2low] = blockL
|
3691
3839
|
# Add the inner signals
|
3692
3840
|
self.each_inner { |inner| blockL.add_inner(inner.to_low) }
|
3693
3841
|
# Add the statements
|
@@ -3781,6 +3929,7 @@ module HDLRuby::High
|
|
3781
3929
|
behaviorL = HDLRuby::Low::Behavior.new(blockL)
|
3782
3930
|
# For debugging: set the source high object
|
3783
3931
|
behaviorL.properties[:low2high] = self.hdr_id
|
3932
|
+
self.properties[:high2low] = behaviorL
|
3784
3933
|
eventLs.each(&behaviorL.method(:add_event))
|
3785
3934
|
return behaviorL
|
3786
3935
|
end
|
@@ -3810,6 +3959,7 @@ module HDLRuby::High
|
|
3810
3959
|
timeBehaviorL = HDLRuby::Low::TimeBehavior.new(blockL)
|
3811
3960
|
# For debugging: set the source high object
|
3812
3961
|
timeBehaviorL.properties[:low2high] = self.hdr_id
|
3962
|
+
self.properties[:high2low] = timeBehaviorL
|
3813
3963
|
eventLs.each(&timeBehaviorL.method(:add_event))
|
3814
3964
|
return timeBehaviorL
|
3815
3965
|
end
|
@@ -4116,13 +4266,40 @@ module HDLRuby::High
|
|
4116
4266
|
|
4117
4267
|
# Extends the String class for computing conversion to expression.
|
4118
4268
|
class ::String
|
4119
|
-
# Converts to a new high-level expression.
|
4120
|
-
def to_expr
|
4269
|
+
# # Converts to a new high-level expression.
|
4270
|
+
# def to_expr
|
4271
|
+
# # Convert the string to a bit string.
|
4272
|
+
# bstr = BitString.new(self)
|
4273
|
+
# # Use it to create the new value.
|
4274
|
+
# return Value.new(Bit[bstr.width],self)
|
4275
|
+
# end
|
4276
|
+
|
4277
|
+
# Converts to a new high-level value.
|
4278
|
+
def to_value
|
4121
4279
|
# Convert the string to a bit string.
|
4122
4280
|
bstr = BitString.new(self)
|
4123
4281
|
# Use it to create the new value.
|
4124
4282
|
return Value.new(Bit[bstr.width],self)
|
4125
4283
|
end
|
4284
|
+
|
4285
|
+
# Convert to a new high-level string expression
|
4286
|
+
def to_expr
|
4287
|
+
return StringE.new(self)
|
4288
|
+
end
|
4289
|
+
|
4290
|
+
# For now deactivated, needs rethinking.
|
4291
|
+
# # Rework format to generate HDLRuby string.
|
4292
|
+
# alias_method :__format_old__, :%
|
4293
|
+
# def %(args)
|
4294
|
+
# # Is there any HW argument?
|
4295
|
+
# if args.any? { |arg| arg.is_a?(HDLRuby::Low::Hparent) } then
|
4296
|
+
# # Yes generate a HDLRuby string.
|
4297
|
+
# return StringE.new(self,*args)
|
4298
|
+
# else
|
4299
|
+
# # No process the format normally.
|
4300
|
+
# self.__format_old__(args)
|
4301
|
+
# end
|
4302
|
+
# end
|
4126
4303
|
end
|
4127
4304
|
|
4128
4305
|
|
@@ -4216,11 +4393,14 @@ module HDLRuby::High
|
|
4216
4393
|
|
4217
4394
|
# Converts to a new high-level expression.
|
4218
4395
|
def to_expr
|
4219
|
-
# expr = Concat.new
|
4220
|
-
|
4221
|
-
|
4222
|
-
|
4223
|
-
|
4396
|
+
# expr = Concat.new(TypeTuple.new(:"",:little,*self.map do |elem|
|
4397
|
+
# elem.to_expr.type
|
4398
|
+
# end))
|
4399
|
+
elems = self.map {|elem| elem.to_expr }
|
4400
|
+
typ= TypeTuple.new(:"",:little)
|
4401
|
+
elems.each {|elem| typ.add_type(elem.type) }
|
4402
|
+
expr = Concat.new(typ)
|
4403
|
+
elems.each {|elem| expr.add_expression(elem) }
|
4224
4404
|
expr
|
4225
4405
|
end
|
4226
4406
|
|
@@ -4291,6 +4471,11 @@ module HDLRuby::High
|
|
4291
4471
|
end
|
4292
4472
|
end
|
4293
4473
|
|
4474
|
+
# Add support of the left arrow operator.
|
4475
|
+
def <=(expr)
|
4476
|
+
self.to_expr <= expr
|
4477
|
+
end
|
4478
|
+
|
4294
4479
|
# Array construction shortcuts
|
4295
4480
|
|
4296
4481
|
# Create an array whose number of elements is given by the content
|
@@ -4583,6 +4768,9 @@ def self.configure_high
|
|
4583
4768
|
end
|
4584
4769
|
end
|
4585
4770
|
|
4771
|
+
# Initialize the this.
|
4772
|
+
set_this
|
4773
|
+
|
4586
4774
|
# Generate the standard signals
|
4587
4775
|
$clk = Universe.scope.inner :__universe__clk__
|
4588
4776
|
$rst = Universe.scope.inner :__universe__rst__
|