# DpgenRom2

- Name : DpgenRom2 - 2 words ROM Macro-Generator
- Synopsys :

      Generate ( 'DpgenRom2', modelname
               , param = { 'nbit'     : n
                         , 'val0'     : constVal0
                         , 'val1'     : constVal1
                         , 'physical' : True
                         }
               )

- Description : Generates a `n` bits 2 words optimized ROM named `modelname`.
- Terminal Names :
  - sel0 : address of the value (input, 1 bit)
  - q : the selected word (output, `n` bits)
  - vdd : power
  - vss : ground
- Parameters : Parameters are given in the map `param`.
  - nbit (mandatory) : Defines the size of the generator
  - val0 (mandatory) : Defines the first word
  - val1 (mandatory) : Defines the second word
  - physical (optional, default value : False) : In order to generate a layout
- Behavior :

      q <= WITH sel0 SELECT
           constVal0  WHEN B"0",
           constVal1  WHEN B"1";

- Example :

      from stratus import *

      class inst_rom2 ( Model ) :

        def Interface ( self ) :
          self.sel0 = SignalIn  (    "sel0", 1 )
          self.q    = SignalOut ( "dataout", 4 )

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

        def Netlist ( self ) :
          Generate ( 'DpgenRom2', 'rom2_0b1010_0b1100'
                   , param = { 'nbit'     : 4
                             , 'val0'     : "0b1010"
                             , 'val1'     : "0b1100"
                             , 'physical' : True
                             }
                   )
          self.I = Inst ( 'rom2_0b1010_0b1100', 'inst'
                        , map = { 'sel0' : self.sel0
                                , 'q'    : self.q
                                , 'vdd'  : self.vdd
                                , 'vss'  : self.vss
                                }
                        )

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