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.
2020 2021 2022 |
# File 'lib/idl/ast.rb', line 2020 def initialize(input, interval, csr_field, write_value) super(input, interval, [csr_field, write_value]) end |
Instance Method Details
#csr_field ⇒ Object
2017 |
# File 'lib/idl/ast.rb', line 2017 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
2058 2059 2060 |
# File 'lib/idl/ast.rb', line 2058 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.
2063 |
# File 'lib/idl/ast.rb', line 2063 def execute_unknown(symtab); end |
#field(symtab) ⇒ Object
2040 2041 2042 |
# File 'lib/idl/ast.rb', line 2040 def field(symtab) csr_field.field_def(symtab) end |
#to_idl ⇒ Object
2065 |
# File 'lib/idl/ast.rb', line 2065 def to_idl = "#{csr_field.to_idl} = #{write_value.to_idl}" |
#type(symtab) ⇒ Object
2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 |
# File 'lib/idl/ast.rb', line 2024 def type(symtab) if field(symtab).defined_in_all_bases? if symtab.cfg_arch.mxlen == 64 && symtab.cfg_arch.multi_xlen? Type.new(:bits, width: [field(symtab).location(symtab.cfg_arch, 32).size, field(symtab).location(symtab.cfg_arch, 64).size].max) else Type.new(:bits, width: field(symtab).location(symtab.cfg_arch, symtab.cfg_arch.mxlen).size) end elsif field(symtab).base64_only? Type.new(:bits, width: field(symtab).location(symtab.cfg_arch, 64).size) elsif field(symtab).base32_only? Type.new(:bits, width: field(symtab).location(symtab.cfg_arch, 32).size) else internal_error "Unexpected base for field" end end |
#type_check(symtab) ⇒ Object
2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 |
# File 'lib/idl/ast.rb', line 2044 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 cfg_arch 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
2018 |
# File 'lib/idl/ast.rb', line 2018 def write_value = @children[1] |