##
## Constants.py
##      - class that defines basic constants of the application
##

# $Id: Constants.py,v 1.12 2007/01/18 07:15:10 jarda Exp $


# class Constants() {{{
class Constants(object):
    # DOC {{{
    """Class that defines basic constants of the application.
    """
    # }}}


    # STATIC VARIABLES {{{
    # special values {{{
    BA_NOT_FOUND              = "#####BENCHMARK#ATTRIBUTE#NOT#FOUND#####"
    BA_UNSUPPORTED            = "#####BENCHMAR#ATTRIBUTE#NOT#SUPPORTED#####"
    BA_NOT_YET_IMPLEMENTED    = "#####BENCHMARK#ATTRIBUTE#NOT#YET#IMPLEMENTED#####"
    BA_AMBIGUOUS_VALUE        = "#####BENCHMARK#ATTRIBUTE#AMBIGUOUS#VALUE#####"
    # }}}

    # unsuccessful benchmark attribute values {{{
    UNSUCCESSFUL_BA_VALUES = {
        BA_NOT_FOUND              : 1,
        BA_UNSUPPORTED            : 1,
        BA_NOT_YET_IMPLEMENTED    : 1,
        BA_AMBIGUOUS_VALUE        : 1,
    }
    # }}}

    # human readable representations of the special values {{{
    HUMAN_READABLE_REPRESENTATION = {
        BA_NOT_FOUND              : '*Not found*',
        BA_UNSUPPORTED            : '*Benchmark attribute unsupported*',
        BA_NOT_YET_IMPLEMENTED    : '*Benchmark attribute is not supported yet*',
        BA_AMBIGUOUS_VALUE        : '*Ambiguous value of the benchmark attribute*',
    }
    # }}}

    # benchmark attributes {{{
    BA_BUF_COUNT             = 3
    BA_NOT_COUNT             = 4
    BA_AND_COUNT             = 5
    BA_OR_COUNT              = 6
    BA_XOR_COUNT             = 7
    BA_XNOR_COUNT            = 8
    BA_NAND_COUNT            = 9
    BA_NOR_COUNT             = 10
    BA_GENERAL_GATES_COUNT   = 11
    BA_GATES_COUNT           = 20
    BA_DFF_COUNT             = 30
    BA_INPUTS_COUNT          = 100
    BA_OUTPUTS_COUNT         = 101
    BA_TERMS_COUNT           = 102
    BA_STATES_COUNT          = 103
    BA_RESET_STATE           = 104
    BA_TRANSITIONS_COUNT     = 105
    # }}}

    # supported benchmark attributes {{{
    SUPPORTED_BENCHMARK_ATTRIBUTES = {
        BA_INPUTS_COUNT          : 1,
        BA_OUTPUTS_COUNT         : 1,
        BA_BUF_COUNT             : 1,
        BA_NOT_COUNT             : 1,
        BA_AND_COUNT             : 1,
        BA_OR_COUNT              : 1,
        BA_XOR_COUNT             : 1,
        BA_XNOR_COUNT            : 1,
        BA_NAND_COUNT            : 1,
        BA_NOR_COUNT             : 1,
        BA_GENERAL_GATES_COUNT   : 1,
        BA_GATES_COUNT           : 1,
        BA_DFF_COUNT             : 1,
        BA_TERMS_COUNT           : 1,
        BA_STATES_COUNT          : 1,
        BA_RESET_STATE           : 1,
        BA_TRANSITIONS_COUNT     : 1,
    }
    # }}}

    # gates count benchmark attributes {{{
    GATES_COUNT_BENCHMARK_ATTRIBUTES = {
        BA_BUF_COUNT             : 1,
        BA_NOT_COUNT             : 1,
        BA_AND_COUNT             : 1,
        BA_OR_COUNT              : 1,
        BA_XOR_COUNT             : 1,
        BA_XNOR_COUNT            : 1,
        BA_NAND_COUNT            : 1,
        BA_NOR_COUNT             : 1,
        BA_GENERAL_GATES_COUNT   : 1,
    }
    # }}}

    # benchmark attributes for internal use only {{{
    INTERNAL_BENCHMARK_ATTRIBUTES = {
        BA_GENERAL_GATES_COUNT   : 1,
    }
    # }}}
        
    # calculated flag {{{
    IS_BA_CALCULATED = {
        BA_INPUTS_COUNT          : False,
        BA_OUTPUTS_COUNT         : False,
        BA_BUF_COUNT             : False,
        BA_NOT_COUNT             : False,
        BA_AND_COUNT             : False,
        BA_OR_COUNT              : False,
        BA_XOR_COUNT             : False,
        BA_XNOR_COUNT            : False,
        BA_NAND_COUNT            : False,
        BA_NOR_COUNT             : False,
        BA_GENERAL_GATES_COUNT   : False,
        BA_GATES_COUNT           : True,
        BA_DFF_COUNT             : False,
        BA_TERMS_COUNT           : False,
        BA_STATES_COUNT          : False,
        BA_RESET_STATE           : False,
        BA_TRANSITIONS_COUNT     : False,
    }
    # }}}

    # internal benchmark attribute names {{{
    INTERNAL_BA_NAME = {
        BA_INPUTS_COUNT          : 'INPUTS_COUNT',
        BA_OUTPUTS_COUNT         : 'OUTPUTS_COUNT',
        BA_BUF_COUNT             : 'BUF_GATES_COUNT',
        BA_NOT_COUNT             : 'NOT_GATES_COUNT',
        BA_AND_COUNT             : 'AND_GATES_COUNT',
        BA_OR_COUNT              : 'OR_GATES_COUNT',
        BA_XOR_COUNT             : 'XOR_GATES_COUNT',
        BA_XNOR_COUNT            : 'XNOR_GATES_COUNT',
        BA_NAND_COUNT            : 'NAND_GATES_COUNT',
        BA_NOR_COUNT             : 'NOR_GATES_COUNT',
        BA_GENERAL_GATES_COUNT   : 'GENERAL_GATES_COUNT',
        BA_GATES_COUNT           : 'GATES_COUNT',
        BA_DFF_COUNT             : 'DFF_COUNT',
        BA_TERMS_COUNT           : 'TERMS_COUNT',
        BA_STATES_COUNT          : 'STATES_COUNT',
        BA_RESET_STATE           : 'RESET_STATE',
        BA_TRANSITIONS_COUNT     : 'TRANSITIONS_COUNT',
    }
    # }}}

    # readable benchmark attribute names {{{
    READABLE_BA_NAME = {
        BA_INPUTS_COUNT          : 'Inputs count',
        BA_OUTPUTS_COUNT         : 'Outputs count',
        BA_BUF_COUNT             : 'BUF count',
        BA_NOT_COUNT             : 'NOT count',
        BA_AND_COUNT             : 'AND count',
        BA_OR_COUNT              : 'OR count',
        BA_XOR_COUNT             : 'XOR count',
        BA_XNOR_COUNT            : 'XNOR count',
        BA_NAND_COUNT            : 'NAND count',
        BA_NOR_COUNT             : 'NOR count',
        BA_GENERAL_GATES_COUNT   : 'General gates count',
        BA_GATES_COUNT           : 'Gates count',
        BA_DFF_COUNT             : 'DFF count',
        BA_TERMS_COUNT           : 'Terms count',
        BA_STATES_COUNT          : 'States count',
        BA_RESET_STATE           : 'Reset state',
        BA_TRANSITIONS_COUNT     : 'Transitions count',
    }
    # }}}
    
    # magic method, class and module names prefixes {{{
    GET_INITIAL_ATTRIBUTE_VALUE_PREFIX  = 'getInitialAttributeValue_'
    ACCUMULATE_LINE_PREFIX              = 'accumulateLine_'
    CALCULATE_ATTRIBUTE_DATA_PREFIX     = 'calculateAttributeData_'
    BENCHMARK_FILE_PARSER_MODULE_PREFIX = 'BenchmarkFileParser_'
    BENCHMARK_FILE_PARSER_CLASS_PREFIX  = 'BenchmarkFileParser_'
    # }}}

    # benchmark formats {{{
    BF_BENCH    = 1
    BF_KISS2    = 2
    BF_PLA      = 3
    BF_SLIF     = 4
    BF_BLIF     = 5
    # }}}

    # internal benchmark format names {{{
    INTERNAL_BENCHMARK_FORMAT_NAME = {
        BF_BENCH    : 'BENCH',
        BF_KISS2    : 'KISS2',
        BF_PLA      : 'PLA',
        BF_SLIF     : 'SLIF',
        BF_BLIF     : 'BLIF',
    }
    # }}}

    # mapping of extensions to benchmark formats {{{
    EXT_TO_BENCHMARK_FORMAT = {
        'bench' : BF_BENCH,
        'slif'  : BF_SLIF,
        'pla'   : BF_PLA,
        'kiss2' : BF_KISS2,
        'blif'  : BF_BLIF,
    }
    # }}}
    # }}}


# }}}
