1/* Copyright (c) 2012 Massachusetts Institute of Technology
2 *
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
9 *
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
12 *
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 * THE SOFTWARE.
20 */
21
22#ifndef __DSENT_MODEL_STD_CELLS_CELLMACROS_H__
23#define __DSENT_MODEL_STD_CELLS_CELLMACROS_H__
24
25#include "util/CommonType.h"
26#include "model/std_cells/StdCell.h"
27
28namespace DSENT
29{
30    class StdCell;
31
32    // Contains cell macros that can be created within standard cells
33    class CellMacros
34    {
35        private :
36            CellMacros();
37            ~CellMacros();
38
39        public:
40            //NOR2 Macro
41            //Adds a NOR2 to the standard cell, normalized to some size
42            static void addNor2(StdCell* cell_, const String& name_, bool sizable_, bool a1_to_zn_path_, bool a2_to_zn_path_,
43                                const String& a1_net_, const String& a2_net_, const String& zn_net_);
44            //Updates a NOR2 to to the standard cell, normalized to some size
45            static void updateNor2(StdCell* cell_, const String& name_, double normalized_size_);
46
47            //NAND2 Macro
48            //Adds a NAND2 to the standard cell, normalized to some size
49            static void addNand2(StdCell* cell_, const String& name_, bool sizable_, bool a1_to_zn_path_, bool a2_to_zn_path_,
50                                const String& a1_net_, const String& a2_net_, const String& zn_net_);
51            //Updates a NAND2 to to the standard cell, normalized to some size
52            static void updateNand2(StdCell* cell_, const String& name_, double normalized_size_);
53
54            //INVERTER Macro
55            //Adds a inverter to the standard cell, normalized to some size
56            static void addInverter(StdCell* cell_, const String& name_, bool sizable_, bool a_to_zn_path_,
57                                    const String& a_net_, const String& zn_net_);
58            //Updates an inverter to to the standard cell, normalized to some size
59            static void updateInverter(StdCell* cell_, const String& name_, double normalized_size_);
60
61            //INVZ Macro
62            //Adds a tristated inverter to the standard cell, normalized to some size
63            static void addTristate(StdCell* cell_, const String& name_, bool sizable_, bool a_to_zn_path_, bool oe_to_zn_path_, bool oen_to_zn_path_,
64                                    const String& a_net_, const String& oe_net_, const String& oen_net_, const String& zn_net_);
65            //Updates an tristated inverter to to the standard cell, normalized to some size
66            static void updateTristate(StdCell* cell_, const String& name_, double normalized_size_);
67
68            //Helper functions
69            //Returns the width of NMOS transistors, given the NMOS and PMOS stacking
70            static double calculateNmosWidth(const StdCell* cell_, unsigned int max_stacked_nmos_, unsigned int max_stacked_pmos_, unsigned int current_stack_nmos_);
71            //Returns the width of PMOS transistors, given the NMOS and PMOS stacking
72            static double calculatePmosWidth(const StdCell* cell_, unsigned int max_stacked_nmos_, unsigned int max_stacked_pmos_, unsigned int current_stack_pmos_);
73
74    }; // class CellMacros
75} // namespace DSENT
76
77#endif // __DSENT_MODEL_STD_CELLS_CELLMACROS_H__
78
79