Module: Udb

Extended by:
T::Sig
Defined in:
lib/udb.rb,
lib/udb/z3.rb,
lib/udb/cli.rb,
lib/udb/eqn.rb,
lib/udb/log.rb,
lib/udb/logic.rb,
lib/udb/paths.rb,
lib/udb/config.rb,
lib/udb/schema.rb,
lib/udb/obj/csr.rb,
lib/udb/obj/mmr.rb,
lib/udb/obj/prm.rb,
lib/udb/version.rb,
lib/udb/cfg_arch.rb,
lib/udb/doc_link.rb,
lib/udb/presence.rb,
lib/udb/resolver.rb,
lib/udb/condition.rb,
lib/udb/dep_paths.rb,
lib/udb/z3_loader.rb,
lib/udb/obj/manual.rb,
lib/udb/global_opts.rb,
lib/udb/obj/profile.rb,
lib/udb/architecture.rb,
lib/udb/dep_versions.rb,
lib/udb/version_spec.rb,
lib/udb/obj/csr_field.rb,
lib/udb/obj/extension.rb,
lib/udb/obj/parameter.rb,
lib/udb/obj/portfolio.rb,
lib/udb/obj/has_fields.rb,
lib/udb/obj/instruction.rb,
lib/udb/obj/database_obj.rb,
lib/udb/portfolio_design.rb,
lib/udb/obj/register_file.rb,
lib/udb/obj/exception_code.rb,
lib/udb/yaml/yaml_resolver.rb,
lib/udb/yaml/comment_parser.rb,
lib/udb/yaml/preserving_emitter.rb,
lib/udb/obj/non_isa_specification.rb,
lib/udb/external_documentation_renderer.rb

Overview

typed: false frozen_string_literal: true

Defined Under Namespace

Modules: CliCommands, Code, DepDownloader, EqntottPath, EspressoPath, HasFields, MustPath, Yaml, Z3Loader Classes: AbstractCondition, AbstractConfig, AlwaysFalseCondition, AlwaysTrueCondition, Architecture, ArrayConstraints, Cli, Company, Condition, ConditionalExtensionRequirement, ConditionalExtensionVersion, ConfigNotFoundError, ConfigType, ConfiguredArchitecture, Constraint, Csr, CsrField, DatabaseObject, DocLink, DummyMultiProgressBar, DummyProgressBar, Eqn, ExceptionCode, Extension, ExtensionCondition, ExtensionRequirement, ExtensionRequirementList, ExtensionTerm, ExtensionVersion, ExternalDocumentationRenderer, FreeTerm, FullConfig, GlobalOptions, IdlCondition, Instruction, InstructionSubtype, InstructionType, InterruptCode, InvalidConfigError, License, LogLevel, LogicCondition, LogicNode, LogicNodeType, Manual, ManualChapter, ManualVersion, ManualVolume, Mmr, NonIsaSpecification, ParamCondition, Parameter, ParameterTerm, ParameterWithValue, PartialConfig, Person, Portfolio, PortfolioClass, PortfolioDesign, PortfolioExtensionRequirement, PortfolioGroup, Presence, Prm, Profile, ProfileFamily, ProfileRelease, RegisterFile, RequirementSpec, Resolver, Schema, TopLevelDatabaseObject, TypeConstraint, UnConfig, VersionSpec, XlenCondition, XlenTerm, Z3ExtensionRequirement, Z3ExtensionVersion, Z3FiniteArray, Z3ParameterTerm, Z3Solver, Z3Sovler

Constant Summary collapse

DEFAULT_PROGRESSBAR_LOG_LEVEL =
LogLevel::Info
TermType =
T.type_alias { T.any(ExtensionTerm, ParameterTerm, XlenTerm, FreeTerm) }
EQNTOTT_VERSION =
File.read("#{Kernel.__dir__}/EQNTOTT_VERSION").strip
ESPRESSO_VERSION =
File.read("#{Kernel.__dir__}/ESPRESSO_VERSION").strip
MUST_VERSION =
File.read("#{Kernel.__dir__}/MUST_VERSION").strip
Z3_VERSION =
File.read("#{Kernel.__dir__}/Z3_VERSION").strip

Class Method Summary collapse

Class Method Details

.create_progressbar(fmt, **options) ⇒ Object



134
135
136
137
138
139
140
141
142
143
144
145
146
# File 'lib/udb/log.rb', line 134

def self.create_progressbar(fmt, **options)
  if @top_level_progressbar.nil?

    target_level = options.key?(:level) ? LogLevel.deserialize(options[:level].to_s) : LogLevel::Info
    if target_level <= @log_level
      TTY::ProgressBar.new(fmt, **options)
    else
      DummyProgressBar.new
    end
  else
    @top_level_progressbar.register(fmt, **options)
  end
end

.create_top_level_progressbar(fmt: nil, level: LogLevel::Info, clear: true) ⇒ Object



118
119
120
121
122
123
124
125
126
127
128
129
130
131
# File 'lib/udb/log.rb', line 118

def self.create_top_level_progressbar(fmt: nil, level: LogLevel::Info, clear: true)
  raise "Top-level progressbar already exists" unless @top_level_progressbar.nil?

  @top_level_log_level = level
  if level <= @log_level
    if fmt.nil?
      @top_level_progressbar = TTY::ProgressBar::Multi.new
    else
      @top_level_progressbar = TTY::ProgressBar::Multi.new(fmt)
    end
  else
    @top_level_progressbar = DummyMultiProgressBar.new
  end
end

.default_cfgs_pathObject



84
85
86
87
88
89
90
# File 'lib/udb/paths.rb', line 84

def self.default_cfgs_path
  if repo_root.nil?
    gem_path / ".data" / "cfgs"
  else
    T.must(repo_root) / "cfgs"
  end
end

.default_custom_isa_pathObject



53
54
55
56
57
58
59
60
# File 'lib/udb/paths.rb', line 53

def self.default_custom_isa_path
  if repo_root.nil?
    # not in the udb repo. try for a copy of the database stored with the gem
    gem_path / ".data" / "spec" / "custom" / "isa"
  else
    T.must(repo_root) / "spec" / "custom" / "isa"
  end
end

.default_gen_pathObject



73
74
75
76
77
78
79
80
81
# File 'lib/udb/paths.rb', line 73

def self.default_gen_path
  if repo_root.nil?
    # not in the udb repo. use XDG path
    data_home = Pathname.new(ENV.fetch("XDG_DATA_HOME", "#{ENV["HOME"]}/.local/share"))
    data_home / "udb" / Udb.version / "gen"
  else
    T.must(repo_root) / "gen"
  end
end

.default_schemas_pathObject



63
64
65
66
67
68
69
70
# File 'lib/udb/paths.rb', line 63

def self.default_schemas_path
  if repo_root.nil?
    # not in the udb repo. try for a copy of the database stored with the gem
    gem_path / ".data" / "spec" / "schemas"
  else
    T.must(repo_root) / "spec" / "schemas"
  end
end

.default_std_isa_pathObject



43
44
45
46
47
48
49
50
# File 'lib/udb/paths.rb', line 43

def self.default_std_isa_path
  if repo_root.nil?
    # not in the udb repo. try for a copy of the database stored with the gem
    gem_path / ".data" / "spec" / "std" / "isa"
  else
    T.must(repo_root) / "spec" / "std" / "isa"
  end
end

.delete_top_level_progressbarObject



105
106
107
108
109
# File 'lib/udb/log.rb', line 105

def self.delete_top_level_progressbar
  raise "Top-level progressbar does not exist" if @top_level_progressbar.nil?

  @top_level_progressbar = nil
end

.gem_pathObject



16
17
18
# File 'lib/udb/paths.rb', line 16

def self.gem_path
  @gem_path ||= Pathname.new(Gem::Specification.find_by_name("udb").full_gem_path)
end

.global_optionsObject



15
16
17
# File 'lib/udb/global_opts.rb', line 15

def self.global_options
  @global_options ||= GlobalOptions.new
end

.log_levelObject



51
52
53
# File 'lib/udb/log.rb', line 51

def self.log_level
  @log_level
end

.log_level=(level) ⇒ Object



56
57
58
# File 'lib/udb/log.rb', line 56

def self.log_level=(level)
  @log_level = level
end

.loggerObject



61
62
63
64
65
# File 'lib/udb/log.rb', line 61

def self.logger
  @logger ||= TTY::Logger.new do |config|
    config.level = @log_level.serialize.to_sym
  end
end

.repo_rootObject



33
34
35
36
37
38
39
40
# File 'lib/udb/paths.rb', line 33

def self.repo_root
  @root ||=
    if ENV.key?("UDB_ROOT")
      Pathname.new(ENV["UDB_ROOT"])
    else
      find_udb_root(Pathname.new(__dir__))
    end
end

.set_logger(logger) ⇒ Object



68
69
70
# File 'lib/udb/log.rb', line 68

def self.set_logger(logger)
  @logger = logger
end

.top_level_progressbarObject



100
101
102
# File 'lib/udb/log.rb', line 100

def self.top_level_progressbar
  @top_level_progressbar
end

.versionObject



8
# File 'lib/udb/version.rb', line 8

def self.version = "0.1.13"