Class: Idl::CsrFunctionCallAst
- Includes:
- Rvalue
- Defined in:
- lib/idl/ast.rb
Overview
represents a function call for a CSR register for example:
CSR[mstatus].address()
CSR[mtval].sw_read()
Instance Attribute Summary collapse
-
#function_name ⇒ String
readonly
The function being called.
Instance Method Summary collapse
- #csr ⇒ Object
- #csr_def(symtab) ⇒ Object
- #csr_known?(symtab) ⇒ Boolean
- #csr_name(symtab) ⇒ Object
-
#initialize(input, interval, function_name, csr) ⇒ CsrFunctionCallAst
constructor
A new instance of CsrFunctionCallAst.
-
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree).
- #type(symtab) ⇒ Object
- #type_check(symtab) ⇒ Object
- #value(symtab) ⇒ Object
-
#values(symtab) ⇒ Array<Integer>, ...
included
from Rvalue
Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined.
Constructor Details
#initialize(input, interval, function_name, csr) ⇒ CsrFunctionCallAst
Returns a new instance of CsrFunctionCallAst.
6008 6009 6010 6011 |
# File 'lib/idl/ast.rb', line 6008 def initialize(input, interval, function_name, csr) super(input, interval, [csr]) @function_name = function_name end |
Instance Attribute Details
#function_name ⇒ String (readonly)
Returns The function being called.
6004 6005 6006 |
# File 'lib/idl/ast.rb', line 6004 def function_name @function_name end |
Instance Method Details
#csr ⇒ Object
6006 |
# File 'lib/idl/ast.rb', line 6006 def csr = @children[0] |
#csr_def(symtab) ⇒ Object
6046 6047 6048 |
# File 'lib/idl/ast.rb', line 6046 def csr_def(symtab) csr.csr_def(symtab) end |
#csr_known?(symtab) ⇒ Boolean
6038 6039 6040 |
# File 'lib/idl/ast.rb', line 6038 def csr_known?(symtab) csr.csr_known?(symtab) end |
#csr_name(symtab) ⇒ Object
6042 6043 6044 |
# File 'lib/idl/ast.rb', line 6042 def csr_name(symtab) csr.csr_name(symtab) end |
#to_idl ⇒ String
Return valid IDL representation of the node (and its subtree)
6069 |
# File 'lib/idl/ast.rb', line 6069 def to_idl = "#{csr.to_idl}.#{function_call}()" |
#type(symtab) ⇒ Object
6021 6022 6023 6024 6025 6026 6027 6028 6029 6030 6031 6032 6033 6034 6035 6036 |
# File 'lib/idl/ast.rb', line 6021 def type(symtab) archdef = symtab.archdef case function_name when "sw_read" if csr_known?(symtab) Type.new(:bits, width: archdef.csr(csr.csr_name(symtab)).length(archdef)) else Type.new(:bits, width: symtab.mxlen) end when "address" Type.new(:bits, width: 12) else internal_error "No function '#{function_name}' for CSR. call type check first!" end end |
#type_check(symtab) ⇒ Object
6013 6014 6015 6016 6017 6018 6019 |
# File 'lib/idl/ast.rb', line 6013 def type_check(symtab) unless ["sw_read", "address"].include?(function_name) type_error "'#{function_name}' is not a supported CSR function call" end csr.type_check(symtab) end |
#value(symtab) ⇒ Object
TODO:
check the sw_read function body
6051 6052 6053 6054 6055 6056 6057 6058 6059 6060 6061 6062 6063 6064 6065 6066 |
# File 'lib/idl/ast.rb', line 6051 def value(symtab) case function_name when "sw_read" value_error "CSR not knowable" unless csr_known?(symtab) cd = csr_def(symtab) cd.fields.each { |f| value_error "#{csr_name(symtab)}.#{f.name} not RO" unless f.type(symtab) == "RO" } value_error "TODO: CSRs with sw_read function" when "address" value_error "CSR not knowable" unless csr_known?(symtab) cd = csr_def(symtab) cd.address else internal_error "TODO: #{function_name}" end end |
#values(symtab) ⇒ Array<Integer>, ... Originally defined in module Rvalue
Return a complete list of possible compile-time-known values of the node, or raise a ValueError if the full list cannot be determined
For most AstNodes, this will just be a single-entry array