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

Subversion Repositories apb2spi

[/] [apb2spi/] [trunk/] [tb/] [env/] [spi_agent/] [spi_monitor.sv] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 vlnaran
 
2
class spi_monitor extends uvm_monitor;
3
        `uvm_component_utils(spi_monitor)
4
 
5
        uvm_analysis_port#(spi_seq_item) spi_ap;
6
        virtual spi_if m_v_intf;
7
        spi_seq_item txn;
8
        integer cnt=0;
9
 
10
function new(string name="spi_monitor",uvm_component parent);
11
        super.new(name,parent);
12
        spi_ap=new("spi_ap",this);
13
endfunction
14
 
15
function void build_phase(uvm_phase phase);
16
        super.build_phase(phase);
17
        if(!uvm_config_db#(virtual spi_if)::get(this,"*","spi_vif",m_v_intf))
18
                `uvm_fatal("NO_SPI_MON_V_INTF","Virtual interface couldn't be obtained for spi monitor")
19
endfunction
20
 
21
virtual task run_phase(uvm_phase phase);
22
        txn = spi_seq_item::type_id::create("txn");
23
        forever
24
        begin
25
                wait(m_v_intf.SS==1'b0);
26
                for(int i=0;i<=`SPI_REG_WIDTH-1;i++)
27
                begin
28
                        @(posedge m_v_intf.SCLK)
29
                        txn.wdata[i] = m_v_intf.MOSI;
30
                        txn.rdata[i] = m_v_intf.MISO;
31
                        cnt++;
32
                end
33
                wait(m_v_intf.SS==1'b1);
34
                spi_ap.write(txn);
35
        end
36
endtask
37
 
38
endclass

powered by: WebSVN 2.1.0

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