Initial commit of OpenSPARC T2 design and verification files.
[OpenSPARC-T2-DV] / verif / model / pcie / tl / tl_top.hpp
CommitLineData
86530b38
AT
1// ========== Copyright Header Begin ==========================================
2//
3// OpenSPARC T2 Processor File: tl_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_tl_top_hpp__
36#define INC_tl_top_hpp__
37
38#include <systemc.h>
39
40#include "pcie_common/tlm/tlm_data_channel.hpp"
41#include "etl.hpp"
42#include "itl.hpp"
43#include "rsb.hpp"
44
45namespace pcie {
46
47 class tl_top : public sc_module
48 {
49 public:
50 tl_top(sc_module_name module_name, sc_event *parent_global_event, uint8 *parent_global_event_type) :
51 sc_module (module_name),
52 csr_port("CSR_PORT")
53 {
54 this->parent_global_event = parent_global_event;
55 this->parent_global_event_type = parent_global_event_type;
56
57 m_etl = new etl("etl",parent_global_event,parent_global_event_type);
58 m_itl = new itl("itl",parent_global_event,parent_global_event_type);
59 m_rsb = new rsb("rsb",parent_global_event,parent_global_event_type);
60
61 itl_rsb_data_chnl = new tlm_transport_channel<RefPciePacket,bool>;
62 m_rsb->ing_port(itl_rsb_data_chnl->slave_export);
63 m_itl->rsb_out_port(itl_rsb_data_chnl->target_export);
64
65 etl_rsb_data_chnl = new tlm_data_channel<RefPciePacket>("etl_rsb_chnl",parent_global_event,parent_global_event_type);
66
67 m_etl->eg_etl_rsb_port(*etl_rsb_data_chnl);
68 m_rsb->eg_port(*etl_rsb_data_chnl);
69
70 SC_THREAD(link_events);
71
72 }
73
74 SC_HAS_PROCESS( tl_top );
75
76 csr_if_port< CSR_ADDR_T, CSR_DATA_T > csr_port;
77
78 ~tl_top() {
79 delete m_itl;
80 delete m_etl;
81 delete m_rsb;
82 }
83
84 void etl_data_port(data_out_port<RefPciePacket>::if_type& i) {
85 m_etl->dout_port(i);
86 }
87
88 void itl_data_port(data_in_port<RefPciePacket>::if_type& i) {
89 m_itl->d_in_port(i);
90 }
91
92 void link_events() {
93 sc_event core_status_ev;
94 csr_port.set_notify_event(PEU_CSR_A_CORE_STATUS_HW_ADDR,&core_status_ev);
95 sc_uint<64> core_status;
96
97 while (true) {
98 wait (core_status_ev);
99 core_status = csr_port.read_csr(PEU_CSR_A_CORE_STATUS_HW_ADDR);
100 if (core_status(48,44) == 16) {
101 csr_port.write_csr(PEU_CSR_A_OE_ERR_RW1S_ALIAS_HW_ADDR, 0x100);
102 }
103 }
104 }
105
106 etl *m_etl;
107 itl *m_itl;
108 rsb *m_rsb;
109
110 tlm_transport_channel< RefPciePacket , bool> *itl_rsb_data_chnl;
111 tlm_data_channel< RefPciePacket > *etl_rsb_data_chnl;
112
113 sc_event *parent_global_event;
114 uint8 *parent_global_event_type;
115 };
116} // namespace pcie
117
118#endif // INC_tl_top_hpp__