示例#1
0
    def on_new(self):
        '''|
        | Command new creates a new module project from a .json file located in MPATH.
        | The json file must have the same name as the directory in which it is located.
        | If directory and/or .json file do not exist, this function creates the directory
        | and a default .json file (containing only Reset and Clock interfaces).
        |________'''
        self.check_path_and_create_json( self.full_name )

        gdf = MFDesign()
        gdf.initialize( self.full_name )
        gdf.generate(gdf.module_name + ' (top)')

        if gdf.modules != []:
            sub_modules = gdf.init_submodules()

            print_dotty_file(gdf)

            if sub_modules != []:
                sub_path = gdf.c_path + "/src/modules/"
                os.mkdir(sub_path)
                StrBuilder().write(sub_path + '__init__.py', overwrite=True)
                for m in sub_modules:
                    m.c_path = sub_path + m.module_name
                    m.generate(m.module_name + ' (sub-module)')
                    print_json_file(m)        
示例#2
0
    def on_add(self):
        '''|
        | Command 'add' adds an interface to the .json file and updates the HW module design files
        |________'''
        interface_type = self.arguments[0]
        
        gdf = MFDesign()
        gdf.initialize( self.full_name )

        found = self.check_name( gdf, self.opt_Name )

        if found:
            err("Can not add - interface with the same name exists: " + self.opt_Name)
            exit(0)

        if interface_type == 'HSD':
            gdf.interfaces.append({'push': self.opt_Push, 'direction': self.opt_Direction, 'data': self.opt_Data, 'type': interface_type, 'name': self.opt_Name})

        elif interface_type == 'Bus':
            gdf.interfaces.append({'interfaces': self.opt_BusType, 'type': interface_type, 'name': self.opt_Name})

        elif interface_type == 'Parameter':
            gdf.parameters.append({'value': self.opt_ParValue, 'name': self.opt_Name})

        elif interface_type == 'STAvln':
            gdf.interfaces.append({'direction': self.opt_Direction, 'width': self.opt_Data, 'type': interface_type, 'name': self.opt_Name})

        else: # this should not happen
            err("Unknown type: " + interface_type)
            exit(0)
            
        gdf.overwrite = True
        print_json_file( gdf )

        gdf.update( self.full_name )
示例#3
0
    def on_new(self):
        '''|
        | Command new creates a new module project from a .json file located in MPATH.
        | The json file must have the same name as the directory in which it is located.
        | If directory and/or .json file do not exist, this function creates the directory
        | and a default .json file (containing only Reset and Clock interfaces).
        |________'''
        self.check_path_and_create_json(self.full_name)

        gdf = MFDesign()
        gdf.initialize(self.full_name)
        gdf.generate(gdf.module_name + ' (top)')

        if gdf.modules != []:
            sub_modules = gdf.init_submodules()

            print_dotty_file(gdf)

            if sub_modules != []:
                sub_path = gdf.c_path + "/src/modules/"
                os.mkdir(sub_path)
                StrBuilder().write(sub_path + '__init__.py', overwrite=True)
                for m in sub_modules:
                    m.c_path = sub_path + m.module_name
                    m.generate(m.module_name + ' (sub-module)')
                    print_json_file(m)
示例#4
0
    def on_remove(self):
        '''|
        | Command 'remove' removes an interface from the .json file and updates the HW module design files
        |________'''
        interface_name = self.arguments[0]

        gdf = MFDesign()
        gdf.initialize(self.full_name)

        found = self.check_name(gdf, interface_name)

        if not found:
            err("Name not found: " + interface_name)
            exit(0)

        # Remove Interface
        gdf.interfaces[:] = [
            value for value in gdf.interfaces
            if value["name"] != interface_name
        ]
        # Remove Parameter
        gdf.parameters[:] = [
            value for value in gdf.parameters
            if value["name"] != interface_name
        ]

        gdf.overwrite = True
        print_json_file(gdf)

        gdf.update(self.full_name)
示例#5
0
    def on_add(self):
        '''|
        | Command 'add' adds an interface to the .json file and updates the HW module design files
        |________'''
        interface_type = self.arguments[0]

        gdf = MFDesign()
        gdf.initialize(self.full_name)

        found = self.check_name(gdf, self.opt_Name)

        if found:
            err("Can not add - interface with the same name exists: " +
                self.opt_Name)
            exit(0)

        if interface_type == 'HSD':
            gdf.interfaces.append({
                'push': self.opt_Push,
                'direction': self.opt_Direction,
                'data': self.opt_Data,
                'type': interface_type,
                'name': self.opt_Name
            })

        elif interface_type == 'Bus':
            gdf.interfaces.append({
                'interfaces': self.opt_BusType,
                'type': interface_type,
                'name': self.opt_Name
            })

        elif interface_type == 'Parameter':
            gdf.parameters.append({
                'value': self.opt_ParValue,
                'name': self.opt_Name
            })

        elif interface_type == 'STAvln':
            gdf.interfaces.append({
                'direction': self.opt_Direction,
                'width': self.opt_Data,
                'type': interface_type,
                'name': self.opt_Name
            })

        else:  # this should not happen
            err("Unknown type: " + interface_type)
            exit(0)

        gdf.overwrite = True
        print_json_file(gdf)

        gdf.update(self.full_name)
示例#6
0
    def on_remove(self):
        '''|
        | Command 'remove' removes an interface from the .json file and updates the HW module design files
        |________'''
        interface_name = self.arguments[0]

        gdf = MFDesign()
        gdf.initialize( self.full_name )

        found = self.check_name( gdf, interface_name )

        if not found:
            err("Name not found: " + interface_name)
            exit(0)

        # Remove Interface
        gdf.interfaces[:] = [value for value in gdf.interfaces if value["name"] != interface_name]
        # Remove Parameter
        gdf.parameters[:] = [value for value in gdf.parameters if value["name"] != interface_name]

        gdf.overwrite = True
        print_json_file( gdf )

        gdf.update( self.full_name )