Class: Idl::CsrFieldAssignmentAst
- Includes:
- Executable
- Defined in:
- lib/idl/ast.rb
Instance Method Summary collapse
- #csr_field ⇒ Object
-
#execute(symtab) ⇒ void
“execute” the statement by updating the variables in the symbol table.
-
#execute_unknown(symtab) ⇒ void
“execute” the statement, forcing any variable assignments to an unknown state This is used down unknown conditional paths.
- #field(symtab) ⇒ Object
-
#initialize(input, interval, csr_field, write_value) ⇒ CsrFieldAssignmentAst
constructor
A new instance of CsrFieldAssignmentAst.
- #to_idl ⇒ Object
- #type(symtab) ⇒ Object
- #type_check(symtab) ⇒ Object
- #write_value ⇒ Object
Constructor Details
#initialize(input, interval, csr_field, write_value) ⇒ CsrFieldAssignmentAst
Returns a new instance of CsrFieldAssignmentAst.
2015 2016 2017 |
# File 'lib/idl/ast.rb', line 2015 def initialize(input, interval, csr_field, write_value) super(input, interval, [csr_field, write_value]) end |
Instance Method Details
#csr_field ⇒ Object
2012 |
# File 'lib/idl/ast.rb', line 2012 def csr_field = @children[0] |
#execute(symtab) ⇒ void
This method returns an undefined value.
“execute” the statement by updating the variables in the symbol table
2053 2054 2055 |
# File 'lib/idl/ast.rb', line 2053 def execute(symtab) value_error "CSR field writes are never compile-time-executable" end |
#execute_unknown(symtab) ⇒ void
This method returns an undefined value.
“execute” the statement, forcing any variable assignments to an unknown state This is used down unknown conditional paths.
2058 |
# File 'lib/idl/ast.rb', line 2058 def execute_unknown(symtab); end |
#field(symtab) ⇒ Object
2035 2036 2037 |
# File 'lib/idl/ast.rb', line 2035 def field(symtab) csr_field.field_def(symtab) end |
#to_idl ⇒ Object
2060 |
# File 'lib/idl/ast.rb', line 2060 def to_idl = "#{csr_field.to_idl} = #{write_value.to_idl}" |
#type(symtab) ⇒ Object
2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 |
# File 'lib/idl/ast.rb', line 2019 def type(symtab) if field(symtab).defined_in_all_bases? if symtab.archdef.mxlen == 64 && symtab.archdef.multi_xlen? Type.new(:bits, width: [field(symtab).location(symtab.archdef, 32).size, field(symtab).location(symtab.archdef, 64).size].max) else Type.new(:bits, width: field(symtab).location(symtab.archdef, symtab.archdef.mxlen).size) end elsif field(symtab).base64_only? Type.new(:bits, width: field(symtab).location(symtab.archdef, 64).size) elsif field(symtab).base32_only? Type.new(:bits, width: field(symtab).location(symtab.archdef, 32).size) else internal_error "Unexpected base for field" end end |
#type_check(symtab) ⇒ Object
2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 |
# File 'lib/idl/ast.rb', line 2039 def type_check(symtab) csr_field.type_check(symtab) value_try do if ["RO", "RO-H"].any?(csr_field.field_def(symtab).type(symtab)) type_error "Cannot write to read-only CSR field" end end # ok, we don't know the type because the archdef isn't configured write_value.type_check(symtab) type_error "Incompatible type in assignment" unless write_value.type(symtab).convertable_to?(type(symtab)) end |
#write_value ⇒ Object
2013 |
# File 'lib/idl/ast.rb', line 2013 def write_value = @children[1] |