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.
610 611 612 613 614 |
# File 'lib/udb/obj/instruction.rb', line 610 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
605 606 607 |
# File 'lib/udb/obj/instruction.rb', line 605 def name @name end |
#range ⇒ Object (readonly)
range in the encoding
608 609 610 |
# File 'lib/udb/obj/instruction.rb', line 608 def range @range end |
Instance Method Details
#eql?(other) ⇒ Boolean
622 623 624 |
# File 'lib/udb/obj/instruction.rb', line 622 def eql?(other) @name == other.name && @range == other.range end |
#hash ⇒ Object
626 627 628 |
# File 'lib/udb/obj/instruction.rb', line 626 def hash [@name, @range].hash end |
#opcode? ⇒ Boolean
is this encoding field a fixed opcode?
617 618 619 |
# File 'lib/udb/obj/instruction.rb', line 617 def opcode? name.match?(/^[01]+$/) end |
#pretty_to_s ⇒ Object
630 631 632 633 634 |
# File 'lib/udb/obj/instruction.rb', line 630 def pretty_to_s return @pretty unless @pretty.nil? @name end |
#size ⇒ Object
636 637 638 |
# File 'lib/udb/obj/instruction.rb', line 636 def size @range.size end |