HDLRuby 3.7.5 → 3.7.6

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: af734e680200b79bc927ebf845cf13e712f5614a6f2188f23385f53f059442d1
4
- data.tar.gz: be3d20a777119fd87686749b798df6a9f27ac9a0e7101821b1ab5a64d186a3c4
3
+ metadata.gz: d8331701e40f0efc7e0481fdacf241194aa5aba8a707ee257a75a73f295ba677
4
+ data.tar.gz: 9d41bbff0f3ad714e012c65a7ff2b920551cc1db607a7c20f281dfc5b6dbde1c
5
5
  SHA512:
6
- metadata.gz: 14dd0ec35076907dddb6448965c6ce6a9ffc5e00d229760a0f3d2a30d0c8f3cf60b27567cac50abfe6c321db6e86a86ef3961c166372283eef55e273c8c85279
7
- data.tar.gz: c63ef648b2782b10b02afba2247ba782bc34e83617a5d5b1bb11524844f2036e6cf47f6c435159f505ce2ee99201bb7c2663d39a04c76dd654e411249593d485
6
+ metadata.gz: 83b7cf2d52d862a704166a50c6c9440bd1d3349a062a2e146cfbdf8c1314435b3237acc371a7f9377a7de70b2565f17f6829441a386fe369c975d8e67f7b45c7
7
+ data.tar.gz: c1ff187b98317042cc4ba243fa35d08e6771c73d2c8d77a66444bb13faa6c3fd2a37b7733087a2cbe2fe97dcb25928485a44af334b41751222040d41655d8d68
data/README.md CHANGED
@@ -15,9 +15,15 @@ And if you want an html version the following command with create a `tuto` folde
15
15
  hdrcc --get-tuto
16
16
  ```
17
17
 
18
- __What's new__
18
+ __What's new_
19
19
 
20
- For HDLRuby version 3.7.4/3.7.5:
20
+ For HDLRuby version 3.7.6:
21
+
22
+ * Added initial value to signals for the software sequencers.
23
+
24
+ * Fixed hprint in software sequencer.
25
+
26
+ For HDLRuby versions 3.7.4/3.7.5:
21
27
 
22
28
  * Various bug fixes.
23
29
 
@@ -8,11 +8,11 @@ system :my_seqencer do
8
8
  inner :clk,:rst
9
9
  [65536].inner :count
10
10
 
11
- # sequencer(clk.posedge,rst) do
12
- # sloop do
13
- # # count <= count + 1
14
- # end
15
- # end
11
+ sequencer(clk.posedge,rst) do
12
+ sloop do
13
+ count <= count + 1
14
+ end
15
+ end
16
16
 
17
17
 
18
18
 
@@ -96,6 +96,12 @@ module RubyHDL::High
96
96
  type = type.to_type
97
97
  last_sig = nil
98
98
  names.each do |name|
99
+ init = nil
100
+ if name.is_a?(Hash) then
101
+ init = name.values[0]
102
+ name = name.keys[0]
103
+ # puts "init=#{init}"
104
+ end
99
105
  name = name.to_sym
100
106
  # Create and add the signal.
101
107
  sig = SignalI.new(name,type,:inner)
@@ -104,6 +110,9 @@ module RubyHDL::High
104
110
  # self.register(name) { puts("sig=",sig.inspect); sig }
105
111
  self.register(name) { sig }
106
112
  last_sig = sig
113
+
114
+ # Sets the initial value if any.
115
+ sig.value = init if init
107
116
  end
108
117
  return last_sig
109
118
  end
@@ -587,6 +596,11 @@ module RubyHDL::High
587
596
  end
588
597
  alias_method :to_expr, :to_value
589
598
 
599
+ def as(type)
600
+ # For now, cast is ignored.
601
+ return self
602
+ end
603
+
590
604
  def to_ruby
591
605
  return self
592
606
  end
@@ -2151,7 +2165,8 @@ module RubyHDL::High
2151
2165
 
2152
2166
  # Convert to Ruby code.
2153
2167
  def to_ruby
2154
- return "#{@base.to_ruby}[#{@rng.first.to_ruby}..#{@rng.last.to_ruby}]"
2168
+ # return "#{@base.to_ruby}[#{@rng.first.to_ruby}..#{@rng.last.to_ruby}]"
2169
+ return "#{@base.to_ruby}[#{@rng.last.to_ruby}..#{@rng.first.to_ruby}]"
2155
2170
  end
2156
2171
 
2157
2172
  # Convert to C code.
@@ -2962,6 +2977,54 @@ module RubyHDL::High
2962
2977
  end
2963
2978
  end
2964
2979
 
2980
+ # Describes a SW implementation of a hardware print statement.
2981
+ class Print < Statement
2982
+ using RubyHDL::High
2983
+
2984
+ # Create a new hprint statement in sequencer +sequencer+
2985
+ # for displaying +args+.
2986
+ def initialize(sequencer,*args)
2987
+ @sequencer = sequencer
2988
+ @arguments = args
2989
+ end
2990
+
2991
+ # Convert to Ruby code.
2992
+ def to_ruby
2993
+ return "" if @arguments.empty?
2994
+ res = "print("
2995
+ @arguments.each do |arg|
2996
+ if arg.is_a?(::String) then
2997
+ res << "\"#{arg}\""
2998
+ else
2999
+ res << arg.to_ruby
3000
+ end
3001
+ end
3002
+ res << ")\n"
3003
+ return res
3004
+ end
3005
+
3006
+ # Convert to C code.
3007
+ def to_c
3008
+ return "" if @arguments.empty?
3009
+ # Create the format.
3010
+ format = @arguments.each do |arg|
3011
+ if arg.is_a?(Expression) then
3012
+ arg.type.signed? ? "%lld" : "%llu"
3013
+ else
3014
+ "%s"
3015
+ end
3016
+ end.join
3017
+ return "printf(\"#{format}\"," +
3018
+ @arguments.each do |arg|
3019
+ if arg.is_a?(::String) then
3020
+ "\"#{arg}\""
3021
+ else
3022
+ arg.to_c
3023
+ end
3024
+ end.join(",")
3025
+ end
3026
+ end
3027
+
2965
3028
 
2966
3029
  # Describes a SW implementation of an iterator statement.
2967
3030
  class Siter < Statement
@@ -3645,10 +3708,11 @@ module RubyHDL::High
3645
3708
 
3646
3709
  # Displays a string for debugging purpose.
3647
3710
  def hprint(*args)
3648
- args.each do |arg|
3649
- arg = arg.to_value if arg.is_a?(RubyHDL::High::Expression)
3650
- print arg
3651
- end
3711
+ # args.each do |arg|
3712
+ # arg = arg.to_value if arg.is_a?(RubyHDL::High::Expression)
3713
+ # print arg
3714
+ # end
3715
+ self << RubyHDL::High::Print.new(@sequencer,*args)
3652
3716
  end
3653
3717
 
3654
3718
  # The SW-specific statements and expressions.
@@ -3771,7 +3835,7 @@ module RubyHDL::High
3771
3835
  signal.to_ruby + " = RubyHDL.#{signal.name}"
3772
3836
  else
3773
3837
  signal.to_ruby + " ||= " +
3774
- (signal.array? ? "[]" : signal.value? ? signal.value.inspect : "0")
3838
+ (signal.array? ? "[*#{signal.value? ? signal.value : "nil"}]" : signal.value? ? signal.value.inspect : "0")
3775
3839
  end
3776
3840
  end.join("\n")}
3777
3841
 
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "3.7.5"
2
+ VERSION = "3.7.6"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: HDLRuby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.7.5
4
+ version: 3.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lovic Gauthier