[][src]Crate moore_svlog

The SystemVerilog implementation of the moore compiler.

This crate implements a query-based compiler for the SystemVerilog language. It strives to be a complete implementation of IEEE 1800-2017, mapping any input source text to the equivalent LLHD code.

The implementation uses different representations of the source text for different parts of the compilation. Such a scheme is necessary due to the very messy nature of SystemVerilog, with its strange mixture of static and dynamic typing. Although the compiler uses queries to be able to handle the more involved and loopy dependencies, the representations form a rough chain of processing that each construct flows through (albeit each at its own pace):

  • AST: Abstract Syntax Tree emitted by the parser in the syntax crate.
  • RST: Resolved Syntax Tree which has ambiguities in the grammar resolved. This is possible by building name resolution scopes and defs on the AST representation, and resolving names to disambiguate things in the grammar.
  • HIR: The High-level Intermediate Representation, which does things like taking the list of constructs in a module body and separating them into lists of declarations, instances, parameters, etc. Also tries to get rid of syntactic sugar where appropriate. Type-checking is performed on this representation, and ParamEnv is used to represent different parametrizations of the same HIR module/interface.
  • MIR: The Medium-level Intermediate Representation, which has all implicit casting operations and parametrizations made explicit and fully unrolled. At this point most SystemVerilog craziness has been resolved and the nodes are crisp and have a clean, fully checked type.
  • LLHD: The Low-level Hardware Description, emitted as the final step during code generation.

Re-exports

pub extern crate moore_svlog_syntax as syntax;

Modules

ast

An abstract syntax tree for SystemVerilog.

cat

The categorizing lexer. Tokenizes an input stream of characters, yielding a stream of newline, whitespace, comment, symbol, and text tokens.

hir

The high-level intermediate representation for SystemVerilog.

lexer

A lexical analyzer for SystemVerilog files, based on IEEE 1800-2009, section 5.

mir

The medium-level intermediate representation for SystemVerilog.

parser

A parser for the SystemVerilog language. Based on IEEE 1800-2009.

pattern_mapping

A mapping from a pattern expression's arguments to the underlying type's fields.

port_list

A list of ports on a node, with ANSI/non-ANSI styles resolved.

preproc

A preprocessor for SystemVerilog files that takes the raw stream of tokens generated by a lexer and performs include and macro resolution.

resolver

Name resolution.

rst

A resolved syntax tree.

token

Defines all tokens that may result from performing lexical analysis on a SystemVerilog source file. This module is inspired heavily by the tokens used in the Rust compiler.

ty

A generalized SystemVerilog type system.

typeck

Type checking and computation.

value

Representation of constant values and their operations

Macros

assert_span

Assert that a condition holds, or emit a bug diagnostic and panic.

assert_type

Assert that two types are identical, or emit a bug diagnostic and panic.

bug_span

Emit a bug diagnostic and panic.

database_storage

This macro generates the "query storage" that goes into your database. It requires you to list all of the query groups that you need as well as the queries within those groups. The format looks like so:

query_group

A macro that helps in defining the "context trait" of a given module. This is a trait that defines everything that a block of queries need to execute, as well as defining the queries themselves that are exported for others to use.

Structs

AccessedNodesQueryKey

The arguments passed to the accessed_nodes query.

CanonicalizePortsQueryKey

The arguments passed to the canonicalize_ports query.

CastExprTypeQueryKey

The arguments passed to the cast_expr_type query.

CastTypeQueryKey

The arguments passed to the cast_type query.

CodeGenerator

A code generator.

ConstMirRvalueIntQueryKey

The arguments passed to the const_mir_rvalue_int query.

ConstMirRvalueQueryKey

The arguments passed to the const_mir_rvalue query.

ConstMirRvalueStringQueryKey

The arguments passed to the const_mir_rvalue_string query.

ConstantValueOfQueryKey

The arguments passed to the constant_value_of query.

DisambKindQueryKey

The arguments passed to the disamb_kind query.

DisambTypeOrExprQueryKey

The arguments passed to the disamb_type_or_expr query.

GeneratedScopeQueryKey

The arguments passed to the generated_scope query.

GlobalArenas

The arenas that allocate things in the global context.

GlobalContext

The central data structure of the compiler. It stores references to various arenas and tables that store the results of the various computations that have been performed.

GlobalTables

The lookup tables for a global context.

HirOfExprQueryKey

The arguments passed to the hir_of_expr query.

HirOfInterfaceQueryKey

The arguments passed to the hir_of_interface query.

HirOfModuleQueryKey

The arguments passed to the hir_of_module query.

InstDetails

Instantiation details

InstDetailsQueryKey

The arguments passed to the inst_details query.

InstTargetDetails

Instantiation target details

InstTargetDetailsQueryKey

The arguments passed to the inst_target_details query.

InstVerbosityVisitor

A visitor that emits instantiation details diagnostics.

IsConstantQueryKey

The arguments passed to the is_constant query.

MapPatternQueryKey

The arguments passed to the map_pattern query.

MapToTypeOrErrorQueryKey

The arguments passed to the map_to_type_or_error query.

MapToTypeQueryKey

The arguments passed to the map_to_type query.

Name

A name is a lightweight 32 bit tag that refers to a string in a name table. During parsing, encountered strings are inserted into the name table and only the corresponding tag is kept in the token. Names which have their most significant bit set represent case sensitive names, such as for extended identifiers.

NameckQueryKey

The arguments passed to the nameck query.

NeedOperationTypeQueryKey

The arguments passed to the need_operation_type query.

NeedSelfDeterminedTypeQueryKey

The arguments passed to the need_self_determined_type query.

NeedTypeContextQueryKey

The arguments passed to the need_type_context query.

NodeEnvId

A node id with corresponding parameter environment.

OperationTypeQueryKey

The arguments passed to the operation_type query.

PackedTypeFromAstQueryKey

The arguments passed to the packed_type_from_ast query.

ParamEnv

A parameter environment.

ParamEnvData

A parameter environment.

PortMapping

A port mapping.

PortMappingQueryKey

The arguments passed to the port_mapping query.

QueryStorage

A collection of query caches and runtime data for a QueryDatabase.

Ref

A node reference.

ResolveFieldAccessQueryKey

The arguments passed to the resolve_field_access query.

ResolveHierarchicalOrErrorQueryKey

The arguments passed to the resolve_hierarchical_or_error query.

ResolveHierarchicalQueryKey

The arguments passed to the resolve_hierarchical query.

ResolveImportedScopeQueryKey

The arguments passed to the resolve_imported_scope query.

ResolveInstTargetQueryKey

The arguments passed to the resolve_inst_target query.

ResolveLocalOrErrorQueryKey

The arguments passed to the resolve_local_or_error query.

ResolveLocalQueryKey

The arguments passed to the resolve_local query.

ResolveNamespaceOrErrorQueryKey

The arguments passed to the resolve_namespace_or_error query.

ResolveNamespaceQueryKey

The arguments passed to the resolve_namespace query.

ScopeLocationQueryKey

The arguments passed to the scope_location query.

SelfDeterminedTypeQueryKey

The arguments passed to the self_determined_type query.

Span

A span of locations within a source file, expressed as a half-open interval of bytes [begin,end).

Spanned

A wrapper that associates a span with a value.

TypeContextQueryKey

The arguments passed to the type_context query.

TypeDefaultValueQueryKey

The arguments passed to the type_default_value query.

TypeOfExprQueryKey

The arguments passed to the type_of_expr query.

TypeOfExtPortQueryKey

The arguments passed to the type_of_ext_port query.

TypeOfInstQueryKey

The arguments passed to the type_of_inst query.

TypeOfIntPortQueryKey

The arguments passed to the type_of_int_port query.

TypeOfNetDeclQueryKey

The arguments passed to the type_of_net_decl query.

TypeOfQueryKey

The arguments passed to the type_of query.

TypeOfStructMemberQueryKey

The arguments passed to the type_of_struct_member query.

TypeOfValueParamQueryKey

The arguments passed to the type_of_value_param query.

TypeOfVarDeclQueryKey

The arguments passed to the type_of_var_decl query.

UnpackedTypeFromAstQueryKey

The arguments passed to the unpacked_type_from_ast query.

Enums

ParamEnvBinding

A binding in a parameter environment.

ParamEnvSource

A location that implies a parameter environment.

PortMappingSource

A location that implies a port mapping.

QueryTag

A tag identifying any of the queries in QueryDatabase.

Traits

BaseContext

The fundamental compiler context.

Context

A collection of compiler queries.

IntoNodeEnvId

A helper trait to allow for easy wrapping of node IDs.

QueryDatabase

A collection of compiler queries.

Type Definitions

Result

A general result returned by the queries.