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

Subversion Repositories apb2spi

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

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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