original_docstring: 
          Handles slice RAMB18 FASM feature emission.
          
docstring: Handles slice RAMB18 FASM feature emission.
docstring_tokens: Handles slice RAMB18 FASM feature emission .
code: def handle_brams(self):
          """
          Handles slice RAMB18 FASM feature emission.
          """
  
          # TODO: handle ramb36 as well
  
          init_re = re.compile("INITP?_[0-9][0-9]")
  
          z_features = ["INIT_A", "INIT_B", "SRVAL_A", "SRVAL_B"]
          str_features = [
              "RDADDR_COLLISION_HWCONFIG", "RSTREG_PRIORITY_A",
              "RSTREG_PRIORITY_B", "WRITE_MODE_A", "WRITE_MODE_B"
          ]
          rw_widths = [
              "READ_WIDTH_A", "READ_WIDTH_B", "WRITE_WIDTH_A", "WRITE_WIDTH_B"
          ]
  
          allowed_cell_types = ["RAMB18E1"]
          allowed_site_types = ["RAMB18E1"]
  
          fasm_features = list()
          for cell_instance, cell_data in self.physical_cells_instances.items():
              cell_type = cell_data.cell_type
              if cell_type not in allowed_cell_types:
                  continue
  
              tile_name = cell_data.tile_name
              tile_type = cell_data.tile_type
              site_name = cell_data.site_name
              bram_prefix = self.get_bram_prefix(site_name, tile_type)
  
              is_y1 = "Y1" in bram_prefix
  
              self.add_cell_feature((tile_name, bram_prefix, "IN_USE"))
  
              attributes = cell_data.attributes
  
              ram_mode = attributes["RAM_MODE"]
              for attr, value in attributes.items():
                  init_param = self.device_resources.get_parameter_definition(
                      cell_type, attr)
  
                  init_match = init_re.match(attr)
                  fasm_feature = None
                  if init_match:
                      init_value = init_param.decode_integer(value)
  
                      if init_value == 0:
                          continue
  
                      init_str_value = "{:b}".format(init_value)
                      init_str = "{len}'b{value}".format(
                          len=len(init_str_value), value=init_str_value)
                      fasm_feature = "{}[{}:0]={}".format(
                          attr, len(init_str_value), init_str)
                      fasm_features.append(fasm_feature)
  
                  elif attr in z_features:
                      init_value = init_param.decode_integer(value)
                      width = init_param.width
  
                      init_str_value = "{value:0{width}b}".format(
                          value=init_value, width=width)
  
                      feature_value = invert_bitstring(init_str_value)
  
                      fasm_feature = "Z{}[{}:0]={}'b{}".format(
                          attr, width - 1, width, feature_value)
                      fasm_features.append(fasm_feature)
  
                  elif attr in str_features:
                      fasm_features.append("{}_{}".format(attr, value))
  
                  elif attr in rw_widths:
                      init_value = init_param.decode_integer(value)
  
                      # Handle special INIT value case
                      if is_y1 and init_value == 36 and ram_mode == "SDP" and attr == "READ_WIDTH_A":
                          init_value = 18
  
                      fasm_features.append("{}_{}".format(attr, init_value))
  
                      if init_value == 36 and ram_mode == "SDP":
                          fasm_feature.append("SDP_{}_36".format(attr))
  
              for fasm_feature in fasm_features:
                  self.add_cell_feature((tile_name, bram_prefix, fasm_feature))
  
          for feature in ["ALMOST_EMPTY_OFFSET", "ALMOST_FULL_OFFSET"]:
              value = "1" * 13
              fasm_feature = "Z{}[12:0]=13'b{}".format(feature, value)
              self.add_cell_feature((tile_name, fasm_feature))
code_tokens: def handle_brams ( self ) : init_re = re . compile ( "INITP?_[0-9][0-9]" ) z_features = [ "INIT_A" , "INIT_B" , "SRVAL_A" , "SRVAL_B" ] str_features = [ "RDADDR_COLLISION_HWCONFIG" , "RSTREG_PRIORITY_A" , "RSTREG_PRIORITY_B" , "WRITE_MODE_A" , "WRITE_MODE_B" ] rw_widths = [ "READ_WIDTH_A" , "READ_WIDTH_B" , "WRITE_WIDTH_A" , "WRITE_WIDTH_B" ] allowed_cell_types = [ "RAMB18E1" ] allowed_site_types = [ "RAMB18E1" ] fasm_features = list ( ) for cell_instance , cell_data in self . physical_cells_instances . items ( ) : cell_type = cell_data . cell_type if cell_type not in allowed_cell_types : continue tile_name = cell_data . tile_name tile_type = cell_data . tile_type site_name = cell_data . site_name bram_prefix = self . get_bram_prefix ( site_name , tile_type ) is_y1 = "Y1" in bram_prefix self . add_cell_feature ( ( tile_name , bram_prefix , "IN_USE" ) ) attributes = cell_data . attributes ram_mode = attributes [ "RAM_MODE" ] for attr , value in attributes . items ( ) : init_param = self . device_resources . get_parameter_definition ( cell_type , attr ) init_match = init_re . match ( attr ) fasm_feature = None if init_match : init_value = init_param . decode_integer ( value ) if init_value == 0 : continue init_str_value = "{:b}" . format ( init_value ) init_str = "{len}'b{value}" . format ( len = len ( init_str_value ) , value = init_str_value ) fasm_feature = "{}[{}:0]={}" . format ( attr , len ( init_str_value ) , init_str ) fasm_features . append ( fasm_feature ) elif attr in z_features : init_value = init_param . decode_integer ( value ) width = init_param . width init_str_value = "{value:0{width}b}" . format ( value = init_value , width = width ) feature_value = invert_bitstring ( init_str_value ) fasm_feature = "Z{}[{}:0]={}'b{}" . format ( attr , width - 1 , width , feature_value ) fasm_features . append ( fasm_feature ) elif attr in str_features : fasm_features . append ( "{}_{}" . format ( attr , value ) ) elif attr in rw_widths : init_value = init_param . decode_integer ( value ) if is_y1 and init_value == 36 and ram_mode == "SDP" and attr == "READ_WIDTH_A" : init_value = 18 fasm_features . append ( "{}_{}" . format ( attr , init_value ) ) if init_value == 36 and ram_mode == "SDP" : fasm_feature . append ( "SDP_{}_36" . format ( attr ) ) for fasm_feature in fasm_features : self . add_cell_feature ( ( tile_name , bram_prefix , fasm_feature ) ) for feature in [ "ALMOST_EMPTY_OFFSET" , "ALMOST_FULL_OFFSET" ] : value = "1" * 13 fasm_feature = "Z{}[12:0]=13'b{}" . format ( feature , value ) self . add_cell_feature ( ( tile_name , fasm_feature ) )
short_docstring: Handles slice RAMB18 FASM feature emission.
short_docstring_tokens: Handles slice RAMB18 FASM feature emission .
comment: """
          Handles slice RAMB18 FASM feature emission.
          """$SEP$# TODO: handle ramb36 as well$SEP$# Handle special INIT value case