U RAL DMA - verificationguide.com - EDA Playground
Warning! This exercise has been opened in another tab; autosave has been disabled. Close this tab or refresh to reactivate.

 Languages & Libraries

 Tools & Simulators

 Examples

204


44
 
1
//-------------------------------------------------------------------------
2
//  Register Access Sequence
3
//-------------------------------------------------------------------------
4
class dma_reg_seq extends uvm_sequence;
5
6
  `uvm_object_utils(dma_reg_seq)
7
  
8
  dma_reg_model regmodel;
9
  
10
  //---------------------------------------
11
  // Constructor 
12
  //---------------------------------------    
13
  function new (string name = ""); 
14
    super.new(name);    
15
  endfunction
16
  
17
  //---------------------------------------
18
  // Sequence body 
19
  //---------------------------------------      
20
  task body;  
21
    uvm_status_e   status;
22
    uvm_reg_data_t incoming;
23
    bit [31:0]     rdata;
24
    
25
    if (starting_phase != null)
26
      starting_phase.raise_objection(this);
27
    
28
    //Write to the Registers
29
    regmodel.reg_intr.write(status, 32'h1234_1234);
30
    regmodel.reg_ctrl.write(status, 32'h1234_5678);
31
    regmodel.reg_io_addr.write(status, 32'h1234_9ABC);
32
    regmodel.reg_mem_addr.write(status, 32'h1234_DEF0);
33
    
34
    //Read from the registers
35
    regmodel.reg_intr.read(status, rdata);
36
    regmodel.reg_ctrl.read(status, rdata);
37
    regmodel.reg_io_addr.read(status, rdata);
38
    regmodel.reg_mem_addr.read(status, rdata);
39
      
40
    if (starting_phase != null)
41
      starting_phase.drop_objection(this);  
42
    
43
  endtask
44
endclass
57
 
1
//------------------------------------------------------------------------
2
//              DMA RTL - www.verificationguide.com
3
//------------------------------------------------------------------------
4
5
module DMA
6
  #( parameter ADDR_WIDTH = 32,
7
     parameter DATA_WIDTH = 32 ) (
8
    input clk,
9
    input reset,
10
    
11
    //control signals
12
    input [ADDR_WIDTH-1:0]  addr,
13
    input                   wr_en,
14
    input                   valid,
15
    
16
    //data signals
17
    input  [DATA_WIDTH-1:0] wdata,
18
    output [DATA_WIDTH-1:0] rdata
19
  ); 
20
  
21
  logic [DATA_WIDTH-1:0] t_data;
22
  
23
  reg [DATA_WIDTH-1:0] intr;
24
  reg [DATA_WIDTH-1:0] control;
25
  reg [DATA_WIDTH-1:0] io_address;
26
  reg [DATA_WIDTH-1:0] mem_address;
27
  
28
  //Reset 
29
  always @(posedge reset) begin //{
30
    intr        <= 0;
31
    control     <= 0;
32
    io_address  <= 0;
33
    mem_address <= 0;
34
  end //}
35
36
  assign rdata = t_data;
37
38
  always @(posedge clk) begin //{
39
    if (wr_en & valid) begin//{
40
           if (addr == 32'h400) intr        <= wdata;
41
      else if (addr == 32'h404) control     <= wdata;
42
      else if (addr == 32'h408) io_address  <= wdata;
43
      else if (addr == 32'h40C) mem_address <= wdata;
44
      $display("Design WR addr %0h Data %0h",addr,wdata);
45
    end //}
46
    else if (!wr_en & valid) begin//{
47
      
48
           if (addr == 32'h400) t_data = intr         ;
49
      else if (addr == 32'h404) t_data = control      ;
50
      else if (addr == 32'h408) t_data = io_address   ;
51
      else if (addr == 32'h40C) t_data = mem_address  ;
52
      $display("Design RD addr %0h Data %0h",addr,t_data);
53
      //rdata = t_data;
54
    end //}
55
  end  
56
57
endmodule
8443 views and 10 likes     
A short description will be helpful for you to remember your playground's details
 
100:0