From 4fe1436e1fb01b269b0174522074b3d9092d16e7 Mon Sep 17 00:00:00 2001
From: Gabriel Gouvine <gabriel.gouvine_git@m4x.org>
Date: Sat, 10 Jun 2023 14:45:07 +0200
Subject: [PATCH] Remove uniform density option, replaced by densityVariation

---
 crlcore/python/technos/common/etesian.py           |  1 -
 cumulus/src/designflow/technos.py                  |  2 +-
 .../content/pages/python-tutorial/ToolEngines.rst  | 14 +++++++-------
 .../content/pages/users-guide/ViewerTools.rst      |  7 +++----
 .../examples/scripts/coriolis2/settings.py         |  2 +-
 .../sphinx/pages/users-guide/ViewerTools.rst       |  7 +++----
 etesian/src/Configuration.cpp                      |  4 ----
 etesian/src/etesian/Configuration.h                |  6 ------
 etesian/src/etesian/EtesianEngine.h                |  2 --
 unittests/python/test_hurricane.py                 |  2 +-
 10 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/crlcore/python/technos/common/etesian.py b/crlcore/python/technos/common/etesian.py
index b5c5e7dc..7142db10 100644
--- a/crlcore/python/technos/common/etesian.py
+++ b/crlcore/python/technos/common/etesian.py
@@ -21,7 +21,6 @@ param.setDouble( 1.0 )
 
 Cfg.getParamDouble    ( 'etesian.spaceMargin'      ).setPercentage( 0.05 )
 Cfg.getParamDouble    ( 'etesian.densityVariation' ).setPercentage( 0.05 )
-Cfg.getParamBool      ( 'etesian.uniformDensity'   ).setBool      ( False )
 Cfg.getParamBool      ( 'etesian.routingDriven'    ).setBool      ( False )
 Cfg.getParamString    ( 'etesian.feedNames'        ).setString    ( 'tie_x0,rowend_x0' )
 Cfg.getParamString    ( 'etesian.cell.zero'        ).setString    ( 'zero_x0' )
diff --git a/cumulus/src/designflow/technos.py b/cumulus/src/designflow/technos.py
index 814fc605..b9d980e2 100644
--- a/cumulus/src/designflow/technos.py
+++ b/cumulus/src/designflow/technos.py
@@ -295,7 +295,7 @@ def setupTSMC_c180_c4m ( checkToolkit=None, ndaTop=None ):
         cfg.misc.verboseLevel1       = True
         cfg.misc.verboseLevel2       = True
         cfg.etesian.graphics         = 3
-        cfg.etesian.uniformDensity   = True
+        cfg.etesian.densityVariation = 0.04
         cfg.etesian.spaceMargin      = 0.04
         cfg.katana.eventsLimit       = 4000000
         af  = CRL.AllianceFramework.get()
diff --git a/documentation/content/pages/python-tutorial/ToolEngines.rst b/documentation/content/pages/python-tutorial/ToolEngines.rst
index 3e2b40bd..bfc26763 100644
--- a/documentation/content/pages/python-tutorial/ToolEngines.rst
+++ b/documentation/content/pages/python-tutorial/ToolEngines.rst
@@ -36,15 +36,15 @@ You can configure the placer in two ways:
    .. code-block:: Python
    
       with overlay.CfgCache(priority=Cfg.Parameter.Priority.UserFile) as cfg:
-          cfg.etesian.effort          = 2
-          cfg.etesian.uniformDensity  = True
-          cfg.etesian.spaceMargin     = 0.8
-          cfg.etesian.aspectRatio     = 1.0
+          cfg.etesian.effort           = 2
+          cfg.etesian.spaceMargin      = 0.8
+          cfg.etesian.densityVariation = 0.1
+          cfg.etesian.aspectRatio      = 1.0
 
 
-   With this setup, the cells will be spread uniformally over the
-   area (``etesian.uniformDensity``), with ``80%`` of free space
-   added and an aspect ratio of ``100%`` (square shape).
+   With this setup, the placement will have ``80%`` of free space added and
+   an aspect ratio of ``100%`` (square shape). Some variations in density
+   is allowed, with at most ``10%`` unused space.
 
 
 8.1 Router -- Katana
diff --git a/documentation/content/pages/users-guide/ViewerTools.rst b/documentation/content/pages/users-guide/ViewerTools.rst
index 9818f43d..c4f567f7 100644
--- a/documentation/content/pages/users-guide/ViewerTools.rst
+++ b/documentation/content/pages/users-guide/ViewerTools.rst
@@ -176,11 +176,10 @@ Etesian Configuration Parameters
 |                                   | The extra white space added to the total area |
 |                                   | of the standard cells                         |
 +-----------------------------------+------------------+----------------------------+
-|``etesian.uniformDensity``         | TypeBool         | :cb:`False`                |
+|``etesian.densityVariation``       | TypePercentage   | :cb:`5`                    |
 |                                   +------------------+----------------------------+
-|                                   | Whether the cells will be spread envenly      |
-|                                   | across the area or allowed to form denser     |
-|                                   | clusters                                      |
+|                                   | Control deviation from uniform density in the |
+|                                   | placement, as a percentage of area.           |
 +-----------------------------------+------------------+----------------------------+
 |``etesian.effort``                 | TypeInt          | :cb:`2`                    |
 |                                   +------------------+----------------------------+
diff --git a/documentation/examples/scripts/coriolis2/settings.py b/documentation/examples/scripts/coriolis2/settings.py
index b46f5574..6661d8c6 100644
--- a/documentation/examples/scripts/coriolis2/settings.py
+++ b/documentation/examples/scripts/coriolis2/settings.py
@@ -24,8 +24,8 @@ with overlay.CfgCache(priority=Cfg.Parameter.Priority.UserFile) as cfg:
     cfg.misc.minTraceLevel          = 1900
     cfg.misc.maxTraceLevel          = 3000
     cfg.etesian.effort              = 2
-    cfg.etesian.uniformDensity      = True
     cfg.etesian.spaceMargin         = 0.8
+    cfg.etesian.densityVariation    = 0.1
     cfg.etesian.aspectRatio         = 1.0
     cfg.katana.eventsLimit          = 1000000
     cfg.katana.termSatReservedLocal = 6 
diff --git a/documentation/sphinx/pages/users-guide/ViewerTools.rst b/documentation/sphinx/pages/users-guide/ViewerTools.rst
index 9818f43d..c4f567f7 100644
--- a/documentation/sphinx/pages/users-guide/ViewerTools.rst
+++ b/documentation/sphinx/pages/users-guide/ViewerTools.rst
@@ -176,11 +176,10 @@ Etesian Configuration Parameters
 |                                   | The extra white space added to the total area |
 |                                   | of the standard cells                         |
 +-----------------------------------+------------------+----------------------------+
-|``etesian.uniformDensity``         | TypeBool         | :cb:`False`                |
+|``etesian.densityVariation``       | TypePercentage   | :cb:`5`                    |
 |                                   +------------------+----------------------------+
-|                                   | Whether the cells will be spread envenly      |
-|                                   | across the area or allowed to form denser     |
-|                                   | clusters                                      |
+|                                   | Control deviation from uniform density in the |
+|                                   | placement, as a percentage of area.           |
 +-----------------------------------+------------------+----------------------------+
 |``etesian.effort``                 | TypeInt          | :cb:`2`                    |
 |                                   +------------------+----------------------------+
diff --git a/etesian/src/Configuration.cpp b/etesian/src/Configuration.cpp
index 8f4d5cdd..54abfd7c 100644
--- a/etesian/src/Configuration.cpp
+++ b/etesian/src/Configuration.cpp
@@ -57,7 +57,6 @@ namespace Etesian {
                           (Cfg::getParamEnumerate ("etesian.effort"         , Standard   )->asInt()) )
     , _updateConf       ( static_cast<GraphicUpdate>                        
                           (Cfg::getParamEnumerate ("etesian.graphics"       , FinalOnly  )->asInt()) )
-    , _spreadingConf    (  Cfg::getParamBool      ("etesian.uniformDensity" , false      )->asBool()? ForceUniform : MaxDensity )
     , _routingDriven    (  Cfg::getParamBool      ("etesian.routingDriven"  , false      )->asBool())
     , _spaceMargin      (  Cfg::getParamPercentage("etesian.spaceMargin"    ,  5.0)->asDouble() )
     , _densityVariation (  Cfg::getParamPercentage("etesian.densityVariation",  5.0)->asDouble() )
@@ -106,7 +105,6 @@ namespace Etesian {
     , _cg               (NULL)
     , _placeEffort      ( other._placeEffort     )
     , _updateConf       ( other._updateConf      )
-    , _spreadingConf    ( other._spreadingConf   )
     , _spaceMargin      ( other._spaceMargin     )
     , _densityVariation ( other._densityVariation)
     , _aspectRatio      ( other._aspectRatio     )
@@ -140,7 +138,6 @@ namespace Etesian {
     cmess1 << Dots::asIdentifier("     - Cell Gauge"       ,getString(_cg->getName())) << endl;
     cmess1 << Dots::asInt       ("     - Place Effort"     ,_placeEffort             ) << endl;
     cmess1 << Dots::asInt       ("     - Update Conf"      ,_updateConf              ) << endl;
-    cmess1 << Dots::asInt       ("     - Spreading Conf"   ,_spreadingConf           ) << endl;
     cmess1 << Dots::asBool      ("     - Routing driven"   ,_routingDriven           ) << endl;
     cmess1 << Dots::asPercentage("     - Space Margin"     ,_spaceMargin             ) << endl;
     cmess1 << Dots::asPercentage("     - Spread Margin"    ,_densityVariation            ) << endl;
@@ -173,7 +170,6 @@ namespace Etesian {
     record->add ( getSlot( "_cg"                    ,       _cg              ) );
     record->add ( getSlot( "_placeEffort"           ,  (int)_placeEffort     ) );
     record->add ( getSlot( "_updateConf"            ,  (int)_updateConf      ) );
-    record->add ( getSlot( "_spreadingConf"         ,  (int)_spreadingConf   ) );
     record->add ( getSlot( "_spaceMargin"           ,       _spaceMargin     ) );
     record->add ( getSlot( "_densityVariation"      ,       _densityVariation    ) );
     record->add ( getSlot( "_aspectRatio"           ,       _aspectRatio     ) );
diff --git a/etesian/src/etesian/Configuration.h b/etesian/src/etesian/Configuration.h
index e108ed84..1878df44 100644
--- a/etesian/src/etesian/Configuration.h
+++ b/etesian/src/etesian/Configuration.h
@@ -48,9 +48,6 @@ namespace Etesian {
                      , LowerBound=2 
                      , FinalOnly =3 
                      };
-  enum Density       { ForceUniform=1
-                     , MaxDensity  =2
-                     };
 
   class Configuration {
     public:
@@ -63,7 +60,6 @@ namespace Etesian {
       inline CellGauge*       getCellGauge              () const;
       inline Effort           getPlaceEffort            () const;
       inline GraphicUpdate    getUpdateConf             () const;
-      inline Density          getSpreadingConf          () const;
       inline bool             getRoutingDriven          () const;
       inline double           getSpaceMargin            () const;
       inline double           getDensityVariation       () const;
@@ -89,7 +85,6 @@ namespace Etesian {
       CellGauge*     _cg;
       Effort         _placeEffort;
       GraphicUpdate  _updateConf;
-      Density        _spreadingConf;
       bool           _routingDriven;
       double         _spaceMargin;
       double         _densityVariation;
@@ -112,7 +107,6 @@ namespace Etesian {
   inline CellGauge*    Configuration::getCellGauge              () const { return _cg; }
   inline Effort        Configuration::getPlaceEffort            () const { return _placeEffort; }
   inline GraphicUpdate Configuration::getUpdateConf             () const { return _updateConf; }
-  inline Density       Configuration::getSpreadingConf          () const { return _spreadingConf; }
   inline bool          Configuration::getRoutingDriven          () const { return _routingDriven; }
   inline double        Configuration::getSpaceMargin            () const { return _spaceMargin; }
   inline double        Configuration::getDensityVariation       () const { return _densityVariation; }
diff --git a/etesian/src/etesian/EtesianEngine.h b/etesian/src/etesian/EtesianEngine.h
index 32ab930f..307267f7 100644
--- a/etesian/src/etesian/EtesianEngine.h
+++ b/etesian/src/etesian/EtesianEngine.h
@@ -90,7 +90,6 @@ namespace Etesian {
       inline  DbU::Unit               getFixedAbWidth           () const;
       inline  Effort                  getPlaceEffort            () const;
       inline  GraphicUpdate           getUpdateConf             () const;
-      inline  Density                 getSpreadingConf          () const;
       inline  double                  getSpaceMargin            () const;
       inline  double                  getDensityVariation       () const;
       inline  double                  getAspectRatio            () const;
@@ -208,7 +207,6 @@ namespace Etesian {
   inline  DbU::Unit              EtesianEngine::getFixedAbWidth           () const { return _fixedAbWidth; }
   inline  Effort                 EtesianEngine::getPlaceEffort            () const { return getConfiguration()->getPlaceEffort(); }
   inline  GraphicUpdate          EtesianEngine::getUpdateConf             () const { return getConfiguration()->getUpdateConf(); }
-  inline  Density                EtesianEngine::getSpreadingConf          () const { return getConfiguration()->getSpreadingConf(); }
   inline  double                 EtesianEngine::getSpaceMargin            () const { return getConfiguration()->getSpaceMargin(); }
   inline  double                 EtesianEngine::getDensityVariation       () const { return getConfiguration()->getDensityVariation(); }
   inline  double                 EtesianEngine::getAspectRatio            () const { return getConfiguration()->getAspectRatio(); }
diff --git a/unittests/python/test_hurricane.py b/unittests/python/test_hurricane.py
index 1f92ee79..87a9a9a9 100755
--- a/unittests/python/test_hurricane.py
+++ b/unittests/python/test_hurricane.py
@@ -29,7 +29,7 @@ def cfg_setup():
         cfg.etesian.aspectRatio = 1.00
         cfg.etesian.aspectRatio = [10, 1000]
         cfg.etesian.spaceMargin = 0.10
-        cfg.etesian.uniformDensity = False
+        cfg.etesian.densityVariation = 1.0
         cfg.etesian.routingDriven = False
         #cfg.etesian.latchUpDistance = u(30.0 - 1.0)
         cfg.etesian.latchUpDistance = 0