Skip to content
This repository was archived by the owner on Nov 11, 2025. It is now read-only.

Update the evaluator: DAG schematic support (globals), new CLI and other fixes#25

Merged
chiplet merged 4 commits into
mainfrom
evaluator-updates
Jul 26, 2021
Merged

Update the evaluator: DAG schematic support (globals), new CLI and other fixes#25
chiplet merged 4 commits into
mainfrom
evaluator-updates

Conversation

@twelho
Copy link
Copy Markdown
Member

@twelho twelho commented Jul 26, 2021

This PR finally completes the last of the originally planned features for the KiCad evaluator in #14: support for sheet-level global definitions. After some discussions with @chiplet we came to the conclusion that the most native way to support this in KiCad is not to allow parent sheets to update their children (causing potential dependency loops between sheets), but instead treat the schematic hierarchy as a DAG with dedicated sheets for defining global properties at the bottom of the graph. Supporting this model in the evaluator also required minimal changes, this PR just updates the indexing of sub-schematics to use their (proper) filename, and fixes a bug with the dependency loop detection when dealing with diamond inheritance.

Note: Internally the tooling (and our data structures) still treat schematics as a tree, which means that shared child schematics (under diamond inheritance) are processed and saved as many times as they are referred to from different parent schematics. Functionally it doesn't make a big difference right now since parent schematics aren't allowed to update children (to not break the DAG), but especially with complex functions (such as vdiv) in common child schematics processing times might become an issue later on. Tracking issue: #26.

The expression evaluation library we use, evalexpr, is also having a hard time with filenames with dashes (-) as it isn't advanced enough to handle those as complete variable identifiers (trying to apply subtraction instead), so I've updated the KiCad schematics and projects under hat-psu to use dashes in their filenames instead.

Finally this PR also adds in a nicer CLI using clap for the evaluator, which should be easy to port over to the parser and other tooling as well.

@twelho twelho added the enhancement New feature or request label Jul 26, 2021
@twelho twelho requested review from chiplet and luxas July 26, 2021 16:54
Copy link
Copy Markdown
Member

@chiplet chiplet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@chiplet
Copy link
Copy Markdown
Member

chiplet commented Jul 26, 2021

Builds on my machine and seems to be working without any issues. The dependency loop fix is required to run the evaluator in any nontrivial design so I'll merge this to get main back to a working state.

@chiplet chiplet merged commit 9604d32 into main Jul 26, 2021
@chiplet chiplet deleted the evaluator-updates branch July 26, 2021 17:20
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants