SILICON
Loading...
Searching...
No Matches
SILICON::project Namespace Reference

Classes

struct  ArchitectureBuildResult
class  CircuitDependencyGraph
 Runtime-only graph of Circuit-to-Circuit instantiation dependencies. More...
class  Document
struct  DocumentChange
class  DocumentStore
struct  DocumentTypeInfo
class  ProjectCircuitResolver
class  ProjectContext
struct  ProjectFile
 In-memory representation of a .sil project archive. More...
struct  ProjectInfo
 Project-level data stored in project.json. More...
 Metadata stored in metadata.json. More...

Enumerations

enum class  DocumentType { Circuit , Verilog , Sisl , RawBinary }
enum class  DocumentCategory { Diagram , Code , Architecture , Binary }
enum class  DocumentChangeKind { Added , Updated , Removed , Reset }

Functions

bool isArchitecturePathSlug (const std::string_view name)
bool isValidArchitectureName (const std::string_view name)
std::optional< std::string > declaredArchitectureName (const std::string_view source)
std::string renameArchitectureDeclaration (const std::string_view source, const std::string_view oldName, const std::string_view newName)
void validateArchitectureDeclaration (const std::string_view directoryName, const std::string_view source)
std::string architectureDirectory (const std::string_view name)
ArchitectureBuildResult buildArchitecture (const std::optional< std::string > expectedName, const std::string_view source)
std::optional< DocumentType > documentTypeForPath (const std::string_view path)
std::optional< std::string > documentSlugForPath (const std::string_view path)
bool isValidDocumentSlug (const std::string_view slug)
std::string documentPathForSlug (const DocumentType type, const std::string_view slug)
Document importDocument (const std::string_view sourcePath, std::string contents)
std::string documentFileName (const Document &document)
std::shared_ptr< const std::string > binaryContentsSnapshot (const DocumentStore &documents, const std::string_view slug)
constexpr const DocumentTypeInfo & documentTypeInfo (const DocumentType type)
constexpr DocumentCategory categoryOf (const DocumentType type)
constexpr bool isCodeDocument (const DocumentType type)
std::string currentUtcTimestamp ()
 Returns the current UTC timestamp formatted as YYYY-MM-DDTHH\:MM\:SSZ.
ProjectMetadata metadataForNewFile ()
 Creates default metadata for a new project file.
ProjectFile readProjectFile (const std::filesystem::path &path)
 Reads and validates a Silicon .sil project archive.
void writeProjectFile (const std::filesystem::path &path, const ProjectFile &projectFile)
 Writes a Silicon .sil project archive.

Variables

constexpr std::array< DocumentTypeInfo, 4 > DOCUMENT_TYPE_INFO
constexpr std::string_view MIME_TYPE = "application/vnd.silicon.project+zip"
 MIME marker stored in Silicon project archives.
constexpr int FORMAT_VERSION = 1
 Current version of the Silicon project archive schema.
const std::string DEFAULT_CIRCUIT_PATH
 Default path of the initial circuit JSON file.

Enumeration Type Documentation

◆ DocumentCategory

enum class DocumentCategory
strong
Enumerator
Diagram 
Code 
Architecture 
Binary 

Definition at line 39 of file projectDocument.hpp.

◆ DocumentChangeKind

enum class DocumentChangeKind
strong
Enumerator
Added 
Updated 
Removed 
Reset 

Definition at line 91 of file projectDocument.hpp.

◆ DocumentType

enum class DocumentType
strong
Enumerator
Circuit 
Verilog 
Sisl 
RawBinary 

Definition at line 37 of file projectDocument.hpp.

Function Documentation

◆ architectureDirectory()

std::string architectureDirectory ( const std::string_view name)
nodiscard

Definition at line 136 of file isaArchitecture.cpp.

◆ binaryContentsSnapshot()

std::shared_ptr< const std::string > binaryContentsSnapshot ( const DocumentStore & documents,
std::string_view slug )
nodiscard

Returns an immutable copy of a project raw-binary document, or null if absent.

Definition at line 309 of file projectDocument.cpp.

◆ buildArchitecture()

ArchitectureBuildResult buildArchitecture ( std::optional< std::string > expectedName,
std::string_view source )
nodiscard

Validates that the leading declaration matches expectedName and then builds the architecture with SISL. This is the single definition of a successful architecture build shared by every consumer.

A std::nullopt expectedName skips the declaration check, which is only correct for sources whose architecture name is not known yet. A declaration mismatch is reported through ArchitectureBuildResult::error without parsing, so the source is fully parsed at most once.

Definition at line 141 of file isaArchitecture.cpp.

◆ categoryOf()

DocumentCategory categoryOf ( const DocumentType type)
nodiscardconstexpr

Definition at line 81 of file projectDocument.hpp.

◆ currentUtcTimestamp()

std::string currentUtcTimestamp ( )
nodiscard

Returns the current UTC timestamp formatted as YYYY-MM-DDTHH\:MM\:SSZ.

Definition at line 256 of file projectFile.cpp.

◆ declaredArchitectureName()

std::optional< std::string > declaredArchitectureName ( std::string_view source)
nodiscard

Reads only the leading declaration so unfinished imports can still be edited.

Definition at line 108 of file isaArchitecture.cpp.

◆ documentFileName()

std::string documentFileName ( const Document & document)
nodiscard

Returns the external leaf filename used when exporting a project document.

Definition at line 256 of file projectDocument.cpp.

◆ documentPathForSlug()

std::string documentPathForSlug ( const DocumentType type,
const std::string_view slug )
nodiscard

Definition at line 191 of file projectDocument.cpp.

◆ documentSlugForPath()

std::optional< std::string > documentSlugForPath ( const std::string_view path)
nodiscard

Definition at line 174 of file projectDocument.cpp.

◆ documentTypeForPath()

std::optional< DocumentType > documentTypeForPath ( const std::string_view path)
nodiscard

Definition at line 165 of file projectDocument.cpp.

◆ documentTypeInfo()

const DocumentTypeInfo & documentTypeInfo ( const DocumentType type)
nodiscardconstexpr

Definition at line 72 of file projectDocument.hpp.

◆ importDocument()

Document importDocument ( std::string_view fileName,
std::string contents )
nodiscard

Creates a project document from an external file name and payload.

Definitive extensions are preferred; otherwise the payload is inspected for a Silicon circuit or non-text binary data. Code types are extension-only.

Exceptions
std::invalid_argumentif the name is invalid or the file type is unsupported.

Definition at line 230 of file projectDocument.cpp.

◆ isArchitecturePathSlug()

bool isArchitecturePathSlug ( std::string_view name)
nodiscard

Checks that a ZIP path segment cannot escape its architecture directory.

Definition at line 31 of file isaArchitecture.cpp.

◆ isCodeDocument()

bool isCodeDocument ( const DocumentType type)
nodiscardconstexpr

Definition at line 86 of file projectDocument.hpp.

◆ isValidArchitectureName()

bool isValidArchitectureName ( std::string_view name)
nodiscard

Validates an architecture identifier with SISL itself.

Definition at line 44 of file isaArchitecture.cpp.

◆ isValidDocumentSlug()

bool isValidDocumentSlug ( const std::string_view slug)
nodiscard

Definition at line 185 of file projectDocument.cpp.

◆ metadataForNewFile()

ProjectMetadata metadataForNewFile ( )
nodiscard

Creates default metadata for a new project file.

Definition at line 263 of file projectFile.cpp.

◆ readProjectFile()

ProjectFile readProjectFile ( const std::filesystem::path & path)
nodiscard

Reads and validates a Silicon .sil project archive.

Only the reserved archive entries and recognized project documents are accepted.

Exceptions
std::runtime_errorif the archive cannot be opened, does not contain the expected ZIP structure, has invalid JSON, references an unsupported format version, contains an unknown entry, or violates the document layout.

Definition at line 272 of file projectFile.cpp.

◆ renameArchitectureDeclaration()

std::string renameArchitectureDeclaration ( std::string_view source,
std::string_view oldName,
std::string_view newName )
nodiscard

Updates a matching leading declaration while preserving the rest of the source.

Definition at line 115 of file isaArchitecture.cpp.

◆ validateArchitectureDeclaration()

void validateArchitectureDeclaration ( std::string_view directoryName,
std::string_view source )

Throws when a readable declaration disagrees with its containing directory.

Definition at line 126 of file isaArchitecture.cpp.

◆ writeProjectFile()

void writeProjectFile ( const std::filesystem::path & path,
const ProjectFile & projectFile )

Writes a Silicon .sil project archive.

The writer emits every document listed by projectFile.

Exceptions
std::runtime_errorif the project has no circuit document or the archive cannot be created/finalized.

Definition at line 300 of file projectFile.cpp.

Variable Documentation

◆ DEFAULT_CIRCUIT_PATH

const std::string DEFAULT_CIRCUIT_PATH
inline
Initial value:
=
std::string documentPathForSlug(const DocumentType type, const std::string_view slug)

Default path of the initial circuit JSON file.

The archive layout is:

mimetype application/vnd.silicon.project+zip, stored uncompressed
metadata.json archive/schema metadata
project.json project-level information
circuits/untitled.json serialized circuit document JSON

Every project contains at least one document whose type is Circuit. No circuit has project-level priority.

Definition at line 60 of file projectFile.hpp.

◆ DOCUMENT_TYPE_INFO

std::array<DocumentTypeInfo, 4> DOCUMENT_TYPE_INFO
inlineconstexpr
Initial value:
{{
.root = "circuits/",
.suffix = ".json",
.editableText = false},
.root = "code/",
.suffix = ".v",
.editableText = true},
.root = "isa/",
.suffix = "/instr_format.sisl",
.editableText = true},
.root = "bin/",
.suffix = {},
.editableText = false},
}}

Definition at line 49 of file projectDocument.hpp.

◆ FORMAT_VERSION

int FORMAT_VERSION = 1
inlineconstexpr

Current version of the Silicon project archive schema.

Readers reject archives whose metadata.json.formatVersion differs from this value.

Definition at line 43 of file projectFile.hpp.

◆ MIME_TYPE

std::string_view MIME_TYPE = "application/vnd.silicon.project+zip"
inlineconstexpr

MIME marker stored in Silicon project archives.

A .sil file is a ZIP archive. The first entry written by Silicon is a stored, uncompressed mimetype file containing this exact value, allowing readers to reject unrelated ZIP files before parsing JSON payloads.

Definition at line 35 of file projectFile.hpp.