1 // -*- mode: C++; c-file-style: "cc-mode" -*-
2 //=============================================================================
3 //
4 // Code available from: https://verilator.org
5 //
6 // Copyright 2001-2021 by Wilson Snyder. This program is free software; you
7 // can redistribute it and/or modify it under the terms of either the GNU
8 // Lesser General Public License Version 3 or the Perl Artistic License
9 // Version 2.0.
10 // SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0
11 //
12 //=============================================================================
13 ///
14 /// \file
15 /// \brief Verilated coverage item keys internal header
16 ///
17 /// This file is not part of the Verilated public-facing API.
18 /// It is only for internal use by the Verilated library coverage routines.
19 ///
20 //=============================================================================
21 
22 #ifndef VERILATOR_VERILATED_COV_KEY_H_
23 #define VERILATOR_VERILATED_COV_KEY_H_
24 
25 #include "verilatedos.h"
26 
27 #include <string>
28 
29 //=============================================================================
30 // Data used to edit below file, using vlcovgen
31 
32 #define VLCOVGEN_ITEM(string_parsed_by_vlcovgen)
33 
34 // clang-format off
35 VLCOVGEN_ITEM("'name':'column',      'short':'n',  'group':1, 'default':0,    'descr':'Column number for the item.  Used to disambiguate multiple coverage points on the same line number'")
36 VLCOVGEN_ITEM("'name':'filename',    'short':'f',  'group':1, 'default':None, 'descr':'Filename of the item'")
37 VLCOVGEN_ITEM("'name':'linescov',    'short':'S',  'group':1, 'default':'',   'descr':'List of comma-separated lines covered'")
38 VLCOVGEN_ITEM("'name':'per_instance','short':'P',  'group':1, 'default':0,    'descr':'True if every hierarchy is independently counted; otherwise all hierarchies will be combined into a single count'")
39 VLCOVGEN_ITEM("'name':'thresh',      'short':'s',  'group':1, 'default':None, 'descr':'Number of hits to consider covered (aka at_least)'")
40 VLCOVGEN_ITEM("'name':'type',        'short':'t',  'group':1, 'default':'',   'descr':'Type of coverage (block, line, fsm, etc)'")
41 // Bin attributes
42 VLCOVGEN_ITEM("'name':'comment',     'short':'o',  'group':0, 'default':'',   'descr':'Textual description for the item'")
43 VLCOVGEN_ITEM("'name':'hier',        'short':'h',  'group':0, 'default':'',   'descr':'Hierarchy path name for the item'")
44 VLCOVGEN_ITEM("'name':'lineno',      'short':'l',  'group':0, 'default':0,    'descr':'Line number for the item'")
45 VLCOVGEN_ITEM("'name':'weight',      'short':'w',  'group':0, 'default':None, 'descr':'For totaling items, weight of this item'")
46 // clang-format on
47 
48 // VLCOVGEN_CIK_AUTO_EDIT_BEGIN
49 #define VL_CIK_COLUMN "n"
50 #define VL_CIK_COMMENT "o"
51 #define VL_CIK_FILENAME "f"
52 #define VL_CIK_HIER "h"
53 #define VL_CIK_LINENO "l"
54 #define VL_CIK_LINESCOV "S"
55 #define VL_CIK_PER_INSTANCE "P"
56 #define VL_CIK_THRESH "s"
57 #define VL_CIK_TYPE "t"
58 #define VL_CIK_WEIGHT "w"
59 // VLCOVGEN_CIK_AUTO_EDIT_END
60 
61 //=============================================================================
62 // VerilatedCovKey
63 // Namespace-style static class for \internal use.
64 
65 class VerilatedCovKey final {
66 public:
67     // Return the short key code for a given a long coverage key
shortKey(const std::string & key)68     static std::string shortKey(const std::string& key) VL_PURE {
69         // VLCOVGEN_SHORT_AUTO_EDIT_BEGIN
70         if (key == "column") return VL_CIK_COLUMN;
71         if (key == "comment") return VL_CIK_COMMENT;
72         if (key == "filename") return VL_CIK_FILENAME;
73         if (key == "hier") return VL_CIK_HIER;
74         if (key == "lineno") return VL_CIK_LINENO;
75         if (key == "linescov") return VL_CIK_LINESCOV;
76         if (key == "per_instance") return VL_CIK_PER_INSTANCE;
77         if (key == "thresh") return VL_CIK_THRESH;
78         if (key == "type") return VL_CIK_TYPE;
79         if (key == "weight") return VL_CIK_WEIGHT;
80         // VLCOVGEN_SHORT_AUTO_EDIT_END
81         return key;
82     }
83 };
84 
85 #endif  // guard
86