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

Subversion Repositories uart2bus_testbench

[/] [uart2bus_testbench/] [trunk/] [tb/] [interfaces/] [rf_interface.sv] - Blame information for rev 2

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

Line No. Rev Author Line
1 2 HanySalah
//-----------------------------------------------------------------------------
2
//
3
//                             UART2BUS VERIFICATION
4
//
5
//-----------------------------------------------------------------------------
6
// CREATOR    : HANY SALAH
7
// PROJECT    : UART2BUS UVM TEST BENCH
8
// UNIT       : INTERFACE
9
//-----------------------------------------------------------------------------
10
// TITLE      : UART Interface
11
// DESCRIPTION: This
12
//-----------------------------------------------------------------------------
13
// LOG DETAILS
14
//-------------
15
// VERSION      NAME        DATE        DESCRIPTION
16
//    1       HANY SALAH    25122015    FILE CREATION
17
//-----------------------------------------------------------------------------
18
// ALL COPYRIGHTS ARE RESERVED FOR THE PRODUCER ONLY .THIS FILE IS PRODUCED FOR
19
// OPENCORES MEMBERS ONLY AND IT IS PROHIBTED TO USE THIS MATERIAL WITHOUT THE
20
// CREATOR'S PERMISSION
21
//-----------------------------------------------------------------------------
22
`include "defin_lib.svh"
23
interface rf_interface (input bit clock,        // Global Clock Signal
24
                        input bit reset);       // Global Asynchronous Reset Signal
25
 
26
 
27
 
28
//--------------------------------
29
//
30
//   Register File Side Signals
31
//
32
//--------------------------------
33
 
34
  logic [15:0]   int_address;    // Address Bus To Register File
35
 
36
  logic [7:0]         int_wr_data;    // Write Data To Register File
37
  logic               int_write;      // Write Contorl To Register File
38
 
39
  logic [7:0]         int_rd_data;    // Read Data From Register File
40
  logic               int_read;       // Read Control To Register File
41
 
42
//--------------------------------
43
//
44
//  CONTROL SIGNALS
45
//
46
//--------------------------------
47
 
48
  logic               int_gnt;
49
  logic               int_req;
50
//--------------------------------
51
//
52
//   Internal Variables
53
//
54
//--------------------------------
55
 
56
  // Memory of 64K bytes as Register File
57
  byte       register_file [`mem_size-1:0];
58
 
59
//--------------------------------
60
//
61
//   Operation Blocks
62
//
63
//--------------------------------
64
 
65
  always
66
    begin
67
    @(posedge clock or posedge reset);
68
      begin
69
      if (reset)
70
        begin
71
        reset_mem();
72
        end
73
      else if (int_write)
74
        begin
75
        fill_byte(int_address,int_wr_data);
76
        end
77
      else if (int_read)
78
        begin
79
        int_rd_data = read_mem_data(int_address);
80
        end
81
      end
82
    end
83
 
84
//--------------------------------
85
//
86
//   Non Standard Routines
87
//
88
//--------------------------------
89
 
90
  // fill_byte routine is a function that fill only single byte in the register
91
  // file
92
function void fill_byte (bit [`size-1:0] address,
93
                         byte            data);
94
 
95
  register_file[address] = data;
96
endfunction:fill_byte
97
 
98
  // fill_block routine is a function that fill continuous block of locations
99
  // in the register file
100
function automatic void fill_block(bit [`size-1:0] address,
101
                                   ref byte data [],
102
                                   int unsigned block_length);
103
 
104
    for (int unsigned index = 0; index < block_length; index++)
105
      begin
106
      register_file[address+index] = data [index];
107
      end
108
endfunction:fill_block
109
 
110
  // reset_mem routine is a function that fill reset the register file to contents
111
  // zero
112
 function void reset_mem();
113
  for (int unsigned index = 0; index < `mem_size; index++)
114
    begin
115
    register_file[index] = 8'b0;
116
    end
117
endfunction:reset_mem
118
 
119
  // read_mem_data routine is a function that load bus with the data content
120
  function byte read_mem_data(bit [`size-1:0] address);
121
    return register_file[address];
122
  endfunction: read_mem_data
123
 
124
  task automatic read_block(input int unsigned data_length,
125
                            input bit [15:0] address,
126
                            ref byte data []);
127
    data = new [data_length];
128
    for (int unsigned index=0;index
129
      begin
130
      data[index] = read_mem_data(address+index);
131
      end
132
  endtask:read_block
133
 
134
  //-----------------------------------------
135
  //
136
  //        MONITOR ROUTINES
137
  //
138
  //-----------------------------------------
139
 
140
  task automatic capture_transaction (output bit[`size-1:0] address,
141
                                      ref byte data []);
142
    int index;
143
    index = 0;
144
    @(posedge int_gnt);
145
    while (int_gnt)
146
      begin
147
      @(posedge clock);
148
      if(index == 0)
149
        begin
150
        address = int_address;
151
        end
152
      if(int_read)
153
        begin
154
        data [index] = int_rd_data;
155
        end
156
      else if (int_write)
157
        begin
158
        data [index] = int_wr_data;
159
        end
160
      else
161
        begin
162
        $error("both int_write and int_read is inactive");
163
        end
164
      index++;
165
      end
166
  endtask:capture_transaction
167
endinterface:rf_interface

powered by: WebSVN 2.1.0

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