Projects & Imports
Neo supports multi-file hardware projects using a neo.toml manifest, module-path import declarations, and explicit pub visibility.
Project Manifest (neo.toml)
Place a neo.toml file at the root of your project directory:
[project]
root = "src"
entry = "src/main.neo"[project].root(optional, defaults to"src"): Base directory for root-relative module imports.[project].entry(optional, defaults to<root>/main.neo): Default entry file when runningneo checkorneo buildon a project directory orneo.toml.- Top-level
rootorentrykeys outside[project]are rejected as invalid schema.
When running neo check path/to/file.neo or neo build path/to/file.neo:
- Neo walks upward from the target file or directory looking for
neo.toml. - If found,
rootcomes from[project].root(or<manifest_dir>/src) unless overridden with--root <dir>. - If no
neo.tomlexists, the entry file's parent directory serves as the import root (unless--root <dir>is supplied).
Visibility: pub and pub import
Top-level declarations (enum, struct, union, interface, module) are private to their file by default. Mark a declaration pub to allow other files to import it:
// src/types.neo
pub enum Op {
Add = 0,
Sub = 1,
}
pub struct Pair {
a: Int(32),
b: Int(32),
}
// Private helper — cannot be imported by other files
struct InternalTemp {
v: Bits(8),
}Attempting to import a non-pub symbol produces a private_import error with related span information pointing to its declaration.
You can re-export imported symbols from another file using pub import:
// src/reexport.neo
pub import types::Pair as ReexportedPair;Import Syntax & Path Resolution
Import statements appear at the top of a .neo file and use ::-separated module paths:
// Single item import
import types::Op;
// Renamed import using `as`
import types::Op as AluOp;
// Grouped imports from the same file
import types::{Op, Pair as DataPair};
// Nested directory module (resolves to `<root>/alu/adder.neo`)
import alu::adder::Alu;
// Relative to the current file's directory (`self::`)
import self::helpers::Mux2;
// Relative to parent directories (`super::`, repeatable)
import super::common::{Word, Byte};Path Resolution Rules
- Root-relative (
foo::bar::Item): Resolves to<root>/foo/bar.neoand importsItem. - Sibling-relative (
self::foo::Item): Resolves to<current_file_dir>/foo.neo. - Parent-relative (
super::...::foo::Item): Pops one directory per leadingsuper::from<current_file_dir>, then resolvesfoo.neo. - Sandboxed to root: Any resolved import path that escapes
<root>(e.g., too manysuper::segments) is rejected. - Acyclic dependency graph: Circular file imports are detected and reported cleanly during workspace loading, while forward references within the same file are supported.
Example Layout
my-project/
├── neo.toml
└── src/
├── main.neo # Entry file with @top module
├── types.neo # pub enum / pub struct definitions
├── reexport.neo # pub import re-exports
└── alu/
└── adder.neo # pub module AluRun neo check or neo build --format sv from my-project/ and Neo automatically discovers neo.toml, resolves the transitive import graph, checks all files in topological order, and elaborates every @top module in src/main.neo.