<commit_before>#! /usr/bin/python
# -*- coding: utf-8 -*-
#-----------------------------------------------------------------------------
# Name:     SynthesisCli.py
# Purpose:
# Author:   <NAME> <<EMAIL>>
# Created:  30/05/2008
#-----------------------------------------------------------------------------
#  Copyright (2008)  Armadeus Systems
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#-----------------------------------------------------------------------------
# Revision list :
#
# Date       By        Changes
#
#-----------------------------------------------------------------------------

__doc__ = ""
__version__ = "1.0.0"
__versionTime__ = "30/05/2008"
__author__ = "<NAME> <<EMAIL>>"

from periphondemand.bin.define                     import *

from periphondemand.bin.utils.settings             import Settings
from periphondemand.bin.utils.basecli              import BaseCli
from periphondemand.bin.utils.error                import Error
from periphondemand.bin.utils.display              import Display
from periphondemand.bin.utils import wrappersystem as sy

from periphondemand.bin.toolchain.synthesis        import Synthesis

settings = Settings()
display  = Display()

class SynthesisCli(BaseCli):
    """
    """

    def __init__(self,parent):
        BaseCli.__init__(self,parent)

    def complete_selecttoolchain(self,text,line,begidx,endidx):
        toolchainlist = []
        try:
            toolchainlist = self.completeargs(text,line,"[synthesistoolchain]")
        except Exception,e:
            print e
        return toolchainlist

    def do_selecttoolchain(self,line):
        """\
Usage : selecttoolchain [synthesistoolchain]
select toolchain used for simulation
        """
        try:
            self.checkargs(line,"[synthesistoolchain]")
        except Error,e:
            print e
            return

        if line.strip() == "":
            if len(settings.active_project.getSynthesisToolChainList())==1:
                settings.active_project.setSynthesisToolChain(
                    settings.active_project.getSynthesisToolChainList()[0])
            else:
                if settings.active_project.getSynthesisToolChain() == None:
                    print "Choose a toolchain\n"
                    for toolchain in \
                            settings.active_project.getSynthesisToolChainList():
                        print toolchain
                    return
        else:
            try:
                settings.active_project.setSynthesisToolChain(line)
            except Error,e:
                print e
                return

    def complete_generateproject(self,text,line,begidx,endidx):
        toollist = []
        try:
            toollist = self.completeargs(text,line,"[synthesistoolchain]")
        except Exception,e:
            print e
        return toollist

    def do_generateproject(self,line):
        """\
Usage : generateproject [synthesistoolchain]
generate the project for synthesis tool
        """
        try:
            self.checkargs(line,"[synthesistoolchain]")
        except Error,e:
            print e
            return
        # select toolchain
        if line.strip() != "":
            try:
                self.do_selecttoolchain(line)
            except Error,e:
                print e
                return
        elif settings.active_project.synthesis== None:
            print Error("Toolchain must be selected before")
            return

        # generate project
        try:
            settings.active_project.synthesis.generateProject()
            print display
            pinoutfile = settings.active_project.synthesis.generatePinout(None)
            print display
            tclname = settings.active_project.synthesis.generateTCL(None)
        except Error,e:
            print e
            return
        print display

    def do_generatetcl(self,line):
        """\
Usage : generatetcl [filename]
Made a tcl script for synthesis,tools supported are:
ise
        """

        if settings.active_project.synthesis == None:
            print Error("Select toolchain before")
            return
        if line.strip() != "":
            filename = settings.path + TOOLCHAINPATH+\
                    SYNTHESISPATH+"/"+line.strip()
        else:
            filename = None
        try:
            settings.active_project.synthesis.generateTCL(filename)
        except Error,e:
            print e
            return
        print display

    def do_generatepinout(self,line):
        """\
Usage : generatepinout [filename]
generate ucf file, tool supported are :
ise
        """
        if settings.active_project.synthesis == None:
            print Error("Select toolchain before")
            return
        if line.strip() != "":
            filename = settings.path + TOOLCHAINPATH+SYNTHESISPATH+"/"+line.strip()
        else:
            filename = None
        try:
            settings.active_project.synthesis.generatePinout(filename)
        except Error,e:
            print e
            return
        print display

    def do_generatebitstream(self,line):
        """\
Usage : generatebitstream
generate the bitstream for fpga configuration
        """
        if settings.active_project.synthesis == None:
            print Error("Select toolchain before")
            return
        try:
            settings.active_project.synthesis.generateBitStream()
        except Error,e:
            print e
            return
        print display

    def complete_setiostandard(self, text, line, begidx, endidx):
        IOlist = []
        try:
            IOlist = self.completeargs(text, line, "<IO_name>")
        except Exception, e:
            print e
        return IOlist

    def do_setiostandard(self, line):
        """\
Usage : setIOstandard <IO_name> <standard_value>
set IO standard value
        """
        try:
            self.checkargs(line,"<IO_name> <standard_value>")
        except Exception, e:
            print display
            print e
            return
        arg = line.split(' ')
        io_name = arg[0]
        standard_value = arg[1]
        try:
            print settings.active_project.getIO(io_name).setStandard(standard_value)
        except Error, e:
            print display
            print e
            return

    def complete_getiostandard(self, text, line, begidx, endidx):
        IOlist = []
        try:
            IOlist = self.completeargs(text, line, "<IO_name>")
        except Exception, e:
            print e
        return IOlist


    def do_getiostandard(self, line):
        """\
Usage : getIOstandard <IO_name>
get IO standard value
        """
        try:
            self.checkargs(line,"<IO_name>")
        except Exception, e:
            print display
            print e
            return
        arg = line.split(' ')
        io_name = arg[0]
        try:
            print settings.active_project.getIO(io_name).getStandard()
        except Error, e:
            print display
            print e
            return
        print display

    def do_setfpga(self, line):
        """\
Usage : setfpga <attribute_name> <attribute_value>
Set fpga attribute
        """
        print "TODO"

    def do_getfpga(self, line):
        """\
Usage : getfpga
get fpga attributes values
        """
        print "TODO"
<commit_msg>[synthesiscli] adding setiodrive and getiodrive commands<commit_after>#! /usr/bin/python
# -*- coding: utf-8 -*-
#-----------------------------------------------------------------------------
# Name:     SynthesisCli.py
# Purpose:
# Author:   <NAME> <<EMAIL>>
# Created:  30/05/2008
#-----------------------------------------------------------------------------
#  Copyright (2008)  Armadeus Systems
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
#-----------------------------------------------------------------------------
# Revision list :
#
# Date       By        Changes
#
#-----------------------------------------------------------------------------

__doc__ = ""
__version__ = "1.0.0"
__versionTime__ = "30/05/2008"
__author__ = "<NAME> <<EMAIL>>"

from periphondemand.bin.define                     import *

from periphondemand.bin.utils.settings             import Settings
from periphondemand.bin.utils.basecli              import BaseCli
from periphondemand.bin.utils.error                import Error
from periphondemand.bin.utils.display              import Display
from periphondemand.bin.utils import wrappersystem as sy

from periphondemand.bin.toolchain.synthesis        import Synthesis

settings = Settings()
display  = Display()

class SynthesisCli(BaseCli):
    """
    """

    def __init__(self,parent):
        BaseCli.__init__(self,parent)

    def complete_selecttoolchain(self,text,line,begidx,endidx):
        toolchainlist = []
        try:
            toolchainlist = self.completeargs(text,line,"[synthesistoolchain]")
        except Exception,e:
            print e
        return toolchainlist

    def do_selecttoolchain(self,line):
        """\
Usage : selecttoolchain [synthesistoolchain]
select toolchain used for simulation
        """
        try:
            self.checkargs(line,"[synthesistoolchain]")
        except Error,e:
            print e
            return

        if line.strip() == "":
            if len(settings.active_project.getSynthesisToolChainList())==1:
                settings.active_project.setSynthesisToolChain(
                    settings.active_project.getSynthesisToolChainList()[0])
            else:
                if settings.active_project.getSynthesisToolChain() == None:
                    print "Choose a toolchain\n"
                    for toolchain in \
                            settings.active_project.getSynthesisToolChainList():
                        print toolchain
                    return
        else:
            try:
                settings.active_project.setSynthesisToolChain(line)
            except Error,e:
                print e
                return

    def complete_generateproject(self,text,line,begidx,endidx):
        toollist = []
        try:
            toollist = self.completeargs(text,line,"[synthesistoolchain]")
        except Exception,e:
            print e
        return toollist

    def do_generateproject(self,line):
        """\
Usage : generateproject [synthesistoolchain]
generate the project for synthesis tool
        """
        try:
            self.checkargs(line,"[synthesistoolchain]")
        except Error,e:
            print e
            return
        # select toolchain
        if line.strip() != "":
            try:
                self.do_selecttoolchain(line)
            except Error,e:
                print e
                return
        elif settings.active_project.synthesis== None:
            print Error("Toolchain must be selected before")
            return

        # generate project
        try:
            settings.active_project.synthesis.generateProject()
            print display
            pinoutfile = settings.active_project.synthesis.generatePinout(None)
            print display
            tclname = settings.active_project.synthesis.generateTCL(None)
        except Error,e:
            print e
            return
        print display

    def do_generatetcl(self,line):
        """\
Usage : generatetcl [filename]
Made a tcl script for synthesis,tools supported are:
ise
        """

        if settings.active_project.synthesis == None:
            print Error("Select toolchain before")
            return
        if line.strip() != "":
            filename = settings.path + TOOLCHAINPATH+\
                    SYNTHESISPATH+"/"+line.strip()
        else:
            filename = None
        try:
            settings.active_project.synthesis.generateTCL(filename)
        except Error,e:
            print e
            return
        print display

    def do_generatepinout(self,line):
        """\
Usage : generatepinout [filename]
generate ucf file, tool supported are :
ise
        """
        if settings.active_project.synthesis == None:
            print Error("Select toolchain before")
            return
        if line.strip() != "":
            filename = settings.path + TOOLCHAINPATH+SYNTHESISPATH+"/"+line.strip()
        else:
            filename = None
        try:
            settings.active_project.synthesis.generatePinout(filename)
        except Error,e:
            print e
            return
        print display

    def do_generatebitstream(self,line):
        """\
Usage : generatebitstream
generate the bitstream for fpga configuration
        """
        if settings.active_project.synthesis == None:
            print Error("Select toolchain before")
            return
        try:
            settings.active_project.synthesis.generateBitStream()
        except Error,e:
            print e
            return
        print display

    def complete_setiostandard(self, text, line, begidx, endidx):
        IOlist = []
        try:
            IOlist = self.completeargs(text, line, "<IO_name>")
        except Exception, e:
            print e
        return IOlist

    def do_setiostandard(self, line):
        """\
Usage : setiostandard <IO_name> <standard_value>
set IO standard value
        """
        try:
            self.checkargs(line,"<IO_name> <standard_value>")
        except Exception, e:
            print display
            print e
            return
        arg = line.split(' ')
        io_name = arg[0]
        standard_value = arg[1]
        try:
            settings.active_project.getIO(io_name).setStandard(standard_value)
        except Error, e:
            print display
            print e
            return

    def complete_getiostandard(self, text, line, begidx, endidx):
        IOlist = []
        try:
            IOlist = self.completeargs(text, line, "<IO_name>")
        except Exception, e:
            print e
        return IOlist


    def do_getiostandard(self, line):
        """\
Usage : getiostandard <IO_name>
get IO standard value
        """
        try:
            self.checkargs(line,"<IO_name>")
        except Exception, e:
            print display
            print e
            return
        arg = line.split(' ')
        io_name = arg[0]
        try:
            print settings.active_project.getIO(io_name).getStandard()
        except Error, e:
            print display
            print e
            return
        print display

    def complete_setiodrive(self, text, line, begidx, endidx):
        IOlist = []
        try:
            IOlist = self.completeargs(text, line, "<IO_name>")
        except Exception, e:
            print e
        return IOlist

    def do_setiodrive(self, line):
        """\
Usage : setiodrive <IO_name> <drive_value>
set IO drive value
        """
        try:
            self.checkargs(line,"<IO_name> <drive_value>")
        except Exception, e:
            print display
            print e
            return
        arg = line.split(' ')
        io_name = arg[0]
        drive_value = arg[1]
        try:
            settings.active_project.getIO(io_name).setDrive(drive_value)
        except Error, e:
            print display
            print e
            return

    def complete_getiodrive(self, text, line, begidx, endidx):
        IOlist = []
        try:
            IOlist = self.completeargs(text, line, "<IO_name>")
        except Exception, e:
            print e
        return IOlist


    def do_getiodrive(self, line):
        """\
Usage : getiodrive <IO_name>
get IO drive value
        """
        try:
            self.checkargs(line,"<IO_name>")
        except Exception, e:
            print display
            print e
            return
        arg = line.split(' ')
        io_name = arg[0]
        try:
            print settings.active_project.getIO(io_name).getDrive()
        except Error, e:
            print display
            print e
            return
        print display


    def do_setfpga(self, line):
        """\
Usage : setfpga <attribute_name> <attribute_value>
Set fpga attribute
        """
        print "TODO"

    def do_getfpga(self, line):
        """\
Usage : getfpga
get fpga attributes values
        """
        print "TODO"

{'fraction_non_alphanumeric': 0.11755673093328783, 'fraction_numerical': 0.005175453563100722, 'mean_word_length': 1.6800792562109435, 'pattern_counts': {'":': 8, '<': 43, '<?xml version=': 0, '>': 43, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2119730', 'n_tokens_mistral': 4720, 'n_tokens_neox': 4523, 'n_words': 1215}