Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / model / pcie / csr / csr_top.hpp
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: csr_top.hpp
4// Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved
5// 4150 Network Circle, Santa Clara, California 95054, U.S.A.
6//
7// * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
8//
9// This program is free software; you can redistribute it and/or modify
10// it under the terms of the GNU General Public License as published by
11// the Free Software Foundation; version 2 of the License.
12//
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17//
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21//
22// For the avoidance of doubt, and except that if any non-GPL license
23// choice is available it will apply instead, Sun elects to use only
24// the General Public License version 2 (GPLv2) at this time for any
25// software where a choice of GPL license versions is made
26// available with the language indicating that GPLv2 or any later version
27// may be used, or where a choice of which version of the GPL is applied is
28// otherwise unspecified.
29//
30// Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
31// CA 95054 USA or visit www.sun.com if you need additional information or
32// have any questions.
33//
34// ========== Copyright Header End ============================================
35#ifndef INC_csr_top_hpp__
36#define INC_csr_top_hpp__
37
38#include <systemc.h>
39
40#include "pcie_common/logger.hpp"
41#include "tlm.h"
42
43#include "pcie_common/csr_if_port.hpp"
44#include "csr_arb.hpp"
45#include "csr.hpp"
46#include "tlm.h"
47#include "tlm_core/tlm_fifo/tlm_fifo.h"
48
49#include "pcie_common/logger.hpp"
50
51USING_NAMESPACE(Logger);
52
53namespace pcie {
54
55 template <int N = 1>
56 class csr_top : public sc_module
57 {
58 public:
59 typedef csr_req<CSR_ADDR_T, CSR_DATA_T> REQ;
60 typedef csr_rsp<CSR_DATA_T> RSP;
61
62 typedef tlm_transport_channel < REQ, RSP > arb_channel_type;
63
64 arb_channel_type chnl[N];
65
66 csr_top(sc_module_name module_name, sc_event *parent_global_event, uint8 *parent_global_event_type) :
67 sc_module (module_name),
68 csr_clock("CSR_CLK",50,SC_PS,0.5)
69 {
70 this->parent_global_event = parent_global_event;
71 this->parent_global_event_type = parent_global_event_type;
72 LOG_DEBUG << ">> CSR_TOP()";
73 LOG_DEBUG << "CSR_TOP():: calling new csr_arb";
74 tl_csr = new csr<CSR_ADDR_T, CSR_DATA_T> ("PCIE_CSR", parent_global_event,parent_global_event_type);
75 LOG_DEBUG << "CSR_TOP():: calling new csr_arb.. done";
76 tl_arb = new csr_arb< REQ, RSP, N > ("PCIE_CSR_ARB");
77 LOG_DEBUG << "CSR_TOP():: calling new csr_arb.. done";
78 for (int i = 0; i < N; i++) {
79 tl_arb->master_port[i](chnl[i].slave_export);
80 tl_arb->add_interface(&(tl_arb->master_port[i]), 1);
81 }
82 LOG_DEBUG << "CSR_TOP():: Ports connect";
83 tl_arb->slave_port (tl_csr->target_port);
84 tl_arb->csr_clock(csr_clock);
85
86 LOG_DEBUG << ">> CSR_TOP()";
87 }
88
89 ~csr_top()
90 {
91 delete tl_csr;
92 delete tl_arb;
93 }
94
95 sc_event *parent_global_event;
96 uint8 *parent_global_event_type;
97
98 private:
99 csr_arb< REQ, RSP, N > *tl_arb;
100 csr<CSR_ADDR_T, CSR_DATA_T > *tl_csr;
101 sc_clock csr_clock;
102 };
103} // namespace pcie
104
105#endif // INC_csr_top_hpp__