Documentation
¶
Overview ¶
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
SPDX-License-Identifier: Apache-2.0
Index ¶
- Variables
- type Annotation
- type Constant
- type Declaration
- type DeclarationKind
- type Function
- func (p *Function[S]) Annotations() []string
- func (p *Function[S]) Arity() (nInputs, nOutputs uint)
- func (p *Function[S]) Externs() []S
- func (p *Function[S]) Inputs() []variable.Descriptor[S]
- func (p *Function[S]) Name() string
- func (p *Function[S]) Outputs() []variable.Descriptor[S]
- func (p *Function[S]) SetAnnotations(annotations []string)
- func (p *Function[S]) Variable(id variable.Id) variable.Descriptor[S]
- type Include
- type Memory
- func NewMemory[S symbol.Symbol[S]](name string, kind MemoryKind, address []variable.Descriptor[S], ...) *Memory[S]
- func NewRandomAccessMemory[S symbol.Symbol[S]](name string, address []variable.Descriptor[S], data []variable.Descriptor[S]) *Memory[S]
- func NewReadOnlyMemory[S symbol.Symbol[S]](public bool, name string, address []variable.Descriptor[S], ...) *Memory[S]
- func NewStaticMemory[S symbol.Symbol[S]](public bool, name string, address []variable.Descriptor[S], ...) *Memory[S]
- func NewWriteOnceMemory[S symbol.Symbol[S]](public bool, name string, address []variable.Descriptor[S], ...) *Memory[S]
- func (p *Memory[S]) Annotations() []string
- func (p *Memory[S]) Arity() (nInputs, nOutputs uint)
- func (p *Memory[S]) Externs() []S
- func (p *Memory[S]) IsInput() bool
- func (p *Memory[S]) IsOutput() bool
- func (p *Memory[S]) IsReadable() bool
- func (p *Memory[S]) IsStatic() bool
- func (p *Memory[S]) IsWriteable() bool
- func (p *Memory[S]) Name() string
- func (p *Memory[S]) SetAnnotations(annotations []string)
- type MemoryKind
- type Resolved
- type ResolvedConstant
- type ResolvedFunction
- type ResolvedInclude
- type ResolvedMemory
- type ResolvedTypeAlias
- type TypeAlias
- type Unresolved
- type UnresolvedConstant
- type UnresolvedFunction
- type UnresolvedInclude
- type UnresolvedMemory
- type UnresolvedTypeAlias
Constants ¶
This section is empty.
Variables ¶
var ANNOTATIONS = []Annotation{ NewAnnotation("inline", "marks a function to be inlined at every call site", FUNCTION_KIND), NewAnnotation("native", "marks a function as backed by a native circuit", FUNCTION_KIND), NewAnnotation("paged", "marks a read/write memory to use the paged (array of pages) layout", MEMORY_KIND), NewAnnotation("debug", "marks a function as debug-only, elided entirely (calls and definition) unless verbose mode is enabled", FUNCTION_KIND), }
ANNOTATIONS is the global registry of known annotations. Each entry describes one valid annotation and the declaration kinds on which it may appear.
Functions ¶
This section is empty.
Types ¶
type Annotation ¶
type Annotation struct {
// contains filtered or unexported fields
}
Annotation is a schema for a source-level annotation. It records the annotation's name (without the surrounding "#[" and "]") and the set of declaration kinds on which it may legally appear.
func NewAnnotation ¶
func NewAnnotation(name, description string, permitted DeclarationKind) Annotation
NewAnnotation constructs an Annotation schema with the given name, description, and the set of declaration kinds on which it is permitted.
func (Annotation) Description ¶
func (a Annotation) Description() string
Description returns a human-readable description of what the annotation is for.
func (Annotation) Name ¶
func (a Annotation) Name() string
Name returns the annotation's name without the surrounding "#[" and "]".
func (Annotation) Permits ¶
func (a Annotation) Permits(kind DeclarationKind) bool
Permits reports whether this annotation is allowed on a declaration of the given kind.
type Constant ¶
type Constant[S symbol.Symbol[S]] struct { DataType data.Type[S] ConstExpr expr.Expr[S] // contains filtered or unexported fields }
Constant represents a named constant at the source level.
func NewConstant ¶
func NewConstant[S symbol.Symbol[S]](name string, datatype data.Type[S], constexpr expr.Expr[S]) *Constant[S]
NewConstant creates a new named constant in a given base
func (*Constant[S]) Annotations ¶
Annotations implementation for Declaration interface
func (*Constant[I]) Externs ¶
func (p *Constant[I]) Externs() []I
Externs implementation for Declaration interface.
func (*Constant[S]) SetAnnotations ¶
SetAnnotations implementation for Declaration interface
type Declaration ¶
type Declaration[S any] interface { // Arity returns the number of inputs/outputs for this declaration. Arity() (inputs uint, outputs uint) // Return name of this component Name() string // Determine all reference external symbols Externs() []S // Annotations returns the annotations associated with this declaration. Annotations() []string // SetAnnotations sets the annotations associated with this declaration. SetAnnotations(annotations []string) }
Declaration represents something declared within a source file, in particular - includes - constants - input / output / memory / static "memories" - functions - type aliases
type DeclarationKind ¶
type DeclarationKind uint
DeclarationKind identifies the kind of a top-level declaration. The values are bit flags so they can be combined with bitwise OR when an annotation is permitted on more than one kind of declaration.
const ( // FUNCTION_KIND identifies a function declaration. FUNCTION_KIND DeclarationKind = 1 << iota // MEMORY_KIND identifies a memory declaration. MEMORY_KIND // CONSTANT_KIND identifies a constant declaration. CONSTANT_KIND // TYPE_ALIAS_KIND identifies a type alias declaration. TYPE_ALIAS_KIND // INCLUDE_KIND identifies an include declaration. INCLUDE_KIND )
func (DeclarationKind) String ¶
func (k DeclarationKind) String() string
String returns a human-readable label for a DeclarationKind, used in error messages.
type Function ¶
type Function[S symbol.Symbol[S]] struct { // Effects describes zero or more external memories which this function is // permitted to access. Effects []*S // Variables describes zero or more variables of a given width. Each // variable can be designated as an input / output or temporary. Variables []variable.Descriptor[S] // Number of input variables NumInputs uint // Number of output variables NumOutputs uint // Code defines the body of this function. Code []stmt.Stmt[S] // contains filtered or unexported fields }
Function contains information about an executable function in the system. A function has one or more variables where: the first n are the parameters; the next m are the returns; and all remaining registers are internal. Additionally, a function has some number of "instructions" which capture its semantics (i.e. intended behaviour). The notion of an instruction is specifically left undefined by this interface to support different levels of the compilation pipeline. For example, a compiled function has instructions which are simply bytes (or words) for efficient execution. However, the instructions of an "assembly" level function implement the Instruction interface, which is better suited to analysis and/or translation into constraints.
func NewFunction ¶
func NewFunction[S symbol.Symbol[S]](name string, effects []*S, vars []variable.Descriptor[S], code []stmt.Stmt[S]) *Function[S]
NewFunction constructs a new function with the given variables and code
func (*Function[S]) Annotations ¶
Annotations implementation for Declaration interface
func (*Function[S]) Externs ¶
func (p *Function[S]) Externs() []S
Externs implementation for Declaration interface
func (*Function[S]) Inputs ¶
func (p *Function[S]) Inputs() []variable.Descriptor[S]
Inputs returns an array containing the output variables of this function
func (*Function[S]) Outputs ¶
func (p *Function[S]) Outputs() []variable.Descriptor[S]
Outputs returns an array containing the output variables of this function
func (*Function[S]) SetAnnotations ¶
SetAnnotations implementation for Declaration interface
type Include ¶
type Include[S any] struct { // contains filtered or unexported fields }
Include corresponds with a specific include statement used within a source file.
func NewInclude ¶
NewInclude constructs a new include representing the given path.
func (*Include[S]) Annotations ¶
Annotations implementation for Decl interface.
func (*Include[S]) Externs ¶
func (p *Include[S]) Externs() []S
Externs implementation for Decl interface.
func (*Include[S]) Pattern ¶
Pattern returns the include pattern; observe that this may include a wildcard match, or it might identify a single file.
func (*Include[S]) SetAnnotations ¶
SetAnnotations implementation for Decl interface.
type Memory ¶
type Memory[S symbol.Symbol[S]] struct { // Kind of memory (i.e. read-only, random access, etc) Kind MemoryKind // Address bus for memory (where, for random access, the first line always // denotes the index type used). Address []variable.Descriptor[S] // Data bus for memory. Data []variable.Descriptor[S] // Contents (for static memory only). Each element is a compile-time constant // expression. Contents []expr.Expr[S] // contains filtered or unexported fields }
Memory represents a declaration of some form of memory, such as random access, read only, etc.
func NewMemory ¶
func NewMemory[S symbol.Symbol[S]](name string, kind MemoryKind, address []variable.Descriptor[S], data []variable.Descriptor[S], contents []expr.Expr[S]) *Memory[S]
NewMemory constructs a new memory.
func NewRandomAccessMemory ¶
func NewRandomAccessMemory[S symbol.Symbol[S]](name string, address []variable.Descriptor[S], data []variable.Descriptor[S]) *Memory[S]
NewRandomAccessMemory constructs a new random access memory.
func NewReadOnlyMemory ¶
func NewReadOnlyMemory[S symbol.Symbol[S]](public bool, name string, address []variable.Descriptor[S], data []variable.Descriptor[S]) *Memory[S]
NewReadOnlyMemory constructs a new read-only access memory.
func NewStaticMemory ¶
func NewStaticMemory[S symbol.Symbol[S]](public bool, name string, address []variable.Descriptor[S], data []variable.Descriptor[S], contents []expr.Expr[S]) *Memory[S]
NewStaticMemory constructs a new static memory.
func NewWriteOnceMemory ¶
func NewWriteOnceMemory[S symbol.Symbol[S]](public bool, name string, address []variable.Descriptor[S], data []variable.Descriptor[S]) *Memory[S]
NewWriteOnceMemory constructs a new write-once memory.
func (*Memory[S]) Annotations ¶
Annotations implementation for Declaration interface
func (*Memory[S]) Externs ¶
func (p *Memory[S]) Externs() []S
Externs implementation for Declaration interface
func (*Memory[S]) IsReadable ¶
IsReadable checks whether this memory can be read or not.
func (*Memory[S]) IsWriteable ¶
IsWriteable checks whether this memory can be written or not.
func (*Memory[S]) SetAnnotations ¶
SetAnnotations implementation for Declaration interface
type MemoryKind ¶
type MemoryKind uint8
MemoryKind determines the type of a given memory
- STATIC: static ROM; identical across all executions of a given machine
- ROM: read-only memory; variable across executions
- WOM: write-only and write-once memory; variable across executions
- RAM: ubiquitous form of memory; supports arbitrary reads / writes
as well as PRIVATE vs PUBLIC memories.
const ( // A (public) static ROM; identical across all executions of a given machine PUBLIC_STATIC_MEMORY MemoryKind = iota // A (private) static ROM; identical across all executions of a given machine PRIVATE_STATIC_MEMORY // A (public) read-only memory; variable across executions PUBLIC_READ_ONLY_MEMORY // A (private) read-only memory; variable across executions PRIVATE_READ_ONLY_MEMORY // A (public) write-once memory; variable across executions PUBLIC_WRITE_ONCE_MEMORY // A (private) write-once memory; variable across executions PRIVATE_WRITE_ONCE_MEMORY // The ubiquitous form of memory; supports Arbitrary reads / writes; always PRIVATE RANDOM_ACCESS_MEMORY )
MemoryKind constants
type Resolved ¶
type Resolved = Declaration[symbol.Resolved]
Resolved represents a declaration where external identifiers are otherwise resolved. As such, it should not be possible that such a declaration refers to unknown (or otherwise incorrect) external components.
type ResolvedConstant ¶
ResolvedConstant represents a constant whose expression uses only external identifiers which are resolved. As such, it should not be possible that such a declaration refers to unknown (or otherwise incorrect) external components.
type ResolvedFunction ¶
ResolvedFunction represents a function which contains instructions whose external identifiers are otherwise resolved. As such, it should not be possible that such a declaration refers to unknown (or otherwise incorrect) external components.
type ResolvedInclude ¶
ResolvedInclude is simply a useful alias.
type ResolvedMemory ¶
ResolvedMemory represents a memory whose external identifiers are otherwise resolved. As such, it should not be possible that such a declaration refers to unknown (or otherwise incorrect) external components.
type ResolvedTypeAlias ¶
ResolvedTypeAlias represents a type alias whose contents uses only external identifiers which are resolved. As such, it should not be possible that such a declaration refers to unknown (or otherwise incorrect) external components.
type TypeAlias ¶
type TypeAlias[I symbol.Symbol[I]] struct { DataType data.Type[I] // contains filtered or unexported fields }
TypeAlias represents an alias for either a type at the source level or for another alias.
func NewTypeAlias ¶
NewTypeAlias creates a new type alias for a fundamental type
func (*TypeAlias[I]) Annotations ¶
Annotations implementation for Declaration interface
func (*TypeAlias[I]) Externs ¶
func (p *TypeAlias[I]) Externs() []I
Externs implementation for Declaration interface.
func (*TypeAlias[I]) SetAnnotations ¶
SetAnnotations implementation for Declaration interface
type Unresolved ¶
type Unresolved = Declaration[symbol.Unresolved]
Unresolved represents a declaration which contains string identifiers for external (i.e. unlinked) components. As such, its possible that such a declaration may fail with an error at link time due to an unresolvable reference to an external component (e.g. function, RAM, ROM, etc).
type UnresolvedConstant ¶
type UnresolvedConstant = Constant[symbol.Unresolved]
UnresolvedConstant represents a constant whose expression may contain string identifiers for external (i.e. unlinked) components. As such, its possible that such an expression may fail with an error at link time due to an unresolvable reference to an external component (e.g. function, RAM, ROM, etc).
type UnresolvedFunction ¶
type UnresolvedFunction = Function[symbol.Unresolved]
UnresolvedFunction represents a function which contains string identifiers for external (i.e. unlinked) components. As such, its possible that such a function may fail with an error at link time due to an unresolvable reference to an external component (e.g. function, RAM, ROM, etc).
type UnresolvedInclude ¶
type UnresolvedInclude = Include[symbol.Unresolved]
UnresolvedInclude is simply a useful alias.
type UnresolvedMemory ¶
type UnresolvedMemory = Memory[symbol.Unresolved]
UnresolvedMemory represents a memory which contains string identifiers for external (i.e. unlinked) components. As such, its possible that such a memory may fail with an error at link time due to an unresolvable reference to an external component (e.g. function, RAM, ROM, etc).
type UnresolvedTypeAlias ¶
type UnresolvedTypeAlias = TypeAlias[symbol.Unresolved]
UnresolvedTypeAlias represents a type alias whose contents may contain string identifiers for external (i.e. unlinked) components. As such, its possible that such an expression may fail with an error at link time due to an unresolvable reference to an external component (e.g. function, RAM, ROM, etc).