From 76e30ed8ab892456d240871c2db62f06e53e502f Mon Sep 17 00:00:00 2001 From: Madeleine Masser-Frye <51804758+mmasserfrye@users.noreply.github.com> Date: Wed, 15 Jun 2022 18:28:36 +0000 Subject: [PATCH] cleanup, plots for paper --- pipelined/src/ppa/ppa.sv | 24 ++++ synthDC/bestSynths.csv | 200 ++++++++++++++++----------------- synthDC/ppaAnalyze.py | 237 +++++++++++++++++++++++++++------------ 3 files changed, 289 insertions(+), 172 deletions(-) diff --git a/pipelined/src/ppa/ppa.sv b/pipelined/src/ppa/ppa.sv index ec10da6f..5363bb9b 100644 --- a/pipelined/src/ppa/ppa.sv +++ b/pipelined/src/ppa/ppa.sv @@ -549,6 +549,30 @@ module ppa_mux8d_1 #(parameter WIDTH = 1) ( assign y = s[2] ? (s[1] ? (s[0] ? d5 : d4) : (s[0] ? d6 : d7)) : (s[1] ? (s[0] ? d3 : d2) : (s[0] ? d1 : d0)); endmodule +module ppa_mux2_1 #(parameter WIDTH = 1) ( + input logic [WIDTH-1:0] d0, d1, + input logic s, + output logic [WIDTH-1:0] y); + + assign y = s ? d1 : d0; +endmodule + +module ppa_mux4_1 #(parameter WIDTH = 1) ( + input logic [WIDTH-1:0] d0, d1, d2, d3, + input logic [1:0] s, + output logic [WIDTH-1:0] y); + + assign y = s[1] ? (s[0] ? d3 : d2) : (s[0] ? d1 : d0); +endmodule + +module ppa_mux8_1 #(parameter WIDTH = 1) ( + input logic [WIDTH-1:0] d0, d1, d2, d3, d4, d5, d6, d7, + input logic [2:0] s, + output logic [WIDTH-1:0] y); + + assign y = s[2] ? (s[1] ? (s[0] ? d5 : d4) : (s[0] ? d6 : d7)) : (s[1] ? (s[0] ? d3 : d2) : (s[0] ? d1 : d0)); +endmodule + module ppa_mux2_8 #(parameter WIDTH = 8) ( input logic [WIDTH-1:0] d0, d1, input logic s, diff --git a/synthDC/bestSynths.csv b/synthDC/bestSynths.csv index cbe89c6b..ab047e48 100644 --- a/synthDC/bestSynths.csv +++ b/synthDC/bestSynths.csv @@ -1,101 +1,101 @@ Module,Tech,Width,Target Freq,Delay,Area,L Power (nW),D energy (fJ) -priorityencoder,sky90,8,7994,0.12495882036527395,60.760001,44.346,13.42057730723042 -priorityencoder,sky90,16,5761,0.16976997552508244,136.220003,77.243,21.28915493084534 -priorityencoder,sky90,32,4776,0.20887023450586265,379.260006,246.78,50.06619521105528 -priorityencoder,sky90,64,4096,0.244021625,794.780014,364.853,72.71844425000002 -priorityencoder,sky90,128,3409,0.2933331557641537,1602.300031,610.009,126.1332569785861 -add,sky90,8,3652,0.2733695629791895,245.000005,139.276,101.6934774282585 -add,sky90,16,2931,0.33991248447628797,623.280012,352.919,268.5308627362675 -add,sky90,32,2420,0.4132191404958678,1330.840024,582.809,520.6561170247934 -add,sky90,64,2139,0.4674681813931744,2781.240054,1050.0,939.1435764188874 -add,sky90,128,1885,0.5304949787798409,6186.740118,2230.0,2147.9741690795754 -csa,sky90,8,5740,0.16671402787456446,290.080006,207.654,143.04063591637635 -csa,sky90,16,5984,0.16522529946524064,588.000011,322.135,321.19798216042784 -csa,sky90,32,5740,0.16671402787456446,1160.320023,826.559,570.4954033867597 -csa,sky90,64,5984,0.16522529946524064,2469.600048,1440.0,1354.3517797165773 -csa,sky90,128,5984,0.16522529946524064,4897.060095,2990.0,2649.0572263262034 -shiftleft,sky90,8,4321,0.23108991020597083,250.880004,181.951,70.25133270261513 -shiftleft,sky90,16,3355,0.29803959314456036,666.400006,558.433,195.51397310283156 -shiftleft,sky90,32,2500,0.39945200000000003,1400.420023,738.137,368.29474400000004 -shiftleft,sky90,64,2203,0.45385946391284615,3914.120062,2680.0,1144.633567988198 -shiftleft,sky90,128,1907,0.5242938489774515,9192.400136,6080.0,2900.3935725432616 -comparator,sky90,8,4829,0.2066692116380203,198.940004,136.459,48.56726473493477 -comparator,sky90,16,4014,0.24886605181863478,355.740006,188.666,62.714245058295965 -comparator,sky90,32,3596,0.27763876307007784,697.760013,316.793,109.38967264961067 -comparator,sky90,64,3129,0.31954192361776923,1372.980026,508.393,204.82637303899006 -comparator,sky90,128,2682,0.37267507755406415,2836.120055,772.571,463.6077964772558 -flop,sky90,8,10,0.1143419999999935,133.279999,64.8145,0.22163481569998741 -flop,sky90,16,10,0.1143419999999935,266.5599975,129.629,0.4426750529999749 -flop,sky90,32,10,0.1143419999999935,533.119995,259.258,0.88306326599995 -flop,sky90,64,10,0.1143419999999935,1066.23999,520.0,1.7717864609998994 -flop,sky90,128,10,0.1143419999999935,2132.4799805,1035.0,3.537741479999799 -mux2,sky90,8,5280,0.1887229393939394,63.700001,23.506,19.476207345454547 -mux2,sky90,16,4815,0.20207331983385254,119.560002,32.354,37.76750347694705 -mux2,sky90,32,5049,0.21904002158843336,237.160005,57.793,84.98752837631214 -mux2,sky90,64,4087,0.2460982481037436,482.160008,124.422,156.51848579398091 -mux2,sky90,128,3920,0.25878504081632653,955.500018,279.611,313.9062545102041 -mux4,sky90,8,4655,0.21455177121374866,159.740002,86.462,42.03069198077337 -mux4,sky90,16,4452,0.22313914914645103,392.0,398.313,103.09028690566036 -mux4,sky90,32,3802,0.2622634634402946,465.500009,150.568,139.26189908679646 -mux4,sky90,64,3699,0.2695173360367667,877.100017,304.149,274.9076827575021 -mux4,sky90,128,3166,0.3157249696778269,1984.500039,725.267,569.5678452987997 -mux8,sky90,8,3577,0.2789168803466592,287.140006,116.648,60.83177160360637 -mux8,sky90,16,3419,0.2915101822170225,588.000006,280.193,150.71076420620065 -mux8,sky90,32,3092,0.33231726520051746,1062.320021,325.058,219.99402956274258 -mux8,sky90,64,3020,0.33032882781456957,2207.940042,730.503,445.61358872185434 -mux8,sky90,128,2666,0.37501377344336084,3761.240072,1460.0,854.281375903976 -mult,sky90,8,1310,0.7631557786259543,2194.220041,1440.0,1420.996059801527 -mult,sky90,16,997,1.0029260270812437,7519.540137,4940.0,6375.600754155466 -mult,sky90,32,763,1.3106129895150722,25200.700446,14900.0,24931.79089954522 -mult,sky90,64,632,1.5822664810126583,86011.661365,42600.0,88845.84517534176 -mult,sky90,128,524,1.9083759465648855,296198.144128,114000.0,273311.87793918326 -priorityencoder,tsmc28,8,31306,0.03191275857663067,8.316,34.836,1.713715135565067 -priorityencoder,tsmc28,16,21202,0.04705136175832468,21.294,73.912,3.815865438600132 -priorityencoder,tsmc28,32,16453,0.060740189205615996,62.118,205.801,9.439025402552724 -priorityencoder,tsmc28,64,13786,0.07244435673872045,137.088001,428.365,18.328422254896275 -priorityencoder,tsmc28,128,11439,0.0874122290410001,315.252,980.365,40.908923191188045 -add,tsmc28,8,13787,0.07226709545223761,33.012,176.194,12.328766484151734 -add,tsmc28,16,11520,0.08680155555555555,90.972001,475.452,33.67900355555555 -add,tsmc28,32,9810,0.1019177991845056,209.286002,1060.0,81.43232154841998 -add,tsmc28,64,8203,0.12186861952944045,392.616003,1800.0,142.34254761038645 -add,tsmc28,128,7210,0.13869425520110956,868.140006,4090.0,331.3405756754508 -csa,tsmc28,8,23865,0.04077636748376283,49.392,473.393,20.91827651917033 -csa,tsmc28,16,23865,0.04077636748376283,98.783999,946.879,41.75500030337314 -csa,tsmc28,32,23865,0.04077636748376283,197.567999,1890.0,83.30611876932745 -csa,tsmc28,64,23865,0.04077636748376283,395.135998,3790.0,166.5306848036874 -csa,tsmc28,128,23865,0.04077636748376283,790.271996,7570.0,333.1021459748586 -shiftleft,tsmc28,8,15183,0.06578013640255549,48.384,333.876,15.51753417736284 -shiftleft,tsmc28,16,11800,0.0847177627118644,130.788,613.549,33.71766955932203 -shiftleft,tsmc28,32,9587,0.10430391697089808,384.803997,1940.0,101.80062296359652 -shiftleft,tsmc28,64,8269,0.12088260744951022,967.427998,4980.0,272.83204501354453 -shiftleft,tsmc28,128,7023,0.14238329232521713,1836.953994,8670.0,566.543120162039 -comparator,tsmc28,8,17054,0.05854826984871585,32.256,160.477,8.752966342383019 -comparator,tsmc28,16,13709,0.07280278080093369,48.132,204.944,11.852292714392004 -comparator,tsmc28,32,12136,0.08238147264337507,146.16,623.674,35.50641470929466 -comparator,tsmc28,64,10862,0.09205807659731172,291.312,1240.0,69.41178975437303 -comparator,tsmc28,128,9371,0.10671119720414043,558.432,2400.0,127.9467254477644 -flop,tsmc28,8,10,0.048889000000002625,15.12,78.6345,0.013320296940000717 -flop,tsmc28,16,10,0.048889000000002625,30.24,157.29,0.026541838100001425 -flop,tsmc28,32,10,0.048889000000002625,60.4799995,314.5805,0.05332812120000287 -flop,tsmc28,64,10,0.048889000000002625,120.959999,630.0,0.10640935295000573 -flop,tsmc28,128,10,0.048889000000002625,241.919998,1260.0,0.21305826200001143 -mux2,tsmc28,8,27000,0.04027303703703704,10.332,86.166,4.244778103703704 -mux2,tsmc28,16,19440,0.052470329218107,15.372,84.373,5.1473392962962965 -mux2,tsmc28,32,17903,0.05585556035301346,32.130001,171.146,9.897605294553983 -mux2,tsmc28,64,18546,0.05385698274560552,90.846,517.414,27.359347234767604 -mux2,tsmc28,128,16594,0.0601057455706882,184.968,1150.0,58.603101931421 -mux4,tsmc28,8,18130,0.05509219801434087,27.971999,133.963,8.021424030888031 -mux4,tsmc28,16,16440,0.06065625060827251,39.438,185.149,12.373875124087593 -mux4,tsmc28,32,15168,0.0658052700421941,69.174,324.969,23.229260324894515 -mux4,tsmc28,64,13915,0.07180589399928135,137.465999,648.086,45.59674268954365 -mux4,tsmc28,128,13089,0.07639603056001222,296.603997,1440.0,94.50188980273512 -mux8,tsmc28,8,12885,0.07750962359332557,44.856,215.13,11.90547818393481 -mux8,tsmc28,16,12256,0.08154268929503918,121.841998,521.624,25.93057519582246 -mux8,tsmc28,32,11695,0.08537362676357418,168.21,815.694,46.35787933262078 -mux8,tsmc28,64,11000,0.0907930909090909,304.037999,1490.0,81.89536799999999 -mux8,tsmc28,128,10464,0.09547474923547401,664.775992,2850.0,153.04602302446486 -mult,tsmc28,8,5000,0.19998100000000002,444.150001,3260.0,306.970835 -mult,tsmc28,16,3819,0.26184265147944485,1634.472002,11800.0,1455.3214569227544 -mult,tsmc28,32,2973,0.3363555785401951,5141.430011,36900.0,5416.333881232761 -mult,tsmc28,64,2390,0.4184090418410042,16045.092071,109000.0,18545.980779602512 -mult,tsmc28,128,1868,0.5353279057815846,44272.49428,262000.0,50011.4036139272 +priorityencoder,sky90,8,7683,0.12508649056358195,50.960001,24.761,1.0685929975270078e-05 +priorityencoder,sky90,16,5773,0.16977016282695304,136.220003,77.243,2.1773774467348e-05 +priorityencoder,sky90,32,4500,0.2218912222222222,372.400007,189.626,4.371111111111111e-05 +priorityencoder,sky90,64,4098,0.2439914738897023,797.720015,382.205,7.393850658857981e-05 +priorityencoder,sky90,128,3409,0.2933331557641537,1602.300031,610.009,0.0001261366969785861 +add,sky90,8,3658,0.27337042810278844,253.820005,154.438,0.00010825587752870422 +add,sky90,16,2942,0.3393218266485384,722.260013,485.109,0.00032460910944935416 +add,sky90,32,2468,0.40496338573743923,1440.600027,714.057,0.0006580226904376014 +add,sky90,64,2139,0.4674681813931744,2781.240054,1050.0,0.0009392239364188873 +add,sky90,128,1885,0.5304949787798409,6186.740118,2230.0,0.0021480106100795755 +csa,sky90,8,5758,0.16536141368530738,266.560005,154.202,0.00013650573115665162 +csa,sky90,16,5931,0.1654056314280897,533.12001,308.404,0.00027263530601922105 +csa,sky90,32,5758,0.16536141368530738,1066.240021,616.808,0.0005448072247308093 +csa,sky90,64,5931,0.1654056314280897,2132.480042,1230.0,0.0010905412240768842 +csa,sky90,128,5931,0.1654056314280897,4264.960083,2470.0,0.002178553363682347 +shiftleft,sky90,8,4327,0.23025600254217704,259.700005,196.451,7.534088282874971e-05 +shiftleft,sky90,16,3355,0.29803959314456036,666.400006,558.433,0.00019552906110283157 +shiftleft,sky90,32,2503,0.39951757530962845,1475.880027,768.262,0.0003807431082700759 +shiftleft,sky90,64,2203,0.45385946391284615,3914.120062,2680.0,0.001144802541988198 +shiftleft,sky90,128,1907,0.5242938489774515,9192.400136,6080.0,0.0029008914525432616 +comparator,sky90,8,4839,0.20629126741062204,200.900004,136.6,5.001033271337053e-05 +comparator,sky90,16,4018,0.24806303982080635,358.680007,189.253,6.321553011448482e-05 +comparator,sky90,32,3602,0.276293542476402,690.900013,315.709,0.00010771793448084398 +comparator,sky90,64,3129,0.31954192361776923,1372.980026,508.393,0.0002048577820389901 +comparator,sky90,128,2791,0.35824651809387315,2744.980052,796.047,0.0003439627373701182 +flop,sky90,8,10,0.1143419999999935,133.279999,64.8145,0.000193835 +flop,sky90,16,10,0.1143419999999935,266.5599975,129.629,0.00038715000000000006 +flop,sky90,32,10,0.1143419999999935,533.119995,259.258,0.0007723000000000001 +flop,sky90,64,10,0.1143419999999935,1066.23999,520.0,0.00154955 +flop,sky90,128,10,0.1143419999999935,2132.4799805,1035.0,0.003094 +mux2,sky90,8,5299,0.1883518518588413,63.700001,21.541,1.932440083034535e-05 +mux2,sky90,16,4850,0.20207356701030926,119.560002,32.354,3.884536082474227e-05 +mux2,sky90,32,5003,0.19908807195682593,375.340008,259.372,0.00013671796921846892 +mux2,sky90,64,3989,0.24961239583855604,479.220007,148.175,0.00016570569064928555 +mux2,sky90,128,4004,0.24974824975024976,1302.420025,767.078,0.0004665334665334665 +mux4,sky90,8,4661,0.21448923471358078,164.640002,88.494,4.31452478009011e-05 +mux4,sky90,16,4392,0.22421770309653916,359.659999,419.855,0.0001006375227686703 +mux4,sky90,32,4118,0.24283532831471588,594.860011,331.197,0.00013161728994657602 +mux4,sky90,64,3710,0.26931477897574124,899.640016,344.331,0.00028625336927223723 +mux4,sky90,128,3167,0.31575023618566467,2016.840039,722.109,0.0005917271866119355 +mux8,sky90,8,3585,0.2789170278940028,287.140006,116.648,6.089260808926081e-05 +mux8,sky90,16,3362,0.295237998810232,582.120003,282.366,0.00014455681142177274 +mux8,sky90,32,3178,0.3140553102580239,1319.079995,670.683,0.0003577721837633732 +mux8,sky90,64,2906,0.3440756228492774,2132.48004,808.482,0.0004428768066070199 +mux8,sky90,128,2667,0.3749401308586427,4575.620089,1830.0,0.0009786276715410573 +mult,sky90,8,1310,0.7631557786259543,2194.220041,1440.0,0.0014213740458015268 +mult,sky90,16,997,1.0029260270812437,7519.540137,4940.0,0.0063761283851554666 +mult,sky90,32,763,1.3106129895150722,25200.700446,14900.0,0.024931847968545216 +mult,sky90,64,632,1.5822664810126583,86011.661365,42600.0,0.08884651898734176 +mult,sky90,128,524,1.9083759465648855,296198.144128,114000.0,0.2733148854961832 +priorityencoder,tsmc28,8,31335,0.031912196106590074,8.316,34.836,1.716929950534546e-06 +priorityencoder,tsmc28,16,21253,0.04703118086858326,21.672,78.026,4.008845810003294e-06 +priorityencoder,tsmc28,32,16464,0.06071258114674442,61.614,207.499,9.323372206025267e-06 +priorityencoder,tsmc28,64,13804,0.07239877021153289,137.466,425.592,1.847290640394089e-05 +priorityencoder,tsmc28,128,11440,0.0874065874125874,317.646,973.649,4.117132867132867e-05 +add,tsmc28,8,13838,0.07207477814713109,34.272,187.089,1.3311172134701546e-05 +add,tsmc28,16,11521,0.08678002100512108,90.972001,475.207,3.367763214998698e-05 +add,tsmc28,32,9812,0.1018860211985324,209.286002,1060.0,8.153281695882594e-05 +add,tsmc28,64,8206,0.12185605215695831,388.836003,1770.0,0.0001409943943456008 +add,tsmc28,128,7354,0.13597341881968997,907.452008,4360.0,0.00034511830296437315 +csa,tsmc28,8,24524,0.040663382319360626,52.416,482.462,2.173381177621921e-05 +csa,tsmc28,16,24524,0.040663382319360626,104.832,964.99,4.346762355243842e-05 +csa,tsmc28,32,24524,0.040663382319360626,209.664,1930.0,8.677214157559942e-05 +csa,tsmc28,64,24524,0.040663382319360626,419.327999,3860.0,0.00017342195400424075 +csa,tsmc28,128,24524,0.040663382319360626,838.655998,7720.0,0.00034717011906703634 +shiftleft,tsmc28,8,15202,0.0656078183133798,50.652,367.074,1.6991185370346006e-05 +shiftleft,tsmc28,16,11804,0.08465604506946797,127.511999,602.29,3.388681802778719e-05 +shiftleft,tsmc28,32,9587,0.10430391697089808,384.803997,1940.0,0.00010180452696359654 +shiftleft,tsmc28,64,8272,0.12086674854932303,1041.263998,5460.0,0.0002895309477756286 +shiftleft,tsmc28,128,7023,0.14238329232521713,1836.953994,8670.0,0.000566566994162039 +comparator,tsmc28,8,17422,0.05733769130983814,35.784,170.595,9.488003673516243e-06 +comparator,tsmc28,16,13736,0.07273839778683751,54.558,250.167,1.4349155503785673e-05 +comparator,tsmc28,32,12139,0.08236710865804432,145.782,622.975,3.567015404893319e-05 +comparator,tsmc28,64,11080,0.09024670758122744,294.21,1250.0,6.84115523465704e-05 +comparator,tsmc28,128,9371,0.10671119720414043,558.432,2400.0,0.00012794792444776438 +flop,tsmc28,8,10,0.048889000000002625,15.12,78.6345,2.7246000000000003e-05 +flop,tsmc28,16,10,0.048889000000002625,30.24,157.29,5.4290000000000004e-05 +flop,tsmc28,32,10,0.048889000000002625,60.4799995,314.5805,0.00010908 +flop,tsmc28,64,10,0.048889000000002625,120.959999,630.0,0.00021765500000000003 +flop,tsmc28,128,10,0.048889000000002625,241.919998,1260.0,0.00043579999999999997 +mux2,tsmc28,8,29614,0.03374481252110488,16.758,114.564,5.436617815897886e-06 +mux2,tsmc28,16,18767,0.053046021580433735,15.75,88.025,5.142004582511856e-06 +mux2,tsmc28,32,17903,0.05585556035301346,32.130001,171.146,9.897782494553986e-06 +mux2,tsmc28,64,18568,0.05371109651012495,91.35,523.884,2.757432141318397e-05 +mux2,tsmc28,128,16637,0.05991099044298852,176.525999,941.106,5.012923002945243e-05 +mux4,tsmc28,8,18151,0.055092383284667513,27.971999,133.963,8.032615282904523e-06 +mux4,tsmc28,16,16486,0.06057952759917506,39.438,186.231,1.2556108213029237e-05 +mux4,tsmc28,32,15196,0.06580579126085812,69.174,324.969,2.3229797315082915e-05 +mux4,tsmc28,64,13926,0.07180612868016659,137.465999,648.086,4.5741777969266124e-05 +mux4,tsmc28,128,13090,0.07636619404125286,294.335997,1420.0,9.358288770053477e-05 +mux8,tsmc28,8,12902,0.07750336319950395,44.604,214.286,1.17501162610448e-05 +mux8,tsmc28,16,12264,0.08147446510110894,128.771998,548.714,2.666340508806262e-05 +mux8,tsmc28,32,11713,0.08517122410996329,172.115999,823.633,4.695637326047981e-05 +mux8,tsmc28,64,11014,0.09067453550027238,304.163999,1460.0,8.498274922825495e-05 +mux8,tsmc28,128,10474,0.09542350830628223,683.045996,2820.0,0.00015705556616383426 +mult,tsmc28,8,5200,0.1922996923076923,577.206,4340.0,0.00037769230769230767 +mult,tsmc28,16,3819,0.26184265147944485,1634.472002,11800.0,0.0014553548049227546 +mult,tsmc28,32,3033,0.3295775611605671,6343.721998,47200.0,0.0063033300362677225 +mult,tsmc28,64,2390,0.4184090418410042,16045.092071,109000.0,0.01854602510460251 +mult,tsmc28,128,1868,0.5353279057815846,44272.49428,262000.0,0.05001177730192719 diff --git a/synthDC/ppaAnalyze.py b/synthDC/ppaAnalyze.py index 5f7c54af..6205011d 100755 --- a/synthDC/ppaAnalyze.py +++ b/synthDC/ppaAnalyze.py @@ -60,7 +60,7 @@ def synthsintocsv(): delay = 1000/int(freq) - metrics[0] area = metrics[1] lpower = metrics[4] - denergy = (metrics[2] + metrics[3])*delay*1000 # (switching + internal powers)*delay, more practical units for regression coefs + denergy = (metrics[2] + metrics[3])/int(freq) # (switching + internal powers)*delay, more practical units for regression coefs if ('flop' in module): # since two flops in each module [area, lpower, denergy] = [n/2 for n in [area, lpower, denergy]] @@ -85,22 +85,26 @@ def cleanup(): output = subprocess.check_output(['bash','-c', bashCommand]) allSynths = output.decode("utf-8").split('\n')[:-1] for oneSynth in allSynths: - for phrase in [['Path Length', 'qor'], ['Design Area', 'qor'], ['100', 'power']]: + for phrase in [['Path Length', 'qor']]: #, ['Design Area', 'qor'], ['100', 'power']]: bashCommand = 'grep "{}" '+ oneSynth[2:]+'/reports/*{}*' bashCommand = bashCommand.format(*phrase) try: output = subprocess.check_output(['bash','-c', bashCommand]) except: bc = 'rm -r '+ oneSynth[2:] - try: output = subprocess.check_output(['bash','-c', bc]) - except: pass + output = subprocess.check_output(['bash','-c', bc]) print("All cleaned up!") -def getVals(tech, module, var, freq=None): +def getVals(tech, module, var, freq=None, width=None): ''' for a specified tech, module, and variable/metric returns a list of values for that metric in ascending width order works at a specified target frequency or if none is given, uses the synthesis with the best achievable delay for each width ''' + if width != None: + widthsToGet = width + else: + widthsToGet = widths + metric = [] widthL = [] @@ -112,7 +116,7 @@ def getVals(tech, module, var, freq=None): metric += [osdict[var]] metric = [x for _, x in sorted(zip(widthL, metric))] # ordering else: - for w in widths: + for w in widthsToGet: for oneSynth in bestSynths: if (oneSynth.width == w) & (oneSynth.tech == tech) & (oneSynth.module == module): osdict = oneSynth._asdict() @@ -120,30 +124,59 @@ def getVals(tech, module, var, freq=None): metric += [met] return metric -def csvOfBest(): +def csvOfBest(filename): bestSynths = [] for tech in [x.tech for x in techSpecs]: for mod in modules: for w in widths: m = np.Inf # large number to start best = None - if [mod, tech, w] in leftblue: - for oneSynth in allSynths: + if ([mod, tech, w] in leftblue): + for oneSynth in allSynths: # leftmost blue if (oneSynth.width == w) & (oneSynth.tech == tech) & (oneSynth.module == mod): if (oneSynth.freq < m) & (1000/oneSynth.delay < oneSynth.freq): - if ([mod, tech, w] != ['mux2', 'sky90', 128]) or (oneSynth.area < 1100): - m = oneSynth.freq - best = oneSynth + # if ([mod, tech, w] != ['mux2', 'sky90', 128]) or (oneSynth.area < 1100): + m = oneSynth.freq + best = oneSynth else: - for oneSynth in allSynths: + for oneSynth in allSynths: # best achievable, rightmost green if (oneSynth.width == w) & (oneSynth.tech == tech) & (oneSynth.module == mod): if (oneSynth.delay < m) & (1000/oneSynth.delay > oneSynth.freq): m = oneSynth.delay best = oneSynth + # contenders = [] + # delays = [] + # for oneSynth in allSynths: # choose synth w minimal delay + # if (oneSynth.width == w) & (oneSynth.tech == tech) & (oneSynth.module == mod): + # contenders += [oneSynth] + # delays += [oneSynth.delay] + # if oneSynth.delay < m: + # m = oneSynth.delay + # best = oneSynth + + # for oneSynth in contenders: # if m is min delay, choose best area within s as percent of m + # s = oneSynth.delay/m - 1 + # if s < 0.1: + # if oneSynth.area < best.area: + # best = oneSynth + + # bestval = 1.9 # score algorithm + # for oneSynth in contenders: + # delaydif = abs(1 - oneSynth.delay/best.delay) + # areadif = 1 - oneSynth.area/best.area + # try: val = areadif/delaydif + # except: val = 1 + # # if (oneSynth.width == 64) & (oneSynth.tech == 'sky90') & (oneSynth.module == 'comparator'): + # # print(oneSynth.freq, ' ', delaydif, ' ', areadif, ' ', val) + # if val > bestval: + # bestval = val + # best = oneSynth + if (best != None) & (best not in bestSynths): bestSynths += [best] - file = open("bestSynths.csv", "w") + + file = open(filename, "w") writer = csv.writer(file) writer.writerow(['Module', 'Tech', 'Width', 'Target Freq', 'Delay', 'Area', 'L Power (nW)', 'D energy (fJ)']) for synth in bestSynths: @@ -234,20 +267,18 @@ def oneMetricPlot(module, var, freq=None, ax=None, fits='clsgn', norm=True, colo else: ylabeldic = {"lpower": "Leakage Power (nW)", "denergy": "Dynamic Energy (fJ)", "area": "Area (sq microns)", "delay": "Delay (ns)"} - # fullLeg += genLegend(fits, coefs, r2, combined, ale=ale) - # legLoc = 'upper left' if ale else 'center right' - # ax.add_artist(ax.legend(handles=fullLeg, loc=legLoc)) - - ax.set_xticks(widths) - ax.set_xlabel("Width (bits)") ax.set_ylabel(ylabeldic[var]) + ax.set_xticks(widths) - if (module in ['flop', 'csa']) & (var == 'delay'): - ax.set_ylim(ymin=0) - ytop = ax.get_ylim()[1] - ax.set_ylim(ymax=1.1*ytop) + if singlePlot or (var == 'lpower') or (var == 'denergy'): + ax.set_xlabel("Width (bits)") + if not singlePlot and ((var == 'delay') or (var == 'area')): + ax.tick_params(labelbottom=False) if singlePlot: + fullLeg += genLegend(fits, coefs, r2, combined, ale=ale) + legLoc = 'upper left' if ale else 'center right' + ax.add_artist(ax.legend(handles=fullLeg, loc=legLoc)) titleStr = " (target " + str(freq)+ "MHz)" if freq != None else " (best achievable delay)" ax.set_title(module + titleStr) plt.savefig('./plots/PPA/'+ module + '_' + var + '.png') @@ -260,7 +291,7 @@ def regress(widths, var, fits='clsgn', ale=False): ''' funcArr = genFuncs(fits) - xp = np.linspace(4, 140, 200) + xp = np.linspace(min(widths)/2, max(widths)*1.1, 200) xpToCalc = xp if ale: @@ -413,7 +444,7 @@ def freqPlot(tech, mod, width): median = np.median(list(flatten(freqsL))) f, (ax1, ax2) = plt.subplots(2, 1, sharex=True) - for ax in (ax1, ax2): #, ax3, ax4): + for ax in (ax1, ax2): ax.ticklabel_format(useOffset=False, style='plain') for ind in [0,1]: @@ -421,15 +452,11 @@ def freqPlot(tech, mod, width): delays = delaysL[ind] freqs = freqsL[ind] - # freqs, delays, areas = noOutliers(median, freqs, delays, areas) # comment out to see all syntheses + freqs, delays, areas = noOutliers(median, freqs, delays, areas) # comment out to see all syntheses c = 'blue' if ind else 'green' - # adprod = adprodpow(areas, delays, 1) - # adpow = adprodpow(areas, delays, 2) ax1.scatter(freqs, delays, color=c) ax2.scatter(freqs, areas, color=c) - # ax3.scatter(freqs, adprod, color=c) - # ax4.scatter(freqs, adpow, color=c) legend_elements = [lines.Line2D([0], [0], color='green', ls='', marker='o', label='timing achieved'), lines.Line2D([0], [0], color='blue', ls='', marker='o', label='slack violated')] @@ -440,8 +467,6 @@ def freqPlot(tech, mod, width): ax2.set_xlabel("Target Freq (MHz)") ax1.set_ylabel('Delay (ns)') ax2.set_ylabel('Area (sq microns)') - # ax3.set_ylabel('Area * Delay') - # ax4.set_ylabel('Area * $Delay^2$') ax1.set_title(mod + '_' + width) if ('mux' in mod) & ('d' in mod): width = mod @@ -524,22 +549,13 @@ def squarify(fig): l = (1.-axs/h)/2 fig.subplots_adjust(bottom=l, top=1-l) -def adprodpow(areas, delays, pow): - ''' for each value in [areas] returns area*delay^pow - helper function for freqPlot''' - result = [] - - for i in range(len(areas)): - result += [(areas[i])*(delays[i])**pow] - - return result def plotPPA(mod, freq=None, norm=True, aleOpt=False): ''' for the module specified, plots width vs delay, area, leakage power, and dynamic energy with fits if no freq specified, uses the synthesis with best achievable delay for each width overlays data from both techs ''' - plt.rcParams["figure.figsize"] = (10,7) + plt.rcParams["figure.figsize"] = (7,3.6) fig, axs = plt.subplots(2, 2) arr = [['delay', 'area'], ['lpower', 'denergy']] @@ -557,14 +573,17 @@ def plotPPA(mod, freq=None, norm=True, aleOpt=False): r2 = oneMetricPlot(mod, arr[i][j], ax=axs[i, j], freq=f, norm=norm) ls = '--' if f else '-' leg += [lines.Line2D([0], [0], color='red', label='$R^2$='+str(round(r2, 4)), linestyle=ls)] - axs[i, j].legend(handles=leg) + + if (mod in ['flop', 'csa']) & (arr[i][j] == 'delay'): + axs[i, j].set_ylim(ymin=0) + ytop = axs[i, j].get_ylim()[1] + axs[i, j].set_ylim(ymax=1.1*ytop) + else: + axs[i, j].legend(handles=leg, handlelength=1.5) titleStr = " (target " + str(freq)+ "MHz)" if freq != None else "" plt.suptitle(mod + titleStr) - - fullLeg = [lines.Line2D([0], [0], color='black', label='fastest', linestyle='-')] - fullLeg += [lines.Line2D([0], [0], color='black', label='smallest', linestyle='--')] - fig.legend(handles=fullLeg, ncol=3, loc='center', bbox_to_anchor=(0.3, 0.82, 0.4, 0.2)) + plt.tight_layout(pad=0.05, w_pad=1, h_pad=0.5, rect=(0,0,1,0.97)) if freq != 10: n = 'normalized' if norm else 'unnormalized' @@ -574,32 +593,103 @@ def plotPPA(mod, freq=None, norm=True, aleOpt=False): def plotBestAreas(mod): fig, axs = plt.subplots(1, 1) - ### all areas on one - # mods = ['priorityencoder', 'add', 'csa', 'shiftleft', 'comparator', 'flop'] - # colors = ['red', 'orange', 'yellow', 'green', 'blue', 'purple'] - # legend_elements = [] - # for i in range(len(mods)): - # oneMetricPlot(mods[i], 'area', ax=axs, freq=10, norm=False, color=colors[i]) - # legend_elements += [lines.Line2D([0], [0], color=colors[i], ls='', marker='o', label=mods[i])] - # plt.suptitle('Optimized Areas (target freq 10MHz)') - # plt.legend(handles=legend_elements) - # plt.savefig('./plots/bestareas.png') - # plt.show() - oneMetricPlot(mod, 'area', freq=10) plt.title(mod + ' Optimized Areas (target freq 10MHz)') plt.savefig('./plots/bestAreas/' + mod + '.png') + +def makeDaLegend(): + plt.rcParams["figure.figsize"] = (5.5,0.3) + fig = plt.figure() + fullLeg = [lines.Line2D([0], [0], color='black', label='fastest', linestyle='-')] + fullLeg += [lines.Line2D([0], [0], color='black', label='smallest', linestyle='--')] + fullLeg += [lines.Line2D([0], [0], color='blue', label='tsmc28', marker='^')] + fullLeg += [lines.Line2D([0], [0], color='green', label='sky90', marker='o')] + fullLeg += [lines.Line2D([0], [0], color='red', label='combined', marker='_')] + fig.legend(handles=fullLeg, ncol=5, handlelength=1.4, loc='center') + saveStr = './plots/PPA/legend.png' + plt.savefig(saveStr) + +def calcAvgRsq(): + with open('ppaFitting.csv', newline='') as csvfile: + csvreader = csv.reader(csvfile) + allSynths = list(csvreader)[1:] + csvfile.close() + + others = [] + muxes = [] + + for synth in allSynths: + if ('easy' not in synth) or ('delay' not in synth): + if 'mux' in synth[0]: + muxes += [float(synth[8])] + elif '0.0' != synth[8]: + others += [float(synth[8])] + + print('Others: ', np.mean(others)) + print('Muxes: ', np.mean(muxes)) + +def muxPlot(fits='clsgn', norm=True): + ''' module: string module name + freq: int freq (MHz) + var: string delay, area, lpower, or denergy + fits: constant, linear, square, log2, Nlog2 + plots given variable vs width for all matching syntheses with regression + ''' + ax = plt.gca() + + inputs = [2, 4, 8] + allInputs = inputs*2 + fullLeg = [] + + for crit in ['data', 'control']: + allMetrics = [] + muxes = ['mux2', 'mux4', 'mux8'] + + if crit == 'data': + ls = '--' + muxes = [m + 'd' for m in muxes] + elif crit == 'control': + ls = '-' + + for spec in techSpecs: + metric = [] + for module in muxes: + metric += getVals(spec.tech, module, 'delay', width=[1]) + + if norm: + techdict = spec._asdict() + norm = techdict['delay'] + metric = [m/norm for m in metric] + + if len(metric) == 3: # don't include the spec if we don't have points for all + xp, pred, coefs, r2 = regress(inputs, metric, fits, ale=False) + ax.scatter(inputs, metric, color=spec.color, marker=spec.shape) + ax.plot(xp, pred, color=spec.color, linestyle=ls) + allMetrics += metric + + xp, pred, coefs, r2 = regress(allInputs, allMetrics, fits) + ax.plot(xp, pred, color='red', linestyle=ls) + fullLeg += [lines.Line2D([0], [0], color='red', label=crit, linestyle=ls)] + + ax.set_ylabel('Delay (FO4)') + ax.set_xticks(inputs) + ax.set_xlabel("Number of inputs") + ax.set_title('mux timing') + + ax.legend(handles = fullLeg) + plt.savefig('./plots/PPA/mux.png') + if __name__ == '__main__': ############################## # set up stuff, global variables widths = [8, 16, 32, 64, 128] - modules = ['priorityencoder', 'add', 'csa', 'shiftleft', 'comparator', 'flop', 'mux2', 'mux4', 'mux8', 'mult'] #, 'mux2d', 'mux4d', 'mux8d',] + modules = ['priorityencoder', 'add', 'csa', 'shiftleft', 'comparator', 'flop', 'mux2', 'mux4', 'mux8', 'mult'] # 'mux2d', 'mux4d', 'mux8d'] normAddWidth = 32 # divisor to use with N since normalizing to add_32 fitDict = {'add': ['cg', 'l', 'l'], 'mult': ['cg', 'ls', 'ls'], 'comparator': ['cg', 'l', 'l'], 'csa': ['c', 'l', 'l'], 'shiftleft': ['cg', 'l', 'ln'], 'flop': ['c', 'l', 'l'], 'priorityencoder': ['cg', 'l', 'l']} fitDict.update(dict.fromkeys(['mux2', 'mux4', 'mux8'], ['cg', 'l', 'l'])) - leftblue = [['mux2', 'sky90', 32], ['mux2', 'sky90', 64], ['mux2', 'sky90', 128], ['mux8', 'sky90', 32], ['mux2', 'tsmc28', 8], ['mux2', 'tsmc28', 64]] + leftblue = [] #[['mux2', 'tsmc28', 8], ['mux4', 'sky90', 16]] TechSpec = namedtuple("TechSpec", "tech color shape delay area lpower denergy") techSpecs = [['sky90', 'green', 'o', 43.2e-3, 1330.84, 582.81, 520.66], ['tsmc28', 'blue', '^', 12.2e-3, 209.29, 1060, 81.43]] @@ -612,20 +702,23 @@ if __name__ == '__main__': # synthsintocsv() # slow, run only when new synth runs to add to csv allSynths = synthsfromcsv('ppaData.csv') # your csv here! - bestSynths = csvOfBest() + bestSynths = csvOfBest('bestSynths.csv') # ### plotting examples # squareAreaDelay('sky90', 'add', 32) - # oneMetricPlot('add', 'delay') + # oneMetricPlot('add', 'area') # freqPlot('sky90', 'mux4', 16) # plotBestAreas('add') # makeCoefTable() + # calcAvgRsq() # makeEqTable() - - for mod in modules: - plotPPA(mod, norm=False) - plotPPA(mod, aleOpt=True) - for w in [8, 16, 32, 64, 128]: - freqPlot('sky90', mod, w) - freqPlot('tsmc28', mod, w) - plt.close('all') \ No newline at end of file + # makeDaLegend() + # muxPlot() + + # for mod in modules: + # # plotPPA(mod, norm=False) + # # plotPPA(mod, aleOpt=True) + # for w in widths: + # freqPlot('sky90', mod, w) + # freqPlot('tsmc28', mod, w) + # plt.close('all') \ No newline at end of file