# DpgenNmux2

- Name : DpgenNmux2 - Multiplexer Macro-Generator
- Synopsys :

      Generate ( 'DpgenNmux2', modelname
               , param = { 'nbit'       : n
                         , 'physical'   : True
                         , 'behavioral' : True
                         }
               )

- Description : Generates a `n` bits two inputs multiplexer named `modelname`.
- Terminal Names :
  - cmd : select ( 1 bit )
  - i0 : input ( `n` bits )
  - i1 : input ( `n` bits )
  - nq : output ( `n` bits )
  - vdd : power
  - vss : ground
- Parameters : Parameters are given in the map `param`.
  - nbit (mandatory) : Defines the size of the generator
  - physical (optional, default value : False) : In order to generate a layout
  - behavioral (optional, default value : False) : In order to generate a behavior
- Behavior :

      nq <= WITH cmd SELECT not i0 WHEN '0',
                            not i1 WHEN '1';

- Example :

      from stratus import *

      class inst_nmux2 ( Model ) :

        def Interface ( self ) :
          self.in1 = SignalIn  (  "in1", 5 )
          self.in2 = SignalIn  (  "in2", 5 )
          self.cmd = SignalIn  (  "cmd", 1 )
          self.o   = SignalOut (    "o", 5 )

          self.vdd = VddIn ( "vdd" )
          self.vss = VssIn ( "vss" )

        def Netlist ( self ) :
          Generate ( 'DpgenNmux2', 'nmux2_5'
                   , param = { 'nbit'     : 5
                             , 'physical' : True
                             }
                   )
          self.I = Inst ( 'nmux2_5', 'inst'
                        , map = { 'i0'  : self.in1
                                , 'i1'  : self.in2
                                , 'cmd' : self.cmd
                                , 'nq'  : self.o
                                , 'vdd' : self.vdd
                                , 'vss' : self.vss
                                }
                        )

        def Layout ( self ) :
          Place ( self.I, NOSYM, Ref(0, 0) )