Class: Instruction::EncodingField
- Inherits:
-
Object
- Object
- Instruction::EncodingField
- Defined in:
- lib/arch_obj_models/instruction.rb
Overview
represents a single contiguous instruction encoding field Multiple EncodingFields may make up a single DecodeField, e.g., when an immediate is split across multiple locations
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
name, which corresponds to a name used in riscv_opcodes.
-
#range ⇒ Object
readonly
range in the encoding.
Instance Method Summary collapse
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(name, range, pretty = nil) ⇒ EncodingField
constructor
A new instance of EncodingField.
-
#opcode? ⇒ Boolean
is this encoding field a fixed opcode?.
- #pretty_to_s ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize(name, range, pretty = nil) ⇒ EncodingField
Returns a new instance of EncodingField.
232 233 234 235 236 |
# File 'lib/arch_obj_models/instruction.rb', line 232 def initialize(name, range, pretty = nil) @name = name @range = range @pretty = pretty end |
Instance Attribute Details
#name ⇒ Object (readonly)
name, which corresponds to a name used in riscv_opcodes
227 228 229 |
# File 'lib/arch_obj_models/instruction.rb', line 227 def name @name end |
#range ⇒ Object (readonly)
range in the encoding
230 231 232 |
# File 'lib/arch_obj_models/instruction.rb', line 230 def range @range end |
Instance Method Details
#eql?(other) ⇒ Boolean
244 245 246 |
# File 'lib/arch_obj_models/instruction.rb', line 244 def eql?(other) @name == other.name && @range == other.range end |
#hash ⇒ Object
248 249 250 |
# File 'lib/arch_obj_models/instruction.rb', line 248 def hash [@name, @range].hash end |
#opcode? ⇒ Boolean
is this encoding field a fixed opcode?
239 240 241 |
# File 'lib/arch_obj_models/instruction.rb', line 239 def opcode? name.match?(/^[01]+$/) end |
#pretty_to_s ⇒ Object
252 253 254 255 256 |
# File 'lib/arch_obj_models/instruction.rb', line 252 def pretty_to_s return @pretty unless @pretty.nil? @name end |
#size ⇒ Object
258 259 260 |
# File 'lib/arch_obj_models/instruction.rb', line 258 def size @range.size end |