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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [analysis/] [uart_scoreboard.svh] - Diff between revs 2 and 3

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 2 Rev 3
Line 1... Line 1...
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
//
//
//                             UART2BUS VERIFICATION
//                             UART2BUS VERIFICATION
//
//
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// CREATOR    : HANY SALAH
// CREATOR    : HANY SALAH
// PROJECT    : UART2BUS UVM TEST BENCH
// PROJECT    : UART2BUS UVM TEST BENCH
// UNIT       : ANALYSIS
// UNIT       : ANALYSIS
//-----------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------
// TITLE      : UART ANALYSIS
// TITLE      : UART SCOREBOARD
// DESCRIPTION: This
// DESCRIPTION: SCOREBOARD IS RESPONSIBLE FOR DOING COMPARISONS BETWEEN THE TRANSACTION CREATED IN
//-----------------------------------------------------------------------------
//                                                      THE SEQUENCE AND THE TRANSACTION CAPTURED BY THE MONITOR.
 
//-------------------------------------------------------------------------------------------------
// LOG DETAILS
// LOG DETAILS
//-------------
//-------------
// VERSION      NAME        DATE        DESCRIPTION
// VERSION      NAME        DATE        DESCRIPTION
//    1       HANY SALAH    22012016    FILE CREATION
//    1       HANY SALAH    22012016    FILE CREATION
//-----------------------------------------------------------------------------
//              2                       HANY SALAH              28012016                ADD BINARY COMMAND CHECKING
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR
//              3                               HANY SALAH              18022016                IMPROVE BLOCK DESCRIPTION & ADD COMMENTS
// OPENCORES MEMBERS ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE
//-------------------------------------------------------------------------------------------------
// CREATOR'S PERMISSION
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR OPENCORES MEMBERS
//-----------------------------------------------------------------------------
// ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE CREATOR'S PERMISSION
 
//-------------------------------------------------------------------------------------------------
 
 
class uart_scoreboard extends uvm_scoreboard;
class uart_scoreboard extends uvm_scoreboard;
 
 
 
        // TLM fifo which buffers the trasaction captured by the monitor.
        uvm_tlm_analysis_fifo #(uart_transaction)       mon_fifo;
        uvm_tlm_analysis_fifo #(uart_transaction)       mon_fifo;
 
 
 
        // TLM port connected to the monitor.
        uvm_analysis_export #(uart_transaction) scbd_mon;
        uvm_analysis_export #(uart_transaction) scbd_mon;
 
 
 
        // TLM fifo which buffers the trasaction drived from the driver.
        uvm_tlm_analysis_fifo #(uart_transaction) drv_fifo;
        uvm_tlm_analysis_fifo #(uart_transaction) drv_fifo;
 
 
 
        // TLM port connected to the driver.
        uvm_analysis_export #(uart_transaction) scbd_drv;
        uvm_analysis_export #(uart_transaction) scbd_drv;
 
 
        uart_transaction                        frm_drv,frm_drv_tmp;
        uart_transaction                        frm_drv,frm_drv_tmp;
 
 
        uart_transaction                        frm_mon,frm_mon_tmp;
        uart_transaction                        frm_mon,frm_mon_tmp;
Line 42... Line 49...
        extern function void build_phase (uvm_phase phase);
        extern function void build_phase (uvm_phase phase);
 
 
        extern function void connect_phase (uvm_phase phase);
        extern function void connect_phase (uvm_phase phase);
 
 
        extern task run_phase (uvm_phase phase);
        extern task run_phase (uvm_phase phase);
 
 
 
        extern function void ack_checker ();
endclass:uart_scoreboard
endclass:uart_scoreboard
 
 
 
 
function void uart_scoreboard::build_phase (uvm_phase phase);
function void uart_scoreboard::build_phase (uvm_phase phase);
        super.build_phase(phase);
        super.build_phase(phase);
Line 67... Line 76...
function void uart_scoreboard::connect_phase (uvm_phase phase);
function void uart_scoreboard::connect_phase (uvm_phase phase);
        scbd_mon.connect(mon_fifo.analysis_export);
        scbd_mon.connect(mon_fifo.analysis_export);
        scbd_drv.connect(drv_fifo.analysis_export);
        scbd_drv.connect(drv_fifo.analysis_export);
endfunction:connect_phase
endfunction:connect_phase
 
 
 
// Run Phase
task uart_scoreboard::run_phase (uvm_phase phase);
task uart_scoreboard::run_phase (uvm_phase phase);
        int iteration;
 
        iteration = 0;
 
        forever
        forever
                begin
                begin
                iteration++;
 
                drv_fifo.get(frm_drv_tmp);
                drv_fifo.get(frm_drv_tmp);
                $cast(frm_drv,frm_drv_tmp.clone());
                $cast(frm_drv,frm_drv_tmp.clone());
                mon_fifo.get(frm_mon_tmp);
                mon_fifo.get(frm_mon_tmp);
                $cast(frm_mon,frm_mon_tmp.clone());
                $cast(frm_mon,frm_mon_tmp.clone());
 
 
                if (frm_drv._mode != frm_mon._mode)
                if (frm_drv._mode != frm_mon._mode)
                        begin
                        begin
                        `uvm_fatal("Testbench Bug",$sformatf("Modes aren't similiar .. @time=%0t, It was requested to use %p mode and the applied mode is %p ",$time,frm_drv._mode,frm_mon._mode))
                        `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))
 
                        end
 
 
 
                else if (frm_drv._mode inside {wrong_mode_text,wrong_mode_bin})
 
                        begin
 
                        if (frm_drv._data == frm_mon._data)
 
                                begin
 
                                `uvm_error("Failed UART Undefined Command","DUT responds to undefined Prefix \n")
                        end
                        end
                else
                else
                        begin
                        begin
 
                                `uvm_info("Passed UART Undefined Command","DUT doesn't respond to undefined Prefix \n",UVM_NONE)
 
                                end
 
                        end
 
 
 
                else if (frm_drv._command inside {invalid_read,invalid_write})
 
                        begin
 
                        if (frm_drv._data == frm_mon._data)
 
                                begin
 
                                `uvm_error("Failed UART Invalid Command","DUT responds to invalid binary command \n")
 
                                end
 
                        else
 
                                begin
 
                                `uvm_info("Passed UART Invalid Command","DUT doesn't respond to invalid binary command \n",UVM_NONE)
 
                                end
 
                        end
 
 
 
                else
 
                        begin
                        case (frm_drv._mode)
                        case (frm_drv._mode)
                                text:
                                text:
                                        begin
                                        begin
                                        if(frm_drv._command != frm_mon._command)
                                        if(frm_drv._command != frm_mon._command)
                                                begin
                                                begin
                                                `uvm_fatal("Testbench Bug",$sformatf("Commands aren't identical .. @time=%0t, It was requested to drive %p command and the applied command is %p ",$time,frm_drv._command,frm_mon._command))
                                                `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))
                                                end
                                                end
                                        else
                                        else
                                                begin
                                                begin
                                                case(frm_drv._command)
                                                case(frm_drv._command)
                                                        read:
                                                        read:
                                                                begin
                                                                begin
                                                                if (frm_drv._data != frm_mon._data)
                                                                if (frm_drv._spacetype1 == wrong_space || frm_drv._eoltype == wrong_eol)
 
                                                                        begin
 
                                                                        if (frm_drv._data == frm_mon._data)
                                                                        begin
                                                                        begin
                                                                        `uvm_error("Failed Read Text Mode",$sformatf("Data fields aren't identical ,, @time=%0t It was requested to drive %p and dut reply with the data %p",$time,frm_drv._data,frm_mon._data))
                                                                                `uvm_error("Failed Wrong Read Command","DUT responds to stimulus with wrong white space or eol charachters \n")
 
                                                                                end
 
                                                                        else
 
                                                                                begin
 
                                                                                `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)
 
                                                                                end
 
                                                                        end
 
                                                                else if (frm_drv._data != frm_mon._data)
 
                                                                        begin
 
                                                                        `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))
                                                                        end
                                                                        end
                                                                else if((frm_drv._data                          == frm_mon._data)       &&
                                                                else if((frm_drv._data                          == frm_mon._data)       &&
                                                                                                (frm_drv.address                        == frm_mon.address) &&
                                                                                                (frm_drv.address                        == frm_mon.address) &&
                                                                                                (frm_drv._spacetype1    == frm_mon._spacetype1) &&
                                                                                                (frm_drv._spacetype1    == frm_mon._spacetype1) &&
                                                                                                (frm_drv._eoltype                       == frm_mon._eoltype) &&
                                                                                                (frm_drv._eoltype                       == frm_mon._eoltype) &&
                                                                                                (frm_drv._chartype              == frm_mon._chartype))
                                                                                                (frm_drv._chartype              == frm_mon._chartype))
                                                                        begin
                                                                        begin
                                                                        `uvm_info("Passed Read Text Mode",$sformatf("Data fields are identical ,, @time=%0t 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",$time,frm_drv.address,frm_mon._data,frm_drv._spacetype1,frm_drv._chartype,
                                                                        `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,
                                                                                frm_drv._eoltype),UVM_NONE)
                                                                                frm_drv._eoltype),UVM_NONE)
                                                                        end
                                                                        end
                                                                else
                                                                else
                                                                        begin
                                                                        begin
                                                                        `uvm_error("Failed Read Text Mode",$sformatf("@time=%0t .. 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",$time, frm_drv._data,frm_drv.address,frm_drv._chartype,frm_drv._spacetype1,frm_drv._eoltype,
                                                                        `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,
                                                                         frm_mon._data,frm_mon.address,frm_mon._chartype,frm_mon._spacetype1,frm_mon._eoltype))
                                                                         frm_mon._data,frm_mon.address,frm_mon._chartype,frm_mon._spacetype1,frm_mon._eoltype))
                                                                        end
                                                                        end
                                                                end
                                                                end
                                                        write:
                                                        write:
                                                                begin
                                                                begin
                                                                if (frm_drv._data != frm_mon._data)
                                                                if (frm_drv._spacetype1 == wrong_space || frm_drv._spacetype2 == wrong_space || frm_drv._eoltype == wrong_eol)
 
                                                                        begin
 
                                                                        if (frm_drv._data == frm_mon._data)
                                                                        begin
                                                                        begin
                                                                        `uvm_error("Failed Write Text Mode",$sformatf("Data fields aren't identical ,, @time=%0t It was requested to drive %p and dut register the data %p",$time,frm_drv._data,frm_mon._data))
                                                                                `uvm_error("Failed Wrong Write Command","DUT responds to stimulus with wrong white space or eol charachters \n")
 
                                                                                end
 
                                                                        else
 
                                                                                begin
 
                                                                                `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)
 
                                                                                end
 
                                                                        end
 
                                                                else if (frm_drv._data != frm_mon._data)
 
                                                                        begin
 
                                                                        `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))
                                                                        end
                                                                        end
                                                                else if((frm_drv._data                          == frm_mon._data)       &&
                                                                else if((frm_drv._data                          == frm_mon._data)       &&
                                                                                                (frm_drv.address                        == frm_mon.address) &&
                                                                                                (frm_drv.address                        == frm_mon.address) &&
                                                                                                (frm_drv._spacetype1    == frm_mon._spacetype1) &&
                                                                                                (frm_drv._spacetype1    == frm_mon._spacetype1) &&
 
                                                                                                (frm_drv._spacetype2    == frm_mon._spacetype2) &&
                                                                                                (frm_drv._eoltype                       == frm_mon._eoltype) &&
                                                                                                (frm_drv._eoltype                       == frm_mon._eoltype) &&
                                                                                                (frm_drv._chartype              == frm_mon._chartype))
                                                                                                (frm_drv._chartype              == frm_mon._chartype))
                                                                        begin
                                                                        begin
                                                                        `uvm_info("Passed write Text Mode",$sformatf("Data fields are identical ,, @time=%0t 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",$time,frm_drv.address,frm_mon._data,frm_drv._spacetype1,frm_drv._chartype,
                                                                        `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,
                                                                                frm_drv._eoltype),UVM_NONE)
                                                                                frm_drv._eoltype),UVM_NONE)
                                                                        end
                                                                        end
                                                                else
                                                                else
                                                                        begin
                                                                        begin
                                                                        `uvm_error("Failed write Text Mode",$sformatf("@time=%0t .. 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",$time, frm_drv._data,frm_drv.address,frm_drv._chartype,frm_drv._spacetype1,frm_drv._eoltype,
                                                                        `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,
                                                                         frm_mon._data,frm_mon.address,frm_mon._chartype,frm_mon._spacetype1,frm_mon._eoltype))
                                                                         frm_mon._data,frm_mon.address,frm_mon._chartype,frm_mon._spacetype1,frm_mon._eoltype))
                                                                        end
                                                                        end
 
 
                                                                end
                                                                end
                                                        default:
                                                        default:
                                                                begin
                                                                begin
                                                                        `uvm_fatal("Testbench Bug",$sformatf("@time = %0t .. It isn't allowablt to drive %p command through text mode",$time,frm_drv._command))
                                                                `uvm_fatal("Testbench Bug",$sformatf("It isn't allowablt to drive %p command through text mode \n",frm_drv._command))
                                                                end
                                                                end
                                                endcase
                                                endcase
                                                end
                                                end
                                        end
                                        end
                                binary:
                                binary:
                                        begin
                                        begin
 
                                        if (frm_drv._command != frm_mon._command)
 
                                                begin
 
                                                `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))
                                        end
                                        end
                                wrong_mode:
                                        else if (frm_drv._command inside {read,write})
                                        begin
                                        begin
 
                                                if (frm_drv._reqack             == frm_mon._reqack &&
 
                                                                frm_drv._reqinc                 == frm_mon._reqinc &&
 
                                                                frm_drv.address                 == frm_mon.address &&
 
                                                                frm_drv.length_data == frm_mon.length_data &&
 
                                                                frm_drv._data                   == frm_mon._data)
 
                                                        begin
 
                                                        `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)
 
                                                        ack_checker();
 
                                                        end
 
                                                else
 
                                                        begin
 
                                                        `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",
 
                                                                frm_drv._command,frm_drv.address,frm_drv._data,frm_drv.length_data,
 
                                                                                                                                 frm_mon.address,frm_mon._data,frm_mon.length_data))
 
                                                        end
 
                                                end
 
                                        else if (frm_drv._command == nop)
 
                                                begin
 
                                                `uvm_info("NOP Command",$sformatf("Dut is requested to %p command \n",frm_drv._command),UVM_NONE)
 
                                                ack_checker();
 
                                                end
                                        end
                                        end
                                default:
                                default:
                                        begin
                                        begin
                                        `uvm_fatal("Testbench Bug",$sformatf("Mode is undefined = %p",frm_drv._mode))
                                        `uvm_fatal("Testbench Bug",$sformatf("Mode is undefined = %p \n",frm_drv._mode))
                                        end
                                        end
                        endcase
                        endcase
                        end
                        end
                end
                end
endtask:run_phase
endtask:run_phase
 No newline at end of file
 No newline at end of file
 
 
 
function void uart_scoreboard::ack_checker();
 
 
 
        if(frm_drv._reqack == yes && frm_mon.acknowledge != 8'h5A)
 
                begin
 
                `uvm_error("Undefined Acknowledge",$sformatf("DUT reply with %h  as acknowledge character \n",frm_mon.acknowledge))
 
                end
 
        else if (frm_drv._reqack == no && frm_mon.acknowledge != 8'h00)
 
                begin
 
                `uvm_error("Wrong Response","Command doesn't request Acknowledge and DUT forward acknowledge character \n")
 
                end
 
        else
 
                begin
 
                `uvm_info("Accepted Acknowledge","Acknowledge is the defined as standard \n",UVM_NONE)
 
                end
 
 
 
endfunction:ack_checker
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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