Esempio n. 1
0
def get_clark_s(ruleset, stride):
    """
        Generate number of LUTs and FFs for strided Clark's approach with char 
        classes.
    """
    # Create clark_nfa object
    cn = clark_nfa.clark_nfa(False, stride)
    # Create parser - use default parser
    Test0 = parser.parser("pcre_parser")
    # Load RE file
    Test0.load_file(ruleset)
    # Parse RE and create NFA
    cn.create_by_parser(Test0)
    # Call the compute method
    cn.compute()
    # Get number of used LUTs and FFs
    data = cn.report_logic()
    return ["Clark with stride ", stride, data[0], data[1]]
Esempio n. 2
0
def get_clark_s(ruleset, stride):
    """
        Generate number of LUTs and FFs for strided Clark's approach with char 
        classes.
    """
    # Create clark_nfa object
    cn = clark_nfa.clark_nfa(False, stride)
    # Create parser - use default parser
    Test0 = parser.parser("pcre_parser")
    # Load RE file
    Test0.load_file(ruleset)
    # Parse RE and create NFA
    cn.create_by_parser(Test0)
    # Call the compute method
    cn.compute()
    # Get number of used LUTs and FFs
    data = cn.report_logic()
    return ["Clark with stride ", stride, data[0], data[1]]
Esempio n. 3
0
 def test_strided(self):
     """
         Tests the algorithm with stride = 2.
     """
     # Get test directory
     tdir = aux_func.getPatternMatchDir() + "/algorithms/clark_nfa/test/"
     # Create clark_nfa object
     cn = clark_nfa.clark_nfa(False, 2)
     # Create parser - use default parser
     Test0 = parser.parser("pcre_parser")
     # Load RE file
     Test0.load_file(tdir + "tests/test.pcre")
     # Parse RE and create NFA
     cn.create_by_parser(Test0)
     # Call the compute method
     cn.compute()
     # Create the simulation
     create_simulation(cn)
     # run the simulation
     run_simulation(self)
Esempio n. 4
0
    # Clark mapping method without support for char classes

    for ruleset in rulesets:
        for stride in strides:

            ruleset_filename = rulesets_prefix + ruleset + rulesets_suffix
            # remove any non-alphanumeric character
            ruleset_abc = re.sub('[\W_]', '', ruleset)

            print('Generating (%s,%d)...' % (ruleset_filename, stride))

            start = time.time()

            # Create clark_nfa object
            cn = clark_nfa.clark_nfa(True, stride)
            # Create parser - use default parser
            Test0 = parser.parser("pcre_parser")
            # Load RE file
            Test0.load_file(ruleset_filename)
            # Parse RE and create NFA
            cn.create_by_parser(Test0)
            # Call the compute method
            cn.compute()
            # Get number of used LUTs and FFs
            logic = cn.report_logic()

            stop = time.time()

            report.write('%s %d %d %d %d %d %d %d %f\n' %
                         (ruleset_abc, stride, logic[0], logic[1], logic[2],
Esempio n. 5
0
"""
    This module demonstrate usage of clark_nfa class in various settings.
"""

if __name__ == '__main__':
    # Clark mapping method without suppotr for char classes
    print("-------------------------------------------------------------------")
    print("                     Example of use: Clark NFA                     ")
    print("-------------------------------------------------------------------")
    print(" Ruleset: ../../rules/L7/selected.pcre                             ")
    print(" Character Classes: No                                             ")
    print(" Strided: No                                                       ")
    print(" Genereated VHDL output: clark_nfa_impl_wochc.vhd                  ")
    print("-------------------------------------------------------------------")
    # Create clark_nfa object
    cn = clark_nfa.clark_nfa(True)
    # Create parser - use default parser
    Test0 = parser.parser("pcre_parser")
    # Load RE file
    Test0.load_file("../../rules/L7/selected.pcre")
    # Parse RE and create NFA
    cn.create_by_parser(Test0)
    # Call the compute method
    cn.compute()
    # Get number of used LUTs and FFs
    data = cn.report_logic()
    print(" Used LUTs estimation: " + str(data[0]))
    print(" Used FFs estimation: " + str(data[1]))
    print("-------------------------------------------------------------------")
    # Save implementation
    # Open file
    # Clark mapping method without support for char classes

    for ruleset in rulesets:
        for stride in strides:

            ruleset_filename = rulesets_prefix + ruleset + rulesets_suffix
            # remove any non-alphanumeric character
            ruleset_abc = re.sub('[\W_]', '', ruleset)

            print('Generating (%s,%d)...' % (ruleset_filename, stride))

            start = time.time()

            # Create clark_nfa object
            cn = clark_nfa.clark_nfa(True, stride)
            # Create parser - use default parser
            Test0 = parser.parser("pcre_parser")
            # Load RE file
            Test0.load_file(ruleset_filename)
            # Parse RE and create NFA
            cn.create_by_parser(Test0)
            # Call the compute method
            cn.compute()
            # Get number of used LUTs and FFs
            logic = cn.report_logic()

            stop = time.time()

            #report.write('%s %d %d %d %d %d %d %d %f\n' % (ruleset_abc,
Esempio n. 7
0
 print(
     "                     Example of use: Clark NFA                     ")
 print(
     "-------------------------------------------------------------------")
 print(
     " Ruleset: ../../rules/L7/selected.pcre                             ")
 print(
     " Character Classes: No                                             ")
 print(
     " Strided: No                                                       ")
 print(
     " Genereated VHDL output: clark_nfa_impl_wochc.vhd                  ")
 print(
     "-------------------------------------------------------------------")
 # Create clark_nfa object
 cn = clark_nfa.clark_nfa(True)
 # Create parser - use default parser
 Test0 = parser.parser("pcre_parser")
 # Load RE file
 Test0.load_file("../../rules/L7/selected.pcre")
 # Parse RE and create NFA
 cn.create_by_parser(Test0)
 # Call the compute method
 cn.compute()
 # Get number of used LUTs and FFs
 data = cn.report_logic()
 print(" Used LUTs estimation: " + str(data[0]))
 print(" Used FFs estimation: " + str(data[1]))
 print(
     "-------------------------------------------------------------------")
 # Save implementation