HDLRuby 2.6.23 → 2.7.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d8c97794e72e7b03ad7d6db03c24ff4fb77748c3340bc9b9857a64537118e8f
4
- data.tar.gz: 8077bcb0c9ce65c3372943ffcdeb2fd756fcd6969e94e135bb32a53b3de1e650
3
+ metadata.gz: 4995e808d0aa2901a483011a4848bb9416d68850c95c74b9c2f2bf1fb3f648dc
4
+ data.tar.gz: 729643cd60228ab9ba4f3ab719e434b48963805ed6f4ac01dbcff2fdd6eb54b9
5
5
  SHA512:
6
- metadata.gz: 104fae34f93944ecc476026b0e8c97b548220e92b7e14727f66af0dc8e6e3655b9dee20b1057f177263ad8947fd2a289333b7aa4378e9baaf16dac57cb41b988
7
- data.tar.gz: 47c8c77471d8aff9cc4e601f403d3f32f254658f81884075cdc25e9c4ea422cbd3ef645664fcc3524f2cfb632c2a7c3f11d1cff20451a81e17422e3fab0f4130
6
+ metadata.gz: 82316dd87a532dbfa67d86fcdb13ade3f8329912bb6aa56ae0b5a4efe0a6110922912f52ae3558c4683147bb224ae2ed0b67e1d60e265d5d30624b3a2bee77be
7
+ data.tar.gz: 4df2cfb5c257838246fa2f953b3eeaa751902900ae4ea5319a69ca81f9e7eae49b75163fc621a81b2af1b399360c030ccf8717916c2abb7a5d2ffaad27d2b5df
@@ -0,0 +1,35 @@
1
+ # Test the comparison operators.
2
+
3
+ # A benchmark for the if statement.
4
+ system :if_bench do
5
+ [8].inner :x, :z
6
+
7
+ par do
8
+ hcase(x)
9
+ hwhen(0) { z <= 0 }
10
+ hwhen(1) { z <= 1 }
11
+ hwhen(2) { z <= 4 }
12
+ hwhen(3) { z <= 9 }
13
+ hwhen(4) { z <= 16 }
14
+ hwhen(5) { z <= 25 }
15
+ hwhen(6) { z <= 36 }
16
+ hwhen(7) { z <= 49 }
17
+ hwhen(8) { z <= 64 }
18
+ hwhen(9) { z <= 81 }
19
+ hwhen(10) { z <= 100 }
20
+ hwhen(11) { z <= 121 }
21
+ hwhen(12) { z <= 144 }
22
+ hwhen(13) { z <= 169 }
23
+ hwhen(14) { z <= 196 }
24
+ hwhen(15) { z <= 225 }
25
+ helse { z <= _zzzzzzzz }
26
+ end
27
+
28
+ timed do
29
+ !10.ns
30
+ 20.times do |i|
31
+ x <= i
32
+ !10.ns
33
+ end
34
+ end
35
+ end
@@ -2,7 +2,7 @@
2
2
 
3
3
 
4
4
  function :func do |addr|
5
- bit[4][-4].constant tbl: [ _0000, _0001, _0010, _0011 ]
5
+ bit[4][-4].constant tbl: [ _1000, _1001, _1010, _1011 ]
6
6
 
7
7
  tbl[addr]
8
8
  end
@@ -0,0 +1,24 @@
1
+ # Test the comparison operators.
2
+
3
+ # A benchmark for the if statement.
4
+ system :if_bench do
5
+ [8].inner :x, :y, :z
6
+
7
+ par do
8
+ hif(x == y) { z <= 1 }
9
+ helsif(x < y) { z <= 2 }
10
+ helse { z <= 3 }
11
+ end
12
+
13
+ timed do
14
+ x <= 0
15
+ y <= 0
16
+ !10.ns
17
+ x <= 1
18
+ !10.ns
19
+ y <= 2
20
+ !10.ns
21
+ x <= 2
22
+ !10.ns
23
+ end
24
+ end
@@ -0,0 +1,37 @@
1
+ # Test the comparison operators.
2
+
3
+ # A benchmark for the index access..
4
+ system :if_bench do
5
+ [8].inner :x
6
+ inner :b0,:b1,:b2,:b3,:b4,:b5,:b6,:b7
7
+
8
+ par do
9
+ b0 <= x[0]
10
+ b1 <= x[1]
11
+ b2 <= x[2]
12
+ b3 <= x[3]
13
+ b4 <= x[4]
14
+ b5 <= x[5]
15
+ b6 <= x[6]
16
+ b7 <= x[7]
17
+ end
18
+
19
+ timed do
20
+ x <= 0
21
+ !10.ns
22
+ x <= 1
23
+ !10.ns
24
+ x <= 2
25
+ !10.ns
26
+ x <= 3
27
+ !10.ns
28
+ x <= 4
29
+ !10.ns
30
+ x <= 5
31
+ !10.ns
32
+ x[7] <= 1
33
+ !10.ns
34
+ x[6] <= 1
35
+ !10.ns
36
+ end
37
+ end
@@ -0,0 +1,47 @@
1
+ # Test the comparison operators.
2
+
3
+ # A benchmark for the index access..
4
+ system :if_bench do
5
+ [8].inner :x
6
+ [2].inner :r0,:r1,:r2,:r3
7
+
8
+ par do
9
+ r0 <= x[1..0]
10
+ r1 <= x[3..2]
11
+ r2 <= x[5..4]
12
+ r3 <= x[7..6]
13
+ end
14
+
15
+ timed do
16
+ x <= 0
17
+ !10.ns
18
+ x <= 1
19
+ !10.ns
20
+ x <= 2
21
+ !10.ns
22
+ x <= 3
23
+ !10.ns
24
+ x <= 4
25
+ !10.ns
26
+ x <= 5
27
+ !10.ns
28
+ x <= 6
29
+ !10.ns
30
+ x <= 7
31
+ !10.ns
32
+ x <= 8
33
+ !10.ns
34
+ x <= 81
35
+ !10.ns
36
+ x <= 123
37
+ !10.ns
38
+ x <= 0
39
+ !10.ns
40
+ x[7..6] <= 3
41
+ !10.ns
42
+ x[5..4] <= 2
43
+ !10.ns
44
+ x[3..2] <= 1
45
+ !10.ns
46
+ end
47
+ end
@@ -0,0 +1,30 @@
1
+
2
+ # A benchmark for testing the casts.
3
+ system :with_cast do
4
+ [8].inner :count
5
+ [8].inner :val0,:val1
6
+ [9].inner :val2,:val3
7
+
8
+ timed do
9
+ val0 <= _11111111
10
+ val1 <= _00000010
11
+ val3 <= _000000000
12
+ count <= 0
13
+ !10.ns
14
+ count <= 1
15
+ val2 <= val0 + val1
16
+ val3 <= val3 + 1
17
+ !10.ns
18
+ count <= 2
19
+ val2 <= val0.as(bit[9]) + val1
20
+ val3 <= val3.as(bit[10]) + 1
21
+ !10.ns
22
+ count <= 3
23
+ val2 <= (val0 + val1).as(bit[9])
24
+ val3 <= (val3 + 1).as(bit[10])
25
+ !10.ns
26
+ count <= 4
27
+ val2 <= (val0 + val1).as(bit[8])
28
+ !10.ns
29
+ end
30
+ end
@@ -0,0 +1,26 @@
1
+
2
+ # A benchmark for testing the concat.
3
+ system :with_concat do
4
+ [8].inner :count
5
+ [4].inner :val0,:val1
6
+ [8].inner :val2
7
+ [12].inner :val3
8
+
9
+ val2 <= [val0,val1]
10
+ val3 <= [val2,val0]
11
+
12
+ timed do
13
+ val0 <= _1111
14
+ val1 <= _0000
15
+ count <= 0
16
+ !10.ns
17
+ val0 <= _1001
18
+ val1 <= _0110
19
+ count <= 1
20
+ !10.ns
21
+ val0 <= _1010
22
+ val1 <= _0101
23
+ count <= 2
24
+ !10.ns
25
+ end
26
+ end
@@ -0,0 +1,18 @@
1
+
2
+ # A benchmark for testing the initialization of signals.
3
+ system :with_init do
4
+ [8].constant cst0: 127
5
+ constant cst1: _1
6
+ [8].inner sig0: _10000000
7
+ inner sig1: _1
8
+ [8].inner :sig2
9
+
10
+ timed do
11
+ !10.ns
12
+ sig2 <= cst0 + cst1
13
+ sig0 <= sig0 + sig1
14
+ !10.ns
15
+ sig2 <= sig2 + sig1
16
+ !10.ns
17
+ end
18
+ end
@@ -0,0 +1,42 @@
1
+
2
+
3
+
4
+ # A benchmark for testing the instantiations.
5
+
6
+ system :adder do |typ|
7
+ typ.input :x, :y
8
+ typ.output :z
9
+
10
+ z <= x + y
11
+ end
12
+
13
+ system :truc do
14
+ [8].input :u, :v
15
+ [8].output :q
16
+ end
17
+
18
+
19
+
20
+ system :with_instance do
21
+
22
+ [8].inner :x0, :y0, :z0, :x1, :y1, :z1
23
+
24
+ truc(:montruc).(x0,y0,z0)
25
+
26
+ adder(bit[8]).(:adderI0).(x0,y0,z0)
27
+ adder(bit[8]).(:adderI1).(x: x1, y: y1, z: z1)
28
+
29
+ timed do
30
+ !10.ns
31
+ x0 <= 0
32
+ y0 <= 0
33
+ x1 <= 1
34
+ y1 <= 1
35
+ !10.ns
36
+ x0 <= 1
37
+ y0 <= 1
38
+ x1 <= 2
39
+ y1 <= 2
40
+ !10.ns
41
+ end
42
+ end
@@ -0,0 +1,26 @@
1
+
2
+ # A benchmark for testing array references.
3
+ system :with_concat do
4
+ [8].inner :count
5
+ [8].inner :val0,:val1
6
+ [3].inner :val2
7
+ [8].inner :val3
8
+
9
+ val2 <= val0[4..2]
10
+ val3[6..3] <= val1[7..4]
11
+
12
+ timed do
13
+ val0 <= _00001111
14
+ val1 <= _11000011
15
+ count <= 0
16
+ !10.ns
17
+ val0 <= _11110000
18
+ val1 <= _00111100
19
+ count <= 1
20
+ !10.ns
21
+ val0 <= _10101010
22
+ val1 <= _01010101
23
+ count <= 2
24
+ !10.ns
25
+ end
26
+ end
@@ -0,0 +1,33 @@
1
+
2
+ # A benchmark for sum of sub parts of a vector.
3
+ system :with_concat do
4
+ [8].inner :count
5
+ [16].inner :val0, :val1, :val2, :val3, :val4, :val5, :val6
6
+ bs = []
7
+ 10.times do |i|
8
+ bs << [16].inner(:"b#{i}")
9
+ end
10
+
11
+ vals = [val1,val2,val3,val4]
12
+ par do
13
+ vals.each.with_index { |val,i| val <= val0[(i*4+3)..i*4] }
14
+ end
15
+ val5 <= vals.reduce(:+)
16
+
17
+ par do
18
+ bs.each.with_index { |b,i| b <= val0[i..i] }
19
+ end
20
+ val6 <= bs.reduce(:+)
21
+
22
+ timed do
23
+ val0 <= _1111000011110000
24
+ count <= 0
25
+ !10.ns
26
+ val0 <= _0000111100001111
27
+ count <= 1
28
+ !10.ns
29
+ val0 <= _1010101010101010
30
+ count <= 2
31
+ !10.ns
32
+ end
33
+ end
@@ -0,0 +1,61 @@
1
+
2
+ # A benchmark for testing the literal values.
3
+ system :with_values do
4
+ inner :v1
5
+ [8].inner :v8
6
+ [16].inner :v16
7
+ [32].inner :v32
8
+ [56].inner :v56
9
+ [64].inner :v64
10
+ [96].inner :v96
11
+
12
+
13
+ timed do
14
+ v1 <= 0
15
+ v8 <= 0
16
+ v16 <= 0
17
+ v32 <= 0
18
+ v56 <= 0
19
+ v64 <= 0
20
+ v96 <= 0
21
+ !10.ns
22
+ v1 <= 1
23
+ v8 <= 1
24
+ v16 <= 1
25
+ v32 <= 1
26
+ v56 <= 1
27
+ v64 <= 1
28
+ v96 <= 1
29
+ !10.ns
30
+ v1 <= _1010[2]
31
+ v8 <= _uhFF00[12..4]
32
+ !10.ns
33
+ v8 <= 128
34
+ v16 <= 128
35
+ v32 <= 128
36
+ v56 <= 128
37
+ v64 <= 128
38
+ v96 <= 128
39
+ !10.ns
40
+ v16 <= 0x1000
41
+ v32 <= 0x1000
42
+ v56 <= 0x1000
43
+ v64 <= 0x1000
44
+ v96 <= 0x1000
45
+ !10.ns
46
+ v32 <= 0x10000000
47
+ v56 <= 0x10000000
48
+ v64 <= 0x10000000
49
+ v96 <= 0x10000000
50
+ !10.ns
51
+ v56 <= 0x10000000000000
52
+ v64 <= 0x10000000000000
53
+ v96 <= 0x10000000000000
54
+ !10.ns
55
+ v64 <= 0x1000000000000000
56
+ v96 <= 0x1000000000000000
57
+ !10.ns
58
+ v96 <= 0x1000000000000000000
59
+ !10.ns
60
+ end
61
+ end
data/lib/HDLRuby/hdrcc.rb CHANGED
@@ -486,6 +486,8 @@ if $options[:syntax] then
486
486
  $output << $loader.show_all
487
487
  exit
488
488
  end
489
+ HDLRuby.show Time.now
490
+ HDLRuby.show "##### Starting parser #####"
489
491
 
490
492
  if $options[:debug] then
491
493
  # Debug mode, no error management.
@@ -608,26 +610,29 @@ elsif $options[:clang] then
608
610
  $outfile = File.open($hname,"w")
609
611
  # Adds the generated globals
610
612
  $top_system.each_systemT_deep do |systemT|
611
- # For the h file.
612
- # hname = $output + "/" +
613
- # HDLRuby::Low::Low2C.c_name(systemT.name) +
614
- # ".h"
615
- # hnames << File.basename(hname)
616
- # # Open the file for current systemT
617
- # output = File.open(hname,"w")
613
+ # # For the h file.
614
+ # # hname = $output + "/" +
615
+ # # HDLRuby::Low::Low2C.c_name(systemT.name) +
616
+ # # ".h"
617
+ # # hnames << File.basename(hname)
618
+ # # # Open the file for current systemT
619
+ # # output = File.open(hname,"w")
618
620
  # Generate the H code in to.
619
- $outfile << systemT.to_ch
620
- # # Close the file.
621
- # output.close
622
- # # Clears the name.
623
- # hname = nil
621
+ # $outfile << systemT.to_ch
622
+ systemT.to_ch($outfile)
623
+ # # # Close the file.
624
+ # # output.close
625
+ # # # Clears the name.
626
+ # # hname = nil
624
627
  end
625
628
  # Adds the globals from the non-HDLRuby code
626
629
  $non_hdlruby.each do |code|
627
630
  code.each_chunk do |chunk|
628
631
  if chunk.name == :sim then
629
- $outfile << "extern " +
630
- HDLRuby::Low::Low2C.prototype(chunk.to_c)
632
+ # $outfile << "extern " +
633
+ # HDLRuby::Low::Low2C.prototype(chunk.to_c)
634
+ $outfile << "extern "
635
+ $outfile << HDLRuby::Low::Low2C.prototype(chunk.to_c(""))
631
636
  end
632
637
  end
633
638
  end
@@ -659,7 +664,8 @@ elsif $options[:clang] then
659
664
  # Open the file for current systemT
660
665
  outfile = File.open(name,"w")
661
666
  # Generate the C code in to.
662
- outfile << systemT.to_c(0,*$hnames)
667
+ # outfile << systemT.to_c(0,*$hnames)
668
+ systemT.to_c(outfile,0,*$hnames)
663
669
  # Close the file.
664
670
  outfile.close
665
671
  # Clears the name.
@@ -668,8 +674,10 @@ elsif $options[:clang] then
668
674
  else
669
675
  # Single file generation mode.
670
676
  $top_system.each_systemT_deep.reverse_each do |systemT|
671
- $output << systemT.to_ch
672
- $output << systemT.to_c
677
+ # $output << systemT.to_ch
678
+ systemT.to_ch($output)
679
+ # $output << systemT.to_c
680
+ systemT.to_c($output)
673
681
  end
674
682
  # Adds the main code.
675
683
  $output << HDLRuby::Low::Low2C.main(top_system,
@@ -709,17 +717,19 @@ elsif $options[:verilog] then
709
717
  # top_system = $top_system
710
718
  # Make description compatible with verilog generation.
711
719
  $top_system.each_systemT_deep do |systemT|
712
- HDLRuby.show "casts_without_expression! step..."
713
- systemT.casts_without_expression!
714
- HDLRuby.show Time.now
720
+ # HDLRuby.show "casts_without_expression! step..."
721
+ # systemT.casts_without_expression!
722
+ # HDLRuby.show Time.now
715
723
  HDLRuby.show "to_upper_space! step..."
716
724
  systemT.to_upper_space!
717
725
  HDLRuby.show Time.now
718
- HDLRuby.show "to_global_space! step..."
719
- systemT.to_global_systemTs!
720
- HDLRuby.show Time.now
721
- # systemT.break_types!
722
- # systemT.expand_types!
726
+ end
727
+ HDLRuby.show "to_global_space! step (global)..."
728
+ $top_system.to_global_systemTs!
729
+ HDLRuby.show Time.now
730
+ $top_system.each_systemT_deep do |systemT|
731
+ ## systemT.break_types!
732
+ ## systemT.expand_types!
723
733
  HDLRuby.show "par_in_seq2seq! step..."
724
734
  systemT.par_in_seq2seq!
725
735
  HDLRuby.show Time.now
@@ -818,6 +828,9 @@ elsif $options[:vhdl] then
818
828
  end
819
829
  end
820
830
 
831
+ HDLRuby.show "##### Code generated #####"
832
+ HDLRuby.show Time.now
833
+
821
834
  # # Apply the post drivers if any.
822
835
  # Hdecorator.each_with_property(:post_driver) do |obj, value|
823
836
  # # Load the driver.
@@ -256,9 +256,9 @@ module HDLRuby::High
256
256
  SignalI.new(name,type,:inner))
257
257
  elsif name.is_a?(Hash) then
258
258
  # Names associated with values.
259
- names.each do |name,value|
259
+ name.each do |key,value|
260
260
  res = self.add_inner(
261
- SignalI.new(name,type,:inner,value))
261
+ SignalI.new(key,type,:inner,value))
262
262
  end
263
263
  else
264
264
  raise AnyError,
@@ -550,10 +550,14 @@ module HDLRuby::High
550
550
  expanded = self.class.new(name.to_s) {}
551
551
  # Include the mixin systems given when declaring the system.
552
552
  @to_includes.each { |system| expanded.scope.include(system) }
553
+ # Include the previously includeds. */
554
+ self.scope.each_included { |system| expanded.scope.include(system) }
553
555
 
554
556
  # Sets the generators of the expanded result.
555
557
  expanded.add_generator(self)
556
558
  @to_includes.each { |system| expanded.add_generator(system) }
559
+ # Also for the previously includeds. */
560
+ self.scope.each_included.each { |system| expanded.add_generator(system) }
557
561
 
558
562
  # Fills the scope of the expanded class.
559
563
  # puts "Build top with #{self.name} for #{name}"
@@ -1237,6 +1241,7 @@ module HDLRuby::High
1237
1241
  end
1238
1242
  # Adds it the list of includeds
1239
1243
  @includes[include_name] = system
1244
+ # puts "@includes=#{@includes}"
1240
1245
 
1241
1246
  end
1242
1247
 
@@ -1960,6 +1965,9 @@ module HDLRuby::High
1960
1965
  &ruby_block)
1961
1966
  # ruby_block.call(*args)
1962
1967
  end
1968
+ # sub do
1969
+ # ruby_block.call(*args,*other_block)
1970
+ # end
1963
1971
  end
1964
1972
  else
1965
1973
  define_method(name.to_sym) do |*args,&other_block|
@@ -1968,6 +1976,9 @@ module HDLRuby::High
1968
1976
  HDLRuby::High.top_user.instance_exec(*args,*other_block,
1969
1977
  &ruby_block)
1970
1978
  end
1979
+ # sub do
1980
+ # ruby_block.call(*args,*other_block)
1981
+ # end
1971
1982
  end
1972
1983
  end
1973
1984
  end
@@ -2027,10 +2038,25 @@ module HDLRuby::High
2027
2038
  connects.each do |key,value|
2028
2039
  # Gets the signal corresponding to connect.
2029
2040
  signal = self.get_signal(key)
2041
+ unless signal then
2042
+ # Look into the included systems.
2043
+ self.systemT.scope.each_included do |included|
2044
+ signal = included.get_signal(key)
2045
+ break if signal
2046
+ end
2047
+ end
2030
2048
  # Check if it is an output.
2031
2049
  isout = self.get_output(key)
2050
+ unless isout then
2051
+ # Look into the inlucded systems.
2052
+ self.systemT.scope.each_included do |included|
2053
+ isout = included.get_output(key)
2054
+ break if isout
2055
+ end
2056
+ end
2032
2057
  # Convert it to a reference.
2033
2058
  ref = RefObject.new(self.to_ref,signal)
2059
+ # puts "key=#{key} value=#{value} signal=#{signal} ref=#{ref}"
2034
2060
  # Make the connection.
2035
2061
  if isout then
2036
2062
  value <= ref
@@ -2499,7 +2525,11 @@ module HDLRuby::High
2499
2525
 
2500
2526
  # Casts as +type+.
2501
2527
  def as(type)
2502
- return Cast.new(type.to_type,self.to_expr)
2528
+ if (self.parent)
2529
+ return Cast.new(type.to_type,self.to_expr)
2530
+ else
2531
+ return Cast.new(type.to_type,self)
2532
+ end
2503
2533
  end
2504
2534
 
2505
2535
  # Casts to a bit vector type.
@@ -3071,7 +3101,8 @@ module HDLRuby::High
3071
3101
  # Converts to a new reference.
3072
3102
  def to_ref
3073
3103
  return RefIndex.new(self.type,
3074
- self.ref.to_ref,self.index.to_expr)
3104
+ # self.ref.to_ref,self.index.to_expr)
3105
+ self.ref.to_expr,self.index.to_expr)
3075
3106
  end
3076
3107
 
3077
3108
  # Converts the index reference to HDLRuby::Low.
@@ -3486,7 +3517,8 @@ module HDLRuby::High
3486
3517
  # Converts the system to HDLRuby::Low and set its +name+.
3487
3518
  def to_low(name = self.name)
3488
3519
  # return HDLRuby::Low::SignalI.new(name,self.type.to_low)
3489
- signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low)
3520
+ valueL = self.value ? self.value.to_low : nil
3521
+ signalIL = HDLRuby::Low::SignalI.new(name,self.type.to_low,valueL)
3490
3522
  # # For debugging: set the source high object
3491
3523
  # signalIL.properties[:low2high] = self.hdr_id
3492
3524
  # self.properties[:high2low] = signalIL
@@ -63,6 +63,17 @@ module HDLRuby::Low
63
63
  cur = cur.parent until cur.is_a?(Scope)
64
64
  return cur
65
65
  end
66
+
67
+ # Get the full parents hierachy.
68
+ def hierarchy
69
+ res = []
70
+ cur = self
71
+ while(cur) do
72
+ res << cur
73
+ cur = cur.parent
74
+ end
75
+ return res
76
+ end
66
77
  end
67
78
 
68
79
 
@@ -5331,7 +5342,8 @@ module HDLRuby::Low
5331
5342
  def initialize(type,ref,index)
5332
5343
  super(type)
5333
5344
  # Check and set the accessed reference.
5334
- unless ref.is_a?(Ref) then
5345
+ # unless ref.is_a?(Ref) then
5346
+ unless ref.is_a?(Expression) then
5335
5347
  raise AnyError, "Invalid class for a reference: #{ref.class}."
5336
5348
  end
5337
5349
  @ref = ref