SyoSil ApS UVM Scoreboard  1.0.3.0
cl_scb_test_md5.svh
1 /// Test which verifies that the md5 hash implementation works correctly
2 class cl_scb_test_md5 extends cl_scb_test_single_scb;
3  //-------------------------------------
4  // Non randomizable variables
5  //-------------------------------------
6 
7 
8  //-------------------------------------
9  // UVM Macros
10  //-------------------------------------
11  `uvm_component_utils_begin(cl_scb_test_md5)
12 
13  `uvm_component_utils_end
14 
15  //-------------------------------------
16  // Constructor
17  //-------------------------------------
18  function new(string name = "cl_scb_test_md5", uvm_component parent = null);
19  super.new(name, parent);
20  endfunction: new
21 
22  //-------------------------------------
23  // Functions
24  //-------------------------------------
25  extern function void pre_build();
26  extern task main_phase(uvm_phase phase);
27 
28 
29 endclass: cl_scb_test_md5
30 
31 function void cl_scb_test_md5::pre_build();
32  super.pre_build();
33 
34  this.syoscb_cfgs.syoscb_cfg[0].set_enable_no_insert_check(1'b0);
35 endfunction: pre_build
36 
37 task cl_scb_test_md5::main_phase(uvm_phase phase);
40  string strings[$];
41  string hashes[$];
42 
43  phase.raise_objection(this);
44  super.main_phase(phase);
45 
46  strings.push_back("Hello, world");
47  strings.push_back("This is a super duper long string that takes up a lot of space and exceeds the 512-byte boundary");
48  strings.push_back("The quick brown fox jumps over the lazy dog");
49  strings.push_back("1234567890");
50 
51  //Reference hashes generated with https://www.md5hashgenerator.com/
52  hashes.push_back("bc6e6f16b8a077ef5fbc8d59d0b931b9");
53  hashes.push_back("8eeaea9d3bac8c8b59aad5b9009129a3");
54  hashes.push_back("9e107d9d372bb6826bd81d3542a419d6");
55  hashes.push_back("e807f1fcf82d132f9bb018ca6738a19f");
56 
57  md5 = new;
58  foreach(strings[i]) begin
59  string hash;
60  digest = md5.hash_str(strings[i]);
61  hash = $sformatf("%0x", digest);
62  if(hash != hashes[i]) begin
63  `uvm_error("HASH_MD5", $sformatf(
64  {"MD5 hash of string\n%0s\ndid not match expected value.\n",
65  "Expected :%0s\b",
66  "Got hash :%0s"}, strings[i], hashes[i], hash))
67  end
68  end
69 
70  phase.drop_objection(this);
71 endtask: main_phase
bit< HASH_DIGEST_WIDTH-1:0 > tp_hash_digest
Typedef for a bitstream of HASH_DIGEST_WIDTH bits.
Test which verifies that the md5 hash implementation works correctly.
MD5 hash algorithm implementation.

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:37:46
Find a documentation bug? Report bugs to: scoreboard@syosil.com