APB UVM Agent  0.0.1
reg2apb_adapter.svh
Go to the documentation of this file.
1 //
2 // -------------------------------------------------------------
3 // Copyright 2004-2008 Synopsys, Inc.
4 // Copyright 2010 Mentor Graphics Corp.
5 // All Rights Reserved Worldwide
6 //
7 // Licensed under the Apache License, Version 2.0 (the
8 // "License"); you may not use this file except in
9 // compliance with the License. You may obtain a copy of
10 // the License at
11 //
12 // http://www.apache.org/licenses/LICENSE-2.0
13 //
14 // Unless required by applicable law or agreed to in
15 // writing, software distributed under the License is
16 // distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
17 // CONDITIONS OF ANY KIND, either express or implied. See
18 // the License for the specific language governing
19 // permissions and limitations under the License.
20 // -------------------------------------------------------------
21 
22 /**
23 * Implements the translation between apb_seq_item and uvm_reg_bus_op.
24 *
25 * The mapping is one-to-one due to similarities between UVM RAL and APB.
26 */
27 class reg2apb_adapter extends uvm_reg_adapter;
28 
29  `uvm_object_utils(reg2apb_adapter)
30 
31  /**
32  * Conventional UVM object constructor.
33  */
34  function new(string name = "reg2apb_adapter");
35  super.new(name);
36  // supports_byte_enable = 0;
37  // provides_responses = 1;
38  endfunction
39 
40  /**
41  * Converts a generic, RAL transaction type into an APB bus transaction type.
42  *
43  * This mapping is one to one.
44  */
45  virtual function uvm_sequence_item reg2bus(const ref uvm_reg_bus_op rw);
46  apb_seq_item apb = apb_seq_item::type_id::create("apb");
47  apb.we = (rw.kind == UVM_READ) ? 0 : 1;
48  apb.addr = rw.addr;
49  apb.data = rw.data;
50  return apb;
51  endfunction: reg2bus
52 
53  /**
54  * Converts an APB bus transaction type into a generic, RAL transaction type.
55  *
56  * The mapping is mostly one to one. For simplicity all transactions is flagged
57  * as successful (i.e. status UVM_IS_OK).
58  */
59  virtual function void bus2reg(uvm_sequence_item bus_item,
60  ref uvm_reg_bus_op rw);
61  apb_seq_item apb;
62  if (!$cast(apb, bus_item)) begin
63  `uvm_fatal("NOT_APB_TYPE","Provided bus_item is not of the correct type")
64  return;
65  end
66  rw.kind = apb.we ? UVM_WRITE : UVM_READ;
67  rw.addr = apb.addr;
68  rw.data = apb.data;
69  rw.status = UVM_IS_OK;
70  endfunction: bus2reg
71 
72 endclass: reg2apb_adapter
73 
Implements the translation between apb_seq_item and uvm_reg_bus_op.
Base APB transaction.