cac3aa7eb7c5075b4032cd5577925d1ca318336d
[Mograsim.git] /
1 package net.mograsim.logic.model.examples;
2
3 import java.io.IOException;
4 import java.nio.file.Files;
5 import java.nio.file.Path;
6 import java.util.Map.Entry;
7
8 import net.mograsim.logic.model.am2900.Am2900Loader;
9 import net.mograsim.logic.model.model.LogicModelModifiable;
10 import net.mograsim.logic.model.model.components.ModelComponent;
11 import net.mograsim.logic.model.modeladapter.CoreModelParameters;
12 import net.mograsim.logic.model.modeladapter.LogicCoreAdapter;
13 import net.mograsim.logic.model.serializing.IndirectModelComponentCreator;
14
15 public class CountGatesPerComponent
16 {
17         public static void main(String[] args) throws IOException
18         {
19                 Am2900Loader.setup();
20
21                 Path root = Path.of("components");
22                 Files.walk(root).map(Path::toString).filter(s -> s.endsWith(".json")).map("jsonfile:"::concat)
23                                 .forEach(CountGatesPerComponent::printGatesPerComponent);
24         }
25
26         private static void printGatesPerComponent(String componentID)
27         {
28                 LogicModelModifiable model = new LogicModelModifiable();
29                 IndirectModelComponentCreator.createComponent(model, componentID);
30
31                 LogicCoreAdapter.gateCountsPerComponentClass.clear();
32                 LogicCoreAdapter.convert(model, new CoreModelParameters());
33
34                 System.out.println(componentID + ':');
35                 for (Entry<Class<? extends ModelComponent>, Integer> e : LogicCoreAdapter.gateCountsPerComponentClass.entrySet())
36                         System.out.println("  " + e.getKey().getSimpleName() + ": " + e.getValue());
37                 System.out.println();
38         }
39 }