HDLRuby 2.6.5 → 2.6.8

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: 928c0006bc7fee9ebff9356509ed09ad9109d310e64eea92a41f42d751d560b1
4
- data.tar.gz: d63743942c8c73f79224c129ca8265995ddff3397a5628e185da497b0599a6e0
3
+ metadata.gz: 01f27a3801dbe93fa55cba40a6a66b91f94df070e255689ac9d73f894b006bd0
4
+ data.tar.gz: 911aadbbb04317300946682df515527e72602d36aacb792bc2c3f80ea88fa14d
5
5
  SHA512:
6
- metadata.gz: b7508f64a04a6662c035ce362d9193d617b022dd21bbccaa28f8c70d2a38790919f6d995b545a5082df0be6e23654a4bacb158ea6dfaaa673ea592ccac4c67f9
7
- data.tar.gz: 8e77890ec50610400f848340a4ad4a4eb0d9095aff8c674ecb695cdddf9aabbd7e585b2bf5bfc8b76553612f1e216bcc7e21f00888335f07b95f54c89b88efc2
6
+ metadata.gz: ea09062dfce477be1db11be382672323711d6fa996cb2f3716cd43692ba1063f9ccd651b6b870a09b319fbd8374b82635075a72b00b89a8e305385adf72c097b
7
+ data.tar.gz: 0ecc3b863e4e41ed3f25083dcf579b014a2a6d04dfb41cd71262d45d115b4efb23d8d869c714508ada05b0a239afd484143733a16343f9fd8738375bbf871dbe
@@ -0,0 +1,40 @@
1
+ # Test the comparison operators.
2
+
3
+ # A benchmark for the adder.
4
+ system :adder_bench do
5
+ [8].inner :x, :y
6
+ signed[8].inner :u,:v
7
+ inner :ue, :ult, :ule, :ugt, :uge
8
+ inner :se, :slt, :sle, :sgt, :sge
9
+
10
+ par do
11
+ ue <= (x == y)
12
+ ult <= (x < y)
13
+ ule <= (x <= y)
14
+ ugt <= (x > y)
15
+ uge <= (x >= y)
16
+
17
+ se <= (u == v)
18
+ slt <= (u < v)
19
+ sle <= (u <= v)
20
+ sgt <= (u > v)
21
+ sge <= (u >= v)
22
+ end
23
+
24
+ timed do
25
+ x <= 0
26
+ y <= 0
27
+ u <= 0
28
+ v <= 0
29
+ !10.ns
30
+ x <= 1
31
+ u <= 1
32
+ !10.ns
33
+ y <= 2
34
+ v <= 2
35
+ !10.ns
36
+ x <= 2
37
+ u <= -2
38
+ !10.ns
39
+ end
40
+ end
@@ -0,0 +1,37 @@
1
+ # Test the type method min and max
2
+
3
+ # A benchmark for the adder.
4
+ system :adder_bench do
5
+ [32].inner :x
6
+ signed[32].inner :y
7
+
8
+ timed do
9
+ x <= 0
10
+ y <= 0
11
+ !10.ns
12
+ x <= bit[8].max
13
+ y <= signed[8].max
14
+ !10.ns
15
+ x <= bit[8].min
16
+ y <= signed[8].min
17
+ !10.ns
18
+ x <= bit[10].max
19
+ y <= signed[10].max
20
+ !10.ns
21
+ x <= bit[10].min
22
+ y <= signed[10].min
23
+ !10.ns
24
+ x <= bit[16].max
25
+ y <= signed[16].max
26
+ !10.ns
27
+ x <= bit[16].min
28
+ y <= signed[16].min
29
+ !10.ns
30
+ x <= bit[32].max
31
+ y <= signed[32].max
32
+ !10.ns
33
+ x <= bit[32].min
34
+ y <= signed[32].min
35
+ !10.ns
36
+ end
37
+ end
@@ -0,0 +1,29 @@
1
+
2
+ def connect8(i0,i1,i2,i3,i4,i5,i6,i7,
3
+ o0,o1,o2,o3,o4,o5,o6,o7)
4
+ o0 <= i0
5
+ o1 <= i1
6
+ o2 <= i2
7
+ o3 <= i3
8
+ o4 <= i4
9
+ o5 <= i5
10
+ o6 <= i6
11
+ o7 <= i7
12
+ end
13
+
14
+ # A benchmark for testing the conversion to ruby array of expressions.
15
+ system :with_to_bench do
16
+ [8].inner :val
17
+ inner :b0,:b1,:b2,:b3,:b4,:b5,:b6,:b7
18
+
19
+ connect8(*val,b0,b1,b2,b3,b4,b5,b6,b7)
20
+
21
+ timed do
22
+ val <= _01101010
23
+ !10.ns
24
+ val <= _01011010
25
+ !10.ns
26
+ val <= _00001111
27
+ !10.ns
28
+ end
29
+ end
data/lib/HDLRuby/hdrcc.rb CHANGED
@@ -637,6 +637,7 @@ elsif $options[:clang] then
637
637
  name = $output + "/" +
638
638
  HDLRuby::Low::Low2C.c_name(systemT.name) +
639
639
  ".c"
640
+ # puts "for systemT=#{systemT.name} generating: #{name}"
640
641
  # Open the file for current systemT
641
642
  outfile = File.open(name,"w")
642
643
  # Generate the C code in to.
@@ -609,7 +609,8 @@ module HDLRuby::High
609
609
  # possible arguments +args+.
610
610
  def instantiate(i_name,*args)
611
611
  # Create the eigen type.
612
- eigen = self.expand(High.names_create(i_name.to_s + ":T"), *args)
612
+ # eigen = self.expand(High.names_create(i_name.to_s + ":T"), *args)
613
+ eigen = self.expand(HDLRuby.uniq_name(i_name.to_s + ":T"), *args)
613
614
 
614
615
  # Create the instance and sets its eigen system to +eigen+.
615
616
  instance = @instance_class.new(i_name,eigen)
@@ -758,8 +759,10 @@ module HDLRuby::High
758
759
  "Cannot convert a system without a name to HDLRuby::Low."
759
760
  end
760
761
  # Create the resulting low system type.
761
- systemTL = HDLRuby::Low::SystemT.new(High.names_create(name),
762
+ # systemTL = HDLRuby::Low::SystemT.new(High.names_create(name),
763
+ systemTL = HDLRuby::Low::SystemT.new(HDLRuby.uniq_name(name),
762
764
  self.scope.to_low)
765
+ # puts "New low from system #{self.name}: #{systemTL.name}"
763
766
  # For debugging: set the source high object
764
767
  systemTL.properties[:low2high] = self.hdr_id
765
768
  self.properties[:high2low] = systemTL
@@ -2655,7 +2658,6 @@ module HDLRuby::High
2655
2658
  end
2656
2659
  end
2657
2660
 
2658
-
2659
2661
  # Converts to a select operator using current expression as
2660
2662
  # condition for one of the +choices+.
2661
2663
  #
@@ -2671,6 +2673,7 @@ module HDLRuby::High
2671
2673
  end
2672
2674
 
2673
2675
 
2676
+
2674
2677
  # Methods for conversion for HDLRuby::Low: type processing, flattening
2675
2678
  # and so on
2676
2679
 
@@ -1276,6 +1276,18 @@ module HDLRuby::Low
1276
1276
  end
1277
1277
  end
1278
1278
 
1279
+ # Gets the type max value if any.
1280
+ # Default: not defined.
1281
+ def max
1282
+ raise AnyError, "No max value for type #{self}"
1283
+ end
1284
+
1285
+ # Gets the type min value if any.
1286
+ # Default: not defined.
1287
+ def min
1288
+ raise AnyError, "No min value for type #{self}"
1289
+ end
1290
+
1279
1291
  # Get the direction of the type, little or big endian.
1280
1292
  def direction
1281
1293
  # By default, little endian.
@@ -1617,6 +1629,25 @@ module HDLRuby::Low
1617
1629
  return @base.width * ((first-last).abs + 1)
1618
1630
  end
1619
1631
 
1632
+ # Gets the type max value if any.
1633
+ def max
1634
+ if (self.signed?) then
1635
+ return (2**(self.width-1))-1
1636
+ else
1637
+ return (2**(self.width))-1
1638
+ end
1639
+ end
1640
+
1641
+ # Gets the type min value if any.
1642
+ # Default: not defined.
1643
+ def min
1644
+ if (self.signed?) then
1645
+ return -(2**(self.width-1))
1646
+ else
1647
+ return 0
1648
+ end
1649
+ end
1650
+
1620
1651
  # Get the direction of the type, little or big endian.
1621
1652
  def direction
1622
1653
  return @range.first < @range.last ? :big : :little
@@ -219,6 +219,13 @@ Value shift_right_value(Value src0, Value src1, Value dst);
219
219
  * @return dst */
220
220
  extern Value equal_value(Value src0, Value src1, Value dst);
221
221
 
222
+ /** Computes the greater comparision of two values.
223
+ * @param src0 the first source value of the comparison
224
+ * @param src1 the second source value of the comparison
225
+ * @param dst the destination value
226
+ * @return dst */
227
+ extern Value greater_value(Value src0, Value src1, Value dst);
228
+
222
229
  /** Computes the lesser comparision of two values.
223
230
  * @param src0 the first source value of the comparison
224
231
  * @param src1 the second source value of the comparison
@@ -226,12 +233,19 @@ extern Value equal_value(Value src0, Value src1, Value dst);
226
233
  * @return dst */
227
234
  extern Value lesser_value(Value src0, Value src1, Value dst);
228
235
 
229
- /** Computes the greater comparision of two values.
236
+ /** Computes the greater or equal comparision of two values.
230
237
  * @param src0 the first source value of the comparison
231
238
  * @param src1 the second source value of the comparison
232
239
  * @param dst the destination value
233
240
  * @return dst */
234
- extern Value greater_value(Value src0, Value src1, Value dst);
241
+ extern Value greater_equal_value(Value src0, Value src1, Value dst);
242
+
243
+ /** Computes the lesser or equal comparision of two values.
244
+ * @param src0 the first source value of the comparison
245
+ * @param src1 the second source value of the comparison
246
+ * @param dst the destination value
247
+ * @return dst */
248
+ extern Value lesser_equal_value(Value src0, Value src1, Value dst);
235
249
 
236
250
  /** Selects a value depending on a condition.
237
251
  * @param cond the condition to use for selecting a value
@@ -686,6 +686,21 @@ static Value mod_value_defined_bitstring(Value src0, Value src1, Value dst) {
686
686
  }
687
687
 
688
688
 
689
+ /** Computes the greater comparision of two defined bitstring values.
690
+ * @param src0 the first source value of the addition
691
+ * @param src1 the second source value of the addition
692
+ * @param dst the destination value
693
+ * @return dst */
694
+ static Value greater_value_defined_bitstring(Value src0, Value src1, Value dst) {
695
+ /* Sets state of the destination using the first source. */
696
+ dst->type = src0->type;
697
+ dst->numeric = 1;
698
+
699
+ /* Perform the comparison. */
700
+ dst->data_int = (value2integer(src0) > value2integer(src1));
701
+ return dst;
702
+ }
703
+
689
704
  /** Computes the lesser comparision of two defined bitstring values.
690
705
  * @param src0 the first source value of the addition
691
706
  * @param src1 the second source value of the addition
@@ -701,19 +716,33 @@ static Value lesser_value_defined_bitstring(Value src0, Value src1, Value dst) {
701
716
  return dst;
702
717
  }
703
718
 
719
+ /** Computes the greater or equal comparision of two defined bitstring values.
720
+ * @param src0 the first source value of the addition
721
+ * @param src1 the second source value of the addition
722
+ * @param dst the destination value
723
+ * @return dst */
724
+ static Value greater_equal_value_defined_bitstring(Value src0, Value src1, Value dst) {
725
+ /* Sets state of the destination using the first source. */
726
+ dst->type = src0->type;
727
+ dst->numeric = 1;
704
728
 
705
- /** Computes the greater comparision of two defined bitstring values.
729
+ /* Perform the comparison. */
730
+ dst->data_int = (value2integer(src0) >= value2integer(src1));
731
+ return dst;
732
+ }
733
+
734
+ /** Computes the lesser or equal comparision of two defined bitstring values.
706
735
  * @param src0 the first source value of the addition
707
736
  * @param src1 the second source value of the addition
708
737
  * @param dst the destination value
709
738
  * @return dst */
710
- static Value greater_value_defined_bitstring(Value src0, Value src1, Value dst) {
739
+ static Value lesser_equal_value_defined_bitstring(Value src0, Value src1, Value dst) {
711
740
  /* Sets state of the destination using the first source. */
712
741
  dst->type = src0->type;
713
742
  dst->numeric = 1;
714
743
 
715
744
  /* Perform the comparison. */
716
- dst->data_int = (value2integer(src0) > value2integer(src1));
745
+ dst->data_int = (value2integer(src0) <= value2integer(src1));
717
746
  return dst;
718
747
  }
719
748
 
@@ -1762,13 +1791,29 @@ static Value equal_value_numeric(Value src0, Value src1, Value dst) {
1762
1791
  dst->type = src0->type;
1763
1792
  dst->numeric = 1;
1764
1793
 
1765
- /* Perform the !XOR. */
1766
- // dst->data_int = (src0->data_int == src1->data_int);
1767
- dst->data_int = ~(src0->data_int ^ src1->data_int);
1794
+ // /* Perform the !XOR. */
1795
+ // dst->data_int = ~(src0->data_int ^ src1->data_int);
1796
+ /* Perform the comparison. */
1797
+ dst->data_int = (src0->data_int == src1->data_int) ? 1 : 0;
1768
1798
  return dst;
1769
1799
  }
1770
1800
 
1771
1801
 
1802
+ /** Computes the greater comparision of two numeric values.
1803
+ * @param src0 the first source value of the addition
1804
+ * @param src1 the second source value of the addition
1805
+ * @param dst the destination value
1806
+ * @return the destination value */
1807
+ static Value greater_value_numeric(Value src0, Value src1, Value dst) {
1808
+ /* Sets state of the destination using the first source. */
1809
+ dst->type = src0->type;
1810
+ dst->numeric = 1;
1811
+
1812
+ /* Perform the greater. */
1813
+ dst->data_int = (src0->data_int > src1->data_int);
1814
+ return dst;
1815
+ }
1816
+
1772
1817
  /** Computes the lesser comparision of two numeric values.
1773
1818
  * @param src0 the first source value of the addition
1774
1819
  * @param src1 the second source value of the addition
@@ -1784,18 +1829,33 @@ static Value lesser_value_numeric(Value src0, Value src1, Value dst) {
1784
1829
  return dst;
1785
1830
  }
1786
1831
 
1787
- /** Computes the greater comparision of two numeric values.
1832
+ /** Computes the greater or equal comparision of two numeric values.
1788
1833
  * @param src0 the first source value of the addition
1789
1834
  * @param src1 the second source value of the addition
1790
1835
  * @param dst the destination value
1791
1836
  * @return the destination value */
1792
- static Value greater_value_numeric(Value src0, Value src1, Value dst) {
1837
+ static Value greater_equal_value_numeric(Value src0, Value src1, Value dst) {
1793
1838
  /* Sets state of the destination using the first source. */
1794
1839
  dst->type = src0->type;
1795
1840
  dst->numeric = 1;
1796
1841
 
1797
- /* Perform the lesser. */
1798
- dst->data_int = (src0->data_int > src1->data_int);
1842
+ /* Perform the greater or equal. */
1843
+ dst->data_int = (src0->data_int >= src1->data_int);
1844
+ return dst;
1845
+ }
1846
+
1847
+ /** Computes the lesser or equal comparision of two numeric values.
1848
+ * @param src0 the first source value of the addition
1849
+ * @param src1 the second source value of the addition
1850
+ * @param dst the destination value
1851
+ * @return the destination value */
1852
+ static Value lesser_equal_value_numeric(Value src0, Value src1, Value dst) {
1853
+ /* Sets state of the destination using the first source. */
1854
+ dst->type = src0->type;
1855
+ dst->numeric = 1;
1856
+
1857
+ /* Perform the lesser or equal. */
1858
+ dst->data_int = (src0->data_int <= src1->data_int);
1799
1859
  return dst;
1800
1860
  }
1801
1861
 
@@ -2434,6 +2494,34 @@ Value equal_value(Value src0, Value src1, Value dst) {
2434
2494
  }
2435
2495
 
2436
2496
 
2497
+
2498
+ /** Computes the greater comparision of two general values.
2499
+ * @param src0 the first source value of the addition
2500
+ * @param src1 the second source value of the addition
2501
+ * @param dst the destination value
2502
+ * @return dst */
2503
+ Value greater_value(Value src0, Value src1, Value dst) {
2504
+ /* Might allocate a new value so save the current pool state. */
2505
+ unsigned int pos = get_value_pos();
2506
+ /* Do a numeric computation if possible, otherwise fallback to bitstring
2507
+ * computation. */
2508
+ if (src0->numeric && src1->numeric) {
2509
+ /* Both sources are numeric. */
2510
+ return greater_value_numeric(src0,src1,dst);
2511
+ } else if (is_defined_value(src0) && is_defined_value(src1)) {
2512
+ /* Both sources can be converted to numeric values. */
2513
+ return greater_value_defined_bitstring(src0,src1,dst);
2514
+ } else {
2515
+ /* Cannot compute (for now), simply undefines the destination. */
2516
+ /* First ensure dst has the right shape. */
2517
+ copy_value(src0,dst);
2518
+ /* Then make it undefined. */
2519
+ set_undefined_bitstring(dst);
2520
+ }
2521
+ return dst;
2522
+ }
2523
+
2524
+
2437
2525
  /** Computes the lesser comparision of two general values.
2438
2526
  * @param src0 the first source value of the addition
2439
2527
  * @param src1 the second source value of the addition
@@ -2461,22 +2549,48 @@ Value lesser_value(Value src0, Value src1, Value dst) {
2461
2549
  }
2462
2550
 
2463
2551
 
2464
- /** Computes the greater comparision of two general values.
2465
- * @param src0 the first source value of the addition
2466
- * @param src1 the second source value of the addition
2552
+ /** Computes the greater or equal comparision of two values.
2553
+ * @param src0 the first source value of the comparison
2554
+ * @param src1 the second source value of the comparison
2467
2555
  * @param dst the destination value
2468
2556
  * @return dst */
2469
- Value greater_value(Value src0, Value src1, Value dst) {
2557
+ Value greater_equal_value(Value src0, Value src1, Value dst) {
2470
2558
  /* Might allocate a new value so save the current pool state. */
2471
2559
  unsigned int pos = get_value_pos();
2472
2560
  /* Do a numeric computation if possible, otherwise fallback to bitstring
2473
2561
  * computation. */
2474
2562
  if (src0->numeric && src1->numeric) {
2475
2563
  /* Both sources are numeric. */
2476
- return greater_value_numeric(src0,src1,dst);
2564
+ return greater_equal_value_numeric(src0,src1,dst);
2477
2565
  } else if (is_defined_value(src0) && is_defined_value(src1)) {
2478
2566
  /* Both sources can be converted to numeric values. */
2479
- return greater_value_defined_bitstring(src0,src1,dst);
2567
+ return greater_equal_value_defined_bitstring(src0,src1,dst);
2568
+ } else {
2569
+ /* Cannot compute (for now), simply undefines the destination. */
2570
+ /* First ensure dst has the right shape. */
2571
+ copy_value(src0,dst);
2572
+ /* Then make it undefined. */
2573
+ set_undefined_bitstring(dst);
2574
+ }
2575
+ return dst;
2576
+ }
2577
+
2578
+ /** Computes the lesser or equal comparision of two values.
2579
+ * @param src0 the first source value of the comparison
2580
+ * @param src1 the second source value of the comparison
2581
+ * @param dst the destination value
2582
+ * @return dst */
2583
+ Value lesser_equal_value(Value src0, Value src1, Value dst) {
2584
+ /* Might allocate a new value so save the current pool state. */
2585
+ unsigned int pos = get_value_pos();
2586
+ /* Do a numeric computation if possible, otherwise fallback to bitstring
2587
+ * computation. */
2588
+ if (src0->numeric && src1->numeric) {
2589
+ /* Both sources are numeric. */
2590
+ return lesser_equal_value_numeric(src0,src1,dst);
2591
+ } else if (is_defined_value(src0) && is_defined_value(src1)) {
2592
+ /* Both sources can be converted to numeric values. */
2593
+ return lesser_equal_value_defined_bitstring(src0,src1,dst);
2480
2594
  } else {
2481
2595
  /* Cannot compute (for now), simply undefines the destination. */
2482
2596
  /* First ensure dst has the right shape. */
@@ -2488,6 +2602,7 @@ Value greater_value(Value src0, Value src1, Value dst) {
2488
2602
  }
2489
2603
 
2490
2604
 
2605
+
2491
2606
  /** Selects a value depending on a general condition.
2492
2607
  * @param cond the condition to use for selecting a value
2493
2608
  * @param dst the destination value (used only if new value is created).
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "2.6.5"
2
+ VERSION = "2.6.8"
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.6.5
4
+ version: 2.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovic Gauthier
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2021-05-09 00:00:00.000000000 Z
11
+ date: 2021-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -83,6 +83,7 @@ files:
83
83
  - lib/HDLRuby/hdr_samples/alu.rb
84
84
  - lib/HDLRuby/hdr_samples/bstr_bench.rb
85
85
  - lib/HDLRuby/hdr_samples/calculator.rb
86
+ - lib/HDLRuby/hdr_samples/comparison_bench.rb
86
87
  - lib/HDLRuby/hdr_samples/constant_in_function.rb
87
88
  - lib/HDLRuby/hdr_samples/counter_bench.rb
88
89
  - lib/HDLRuby/hdr_samples/dff.rb
@@ -134,6 +135,7 @@ files:
134
135
  - lib/HDLRuby/hdr_samples/sw_encrypt_cpusim_bench.rb
135
136
  - lib/HDLRuby/hdr_samples/system_open.rb
136
137
  - lib/HDLRuby/hdr_samples/tuple.rb
138
+ - lib/HDLRuby/hdr_samples/type_minmax_bench.rb
137
139
  - lib/HDLRuby/hdr_samples/with_channel.rb
138
140
  - lib/HDLRuby/hdr_samples/with_class.rb
139
141
  - lib/HDLRuby/hdr_samples/with_connector.rb
@@ -148,6 +150,7 @@ files:
148
150
  - lib/HDLRuby/hdr_samples/with_memory_rom.rb
149
151
  - lib/HDLRuby/hdr_samples/with_multi_channels.rb
150
152
  - lib/HDLRuby/hdr_samples/with_reconf.rb
153
+ - lib/HDLRuby/hdr_samples/with_to_array.rb
151
154
  - lib/HDLRuby/hdrcc.rb
152
155
  - lib/HDLRuby/high_samples/_adder_fault.rb
153
156
  - lib/HDLRuby/high_samples/_generic_transmission2.rb