###############################################################################
#
# Copyright 2020 OpenHW Group
# 
# Licensed under the Solderpad Hardware Licence, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# 
#     https://solderpad.org/licenses/
# 
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# 
###############################################################################
#
# Extensions and customizations to Vmanager UVM filter Perl script for Core-V 
# messages in the custom UVM report server
#
###############################################################################
# -------------------------------------------------------------------------
# File name   : uvm.flt
# Title       : UVM SystemVerilog Class Library Filter for VManager 
# Project     : UVM
# Description : This file contains filters for Incisive Verification Manager,
#               to extract messages printed by the SystemVerilog UVM Class
#               Library.
#
# Notes       : Use this filter file in environments based on the UVM
#               Class Library.
# =============================================================================
# Copyright (c) 2007 Cadence Design Systems, Inc. All rights reserved worldwide.
# Please refer to the terms and conditions in $IPCM_HOME.
# =============================================================================



## Seed handling

add_filter ("SV-Seed", 2,
            '^SVSEED.*?:\s+(-?)([0-9]+)\n',
            'sv_seed: \"$1$2\" ; '
           );


## Detect signature miscompare
add_filter ("compliance signature miscompare", 4,
	    '^\s*\.\.\. MISCOMPARE!',
	    failure (1,'compliance','signature miscompare','error', 'RISCV Compliance signature miscompare')
	   );


## OVM and UVM Message filtering

add_filter ("uvm_svcb_dut_critical", 4,
	    '\*{3} (OVM|UVM): DUT fatal at time (\d+).*?\n\S?\s*Checked at (.+?)\n(.+?)\n(.+?)\n',
	    failure (1,'$1','dut_error','critical','$5','$2','$3', '')
	   );

add_filter ("uvm_svcb_dut_error", 4,
	    '\*{3} (OVM|UVM): DUT error at time (\d+).*?\n\S?\s*Checked at (.+?)\n(.+?)\n(.+?)\n',
	    failure (1,'$1','dut_error','error','$5','$2','$3', '')
	   );

add_filter ("uvm_svcb_dut_warning", 2,
	    '\*{3} (OVM|UVM): DUT warning at time (\d+).*?\n\S?\s*Checked at (.+?)\n(.+?)\n(.+?)\n',
	    failure (1,'$1','dut_error','warning','$5','$2','$3', '')
	   );


add_filter ("uvm_critical", 4,
            '(OVM|UVM)_FATAL\s@\s(\d+)(?:\.\d+)?(?:.*?:)?\s*([^\n]*?)\s*([^\s]*?)\s+(?:\[(.+?)\])?\s+(.+?)\n',
            failure (1,'$1','$5','critical','$6','$2','$4','$3')
           );


add_filter ("uvm_error", 4,
            '(OVM|UVM)_ERROR\s@\s(\d+)(?:\.\d+)?(?:.*?:)?\s*([^\n]*?)\s*([^\s]*?)\s+(?:\[(.+?)\])?\s+(.+?)\n',
            failure (1,'$1','$5','error','$6','$2','$4','$3')
           );


add_filter ("uvm_warning_error", 2,
            '(OVM|UVM)_WARNING\s@\s(\d+)(?:\.\d+)?(?:.*?:)?\s*([^\n]*?)\s*([^\s]*?)\s+(?:\[(.+?)\])?\s+(.+?)\n',
            failure (1,'$1','$5','warning','$6','$2','$4','$3')
    	   );


add_generic_failure_filter ("uvm_critical_general",
            '(OVM|UVM)_FATAL@\s*(\d+)(?:\.\d+)?(?:.*?:)?\s*([^\n]*?)\s*(.+?)\n',
            failure (1,'$1','','critical','$4','$2','','$3')
           );


add_generic_failure_filter ("uvm_error_general",
            '(OVM|UVM)_ERROR@\s*(\d+)(?:\.\d+)?(?:.*?:)?\s*([^\n]*?)\s*(.+?)\n',
            failure (1,'$1','','error','$4','$2','','$3')
           );


add_generic_failure_filter ("uvm_warning_general",
            '(OVM|UVM)_WARNING@\s*(\d+)(?:\.\d+)?(?:.*?:)?\s*([^\n]*?)\s*(.+?)\n',
            failure (1,'$1','','warning','$4','$2','','$3')
           );

