OpenCores
URL https://opencores.org/ocsvn/uart2bus_testbench/uart2bus_testbench/trunk

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [analysis/] [uart_scoreboard.svh] - Blame information for rev 5

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 HanySalah
//-------------------------------------------------------------------------------------------------
2 2 HanySalah
//
3 3 HanySalah
//                                                           UART2BUS VERIFICATION
4 2 HanySalah
//
5 3 HanySalah
//-------------------------------------------------------------------------------------------------
6 2 HanySalah
// CREATOR    : HANY SALAH
7
// PROJECT    : UART2BUS UVM TEST BENCH
8
// UNIT       : ANALYSIS
9 3 HanySalah
//-------------------------------------------------------------------------------------------------
10
// TITLE      : UART SCOREBOARD
11
// DESCRIPTION: SCOREBOARD IS RESPONSIBLE FOR DOING COMPARISONS BETWEEN THE TRANSACTION CREATED IN
12
//                                                      THE SEQUENCE AND THE TRANSACTION CAPTURED BY THE MONITOR.
13
//-------------------------------------------------------------------------------------------------
14 2 HanySalah
// LOG DETAILS
15
//-------------
16
// VERSION      NAME        DATE        DESCRIPTION
17
//    1       HANY SALAH    22012016    FILE CREATION
18 3 HanySalah
//              2                       HANY SALAH              28012016                ADD BINARY COMMAND CHECKING
19
//              3                               HANY SALAH              18022016                IMPROVE BLOCK DESCRIPTION & ADD COMMENTS
20
//-------------------------------------------------------------------------------------------------
21
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR OPENCORES MEMBERS
22
// ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE CREATOR'S PERMISSION
23
//-------------------------------------------------------------------------------------------------
24
 
25 2 HanySalah
class uart_scoreboard extends uvm_scoreboard;
26
 
27 3 HanySalah
        // TLM fifo which buffers the trasaction captured by the monitor.
28 2 HanySalah
        uvm_tlm_analysis_fifo #(uart_transaction)       mon_fifo;
29
 
30 3 HanySalah
        // TLM port connected to the monitor.
31 2 HanySalah
        uvm_analysis_export #(uart_transaction) scbd_mon;
32
 
33 3 HanySalah
        // TLM fifo which buffers the trasaction drived from the driver.
34 2 HanySalah
        uvm_tlm_analysis_fifo #(uart_transaction) drv_fifo;
35
 
36 3 HanySalah
        // TLM port connected to the driver.
37 2 HanySalah
        uvm_analysis_export #(uart_transaction) scbd_drv;
38
 
39
        uart_transaction                        frm_drv,frm_drv_tmp;
40
 
41
        uart_transaction                        frm_mon,frm_mon_tmp;
42
 
43
        `uvm_component_utils(uart_scoreboard)
44
 
45
        function new (string name , uvm_component parent);
46
                super.new(name,parent);
47
        endfunction:new
48
 
49
        extern function void build_phase (uvm_phase phase);
50
 
51
        extern function void connect_phase (uvm_phase phase);
52
 
53
        extern task run_phase (uvm_phase phase);
54 3 HanySalah
 
55
        extern function void ack_checker ();
56 2 HanySalah
endclass:uart_scoreboard
57
 
58
 
59
function void uart_scoreboard::build_phase (uvm_phase phase);
60
        super.build_phase(phase);
61
 
62
        frm_drv                 = uart_transaction::type_id::create("frm_drv");
63
        frm_drv_tmp     = uart_transaction::type_id::create("frm_drv_tmp");
64
 
65
        frm_mon                 = uart_transaction::type_id::create("frm_mon");
66
        frm_mon_tmp = uart_transaction::type_id::create("frm_mon_tmp");
67
 
68
        mon_fifo = new ("mon_fifo",this);
69
        scbd_mon = new ("scbd_mon",this);
70
 
71
        drv_fifo = new ("drv_fifo",this);
72
        scbd_drv = new ("scbd_drv",this);
73
 
74
endfunction:build_phase
75
 
76
function void uart_scoreboard::connect_phase (uvm_phase phase);
77
        scbd_mon.connect(mon_fifo.analysis_export);
78
        scbd_drv.connect(drv_fifo.analysis_export);
79
endfunction:connect_phase
80
 
81 3 HanySalah
// Run Phase
82 2 HanySalah
task uart_scoreboard::run_phase (uvm_phase phase);
83 3 HanySalah
 
84 2 HanySalah
        forever
85
                begin
86
                drv_fifo.get(frm_drv_tmp);
87
                $cast(frm_drv,frm_drv_tmp.clone());
88
                mon_fifo.get(frm_mon_tmp);
89
                $cast(frm_mon,frm_mon_tmp.clone());
90
                if (frm_drv._mode != frm_mon._mode)
91
                        begin
92 3 HanySalah
                        `uvm_fatal("Testbench Bug",$sformatf("Modes aren't similiar .. It was requested to use %p mode and the applied mode is %p \n ",frm_drv._mode,frm_mon._mode))
93 2 HanySalah
                        end
94 3 HanySalah
 
95
                else if (frm_drv._mode inside {wrong_mode_text,wrong_mode_bin})
96
                        begin
97
                        if (frm_drv._data == frm_mon._data)
98
                                begin
99
                                `uvm_error("Failed UART Undefined Command","DUT responds to undefined Prefix \n")
100
                                end
101
                        else
102
                                begin
103
                                `uvm_info("Passed UART Undefined Command","DUT doesn't respond to undefined Prefix \n",UVM_NONE)
104
                                end
105
                        end
106
 
107
                else if (frm_drv._command inside {invalid_read,invalid_write})
108
                        begin
109
                        if (frm_drv._data == frm_mon._data)
110
                                begin
111
                                `uvm_error("Failed UART Invalid Command","DUT responds to invalid binary command \n")
112
                                end
113
                        else
114
                                begin
115
                                `uvm_info("Passed UART Invalid Command","DUT doesn't respond to invalid binary command \n",UVM_NONE)
116
                                end
117
                        end
118
 
119 2 HanySalah
                else
120
                        begin
121
                        case (frm_drv._mode)
122
                                text:
123
                                        begin
124
                                        if(frm_drv._command != frm_mon._command)
125
                                                begin
126 3 HanySalah
                                                `uvm_fatal("Testbench Bug",$sformatf("Commands aren't identical .. It was requested to drive %p command and the applied command is %p \n",frm_drv._command,frm_mon._command))
127 2 HanySalah
                                                end
128
                                        else
129
                                                begin
130
                                                case(frm_drv._command)
131
                                                        read:
132
                                                                begin
133 3 HanySalah
                                                                if (frm_drv._spacetype1 == wrong_space || frm_drv._eoltype == wrong_eol)
134 2 HanySalah
                                                                        begin
135 3 HanySalah
                                                                        if (frm_drv._data == frm_mon._data)
136
                                                                                begin
137
                                                                                `uvm_error("Failed Wrong Read Command","DUT responds to stimulus with wrong white space or eol charachters \n")
138
                                                                                end
139
                                                                        else
140
                                                                                begin
141
                                                                                `uvm_info("Passed Wrong Read Command",$sformatf("Dut was requested to read the data of the address %h with wrong white spaces or eol character \n",frm_mon.address),UVM_NONE)
142
                                                                                end
143 2 HanySalah
                                                                        end
144 3 HanySalah
                                                                else if (frm_drv._data != frm_mon._data)
145
                                                                        begin
146
                                                                        `uvm_error("Failed Read Text Mode",$sformatf("Data fields aren't identical ,, It was requested to drive %b and dut reply with the data %b \n",frm_drv._data,frm_mon._data))
147
                                                                        end
148 2 HanySalah
                                                                else if((frm_drv._data                          == frm_mon._data)       &&
149
                                                                                                (frm_drv.address                        == frm_mon.address) &&
150
                                                                                                (frm_drv._spacetype1    == frm_mon._spacetype1) &&
151
                                                                                                (frm_drv._eoltype                       == frm_mon._eoltype) &&
152
                                                                                                (frm_drv._chartype              == frm_mon._chartype))
153
                                                                        begin
154 3 HanySalah
                                                                        `uvm_info("Passed Read Text Mode",$sformatf("Data fields are identical ,, It was requested to read from the address %h and dut reply with the data %p using white space = %p and %p prefix character and %p as end of line character \n",frm_drv.address,frm_mon._data,frm_drv._spacetype1,frm_drv._chartype,
155 2 HanySalah
                                                                                frm_drv._eoltype),UVM_NONE)
156
                                                                        end
157
                                                                else
158
                                                                        begin
159 3 HanySalah
                                                                        `uvm_error("Failed Read Text Mode",$sformatf("It is Requested to request to read data = %p address of %h with character prefix : %p using white space = %p and end of line character %p .. and found data = %p and address=%h with character prefix : %p using white space = %p and end of line character %p \n",frm_drv._data,frm_drv.address,frm_drv._chartype,frm_drv._spacetype1,frm_drv._eoltype,
160 2 HanySalah
                                                                         frm_mon._data,frm_mon.address,frm_mon._chartype,frm_mon._spacetype1,frm_mon._eoltype))
161
                                                                        end
162
                                                                end
163
                                                        write:
164
                                                                begin
165 3 HanySalah
                                                                if (frm_drv._spacetype1 == wrong_space || frm_drv._spacetype2 == wrong_space || frm_drv._eoltype == wrong_eol)
166 2 HanySalah
                                                                        begin
167 3 HanySalah
                                                                        if (frm_drv._data == frm_mon._data)
168
                                                                                begin
169
                                                                                `uvm_error("Failed Wrong Write Command","DUT responds to stimulus with wrong white space or eol charachters \n")
170
                                                                                end
171
                                                                        else
172
                                                                                begin
173
                                                                                `uvm_info("Passed Wrong Write Command",$sformatf("Dut was requested to read the data of the address %h with wrong white spaces or eol character \n",frm_mon.address),UVM_NONE)
174
                                                                                end
175 2 HanySalah
                                                                        end
176 3 HanySalah
                                                                else if (frm_drv._data != frm_mon._data)
177
                                                                        begin
178
                                                                        `uvm_error("Failed Write Text Mode",$sformatf("Data fields aren't identical ,, It was requested to drive %p and dut register the data %p \n",frm_drv._data,frm_mon._data))
179
                                                                        end
180 2 HanySalah
                                                                else if((frm_drv._data                          == frm_mon._data)       &&
181
                                                                                                (frm_drv.address                        == frm_mon.address) &&
182
                                                                                                (frm_drv._spacetype1    == frm_mon._spacetype1) &&
183 3 HanySalah
                                                                                                (frm_drv._spacetype2    == frm_mon._spacetype2) &&
184 2 HanySalah
                                                                                                (frm_drv._eoltype                       == frm_mon._eoltype) &&
185
                                                                                                (frm_drv._chartype              == frm_mon._chartype))
186
                                                                        begin
187 3 HanySalah
                                                                        `uvm_info("Passed write Text Mode",$sformatf("Data fields are identical ,, It was requested to write to the address %h and dut register the data %p using white space = %p and %p prefix character and %p as end of line character \n",frm_drv.address,frm_mon._data,frm_drv._spacetype1,frm_drv._chartype,
188 2 HanySalah
                                                                                frm_drv._eoltype),UVM_NONE)
189
                                                                        end
190
                                                                else
191
                                                                        begin
192 3 HanySalah
                                                                        `uvm_error("Failed write Text Mode",$sformatf("It is Requested to request to write data = %p address of %h with character prefix : %p using white space = %p and end of line character %p .. and found data = %p and address=%h with character prefix : %p using white space = %p and end of line character %p \n",frm_drv._data,frm_drv.address,frm_drv._chartype,frm_drv._spacetype1,frm_drv._eoltype,
193 2 HanySalah
                                                                         frm_mon._data,frm_mon.address,frm_mon._chartype,frm_mon._spacetype1,frm_mon._eoltype))
194
                                                                        end
195
                                                                end
196
                                                        default:
197
                                                                begin
198 3 HanySalah
                                                                `uvm_fatal("Testbench Bug",$sformatf("It isn't allowablt to drive %p command through text mode \n",frm_drv._command))
199 2 HanySalah
                                                                end
200
                                                endcase
201
                                                end
202
                                        end
203
                                binary:
204
                                        begin
205 3 HanySalah
                                        if (frm_drv._command != frm_mon._command)
206
                                                begin
207
                                                `uvm_fatal("Testbench Bug",$sformatf("Commands aren't identical .. It was requested to drive %p command and the applied command is %p \n",frm_drv._command,frm_mon._command))
208
                                                end
209
                                        else if (frm_drv._command inside {read,write})
210
                                                begin
211
                                                if (frm_drv._reqack             == frm_mon._reqack &&
212
                                                                frm_drv._reqinc                 == frm_mon._reqinc &&
213
                                                                frm_drv.address                 == frm_mon.address &&
214
                                                                frm_drv.length_data == frm_mon.length_data &&
215
                                                                frm_drv._data                   == frm_mon._data)
216
                                                        begin
217
                                                        `uvm_info($sformatf("Passed Binary %p Command",frm_drv._command),$sformatf("Dut is requested to %p command to start address=%h with data = %p and data length = %0d \n",frm_drv._command,frm_drv.address,frm_drv._data,frm_drv.length_data),UVM_NONE)
218
                                                        ack_checker();
219
                                                        end
220
                                                else
221
                                                        begin
222
                                                        `uvm_error("Failed Binary Command",$sformatf("Dut is requested to %p command to start address=%h with data = %p, data length = %0d and dut reply with start address = %h and data = %p, length_data=%0d \n",
223
                                                                frm_drv._command,frm_drv.address,frm_drv._data,frm_drv.length_data,
224
                                                                                                                                 frm_mon.address,frm_mon._data,frm_mon.length_data))
225
                                                        end
226
                                                end
227
                                        else if (frm_drv._command == nop)
228
                                                begin
229
                                                `uvm_info("NOP Command",$sformatf("Dut is requested to %p command \n",frm_drv._command),UVM_NONE)
230
                                                ack_checker();
231
                                                end
232 2 HanySalah
                                        end
233
                                default:
234
                                        begin
235 3 HanySalah
                                        `uvm_fatal("Testbench Bug",$sformatf("Mode is undefined = %p \n",frm_drv._mode))
236 2 HanySalah
                                        end
237
                        endcase
238
                        end
239
                end
240 3 HanySalah
endtask:run_phase
241
 
242
function void uart_scoreboard::ack_checker();
243
 
244
        if(frm_drv._reqack == yes && frm_mon.acknowledge != 8'h5A)
245
                begin
246
                `uvm_error("Undefined Acknowledge",$sformatf("DUT reply with %h  as acknowledge character \n",frm_mon.acknowledge))
247
                end
248
        else if (frm_drv._reqack == no && frm_mon.acknowledge != 8'h00)
249
                begin
250
                `uvm_error("Wrong Response","Command doesn't request Acknowledge and DUT forward acknowledge character \n")
251
                end
252
        else
253
                begin
254
                `uvm_info("Accepted Acknowledge","Acknowledge is the defined as standard \n",UVM_NONE)
255
                end
256
 
257
endfunction:ack_checker

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.