SyoSil ApS UVM Scoreboard  1.0.3.0
cl_syoscb_hash_base.svh
1 /// Class which defines the base concept of a hash algorithm.
2 /// All hash functions must extend this class and implement the hash API.
3 /// \param HASH_DIGEST_WIDTH The number of bits in the hash digest for that hashing algorithm
4 class cl_syoscb_hash_base #(int unsigned HASH_DIGEST_WIDTH = 1) extends uvm_object;
5 
6  /// Typedef for a bitstream of HASH_DIGEST_WIDTH bits
7  typedef bit [HASH_DIGEST_WIDTH-1:0] tp_hash_digest;
8 
9  //-------------------------------------
10  // Non randomizable variables
11  //-------------------------------------
12  /// Handle to the configuration object
13  protected cl_syoscb_cfg cfg;
14  /// Handle to a packer suited for this hash algorithm
15  /// The packer should be set in the implementing class' constructor
17 
18  //-------------------------------------
19  // UVM Macros
20  //-------------------------------------
21  `uvm_object_param_utils_begin(cl_syoscb_hash_base#(HASH_DIGEST_WIDTH))
22  `uvm_field_object(cfg, UVM_DEFAULT | UVM_REFERENCE)
23  `uvm_object_utils_end
24 
25  //-------------------------------------
26  // Constructor
27  //-------------------------------------
28  function new(string name = "cl_syoscb_hash_base");
29  super.new(name);
30  endfunction: new
31 
32  //-------------------------------------
33  // UVM Phase methods
34  //-------------------------------------
35 
36  //-------------------------------------
37  // Hash API
38  //-------------------------------------
39  // User-facing functions
40  extern virtual function tp_hash_digest hash(cl_syoscb_item item);
41  extern virtual function tp_hash_digest hash_str(string str);
42 
43  // Internal hash functions
44  extern protected virtual function tp_hash_digest do_hash(bit ser []);
45 
46 
47 
48 endclass: cl_syoscb_hash_base
49 
50 /// <b>Hash API:</b> Returns the hash value of the given bitstream. The bitstream must comply with the
51 /// chosen hash algorithm's requirements.
52 /// \param ser The bitstream to generate the hash for
53 /// \return The hash of the input bitstream
55  `uvm_fatal("IMPL_ERROR", $sformatf("[%s]: cl_syoscb_hash_base::do_hash() *MUST* be overwritten", this.cfg.get_scb_name()))
56  return 'bx;
57 endfunction: do_hash
58 
59 /// <b> Hash API:</b> Hashes a string, returning its hash value
60 /// \param str The string to hash
61 /// \return The hash value of that string
63  bit ser [];
64  tp_hash_digest out;
65 
66  this.packer.pack_string(str);
67 
68  `ifdef UVM_VERSION //Use UVM-IEEE API
69  packer.get_packed_bits(ser);
70  `else
71  packer.get_bits(ser);
72  `endif
73 
74  out=this.do_hash(ser);
75  this.packer.clean();
76 
77  return out;
78 endfunction: hash_str
79 
80 /// <b> Hash API:</b> Hashes a cl_syoscb_item, returning its hash value
81 /// \param item The item to hash
82 /// \return The hash value of that string
84  bit ser [];
85  tp_hash_digest out;
86 
87  void'(item.pack(ser, this.packer));
88  out=this.do_hash(ser);
89  this.packer.clean();
90 
91  return out;
92 endfunction: hash
virtual tp_hash_digest hash_str(string str)
Hash API: Hashes a string, returning its hash value
virtual tp_hash_digest hash(cl_syoscb_item item)
Hash API: Hashes a cl_syoscb_item, returning its hash value
bit< HASH_DIGEST_WIDTH-1:0 > tp_hash_digest
Typedef for a bitstream of HASH_DIGEST_WIDTH bits.
The UVM scoreboard item which wraps uvm_sequence_item .
A base class for packers which should be used with hash algorithms in the scoreboard.
cl_syoscb_hash_packer packer
Handle to a packer suited for this hash algorithm.
Class which defines the base concept of a hash algorithm.
virtual tp_hash_digest do_hash(bit ser [])
Hash API: Returns the hash value of the given bitstream.
Configuration class for the SyoSil UVM scoreboard.
virtual string get_scb_name()
Configuration API: Get the name of the SCB that this cfg is related to
cl_syoscb_cfg cfg
Handle to the configuration object.

Project: SyoSil ApS UVM Scoreboard, Revision: 1.0.3.0

Copyright 2014-2022 SyoSil ApS
All Rights Reserved Worldwide

Licensed under the Apache License, 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

http://www.apache.org/licenses/LICENSE-2.0

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.
doxygen
Doxygen Version: 1.8.14
Generated with IDV SV Filter Version: 2.6.3
Fri Sep 2 2022 14:39:14
Find a documentation bug? Report bugs to: scoreboard@syosil.com