Class: Udb::AbstractCondition Abstract
- Inherits:
-
Object
- Object
- Udb::AbstractCondition
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/udb/condition.rb,
lib/udb/condition.rb
Overview
It cannot be directly instantiated. Subclasses must implement the abstract methods below.
Base class to represent any condition in the UDB data, and to connect/test them
Conditions constructed from UDB data need context to be evaluated; for example, a condition that requires extension A to be implemented implies that Zaamo and Zalrsc must also be implemented.
We add this implied information in a step called expand. Many methods of AbstractCondition
take an optional expand: argument that, when true, expands the condition before operating on it.
Direct Known Subclasses
Instance Method Summary collapse
-
#&(other) ⇒ AbstractCondition
abstract
logical conjunction.
-
#-@ ⇒ AbstractCondition
abstract
logical negation.
- #always_implies?(other_condition) ⇒ Boolean
-
#compatible?(other) ⇒ Boolean
is it possible for this condition and other to be simultaneously true?.
-
#could_be_satisfied_by_cfg_arch?(cfg_arch) ⇒ Boolean
for the given config arch, is condition satisfiable?.
- #covered_by?(other_condition) ⇒ Boolean
-
#empty? ⇒ Boolean
abstract
returns true if this condition is always true or always false (does not depend on extensions or parameters).
-
#equivalent?(other) ⇒ Boolean
is this condition logically equivalent to other? this is true logical equivalence, not just syntatic equivalence, e.g.: (a || a) is equivalent to (a).
-
#ext_req_terms(expand:) ⇒ Array<ExtensionRequirement>
return list of all extension requirements in the condition.
-
#failing_conjuncts(cfg_arch, expand:) ⇒ Array<String>
abstract
returns the failing conjuncts (clauses that are false) for the given cfg_arch.
-
#has_extension_requirement? ⇒ Boolean
abstract
true if the condition references any extension.
-
#has_param? ⇒ Boolean
abstract
true if the condition references any parameter.
-
#implied_extension_conflicts(expand: true) ⇒ Array<ConditionalExtensionRequirement>
abstract
inversion of implied_extension_requirements.
-
#implied_extension_requirements(expand: true) ⇒ Array<ConditionalExtensionRequirement>
abstract
assuming that the condition represents an extension dependency, return the specified extensions along with the condition under which they apply.
-
#implies(other) ⇒ AbstractCondition
logical implication.
-
#mentions?(term, expand: true) ⇒ Boolean
is this condition in any way affected by term?.
- #mentions_xlen?(expand: true) ⇒ Boolean
-
#minimize(expand: true) ⇒ AbstractCondition
abstract
minimizes the condition.
-
#param_terms(expand:) ⇒ Array<Parameter>
return list of all parameters in the condition.
- #partial_eval(ext_reqs: [], expand: true) ⇒ AbstractCondition abstract
-
#partially_evaluate_for_params(cfg_arch, expand:) ⇒ AbstractCondition
abstract
partially evaluate by replacing any known parameter terms with true/false, and returning a new condition.
-
#rv32_only? ⇒ Boolean
is this condition only satisfied when xlen == 32?.
-
#rv64_only? ⇒ Boolean
is this condition only satisfied when xlen == 64?.
-
#satisfiability_depends_on_ext_req?(_ext_req, include_requirements: false) ⇒ Boolean
abstract
If ext_req is not satisfied, is condition satisfiable? When
include_requirementsis true, also assume that the ext_req's requirements are not met. -
#satisfiable? ⇒ Boolean
abstract
is this condition satisfiable?.
-
#satisfiable_by_arch?(cfg_arch) ⇒ Boolean
abstract
return true if the condition could be satisfied by the architecture defintion (ignoring configuration).
-
#satisfiable_by_cfg_arch?(cfg_arch) ⇒ Boolean
abstract
return true if the condition could be satisfied by cfg_arch (including known configuration).
-
#satisfied_by_cfg_arch?(_cfg_arch) ⇒ SatisfiedResult
abstract
If the condition is, possibly is, or is definitely not satisfied by cfg_arch.
-
#satisfied_by_ext_req?(ext_req, include_requirements: false) ⇒ Boolean
abstract
is condition satisfied if
ext_reqis the only thing defined?. -
#to_asciidoc ⇒ String
abstract
string representation of condition in Asciidoc.
-
#to_h ⇒ Hash{String => T.untyped}, Boolean
abstract
convert condition into UDB-compatible hash.
-
#to_idl(cfg_arch) ⇒ String
abstract
convert condition into valid IDL.
-
#to_logic_tree(expand:) ⇒ LogicNode
abstract
convert to the underlying LogicNode-based tree.
- #to_logic_tree_internal ⇒ LogicNode abstract private
-
#to_s(expand: false) ⇒ String
abstract
string representation when expand is true, return the full expanded condition.
-
#to_s_pretty ⇒ String
abstract
condition in prose.
-
#to_s_with_value(cfg_arch, expand:) ⇒ String
abstract
string representation, annotated with actual values of terms where known useful for debugging.
-
#to_yaml ⇒ String
convert condition into UDB-compatible YAML string.
-
#unsatisfiable? ⇒ Boolean
abstract
is this condition unsatisfiable?.
-
#unsatisfiable_by_arch?(cfg_arch) ⇒ Boolean
abstract
return true if the condition cannot be satisfied by the architecture defintion (ignoring configuration).
-
#unsatisfiable_by_cfg_arch?(cfg_arch) ⇒ Boolean
abstract
return true if the condition cannot be satisfied by cfg_arch (including known configuration).
-
#|(other) ⇒ AbstractCondition
abstract
logical disjunction.
Instance Method Details
#&(other) ⇒ AbstractCondition
logical conjunction
385 |
# File 'lib/udb/condition.rb', line 385 def &(other); end |
#-@ ⇒ AbstractCondition
logical negation
we use - instead of ! for negation to avoid ambiguous situations like:
!condition.satisfiable? (is this "negate condition is satisfiable" or "condition is unsatisfiable")
398 |
# File 'lib/udb/condition.rb', line 398 def -@; end |
#always_implies?(other_condition) ⇒ Boolean
290 291 292 |
# File 'lib/udb/condition.rb', line 290 def always_implies?(other_condition) other_condition.covered_by?(self) end |
#compatible?(other) ⇒ Boolean
is it possible for this condition and other to be simultaneously true?
216 217 218 |
# File 'lib/udb/condition.rb', line 216 def compatible?(other) (self & other).satisfiable? end |
#could_be_satisfied_by_cfg_arch?(cfg_arch) ⇒ Boolean
for the given config arch, is condition satisfiable?
261 262 263 |
# File 'lib/udb/condition.rb', line 261 def could_be_satisfied_by_cfg_arch?(cfg_arch) satisfied_by_cfg_arch?(cfg_arch) != SatisfiedResult::No end |
#covered_by?(other_condition) ⇒ Boolean
275 276 277 278 279 280 281 282 283 284 285 286 287 |
# File 'lib/udb/condition.rb', line 275 def covered_by?(other_condition) # cover means other_condition always implies self # can test that by seeing if the contradiction is satisfiable, i.e.: # if other_condition -> self , contradition would be other_condition & not self contradiction = LogicNode.new( LogicNodeType::And, [ other_condition.to_logic_tree(expand: true), LogicNode.new(LogicNodeType::Not, [to_logic_tree(expand: true)]) ] ) !contradiction.satisfiable?(@cfg_arch) end |
#empty? ⇒ Boolean
returns true if this condition is always true or always false (does not depend on extensions or parameters)
132 |
# File 'lib/udb/condition.rb', line 132 def empty?; end |
#equivalent?(other) ⇒ Boolean
is this condition logically equivalent to other? this is true logical equivalence, not just syntatic equivalence, e.g.: (a || a) is equivalent to (a)
269 270 271 272 |
# File 'lib/udb/condition.rb', line 269 def equivalent?(other) contradition = -(self.implies(other) & other.implies(self)) contradition.unsatisfiable? end |
#ext_req_terms(expand:) ⇒ Array<ExtensionRequirement>
return list of all extension requirements in the condition
if expand is true, expand the condition to include transitive requirements
190 191 192 193 194 195 196 197 198 |
# File 'lib/udb/condition.rb', line 190 def ext_req_terms(expand:) if @expanded_ext_req_terms ||= to_logic_tree(expand:).terms.grep(ExtensionTerm).map { |term| term.to_ext_req(@cfg_arch) } else @unexpanded_ext_req_terms ||= to_logic_tree(expand:).terms.grep(ExtensionTerm).map { |term| term.to_ext_req(@cfg_arch) } end end |
#failing_conjuncts(cfg_arch, expand:) ⇒ Array<String>
returns the failing conjuncts (clauses that are false) for the given cfg_arch
338 |
# File 'lib/udb/condition.rb', line 338 def failing_conjuncts(cfg_arch, expand:); end |
#has_extension_requirement? ⇒ Boolean
true if the condition references any extension
300 |
# File 'lib/udb/condition.rb', line 300 def has_extension_requirement?; end |
#has_param? ⇒ Boolean
true if the condition references any parameter
296 |
# File 'lib/udb/condition.rb', line 296 def has_param?; end |
#implied_extension_conflicts(expand: true) ⇒ Array<ConditionalExtensionRequirement>
inversion of implied_extension_requirements
381 |
# File 'lib/udb/condition.rb', line 381 def implied_extension_conflicts(expand: true); end |
#implied_extension_requirements(expand: true) ⇒ Array<ConditionalExtensionRequirement>
assuming that the condition represents an extension dependency, return the specified extensions along with the condition under which they apply
specifically, this returns the complete list of positive terms (terms that are not negated in solution) of requirements, along with a conditionthat must hold for condition to be satisfied when the positive term is met
This list is not transitive; if an implication I1 implies another extension I2, only I1 shows up in the list
377 |
# File 'lib/udb/condition.rb', line 377 def implied_extension_requirements(expand: true); end |
#implies(other) ⇒ AbstractCondition
logical implication
a.implies(b) means:
if a; then b
406 407 408 |
# File 'lib/udb/condition.rb', line 406 def implies(other) -self | other end |
#mentions?(term, expand: true) ⇒ Boolean
is this condition in any way affected by term?
152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/udb/condition.rb', line 152 def mentions?(term, expand: true) to_logic_tree(expand:).terms.any? do |t| case t when ExtensionTerm (term.is_a?(Extension) || term.is_a?(ExtensionVersion) || term.is_a?(ExtensionRequirement)) && (term.name == t.name) when ParameterTerm (term.is_a?(Parameter) || term.is_a?(ParameterWithValue)) && (term.name == t.name) else false end end end |
#mentions_xlen?(expand: true) ⇒ Boolean
166 167 168 169 170 |
# File 'lib/udb/condition.rb', line 166 def mentions_xlen?(expand: true) to_logic_tree(expand:).terms.any? do |t| t.is_a?(XlenTerm) end end |
#minimize(expand: true) ⇒ AbstractCondition
minimizes the condition. see LogicNode#minimize when expand is false, minimize the condition without expanding first when expand is true, expand the condition and then minimize
306 |
# File 'lib/udb/condition.rb', line 306 def minimize(expand: true); end |
#param_terms(expand:) ⇒ Array<Parameter>
return list of all parameters in the condition
if expand is true, expand the condition to include transitive requirements
204 205 206 207 208 209 210 211 212 |
# File 'lib/udb/condition.rb', line 204 def param_terms(expand:) if @expanded_param_terms ||= to_logic_tree(expand:).terms.grep(ParameterTerm).map { |term| @cfg_arch.param(term.name) } else @unexpanded_param_terms ||= to_logic_tree(expand:).terms.grep(ParameterTerm).map { |term| @cfg_arch.param(term.name) } end end |
#partial_eval(ext_reqs: [], expand: true) ⇒ AbstractCondition
241 |
# File 'lib/udb/condition.rb', line 241 def partial_eval(ext_reqs: [], expand: true); end |
#partially_evaluate_for_params(cfg_arch, expand:) ⇒ AbstractCondition
partially evaluate by replacing any known parameter terms with true/false, and returning a new condition
246 |
# File 'lib/udb/condition.rb', line 246 def partially_evaluate_for_params(cfg_arch, expand:); end |
#rv32_only? ⇒ Boolean
is this condition only satisfied when xlen == 32?
174 175 176 177 |
# File 'lib/udb/condition.rb', line 174 def rv32_only? (self & Condition.not(Condition::Xlen32, @cfg_arch)).unsatisfiable? & \ (self & Condition.not(Condition::Xlen64, @cfg_arch)).satisfiable? end |
#rv64_only? ⇒ Boolean
is this condition only satisfied when xlen == 64?
181 182 183 184 |
# File 'lib/udb/condition.rb', line 181 def rv64_only? (self & Condition.not(Condition::Xlen64, @cfg_arch)).unsatisfiable? & \ (self & Condition.not(Condition::Xlen32, @cfg_arch)).satisfiable? end |
#satisfiability_depends_on_ext_req?(_ext_req, include_requirements: false) ⇒ Boolean
If ext_req is not satisfied, is condition satisfiable?
When include_requirements is true, also assume that the ext_req's requirements are not met
257 |
# File 'lib/udb/condition.rb', line 257 def satisfiability_depends_on_ext_req?(_ext_req, include_requirements: false); end |
#satisfiable? ⇒ Boolean
is this condition satisfiable?
144 |
# File 'lib/udb/condition.rb', line 144 def satisfiable?; end |
#satisfiable_by_arch?(cfg_arch) ⇒ Boolean
return true if the condition could be satisfied by the architecture defintion (ignoring configuration)
230 |
# File 'lib/udb/condition.rb', line 230 def satisfiable_by_arch?(cfg_arch); end |
#satisfiable_by_cfg_arch?(cfg_arch) ⇒ Boolean
return true if the condition could be satisfied by cfg_arch (including known configuration)
222 |
# File 'lib/udb/condition.rb', line 222 def satisfiable_by_cfg_arch?(cfg_arch); end |
#satisfied_by_cfg_arch?(_cfg_arch) ⇒ SatisfiedResult
Returns if the condition is, possibly is, or is definitely not satisfied by cfg_arch.
238 |
# File 'lib/udb/condition.rb', line 238 def satisfied_by_cfg_arch?(_cfg_arch); end |
#satisfied_by_ext_req?(ext_req, include_requirements: false) ⇒ Boolean
is condition satisfied if ext_req is the only thing defined?
When include_requirements is true, expand the condition before evaluating
252 |
# File 'lib/udb/condition.rb', line 252 def satisfied_by_ext_req?(ext_req, include_requirements: false); end |
#to_asciidoc ⇒ String
string representation of condition in Asciidoc
342 |
# File 'lib/udb/condition.rb', line 342 def to_asciidoc; end |
#to_h ⇒ Hash{String => T.untyped}, Boolean
convert condition into UDB-compatible hash
310 |
# File 'lib/udb/condition.rb', line 310 def to_h; end |
#to_idl(cfg_arch) ⇒ String
convert condition into valid IDL
320 |
# File 'lib/udb/condition.rb', line 320 def to_idl(cfg_arch); end |
#to_logic_tree(expand:) ⇒ LogicNode
convert to the underlying LogicNode-based tree
136 |
# File 'lib/udb/condition.rb', line 136 def to_logic_tree(expand:); end |
#to_logic_tree_internal ⇒ LogicNode
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
140 |
# File 'lib/udb/condition.rb', line 140 def to_logic_tree_internal; end |
#to_s(expand: false) ⇒ String
string representation when expand is true, return the full expanded condition
325 |
# File 'lib/udb/condition.rb', line 325 def to_s(expand: false); end |
#to_s_pretty ⇒ String
condition in prose
329 |
# File 'lib/udb/condition.rb', line 329 def to_s_pretty; end |
#to_s_with_value(cfg_arch, expand:) ⇒ String
string representation, annotated with actual values of terms where known useful for debugging
334 |
# File 'lib/udb/condition.rb', line 334 def to_s_with_value(cfg_arch, expand:); end |
#to_yaml ⇒ String
convert condition into UDB-compatible YAML string
314 315 316 |
# File 'lib/udb/condition.rb', line 314 def to_yaml YAML.dump(to_h) end |
#unsatisfiable? ⇒ Boolean
is this condition unsatisfiable?
148 |
# File 'lib/udb/condition.rb', line 148 def unsatisfiable?; end |
#unsatisfiable_by_arch?(cfg_arch) ⇒ Boolean
return true if the condition cannot be satisfied by the architecture defintion (ignoring configuration)
234 |
# File 'lib/udb/condition.rb', line 234 def unsatisfiable_by_arch?(cfg_arch); end |
#unsatisfiable_by_cfg_arch?(cfg_arch) ⇒ Boolean
return true if the condition cannot be satisfied by cfg_arch (including known configuration)
226 |
# File 'lib/udb/condition.rb', line 226 def unsatisfiable_by_cfg_arch?(cfg_arch); end |
#|(other) ⇒ AbstractCondition
logical disjunction
389 |
# File 'lib/udb/condition.rb', line 389 def |(other); end |