forked from johan92/fpga-hash-table
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathht_scoreboard.sv
78 lines (61 loc) · 2.16 KB
/
ht_scoreboard.sv
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//-----------------------------------------------------------------------------
// Project : fpga-hash-table
//-----------------------------------------------------------------------------
// Author : Ivan Shevchuk (github/johan92)
//-----------------------------------------------------------------------------
// Description:
// Little scoreboard for hashtable:
// it get commands and dut results, and execute this command on
// hash table reference model. if result is not the same - error
// will be displayed.
//-----------------------------------------------------------------------------
`ifndef _HT_SCOREBOARD_
`define _HT_SCOREBOARD_
class ht_scoreboard;
mailbox #( ht_command_t ) drv2scb;
mailbox #( ht_result_t ) mon2scb;
ref_hash_table ref_ht;
function new( input mailbox #( ht_command_t ) _drv2scb,
mailbox #( ht_result_t ) _mon2scb );
this.drv2scb = _drv2scb;
this.mon2scb = _mon2scb;
this.ref_ht = new( 2**TABLE_ADDR_WIDTH );
endfunction
task run( );
ht_command_t to_dut;
ht_result_t from_dut;
forever
begin
mon2scb.get( from_dut );
drv2scb.get( to_dut );
check( to_dut, from_dut );
end
endtask
function void check( input ht_command_t c, ht_result_t r );
ht_result_t ref_res;
if( r.cmd != c )
begin
$error("DUT command in result don't match (maybe lost some command or reordering...?)");
return;
end
ref_res = ref_ht.do_command( c );
case( c.opcode )
OP_SEARCH:
begin
if( ( ref_res.rescode != r.rescode ) ||
( ref_res.found_value != r.found_value ) )
begin
$error("Did not in %s: key = 0x%x REF: %s found = 0x%x, DUT: %s found = 0x%x", c.opcode, c.key, ref_res.rescode, ref_res.found_value, r.rescode, r.found_value );
end
end
OP_INSERT, OP_DELETE:
begin
if( ref_res.rescode != r.rescode )
begin
$error("Did not in %s REF: %s, DUT: %s", c.opcode, ref_res.rescode, r.rescode );
end
end
endcase
endfunction
endclass
`endif