# DpgenRom4
Keywords: dpgen

- Name : DpgenRom4 - 4 words ROM Macro-Generator
- Synopsys :

      Generate ( 'DpgenRom4', modelname
               , param = { 'nbit'     : n
                         , 'val0'     : constVal0
                         , 'val1'     : constVal1
                         , 'val2'     : constVal2
                         , 'val3'     : constVal3
                         , 'physical' : True
                         }
               )

- Description : Generates a `n` bits 4 words optimized ROM named `modelname`.
- Terminal Names :
  - sel1 : upper bit of the address of the value (input, 1 bit)
  - sel0 : lower bit of the 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
  - val2 (mandatory) : Defines the third word
  - val3 (mandatory) : Defines the fourth word
  - physical (optional, default value : False) : In order to generate a layout
- Behavior :

      q <= WITH sel1 & sel0 SELECT constVal0  WHEN B"00",
                                   constVal1  WHEN B"01",
                                   constVal2  WHEN B"10",
                                   constVal3  WHEN B"11";

- Example :

      from stratus import *

      class inst_rom4 ( Model ) :

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

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

        def Netlist ( self ) :
          Generate ( 'DpgenRom4', 'rom4_0b1010_0b1100_0b1111_0b0001'
                   , param = { 'nbit'     : 4
                             , 'val0'     : "0b1010"
                             , 'val1'     : "0b1100"
                             , 'val2'     : "0b1111"
                             , 'val3'     : "0b0001"
                             , 'physical' : True
                             }
                   )
          self.I = Inst ( 'rom4_0b1010_0b1100_0b1111_0b0001', 'inst'
                        , map = { 'sel0' : self.sel0
                                , 'sel1' : self.sel1
                                , 'q'    : self.q
                                , 'vdd'  : self.vdd
                                , 'vss'  : self.vss
                                }
                        )

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