From 2cce958529ccf839291061f70249317a50ef5e84 Mon Sep 17 00:00:00 2001 From: Karel Heyse Date: Mon, 18 Nov 2013 17:27:56 +0100 Subject: [PATCH] fixed makefile, add target depth option to simplemapper --- Makefile | 13 ++++-- .../recomp/mapping/simple/SimpleMapper.java | 42 +++++++++++++------ .../recomp/mapping/tmapSimple/TMapSimple.java | 17 ++++++-- 3 files changed, 51 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index b05e73e..2d036ef 100644 --- a/Makefile +++ b/Makefile @@ -3,11 +3,12 @@ ABC_VERSION = 810ba683c042 RAPIDSMITH_VERSION = 0.5.1-linux64 HESSIAN_VERSION = 4.0.6 JAVABDD_VERSION = 1.0b2 +JOPT_SIMPLE_VERSION = 4.5 javaClasses = java/src/be/ugent/elis/recomp/mapping/tmapSimple/TMapSimple.java java/src/be/ugent/elis/recomp/aig/MergeAag.java java/src/be/ugent/elis/recomp/mapping/simple/SimpleMapper.java java/src/be/ugent/elis/recomp/aig/MakeCEvaluator.java java/src/be/ugent/elis/recomp/aig/MakeCEvaluator.java java/src/be/ugent/elis/recomp/util/ExtractInfo.java -.PHONY : java third_party all aigtoaig abc javabdd source +.PHONY : java third_party all aigtoaig abc javabdd jopt_simple source .SUFFIXES: .java .class all : java source third_party @@ -18,25 +19,26 @@ java : $(javaClasses:.java=.class) $(javaClasses:.java=.class) : rapidSmith .java.class : mkdir -p java/bin - javac -d java/bin -classpath java/src:third_party/rapidSmith:third_party/rapidSmith/jars/hessian-${HESSIAN_VERSION}.jar:third_party/JavaBDD/javabdd-1.0b2.jar $< - + javac -d java/bin -classpath java/src:third_party/rapidSmith:third_party/rapidSmith/jars/hessian-${HESSIAN_VERSION}.jar:third_party/JavaBDD/javabdd-1.0b2.jar:third_party/jopt-simple-${JOPT_SIMPLE_VERSION}.jar $< source : echo "export PATH=${PWD}/python/src:${PWD}/third_party/bin:"'$${PATH}' > source echo "export CLASSPATH=${PWD}/java/bin:${PWD}/third_party/rapidSmith/jars/hessian-${HESSIAN_VERSION}.jar:"'$${CLASSPATH:-}' >> source echo "export CLASSPATH=${PWD}/third_party/JavaBDD/javabdd-1.0b2.jar:"'$${CLASSPATH:-}' >> source + echo "export CLASSPATH=${PWD}/third_party/jopt-simple-${JOPT_SIMPLE_VERSION}.jar"'$${CLASSPATH:-}' >> source echo "export PYTHONPATH=${PWD}/python/src:"'$${PYTHONPATH:-}' >> source echo "export RAPIDSMITH_PATH=${PWD}/third_party/rapidSmith" >> source echo "export TLUTFLOW_PATH=${PWD}" >> source -third_party : aigtoaig abc rapidSmith javabdd +third_party : aigtoaig abc rapidSmith javabdd jopt_simple aigtoaig : third_party/aiger-${AIGER_VERSION}/aigtoaig third_party/bin/aigtoaig abc : third_party/abc_${ABC_VERSION}/abc third_party/bin/abc third_party/etc/abc.rc rapidSmith : third_party/rapidSmith javabdd : third_party/JavaBDD/javabdd-${JAVABDD_VERSION}.jar +jopt_simple : third_party/jopt-simple-${JOPT_SIMPLE_VERSION}.jar third_party/bin/aigtoaig : mkdir -p third_party/bin @@ -92,3 +94,6 @@ third_party/javabdd_${JAVABDD_VERSION}.tar.gz : third_party/JavaBDD/javabdd-${JAVABDD_VERSION}.jar : third_party/javabdd_${JAVABDD_VERSION}.tar.gz tar -xzf third_party/javabdd_${JAVABDD_VERSION}.tar.gz -C third_party touch third_party/JavaBDD/javabdd-${JAVABDD_VERSION}.jar + +third_party/jopt-simple-${JOPT_SIMPLE_VERSION}.jar : + cd third_party && curl -O http://central.maven.org/maven2/net/sf/jopt-simple/jopt-simple/${JOPT_SIMPLE_VERSION}/jopt-simple-${JOPT_SIMPLE_VERSION}.jar diff --git a/java/src/be/ugent/elis/recomp/mapping/simple/SimpleMapper.java b/java/src/be/ugent/elis/recomp/mapping/simple/SimpleMapper.java index fddee4b..562c772 100644 --- a/java/src/be/ugent/elis/recomp/mapping/simple/SimpleMapper.java +++ b/java/src/be/ugent/elis/recomp/mapping/simple/SimpleMapper.java @@ -77,6 +77,10 @@ e. before Licensee sends such Adaptation to any other people or entities, Licens import javax.print.attribute.standard.PrinterName; +import joptsimple.OptionParser; +import joptsimple.OptionSet; +import joptsimple.OptionSpec; + import be.ugent.elis.recomp.mapping.tmapSimple.ParameterMarker; import be.ugent.elis.recomp.mapping.utils.MappingAIG; import be.ugent.elis.recomp.synthesis.BDDFactorySingleton; @@ -90,40 +94,52 @@ public class SimpleMapper { */ public static void main(String[] args) throws FileNotFoundException { BDDFactorySingleton.get(1000, 1000); + + OptionParser parser = new OptionParser(); + OptionSpec files_option = parser.nonOptions().ofType( String.class ); + OptionSpec depth_option = + parser.accepts("depth").withRequiredArg().ofType( Integer.class ).defaultsTo(-1); + OptionSet options = parser.parse(args); + + // Usage: + // <0> : input file with aag + // <1> : integer/number of inputs per LUT + // <2> : output file with mapped blif + // + // -d : optional target depth + + String[] arguments = options.valuesOf(files_option).toArray(new String[1]); + int target_depth = depth_option.value(options); + + // Read AIG file + MappingAIG a = new MappingAIG(arguments[0]); - // Read AIG file - MappingAIG a = new MappingAIG(args[0]); + int K = Integer.parseInt(arguments[1]); - int K = Integer.parseInt(args[1]); -// a.visitAll(new ParameterMarker(new FileInputStream(args[1]))); - // Mapping System.out.println("Cone Enumeration:"); ConeEnumeration enumerator = new ConeEnumeration(K); + a.visitAll(enumerator); System.out.println("Cone Ranking:"); a.visitAll(new ConeRanking(new DepthOrientedConeComparator())); a.visitAllInverse(new ConeSelection()); double depthBeforeAreaRecovery = a.getDepth(); - a.visitAllInverse(new HeightCalculator()); + a.visitAllInverse(new HeightCalculator(target_depth)); a.visitAll(new ConeRanking(new AreaflowOrientedConeComparator(),true,false)); a.visitAllInverse(new ConeSelection()); - a.visitAllInverse(new HeightCalculator()); + a.visitAllInverse(new HeightCalculator(target_depth)); a.visitAll(new ConeRanking(new AreaOrientedConeComparator(),false,true)); if(depthBeforeAreaRecovery != a.getDepth()) { System.err.println("Depth increased during area recovery: from "+depthBeforeAreaRecovery+" to "+a.getDepth()); System.exit(1); } - -// a.visitAllInverse(new PrintNameVisitor()); - + System.out.println("Cone Selection:"); a.visitAllInverse(new ConeSelection()); - System.out.println(a.numLuts() +"\t"+ a.getDepth() +"\t"+ enumerator.getNmbrCones() +"\t"+ enumerator.getNmbrKCones() +"\t"+ enumerator.getNmbrDominatedCones()); - // Writing a blif - a.printLutStructureBlif(new PrintStream(new BufferedOutputStream(new FileOutputStream(args[2]))), K); + a.printLutStructureBlif(new PrintStream(new BufferedOutputStream(new FileOutputStream(args[2]))), K); } } diff --git a/java/src/be/ugent/elis/recomp/mapping/tmapSimple/TMapSimple.java b/java/src/be/ugent/elis/recomp/mapping/tmapSimple/TMapSimple.java index 4d383b3..94d5730 100644 --- a/java/src/be/ugent/elis/recomp/mapping/tmapSimple/TMapSimple.java +++ b/java/src/be/ugent/elis/recomp/mapping/tmapSimple/TMapSimple.java @@ -96,8 +96,7 @@ public class TMapSimple { * @throws IOException */ public static void main(String[] args) throws IOException { - // Find the base name of the aag file - //String baseName = args[0].substring(0,args[0].lastIndexOf('.')); + BDDFactorySingleton.get(1000, 1000); //Usage: // <0> : input file with aig @@ -110,8 +109,18 @@ public static void main(String[] args) throws IOException { // <5> : input VHDL file (used to copy VHDL header) // <6> : output VHDL file with (T)LUT structure // <7> : output file with VHDL names of TLUT instances - - BDDFactorySingleton.get(1000, 1000); + // + // -d : optional target depth + + OptionParser parser = new OptionParser(); + OptionSpec files_option = parser.nonOptions().ofType( String.class ); + OptionSpec depth_option = + parser.accepts("depth").withRequiredArg().ofType( Integer.class ).defaultsTo(-1); + OptionSet options = parser.parse(args); + + String[] arguments = options.valuesOf(files_option).toArray(new String[1]); + int target_depth = depth_option.value(options); + // Read AIG file MappingAIG a = new MappingAIG(args[0]);