Esempio n. 1
0
 def _write_uvm(self, o):
     """
     Writes the UVM path name(s) for the register as a table
     in restructuredText format.
     """
     o.write("\n\n")
     o.write("UVM names\n")
     o.write("---------\n")
     o.write(".. list-table::\n")
     o.write("   :header-rows: 1\n")
     if self._bootstrap:
         o.write("   :class: table table-bordered table-striped table-condensed\n\n")
     else:
         o.write("   :class: summary\n\n")
     o.write("   * - ID\n")
     o.write("     - UVM name\n")
     for inst in in_groups(self._regset_name, self._prj):
         if self._group and inst.group != self._group:
             continue
         if self._inst and inst.inst != self._inst:
             continue
         if inst.repeat == 1:
             self._display_uvm_entry(inst, -1, o)
         else:
             for i in range(0, inst.repeat):
                 self._display_uvm_entry(inst, i, o)
     o.write("\n\n")
Esempio n. 2
0
    def _write_defines(self, o):

        addr_maps = self._prj.get_address_maps()
        if not addr_maps:
            return

        o.write("\n\nAddresses\n---------\n")
        if not in_groups(self._regset_name, self._prj):
            o.write(".. WARNING::\n   Register set was not added to any groups\n\n")
        else:
            o.write(".. list-table::\n")
            o.write("   :header-rows: 1\n")
            o.write("   :class: summary\n\n")
            o.write("   * - ID\n")
            o.write("     - Offset\n")
            for amap in addr_maps:
                o.write("     - %s\n" % self.text(amap.name))
            for inst in in_groups(self._regset_name, self._prj):
                if inst.repeat == 1:
                    name = full_token(inst.group, inst.inst, self._reg.token,
                                      self._regset_name, -1, inst.format)
                    o.write("   * - ``%s``\n" % self.text(name))
                    o.write("     - ``%s``\n" % reg_addr(self._reg, 0))
                    for map_name in addr_maps:
                        map_base = self._prj.get_address_base(map_name.name)
                        offset = map_base + inst.offset + inst.base
                        o.write("     - ``%s``\n" % reg_addr(self._reg, offset))
                else:
                    for i in range(0, inst.repeat):
                        name = full_token(inst.group, inst.inst, self._reg.token,
                                          self._regset_name, i, inst.format)
                        o.write("   * - ``%s``\n" % self.text(name))
                        o.write("     - ``%s``\n" % reg_addr(self._reg, 0))
                        for map_name in addr_maps:
                            base = self._prj.get_address_base(map_name.name)
                            offset = inst.base + inst.offset + (i * inst.roffset)
                            o.write("     - ``%s``\n" % reg_addr(self._reg,
                                                                 offset + base))
        o.write("\n\n")
Esempio n. 3
0
def find_addresses(project, regset_name, register, offset_only=True):

    address_list = []
    found_groups = in_groups(regset_name, project)

    x_addr_maps = project.get_address_maps()
    addr_maps = set([])
    
    for inst in found_groups:
        for x in x_addr_maps:
            groups_in_addr_map = project.get_address_map_groups(x.name)
            if inst.group in groups_in_addr_map:
                addr_maps.add(x)

    for inst in found_groups:
        
        for grp_inst in range(0, inst.grpt):
            if inst.repeat == 1 and not inst.array:
                if offset_only:
                    offset = inst.offset + inst.base + (
                        grp_inst * inst.grpt_offset)
                    address_list.append(_reg_addr(register, offset))
                else:
                    for map_name in addr_maps:
                        map_base = project.get_address_base(map_name.name)
                        offset = map_base + inst.offset + inst.base + (
                            grp_inst * inst.grpt_offset)
                        address_list.append(_reg_addr(register, offset))
            else:
                for i in range(0, inst.repeat):
                    if offset_only:
                        offset = inst.base + inst.offset + (
                            i * inst.roffset
                            ) + (grp_inst * inst.grpt_offset)
                        address_list.append(_reg_addr(register, offset))
                    else:
                        for map_name in addr_maps:
                            base = project.get_address_base(map_name.name)
                            offset = inst.base + inst.offset + (
                                i * inst.roffset
                                ) + (grp_inst * inst.grpt_offset)
                            address_list.append(_reg_addr(register, offset + base))
    return address_list
Esempio n. 4
0
 def _write_uvm(self, o):
     """
     Writes the UVM path name(s) for the register as a table
     in restructuredText format.
     """
     o.write("\n\n")
     o.write("UVM names\n")
     o.write("---------\n")
     o.write(".. list-table::\n")
     o.write("   :header-rows: 1\n")
     o.write("   :class: summary\n\n")
     o.write("   * - ID\n")
     o.write("     - UVM name\n")
     for inst in in_groups(self._regset_name, self._prj):
         if inst.repeat == 1:
             self._display_uvm_entry(inst, -1, o)
         else:
             for i in range(0, inst.repeat):
                 self._display_uvm_entry(inst, i, o)
     o.write("\n\n")
Esempio n. 5
0
    def _write_defines(self, o, use_uvm=True, use_id=True):

        x_addr_maps = self._prj.get_address_maps()
        instances = in_groups(self._regset_name, self._prj)
        addr_maps = set([])

        for inst in instances:
            for x in x_addr_maps:
                groups_in_addr_map = self._prj.get_address_map_groups(x.name)
                if inst.group in groups_in_addr_map:
                    addr_maps.add(x)

        if not addr_maps:
            return

        o.write("\n\nAddresses\n+++++++++++++++++++++++\n\n")
        if not in_groups(self._regset_name, self._prj):
            o.write(
                ".. WARNING::\n   Register set was not added to any groups\n\n")
        else:
            o.write(".. list-table::\n")
            o.write("   :header-rows: 1\n")
            if len(addr_maps) == 1:
                o.write("   :widths: 50, 50\n")
            elif len(addr_maps) == 2:
                o.write("   :widths: 50, 25, 25\n")
            elif len(addr_maps) == 3:
                o.write("   :widths: 50, 16, 16, 17\n")
            o.write("   :class: summary\n\n")
            o.write("   *")
            if use_uvm:
                o.write(" - Register Name\n")
            if use_id:
                if use_uvm:
                    o.write("    ")
                o.write(" - ID\n")
            for amap in addr_maps:
                o.write("     - %s\n" % self.text(amap.name))
            for inst in in_groups(self._regset_name, self._prj):
                if self._group and inst.group != self._group:
                    continue
                if self._inst and inst.inst != self._inst:
                    continue

                for grp_inst in range(0, inst.grpt):
                    if inst.grpt == 1:
                        u_grp_name = inst.group
                        t_grp_name = inst.group
                    else:
                        u_grp_name = "{0}[{1}]".format(inst.group, grp_inst)
                        t_grp_name = "{0}{1}".format(inst.group, grp_inst)

                    if inst.repeat == 1 and not inst.array:
                        o.write("   *")
                        if use_uvm:
                            name = uvm_name(u_grp_name, self._reg.token,
                                            inst.inst, -1)
                            o.write(" - %s\n" % self.text(name))
                        if use_id:
                            name = full_token(t_grp_name, self._reg.token,
                                              inst.inst, -1, inst.format)
                            if use_uvm:
                                o.write("    ")
                            o.write(" - %s\n" % self.text(name))
                        for map_name in addr_maps:
                            map_base = self._prj.get_address_base(map_name.name)
                            offset = map_base + inst.offset + inst.base + (
                                grp_inst * inst.grpt_offset)
                            o.write("     - %s\n" % reg_addr(self._reg, offset))
                    else:
                        for i in range(0, inst.repeat):
                            o.write("   *")
                            if use_uvm:
                                name = uvm_name(u_grp_name, self._reg.token,
                                                inst.inst, i)
                                o.write(" - %s\n" % self.text(name))
                            if use_id:
                                name = full_token(t_grp_name, self._reg.token,
                                                  inst.inst, i, inst.format)
                                if use_uvm:
                                    o.write("    ")
                                o.write(" - %s\n" % self.text(name))
                            for map_name in addr_maps:
                                base = self._prj.get_address_base(map_name.name)
                                offset = inst.base + inst.offset + (
                                    i * inst.roffset
                                ) + (grp_inst * inst.grpt_offset)
                                o.write("     - %s\n" %
                                        reg_addr(self._reg, offset + base))

        o.write("\n\n")
Esempio n. 6
0
    def str_defines(self, o=None, use_uvm=True, use_id=True):

        ret_str = False
        
        if o is None:
            o = StringIO()
            ret_str = True
    
        x_addr_maps = self._prj.get_address_maps()
        instances = in_groups(self._regset_name, self._prj)
        addr_maps = set([])

        for inst in instances:
            for x in x_addr_maps:
                groups_in_addr_map = self._prj.get_address_map_groups(x.name)
                if inst.group in groups_in_addr_map:
                    addr_maps.add(x)

        if len(addr_maps) == 0:
            o.write(".. warning::\n")
            o.write("   :class: alert alert-warning\n\n")
            o.write("   This register has not been mapped into any address space.\n\n")

        elif in_groups(self._regset_name, self._prj):
            o.write(".. list-table::\n")
            o.write("   :header-rows: 1\n")
            if len(addr_maps) == 1:
                o.write("   :widths: 50, 50\n")
            elif len(addr_maps) == 2:
                o.write("   :widths: 50, 25, 25\n")
            elif len(addr_maps) == 3:
                o.write("   :widths: 50, 16, 16, 17\n")
            if self._bootstrap:
                o.write("   :class: table table-bordered table-striped table-condensed\n\n")
            else:
                o.write("   :class: summary\n\n")
            o.write("   *")
            if use_uvm:
                o.write(" - Register Name\n")
            if use_id:
                if use_uvm:
                    o.write("    ")
                o.write(" - ID\n")
            for amap in addr_maps:
                o.write("     - %s\n" % amap.name)

            for inst in in_groups(self._regset_name, self._prj):
                if self._group and inst.group != self._group:
                    continue
                if self._inst and inst.inst != self._inst:
                    continue

                for grp_inst in range(0, inst.grpt):

                    found_addr = True
                    if inst.repeat == 1 and not inst.array:
                        if self._reg.dimension <= 1:
                            self._addr_entry(o, inst, use_uvm, use_id,
                                             addr_maps, grp_inst, -1, -1)
                        else:
                            for i in range(self._reg.dimension):
                                self._addr_entry(o, inst, use_uvm, use_id, 
                                                 addr_maps, grp_inst, -1, i)
                    else:
                        for gi in range(0, inst.repeat):

                            if self._reg.dimension <= 1:
                                self._addr_entry(o, inst, use_uvm, use_id, 
                                                 addr_maps, grp_inst, gi, -1)
                            else:
                                for i in range(self._reg.dimension):
                                    self._addr_entry(o, inst, use_uvm, use_id,
                                                     addr_maps, grp_inst, gi, i)
                
            o.write("\n\n")

        if ret_str:
            return o.getvalue()