Class: Udb::Instruction::EncodingField
- Inherits:
-
Object
- Object
- Udb::Instruction::EncodingField
- Defined in:
- lib/udb/obj/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.
559 560 561 562 563 |
# File 'lib/udb/obj/instruction.rb', line 559 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
554 555 556 |
# File 'lib/udb/obj/instruction.rb', line 554 def name @name end |
#range ⇒ Object (readonly)
range in the encoding
557 558 559 |
# File 'lib/udb/obj/instruction.rb', line 557 def range @range end |
Instance Method Details
#eql?(other) ⇒ Boolean
571 572 573 |
# File 'lib/udb/obj/instruction.rb', line 571 def eql?(other) @name == other.name && @range == other.range end |
#hash ⇒ Object
575 576 577 |
# File 'lib/udb/obj/instruction.rb', line 575 def hash [@name, @range].hash end |
#opcode? ⇒ Boolean
is this encoding field a fixed opcode?
566 567 568 |
# File 'lib/udb/obj/instruction.rb', line 566 def opcode? name.match?(/^[01]+$/) end |
#pretty_to_s ⇒ Object
579 580 581 582 583 |
# File 'lib/udb/obj/instruction.rb', line 579 def pretty_to_s return @pretty unless @pretty.nil? @name end |
#size ⇒ Object
585 586 587 |
# File 'lib/udb/obj/instruction.rb', line 585 def size @range.size end |