Class: SystemRDL::Evaluator::MemInstance

Inherits:
Instance
  • Object
show all
Includes:
BlockInstance, InstTypeAwareInstance
Defined in:
lib/systemrdl/evaluator/mem.rb

Instance Attribute Summary

Attributes included from BlockInstance

#address, #alignment, #stride

Attributes included from ArrayInstance

#array_info

Attributes included from InstTypeAwareInstance

#external

Attributes inherited from Instance

#array_info, #definition, #instances, #name, #parent, #properties, #token_range

Instance Method Summary collapse

Methods included from BlockInstance

#sw_readable?, #sw_writable?

Methods included from ArrayInstance

#array?, #array_indices, #array_sizes, #first_element?, #last_element?

Methods inherited from Instance

#addrmap?, #array?, #element_name, #field?, #finalize, #find_addrmap, #full_name, #initialize, #layer, #mem?, #property, #property_value, #reg?, #regfile?, #revalidate, #root?, #structural_component?, #to_value, #upper_instances, #validate

Constructor Details

This class inherits a constructor from SystemRDL::Evaluator::Instance

Instance Method Details

#accesswidthObject



169
170
171
# File 'lib/systemrdl/evaluator/mem.rb', line 169

def accesswidth
  (instances.empty? && entrywidth) || super
end

#definable?(definition) ⇒ Boolean

Returns:



181
182
183
# File 'lib/systemrdl/evaluator/mem.rb', line 181

def definable?(definition)
  definition.layer in :reg | :field
end

#entrywidthObject



152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
# File 'lib/systemrdl/evaluator/mem.rb', line 152

def entrywidth
  @entrywidth ||=
    if (memwidth = property_value(:memwidth)&.value)
      if memwidth <= 8
        8
      elsif memwidth.nobits?(memwidth - 1)
        memwidth
      else
        2**memwidth.bit_length
      end
    else
      instances
        .map { |inst| inst.property_value(:regwidth).value }
        .max
    end
end

#instantiable?(definition) ⇒ Boolean

Returns:



185
186
187
# File 'lib/systemrdl/evaluator/mem.rb', line 185

def instantiable?(definition)
  definition.layer in :reg
end

#sizeObject



173
174
175
176
177
178
179
# File 'lib/systemrdl/evaluator/mem.rb', line 173

def size
  @size ||= begin
    width = entrywidth / 8
    entries = property_value(:mementries).value
    width * entries
  end
end