HDLRuby 2.7.1 → 2.7.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4ca0e2aba73e7ceb55e145dd22286398ae7605d04d46212f870ba895d3f983d9
4
- data.tar.gz: 434ae3eb4d974a00ea1510b0e23d66dc51d5f6ac5ef0e4b79af288b5d05f6985
3
+ metadata.gz: 4995e808d0aa2901a483011a4848bb9416d68850c95c74b9c2f2bf1fb3f648dc
4
+ data.tar.gz: 729643cd60228ab9ba4f3ab719e434b48963805ed6f4ac01dbcff2fdd6eb54b9
5
5
  SHA512:
6
- metadata.gz: d097cbd7793ef60fd94c70f7a8acb2e49b13915fd799b7618523c1ba57300195a9ca8a7a61d6e50a8f89779ce6bf64a484bdf5267de93b3159f61186f40e6a82
7
- data.tar.gz: 27db7c7e988abe14635a515572c2774e8a76d44e7f0e85bfb6ec8b1c9dfed85f61ef49e1f597c59fc9b725b6aacc53b976f73a3b49f816820c5ca9691e253559
6
+ metadata.gz: 82316dd87a532dbfa67d86fcdb13ade3f8329912bb6aa56ae0b5a4efe0a6110922912f52ae3558c4683147bb224ae2ed0b67e1d60e265d5d30624b3a2bee77be
7
+ data.tar.gz: 4df2cfb5c257838246fa2f953b3eeaa751902900ae4ea5319a69ca81f9e7eae49b75163fc621a81b2af1b399360c030ccf8717916c2abb7a5d2ffaad27d2b5df
@@ -1,30 +1,35 @@
1
1
  # Test the comparison operators.
2
2
 
3
- # A benchmark for the case statement.
3
+ # A benchmark for the if statement.
4
4
  system :if_bench do
5
- [8].inner :x, :y
5
+ [8].inner :x, :z
6
6
 
7
7
  par do
8
8
  hcase(x)
9
- hwhen(0) { y <= _10000000 }
10
- hwhen(1) { y <= _10000001 }
11
- hwhen(2) { y <= _10000010 }
12
- hwhen(3) { y <= _10000011 }
13
- helse { y <= _00000000 }
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 }
14
26
  end
15
27
 
16
28
  timed do
17
- x <= 0
18
- !10.ns
19
- x <= 1
20
- !10.ns
21
- x <= 2
22
- !10.ns
23
- x <= 3
24
- !10.ns
25
- x <= 4
26
- !10.ns
27
- x <= 5
28
29
  !10.ns
30
+ 20.times do |i|
31
+ x <= i
32
+ !10.ns
33
+ end
29
34
  end
30
35
  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
@@ -27,6 +27,9 @@ system :with_values do
27
27
  v64 <= 1
28
28
  v96 <= 1
29
29
  !10.ns
30
+ v1 <= _1010[2]
31
+ v8 <= _uhFF00[12..4]
32
+ !10.ns
30
33
  v8 <= 128
31
34
  v16 <= 128
32
35
  v32 <= 128
@@ -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
 
@@ -2033,10 +2038,25 @@ module HDLRuby::High
2033
2038
  connects.each do |key,value|
2034
2039
  # Gets the signal corresponding to connect.
2035
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
2036
2048
  # Check if it is an output.
2037
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
2038
2057
  # Convert it to a reference.
2039
2058
  ref = RefObject.new(self.to_ref,signal)
2059
+ # puts "key=#{key} value=#{value} signal=#{signal} ref=#{ref}"
2040
2060
  # Make the connection.
2041
2061
  if isout then
2042
2062
  value <= ref
@@ -3081,7 +3101,8 @@ module HDLRuby::High
3081
3101
  # Converts to a new reference.
3082
3102
  def to_ref
3083
3103
  return RefIndex.new(self.type,
3084
- 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)
3085
3106
  end
3086
3107
 
3087
3108
  # Converts the index reference to HDLRuby::Low.
@@ -3496,7 +3517,8 @@ module HDLRuby::High
3496
3517
  # Converts the system to HDLRuby::Low and set its +name+.
3497
3518
  def to_low(name = self.name)
3498
3519
  # return HDLRuby::Low::SignalI.new(name,self.type.to_low)
3499
- 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)
3500
3522
  # # For debugging: set the source high object
3501
3523
  # signalIL.properties[:low2high] = self.hdr_id
3502
3524
  # self.properties[:high2low] = signalIL
@@ -5342,7 +5342,8 @@ module HDLRuby::Low
5342
5342
  def initialize(type,ref,index)
5343
5343
  super(type)
5344
5344
  # Check and set the accessed reference.
5345
- unless ref.is_a?(Ref) then
5345
+ # unless ref.is_a?(Ref) then
5346
+ unless ref.is_a?(Expression) then
5346
5347
  raise AnyError, "Invalid class for a reference: #{ref.class}."
5347
5348
  end
5348
5349
  @ref = ref
@@ -1610,26 +1610,18 @@ module HDLRuby::Low
1610
1610
  res << "{\n"
1611
1611
  self.value.to_c(res,level+1)
1612
1612
  res << " " * ((level+1)*3)
1613
- res << "Value v=d;\n"
1613
+ res << "dup();\n"
1614
1614
  # Ensure the selection value is testable.
1615
1615
  res << " " * ((level+1)*3)
1616
- res << "if (is_defined_value(v)) {\n"
1616
+ res << "if (is_defined()) {\n"
1617
1617
  # The condition is testable.
1618
1618
  # Generate the case as a succession of if statements.
1619
- first = true
1620
1619
  self.each_when do |w|
1621
1620
  res << " " * ((level+2)*3)
1622
- if first then
1623
- first = false
1624
- else
1625
- res << "else "
1626
- end
1627
- res << "if (value2integer(v) == "
1628
- res << "value2integer(({\n"
1621
+ res << "dup();\n"
1629
1622
  res << " " * ((level+2)*3)
1630
1623
  w.match.to_c(res,level+2)
1631
- res << "d;})"
1632
- res << ")) {\n"
1624
+ res << "if (to_integer() == to_integer()) {\n"
1633
1625
  w.statement.to_c(res,level+3)
1634
1626
  res << " " * (level+2)*3
1635
1627
  res << "}\n"
@@ -1643,6 +1635,8 @@ module HDLRuby::Low
1643
1635
  end
1644
1636
  # Close the case.
1645
1637
  res << " " * (level+1)*3
1638
+ res << "pop();\n" # Remove the testing value.
1639
+ res << " " * (level+1)*3
1646
1640
  res << "}\n"
1647
1641
  res << " " * (level)*3
1648
1642
  res << "}\n"
@@ -754,6 +754,9 @@ extern Value write_range_no_z(Value src, long long first, long long last,
754
754
  * @param val the value to push. */
755
755
  extern void push(Value val);
756
756
 
757
+ /** Duplicates a value in the stack. */
758
+ extern void dup();
759
+
757
760
  /** Pops a value.
758
761
  * @return the value. */
759
762
  extern Value pop();
@@ -27,6 +27,17 @@ void push(Value val) {
27
27
  }
28
28
  }
29
29
 
30
+ /** Duplicates a value in the stack. */
31
+ void dup() {
32
+ if (head > 0 && head < STACK_SIZE) {
33
+ Value val = stack[head];
34
+ stack[--head] = val;
35
+ } else {
36
+ perror("Cannot dup in computation stack.\n");
37
+ exit(1);
38
+ }
39
+ }
40
+
30
41
  /** Pops a value.
31
42
  * @return the value. */
32
43
  Value pop() {
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.7.1"
2
+ VERSION = "2.7.5"
3
3
  end
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.7.1
4
+ version: 2.7.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-01-18 00:00:00.000000000 Z
11
+ date: 2022-02-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,6 +150,8 @@ files:
150
150
  - lib/HDLRuby/hdr_samples/with_fixpoint.rb
151
151
  - lib/HDLRuby/hdr_samples/with_fsm.rb
152
152
  - lib/HDLRuby/hdr_samples/with_function_generator.rb
153
+ - lib/HDLRuby/hdr_samples/with_init.rb
154
+ - lib/HDLRuby/hdr_samples/with_instance.rb
153
155
  - lib/HDLRuby/hdr_samples/with_linear.rb
154
156
  - lib/HDLRuby/hdr_samples/with_loop.rb
155
157
  - lib/HDLRuby/hdr_samples/with_memory.rb