Class: Idl::CsrSoftwareWriteAst

Inherits:
AstNode
  • Object
show all
Includes:
Executable
Defined in:
lib/idl/ast.rb

Instance Method Summary collapse

Constructor Details

#initialize(input, interval, csr, expression) ⇒ CsrSoftwareWriteAst

Returns a new instance of CsrSoftwareWriteAst.



5985
5986
5987
# File 'lib/idl/ast.rb', line 5985

def initialize(input, interval, csr, expression)
  super(input, interval, [csr, expression])
end

Instance Method Details

#csrObject



5982
# File 'lib/idl/ast.rb', line 5982

def csr = @children[0]

#csr_known?(symtab) ⇒ Boolean

Returns:

  • (Boolean)


6001
6002
6003
# File 'lib/idl/ast.rb', line 6001

def csr_known?(symtab)
  csr.csr_known?(symtab)
end

#csr_name(symtab) ⇒ Object



6005
6006
6007
# File 'lib/idl/ast.rb', line 6005

def csr_name(symtab)
  csr.csr_name(symtab)
end

#execute(_symtab) ⇒ void

This method returns an undefined value.

“execute” the statement by updating the variables in the symbol table

Parameters:

  • symtab (SymbolTable)

    The symbol table for the context

Raises:

  • ValueError if some part of the statement cannot be executed at compile time



6015
# File 'lib/idl/ast.rb', line 6015

def execute(_symtab) = value_error "CSR writes are global"

#execute_unknown(_symtab) ⇒ Object

nothing to do for a function call



6018
# File 'lib/idl/ast.rb', line 6018

def execute_unknown(_symtab); end

#expressionObject



5983
# File 'lib/idl/ast.rb', line 5983

def expression = @children[1]

#to_idlString

Return valid IDL representation of the node (and its subtree)

Returns:

  • (String)

    IDL code for the node



6021
# File 'lib/idl/ast.rb', line 6021

def to_idl = "#{csr.to_idl}.sw_write(#{expression.to_idl})"

#type_check(symtab) ⇒ Object



5989
5990
5991
5992
5993
5994
5995
5996
5997
5998
5999
# File 'lib/idl/ast.rb', line 5989

def type_check(symtab)
  cfg_arch = symtab.cfg_arch

  csr.type_check(symtab)
  expression.type_check(symtab)

  e_type = expression.type(symtab)
  return if e_type.kind == :bits && ((e_type.width == :unknown || symtab.mxlen.nil?) || (e_type.width == symtab.mxlen))

  type_error "CSR value must be an XReg"
end

#value(_symtab) ⇒ Object

Return the compile-time-known value of the node



6010
6011
6012
# File 'lib/idl/ast.rb', line 6010

def value(_symtab)
  value_error "CSR writes are global"
end