diff --git a/src/main/java/de/neemann/digital/cli/LengthExport.java b/src/main/java/de/neemann/digital/cli/LengthExport.java
new file mode 100644
index 000000000..1f715df50
--- /dev/null
+++ b/src/main/java/de/neemann/digital/cli/LengthExport.java
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2025 Alessandro Pellegrini.
+ * Use of this source code is governed by the GPL v3 license
+ * that can be found in the LICENSE file.
+ */
+package de.neemann.digital.cli;
+
+import de.neemann.digital.analyse.AnalyseException;
+import de.neemann.digital.analyse.ModelAnalyser;
+import de.neemann.digital.analyse.PathLenAnalyser;
+import de.neemann.digital.cli.cli.Argument;
+import de.neemann.digital.cli.cli.BasicCommand;
+import de.neemann.digital.cli.cli.CLIException;
+import de.neemann.digital.core.BacktrackException;
+import de.neemann.digital.core.Model;
+import de.neemann.digital.core.NodeException;
+import de.neemann.digital.draw.elements.PinException;
+import de.neemann.digital.draw.library.ElementNotFoundException;
+import de.neemann.digital.lang.Lang;
+
+import java.io.IOException;
+
+/**
+ * CLI critical path exporter
+ */
+public class LengthExport extends BasicCommand {
+ private final Argument digFile;
+
+ /**
+ * Creates the critical path export command
+ */
+ public LengthExport() {
+ super("length");
+ digFile = addArgument(new Argument<>("dig", "", false));
+ }
+
+ @Override
+ protected void execute() throws CLIException {
+ try {
+ Model model = new CircuitLoader(digFile.get()).createModel();
+ ModelAnalyser modelAnalyser = new ModelAnalyser(model);
+ PathLenAnalyser pathLenAnalyser = new PathLenAnalyser(modelAnalyser);
+ System.out.println(pathLenAnalyser.getMaxPathLen());
+ } catch (IOException | ElementNotFoundException | PinException | NodeException | BacktrackException
+ | AnalyseException e) {
+ throw new CLIException(Lang.get("cli_errorComputingCriticalPath"), e);
+ }
+ }
+}
diff --git a/src/main/java/de/neemann/digital/cli/Main.java b/src/main/java/de/neemann/digital/cli/Main.java
index fb447ee5b..0f9307b5b 100644
--- a/src/main/java/de/neemann/digital/cli/Main.java
+++ b/src/main/java/de/neemann/digital/cli/Main.java
@@ -20,6 +20,7 @@ public Main() {
addCommand(new CommandLineTester.TestCommand());
addCommand(new SVGExport());
addCommand(new StatsExport());
+ addCommand(new LengthExport());
addCommand(new Runner());
}
diff --git a/src/main/resources/lang/lang_de.xml b/src/main/resources/lang/lang_de.xml
index 5fe453990..e30d24f68 100644
--- a/src/main/resources/lang/lang_de.xml
+++ b/src/main/resources/lang/lang_de.xml
@@ -1814,6 +1814,9 @@ Sind evtl. die Namen der Variablen nicht eindeutig?
Wenn diese Option fehlt, erfolgt eine Ausgabe auf die Konsole.
Fehler bei der Erzeugung der CSV Datei!
+ Gibt die Länge des kritischen Pfads der Schaltung aus.
+ Name der Schaltungsdatei.
+ Fehler bei der Berechnung der kritischen Pfadlänge!
Kein aktivierter Takt in der Schaltung gefunden!
Fehler beim Starten der Schaltung!
diff --git a/src/main/resources/lang/lang_en.xml b/src/main/resources/lang/lang_en.xml
index c595caef4..937efc43b 100644
--- a/src/main/resources/lang/lang_en.xml
+++ b/src/main/resources/lang/lang_en.xml
@@ -1794,6 +1794,9 @@
If this option is missing, the table is written to stdout.
Error while creating the stats file!
+ Prints the length of the critical path of the circuit.
+ File name of the circuit.
+ Error while computing the critical path length!
No running clock found in circuit!
Error running the circuit!
diff --git a/src/main/resources/lang/lang_es.xml b/src/main/resources/lang/lang_es.xml
index 0394b10c7..8555f8176 100644
--- a/src/main/resources/lang/lang_es.xml
+++ b/src/main/resources/lang/lang_es.xml
@@ -2116,6 +2116,9 @@ Sin embargo, no se deben usar por encima de la línea del encabezado que contien
Si no está indicada esta opción, se escribe la tabla en stdout.
Error al crear el archivo de estadísticas.
+ Imprime la longitud del camino crítico del circuito.
+ Nombre del archivo del circuito.
+ Error al calcular la longitud del camino crítico.
Exporta texto plano
Gráfica de datos activos
Rango
diff --git a/src/main/resources/lang/lang_es_ref.xml b/src/main/resources/lang/lang_es_ref.xml
index 9dff76a1d..09967fcc6 100644
--- a/src/main/resources/lang/lang_es_ref.xml
+++ b/src/main/resources/lang/lang_es_ref.xml
@@ -2200,6 +2200,9 @@ However, they must not be used above the header line listing the signal names.&l
If this option is missing, the table is written to stdout.
Error while creating the stats file!
+ Prints the length of the critical path of the circuit.
+ File name of the circuit.
+ Error while computing the critical path length!
Export Plain Text
Triggered Data Graph
Scope
diff --git a/src/main/resources/lang/lang_fr.xml b/src/main/resources/lang/lang_fr.xml
index 23d049c21..82ed7eddd 100644
--- a/src/main/resources/lang/lang_fr.xml
+++ b/src/main/resources/lang/lang_fr.xml
@@ -1789,6 +1789,9 @@ In the file howTo.md you can find more details about translations.
Si cette option est manque, la table de vérité est écrite à la sortie standard.
Erreur lors de la création du fichier de statistiques!
+ Imprime la longueur du chemin critique du circuit.
+ Nom de fichier du circuit.
+ Erreur lors du calcul de la longueur du chemin critique!
Fenêtre
À propos
Analyse
diff --git a/src/main/resources/lang/lang_fr_ref.xml b/src/main/resources/lang/lang_fr_ref.xml
index 8996f74dd..76dc3dd90 100644
--- a/src/main/resources/lang/lang_fr_ref.xml
+++ b/src/main/resources/lang/lang_fr_ref.xml
@@ -1652,6 +1652,9 @@ In the file howTo.md you can find more details about translations.
If this option is missing, the table is written to stdout.
Error while creating the stats file!
+ Prints the length of the critical path of the circuit.
+ File name of the circuit.
+ Error while computing the critical path length!
Windows
About
Analysis
diff --git a/src/main/resources/lang/lang_it.xml b/src/main/resources/lang/lang_it.xml
index d6d3e5577..2417c27a4 100644
--- a/src/main/resources/lang/lang_it.xml
+++ b/src/main/resources/lang/lang_it.xml
@@ -1388,6 +1388,9 @@ In the file howTo.md you can find more details about translations.
Nome del file del circuito.
Nome del file CSV da creare. Se questa opzione manca, la tabella è scritta nello standard output.
Errore durante la creazione dei file di statistica!
+ Stampa la lunghezza del cammino critico del circuito.
+ Nome del file del circuito.
+ Errore durante il calcolo della lunghezza del cammino critico!
Finestre
Informazioni su
Analisi
diff --git a/src/main/resources/lang/lang_it_ref.xml b/src/main/resources/lang/lang_it_ref.xml
index 902022220..030ca5033 100644
--- a/src/main/resources/lang/lang_it_ref.xml
+++ b/src/main/resources/lang/lang_it_ref.xml
@@ -1439,6 +1439,9 @@ In the file howTo.md you can find more details about translations.
Name of the CSV file to be created.
If this option is missing, the table is written to stdout.
Error while creating the stats file!
+ Prints the length of the critical path of the circuit.
+ File name of the circuit.
+ Error while computing the critical path length!
Windows
About
Analysis
diff --git a/src/main/resources/lang/lang_pt.xml b/src/main/resources/lang/lang_pt.xml
index 2b3c99bc8..ecc9036e9 100644
--- a/src/main/resources/lang/lang_pt.xml
+++ b/src/main/resources/lang/lang_pt.xml
@@ -2209,6 +2209,9 @@ In the file howTo.md you can find more details about translations.
Se essa opção for omitida, a tabela será escrita na saída padrão.
Erro ao criar o arquivo com estatísticas!
+ Imprime o comprimento do caminho crítico do circuito.
+ Nome do arquivo contendo circuito.
+ Erro no cálculo do comprimento do caminho crítico!
Exportar para texto puro
Bobina A, negativo
Bobina B, positivo
diff --git a/src/main/resources/lang/lang_pt_ref.xml b/src/main/resources/lang/lang_pt_ref.xml
index 3ab9a376e..17737395b 100644
--- a/src/main/resources/lang/lang_pt_ref.xml
+++ b/src/main/resources/lang/lang_pt_ref.xml
@@ -2250,6 +2250,9 @@ However, they must not be used above the header line listing the signal names.&l
If this option is missing, the table is written to stdout.
Error while creating the stats file!
+ Prints the length of the critical path of the circuit.
+ File name of the circuit.
+ Error while computing the critical path length!
Export Plain Text
Coil A, negative
Coil B, positive
diff --git a/src/main/resources/lang/lang_zh.xml b/src/main/resources/lang/lang_zh.xml
index 4c2c5639f..bf208ee23 100644
--- a/src/main/resources/lang/lang_zh.xml
+++ b/src/main/resources/lang/lang_zh.xml
@@ -1483,6 +1483,9 @@ In the file howTo.md you can find more details about translations.
电路文件名
CSV 文件名,如果为空,将写入到标准输出。
创建统计文件时遇到错误!
+ 打印电路关键路径的长度。
+ 电路文件名.
+ 计算关键路径长度时出错!
导出纯文本
示波器
Scope
diff --git a/src/main/resources/lang/lang_zh_ref.xml b/src/main/resources/lang/lang_zh_ref.xml
index c91ab22a0..90228aba6 100644
--- a/src/main/resources/lang/lang_zh_ref.xml
+++ b/src/main/resources/lang/lang_zh_ref.xml
@@ -1866,6 +1866,9 @@ In the file howTo.md you can find more details about translations.
If this option is missing, the table is written to stdout.
Error while creating the stats file!
+ Prints the length of the critical path of the circuit.
+ File name of the circuit.
+ Error while computing the critical path length!
Export Plain Text
Triggered Data Graph
Scope
diff --git a/src/test/java/de/neemann/digital/cli/LengthExportTest.java b/src/test/java/de/neemann/digital/cli/LengthExportTest.java
new file mode 100644
index 000000000..45d91c9ca
--- /dev/null
+++ b/src/test/java/de/neemann/digital/cli/LengthExportTest.java
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2025 Alessandro Pellegrini.
+ * Use of this source code is governed by the GPL v3 license
+ * that can be found in the LICENSE file.
+ */
+package de.neemann.digital.cli;
+
+import de.neemann.digital.cli.cli.CLIException;
+import de.neemann.digital.integration.Resources;
+import junit.framework.TestCase;
+
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.PrintStream;
+
+public class LengthExportTest extends TestCase {
+
+ public void testLength() throws CLIException {
+ File source = new File(Resources.getRoot(), "../../main/dig/combinatorial/FullAdder.dig");
+ PrintStream old = System.out;
+ try {
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
+ try (PrintStream out = new PrintStream(baos)) {
+ System.setOut(out);
+ new LengthExport().execute(new String[]{source.getPath()});
+ }
+ String outStr = baos.toString();
+ assertEquals("3", outStr.replaceAll("\\R", ""));
+ } finally {
+ System.setOut(old);
+ }
+ }
+
+}
\ No newline at end of file