HDLRuby 3.4.0 → 3.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -2018,7 +2018,8 @@ module HDLRuby::High::Std
2018
2018
 
2019
2019
  # Create a new sequencer for +size+ elements as +typ+ with an HW
2020
2020
  # array-like accesser +access+.
2021
- def initialize(typ,size,&access)
2021
+ # def initialize(typ,size,&access)
2022
+ def initialize(typ,size = nil,&access)
2022
2023
  # Sets the size.
2023
2024
  @size = size
2024
2025
  # Sets the type.
@@ -2029,12 +2030,19 @@ module HDLRuby::High::Std
2029
2030
  width = @size.respond_to?(:width) ? @size.width :
2030
2031
  @size.respond_to?(:type) ? size.type.width : 32
2031
2032
  # puts "width=#{width}"
2032
- # Create the index and the iteration result.
2033
+ # # Create the index and the iteration result.
2034
+ # Create the index (if relevant) and the iteration result.
2033
2035
  idx = nil
2034
2036
  result = nil
2037
+ # HDLRuby::High.cur_system.open do
2038
+ # idx = [width].inner({
2039
+ # HDLRuby.uniq_name("enum_idx") => 0 })
2040
+ # result = typ.inner(HDLRuby.uniq_name("enum_res"))
2041
+ # end
2042
+ idx_required = @size ? true : false
2035
2043
  HDLRuby::High.cur_system.open do
2036
2044
  idx = [width].inner({
2037
- HDLRuby.uniq_name("enum_idx") => 0 })
2045
+ HDLRuby.uniq_name("enum_idx") => 0 }) if idx_required
2038
2046
  result = typ.inner(HDLRuby.uniq_name("enum_res"))
2039
2047
  end
2040
2048
  @index = idx
@@ -2060,26 +2068,32 @@ module HDLRuby::High::Std
2060
2068
  # Get the next element.
2061
2069
  def snext
2062
2070
  @result <= @access.call(@index)
2063
- @index <= @index + 1
2071
+ # @index <= @index + 1
2072
+ @index <= @index + 1 if @index
2064
2073
  return @result
2065
2074
  end
2066
2075
 
2067
2076
  # Tell if there is a next element.
2068
2077
  def snext?
2069
- # puts "@index=#{index}, @size=#{@size}"
2070
- return @index < @size
2078
+ # return @index < @size
2079
+ return @index ? @index < @size : true
2071
2080
  end
2072
2081
 
2073
- # Set the next element.
2082
+ # Set the next element, also return the access result so that
2083
+ # it can be used as bidirectional transaction.
2074
2084
  def snext!(val)
2075
- @access.call(@index,val)
2076
- @index <= @index + 1
2077
- return val
2085
+ # @access.call(@index,val)
2086
+ # @index <= @index + 1
2087
+ # return val
2088
+ res = @access.call(@index,val)
2089
+ @index <= @index + 1 if @index
2090
+ return res
2078
2091
  end
2079
2092
 
2080
2093
  # Restart the iteration.
2081
2094
  def srewind
2082
- @index <= 0
2095
+ # @index <= 0
2096
+ @index <= 0 if @index
2083
2097
  end
2084
2098
  end
2085
2099
 
@@ -2325,9 +2339,10 @@ module HDLRuby::High::Std
2325
2339
 
2326
2340
  # Creates an sequencer enumerator using a specific block access.
2327
2341
  # - +typ+ is the data type of the elements.
2328
- # - +size+ is the number of elements.
2342
+ # - +size+ is the number of elements, nil if not relevant.
2329
2343
  # - +access+ is the block implementing the access method.
2330
- def senumerator(typ,size,&access)
2344
+ # def senumerator(typ,size,&access)
2345
+ def senumerator(typ,size = nil,&access)
2331
2346
  return SEnumeratorBase.new(typ,size,&access)
2332
2347
  end
2333
2348
 
@@ -1,3 +1,3 @@
1
1
  module HDLRuby
2
- VERSION = "3.4.0"
2
+ VERSION = "3.5.1"
3
3
  end