ipxact-tools 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/config/detector.yml +63 -0
- data/lib/ipxact_tools.rb +287 -0
- data/lib/ipxact_tools/graph_pathfinder.rb +191 -0
- data/lib/ipxact_tools/interrupt_line_detector.rb +98 -0
- data/spec/integration/integration_spec.rb +254 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_initiator_port.h +135 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_initiator_port.tpp +247 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_initiator_port_base.h +189 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_router.h +205 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_router.tpp +278 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_slave_base.h +115 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_slave_base.tpp +126 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_target_port.h +168 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_target_port_base.h +133 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/pv_tlm_if.h +280 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/PV/user_types.h +38 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/Leon2Platform/Leon2Platform.xml +77 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/Leon2Platform/design_Leon2Platform.xml +156 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/Leon2Platform/tlmsrc/Leon2Platform.h +149 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/apbSubSystem/apbSubSystem.xml +406 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/apbSubSystem/design_apbSubSystem.xml +135 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM1/apbSubSystem/tlmsrc/apbSubSystem.h +133 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/Leon2Platform/Leon2Platform.xml +77 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/Leon2Platform/design_Leon2Platform.xml +157 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/Leon2Platform/tlmsrc/Leon2Platform.h +150 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/apbSubSystem.xml +422 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/designConfig_apbSubSystem.xml +79 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/design_apbSubSystem.xml +184 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM2/apbSubSystem/tlmsrc/apbSubSystem.h +164 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/Leon2Platform/Leon2Platform.xml +105 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/Leon2Platform/design_Leon2Platform.xml +157 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/Leon2Platform/tlmsrc/Leon2Platform.h +152 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/apbSubSystem.xml +429 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/designConfig_apbSubSystem.xml +64 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/design_apbSubSystem.xml +150 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/SystemTLM3/apbSubSystem/tlmsrc/apbSubSystem.h +167 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbbus/1.4/ahbbus22.xml +236 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbbus/1.4/tlmsrc/ahbbus.h +52 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbram/1.4/ahbram.xml +184 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbram/1.4/tlmsrc/ahbram.cc +93 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/ahbram/1.4/tlmsrc/ahbram.h +77 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbbus/1.4/apbbus8.xml +544 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbbus/1.4/tlmsrc/apbbus.h +55 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbmst/1.4/apbmst.xml +209 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbmst/1.4/tlmsrc/apbmst.h +53 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/apbram.xml +395 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.cc +89 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.h +69 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.v +82 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/apbram/1.0/hdlsrc/apbram.vhd +132 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.4/cgu.xml +686 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.4/tlmsrc/cgu.cc +121 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.4/tlmsrc/cgu.h +81 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.5/cgu.xml +707 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.5/tlmsrc/cgu.cc +121 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/cgu/1.5/tlmsrc/cgu.h +81 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/dma/1.4/dma.xml +272 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/dma/1.4/tlmsrc/dma.cc +230 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/dma/1.4/tlmsrc/dma.h +116 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/irqctrl/1.4/irqctrl.xml +530 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/irqctrl/1.4/tlmsrc/irqctrl.cc +211 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/irqctrl/1.4/tlmsrc/irqctrl.h +108 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/processor/1.4/processor.xml +423 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/processor/1.4/tlmsrc/processor.cc +331 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/processor/1.4/tlmsrc/processor.h +121 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2apb/1.0/pv2apb.xml +240 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2apb/1.0/tlmsrc/pv2apb.cc +153 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2apb/1.0/tlmsrc/pv2apb.h +77 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2tac/1.0/pv2tac.xml +154 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2tac/1.0/tlmsrc/pv2tac.cc +114 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/pv2tac/1.0/tlmsrc/pv2tac.h +67 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/rgu/1.4/rgu.xml +766 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/rgu/1.4/tlmsrc/rgu.cc +126 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/rgu/1.4/tlmsrc/rgu.h +105 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/scmlAdaptor/1.0/scmlAdaptor.xml +154 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/scmlAdaptor/1.0/tlmsrc/scmladaptor.cc +100 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/scmlAdaptor/1.0/tlmsrc/scmladaptor.h +62 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/serial_device/1.0/serial_device.xml +151 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/serial_device/1.0/tlmsrc/serial_device.h +85 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/timers/1.4/timers.xml +460 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/timers/1.4/tlmsrc/timers.cc +201 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/timers/1.4/tlmsrc/timers.h +102 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart.h +152 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart_fifo.h +113 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart_memory_map.h +96 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/inc/uart_types.h +60 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart.cc +125 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart_interrupt_handler.cc +136 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart_register_bank.cc +129 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/tlmsrc/src/uart_serial_tx_rx.cc +145 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_scml/1.0/uart_scml.xml +372 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/Leon2_uart.h +216 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/def_Leon2_uart.h +34 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/tlm_field.h +72 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/tlm_register.h +129 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/include/tlmreg_Leon2_uart.h +133 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/src/Leon2_uart.cc +316 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/src/tlmreg_Leon2_uart.cc +197 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/tlmsrc/src/user_specific_Leon2_uart.cc +146 -0
- data/spec/test_data/spiritconsortium.org/Leon2TLM/uart_tac/1.0/uart_tac.xml +222 -0
- data/spec/unit/graph_pathfinder_spec.rb +128 -0
- metadata +272 -0
@@ -0,0 +1,331 @@
|
|
1
|
+
//
|
2
|
+
// Revision: $Revision: 1506 $
|
3
|
+
// Date: $Date: 2009-04-26 01:51:56 -0500 (Sun, 26 Apr 2009) $
|
4
|
+
//
|
5
|
+
// Copyright (c) 2005, 2006, 2007, 2008, 2009 The SPIRIT Consortium.
|
6
|
+
//
|
7
|
+
// This work forms part of a deliverable of The SPIRIT Consortium.
|
8
|
+
//
|
9
|
+
// Use of these materials are governed by the legal terms and conditions
|
10
|
+
// outlined in the disclaimer available from www.spiritconsortium.org.
|
11
|
+
//
|
12
|
+
// This source file is provided on an AS IS basis. The SPIRIT
|
13
|
+
// Consortium disclaims any warranty express or implied including
|
14
|
+
// any warranty of merchantability and fitness for use for a
|
15
|
+
// particular purpose.
|
16
|
+
//
|
17
|
+
// The user of the source file shall indemnify and hold The SPIRIT
|
18
|
+
// Consortium and its members harmless from any damages or liability.
|
19
|
+
// Users are requested to provide feedback to The SPIRIT Consortium
|
20
|
+
// using either mailto:feedback@lists.spiritconsortium.org or the forms at
|
21
|
+
// http://www.spiritconsortium.org/about/contact_us/
|
22
|
+
//
|
23
|
+
// This file may be copied, and distributed, with or without
|
24
|
+
// modifications; but this notice must be included on any copy.
|
25
|
+
|
26
|
+
/*------------------------------------------------------------------------------
|
27
|
+
* Simple TLM processor
|
28
|
+
* Note: this is a dummy implementation of a Leon2 processor.
|
29
|
+
* One should read this model as a simple testbench generator.
|
30
|
+
*------------------------------------------------------------------------------*/
|
31
|
+
|
32
|
+
/*------------------------------------------------------------------------------
|
33
|
+
* Includes
|
34
|
+
*----------------------------------------------------------------------------*/
|
35
|
+
#include "processor.h"
|
36
|
+
#include <string>
|
37
|
+
#include <map>
|
38
|
+
#include <vector>
|
39
|
+
#include <sstream>
|
40
|
+
#include <stdlib.h>
|
41
|
+
#include <errno.h>
|
42
|
+
#include <unistd.h>
|
43
|
+
|
44
|
+
/*------------------------------------------------------------------------------
|
45
|
+
* Methods
|
46
|
+
*----------------------------------------------------------------------------*/
|
47
|
+
processor::processor( sc_module_name module_name , char* tb_file_name) :
|
48
|
+
sc_module( module_name ),
|
49
|
+
pv_slave_base<ADDRESS_TYPE,DATA_TYPE>(name()),
|
50
|
+
apb_slave_port("apb_slave_port"),
|
51
|
+
ahb_master_port ("ahb_master_port"),
|
52
|
+
irl_port ("irl_port"),
|
53
|
+
irqvec_port ("irq_port"),
|
54
|
+
intack_port ("ack_port"),
|
55
|
+
clk ("clk"),
|
56
|
+
rst_an ("rst_an"),
|
57
|
+
cmdIndex_(0),
|
58
|
+
enableInterrupt_(true)
|
59
|
+
{
|
60
|
+
apb_slave_port( *this );
|
61
|
+
init_local_memory();
|
62
|
+
SC_THREAD( ahbMaster );
|
63
|
+
sensitive << clk;
|
64
|
+
SC_METHOD( restart );
|
65
|
+
sensitive << rst_an;
|
66
|
+
SC_METHOD( catch_it );
|
67
|
+
dont_initialize();
|
68
|
+
sensitive << irl_port;
|
69
|
+
read_testbench_file(tb_file_name);
|
70
|
+
cout << "-----------------------------" << endl;
|
71
|
+
cout << "Elaborating" << endl;
|
72
|
+
cout << "-----------------------------" << endl;
|
73
|
+
intack_port.initialize(0);
|
74
|
+
irqvec_port.initialize(0x0);
|
75
|
+
}
|
76
|
+
|
77
|
+
processor::~processor() {
|
78
|
+
cout << "-----------------------------" << endl;
|
79
|
+
cout << "Simulation done" << endl;
|
80
|
+
cout << "-----------------------------" << endl;
|
81
|
+
}
|
82
|
+
|
83
|
+
void processor::end_of_elaboration() {
|
84
|
+
cout << name() << " constructed." << endl;
|
85
|
+
}
|
86
|
+
|
87
|
+
// the big statemachine (simplified compared to RTL)
|
88
|
+
void processor::ahbMaster() {
|
89
|
+
tlm::tlm_status status;
|
90
|
+
tb_cmd_t trans;
|
91
|
+
int mask;
|
92
|
+
DATA_TYPE localData;
|
93
|
+
DATA_TYPE data;
|
94
|
+
|
95
|
+
while (true) {
|
96
|
+
// while (cmdIndex_ < numTbCmds_) {
|
97
|
+
while (rst_an.read() == false) {
|
98
|
+
wait();
|
99
|
+
}
|
100
|
+
|
101
|
+
while (cmdIndex_ == numTbCmds_)
|
102
|
+
wait();
|
103
|
+
|
104
|
+
if (cmdIndex_ == 0 ) {
|
105
|
+
cout << "-----------------------------" << endl;
|
106
|
+
cout << "Ready to start the simulation" << endl;
|
107
|
+
cout << "-----------------------------" << endl;
|
108
|
+
}
|
109
|
+
|
110
|
+
// get next command
|
111
|
+
trans = tbData_[cmdIndex_];
|
112
|
+
cmdIndex_++;
|
113
|
+
// generate transactions based on command
|
114
|
+
switch (trans.cmd) {
|
115
|
+
case IDLE:
|
116
|
+
for (int j=0; j<trans.idle and rst_an.read(); j++) {
|
117
|
+
wait();
|
118
|
+
while (clk.read() != SC_LOGIC_1)
|
119
|
+
wait();
|
120
|
+
}
|
121
|
+
cout << "[" << name() << "]: stayed IDLE for : "
|
122
|
+
<< std::dec << trans.idle << " clock cycles"
|
123
|
+
<< "\tAt time " << sc_time_stamp() << endl;
|
124
|
+
break;
|
125
|
+
case READ:
|
126
|
+
if ((trans.addr >= PROC_LOCALMEMORY_BASE_ADDR) &&
|
127
|
+
(trans.addr < (PROC_LOCALMEMORY_BASE_ADDR + PROC_LOCALMEMORY_SIZE))) {
|
128
|
+
// internal read
|
129
|
+
localData = local_memory[trans.addr-PROC_LOCALMEMORY_BASE_ADDR]; // & trans.mask;
|
130
|
+
// display vaue read
|
131
|
+
cout << "[" << name() << "]: local memory READ data : "
|
132
|
+
<< std::showbase << std::hex << localData
|
133
|
+
<< " from address \t" << std::showbase << std::hex << trans.addr
|
134
|
+
<< "\tAt time " << sc_time_stamp() << endl;
|
135
|
+
// check vs expected vaue
|
136
|
+
if (trans.data!=localData) {
|
137
|
+
cout << "WARNING: expected data value " << std::showbase << std::hex << trans.data << endl;
|
138
|
+
}
|
139
|
+
} else {
|
140
|
+
status = ahb_master_port.read(trans.addr, data);
|
141
|
+
if (status.is_ok()) {
|
142
|
+
// display value read
|
143
|
+
cout << "[" << name() << "]: external READ data : "
|
144
|
+
<< std::showbase << std::hex << data
|
145
|
+
<< " from address \t" << std::showbase << std::hex << trans.addr
|
146
|
+
<< "\tAt time " << sc_time_stamp() << endl;
|
147
|
+
// check vs expected vaue
|
148
|
+
if ((trans.data & trans.mask) != (data & trans.mask)) {
|
149
|
+
cout << "WARNING: expected data value " << std::showbase << std::hex << trans.data << endl;
|
150
|
+
}
|
151
|
+
}
|
152
|
+
else {
|
153
|
+
cout << "[" << name() << "]: external READ returned ERROR expected data : "
|
154
|
+
<< std::showbase << std::hex << trans.data
|
155
|
+
<< " from address \t" << std::showbase << std::hex << trans.addr
|
156
|
+
<< "\tAt time " << sc_time_stamp() << endl;
|
157
|
+
}
|
158
|
+
}
|
159
|
+
break;
|
160
|
+
case WRITE:
|
161
|
+
if ((trans.addr >= PROC_LOCALMEMORY_BASE_ADDR) &&
|
162
|
+
(trans.addr < (PROC_LOCALMEMORY_BASE_ADDR + PROC_LOCALMEMORY_SIZE))) {
|
163
|
+
// internal write
|
164
|
+
local_memory[trans.addr-PROC_LOCALMEMORY_BASE_ADDR] = trans.data;
|
165
|
+
// display value written
|
166
|
+
cout << "[" << name() << "]: local memory WRITE data : "
|
167
|
+
<< std::showbase << std::hex << trans.data
|
168
|
+
<< " at address \t" << std::showbase << std::hex << trans.addr
|
169
|
+
<< "\tAt time " << sc_time_stamp() << endl;
|
170
|
+
} else {
|
171
|
+
// external write
|
172
|
+
status = ahb_master_port.write(trans.addr, trans.data);
|
173
|
+
if (status.is_ok()) {
|
174
|
+
// display value written
|
175
|
+
cout << "[" << name() << "]: external WRITE data : "
|
176
|
+
<< std::showbase << std::hex << trans.data
|
177
|
+
<< " to address \t" << std::showbase << std::hex << trans.addr
|
178
|
+
<< "\tAt time " << sc_time_stamp() << endl;
|
179
|
+
}
|
180
|
+
else {
|
181
|
+
cout << "[" << name() << "]: external WRITE returned ERROR expected data : "
|
182
|
+
<< std::showbase << std::hex << trans.data
|
183
|
+
<< " to address \t" << std::showbase << std::hex << trans.addr
|
184
|
+
<< "\tAt time " << sc_time_stamp() << endl;
|
185
|
+
}
|
186
|
+
|
187
|
+
}
|
188
|
+
break;
|
189
|
+
case END:
|
190
|
+
cout << "[" << name() << "]: Table Finished "
|
191
|
+
<< "\tAt time " << sc_time_stamp() << endl;
|
192
|
+
break;
|
193
|
+
default:
|
194
|
+
cout << "[" << name() << "]: WARNING Skiping Unknown command" << endl;
|
195
|
+
break;
|
196
|
+
}
|
197
|
+
wait(); // next edge
|
198
|
+
while (clk.read() != SC_LOGIC_1) // wait if not rising
|
199
|
+
wait();
|
200
|
+
}
|
201
|
+
}
|
202
|
+
|
203
|
+
// Watch for a reset
|
204
|
+
void processor::restart() {
|
205
|
+
|
206
|
+
if (!rst_an.read()) {
|
207
|
+
cout << name() << " Reset" << "\tAt time " << sc_time_stamp() << endl;
|
208
|
+
cmdIndex_ = 0;
|
209
|
+
}
|
210
|
+
}
|
211
|
+
|
212
|
+
|
213
|
+
// Handle slave port write requests
|
214
|
+
tlm::tlm_status processor::write( const ADDRESS_TYPE &addr , const DATA_TYPE &data,
|
215
|
+
const unsigned int byte_enable,
|
216
|
+
const tlm::tlm_mode mode,
|
217
|
+
const unsigned int export_id)
|
218
|
+
{
|
219
|
+
tlm::tlm_status status;
|
220
|
+
if ((addr < PROC_BASE_ADDR) || (addr >= PROC_BASE_ADDR+PROC_SIZE)) {
|
221
|
+
cout << "ERROR\t" << name() << " : trying to write out of bounds at address " << addr << endl;
|
222
|
+
status.set_error();
|
223
|
+
return status;
|
224
|
+
}
|
225
|
+
// APB write. for now only effect is to reset the interrupt
|
226
|
+
//enableInterrupt_ = !enableInterrupt_;
|
227
|
+
//cout << name() << " : interrupts enable = " << enableInterrupt_ << endl;
|
228
|
+
apb_memory[addr & PROC_SIZE] = data;
|
229
|
+
|
230
|
+
status.set_ok();
|
231
|
+
return status;
|
232
|
+
}
|
233
|
+
|
234
|
+
// Handle slave port read requests
|
235
|
+
tlm::tlm_status processor::read( const ADDRESS_TYPE &addr , DATA_TYPE &data,
|
236
|
+
const unsigned int byte_enable,
|
237
|
+
const tlm::tlm_mode mode,
|
238
|
+
const unsigned int export_id)
|
239
|
+
{
|
240
|
+
tlm::tlm_status status;
|
241
|
+
if ((addr < PROC_BASE_ADDR) || (addr >= PROC_BASE_ADDR+PROC_SIZE)) {
|
242
|
+
cout << "ERROR\t" << name() << " : trying to read out of bounds at address " << addr << endl;
|
243
|
+
status.set_error();
|
244
|
+
return status;
|
245
|
+
}
|
246
|
+
data = apb_memory[addr & PROC_SIZE];
|
247
|
+
|
248
|
+
status.set_ok();
|
249
|
+
return status;
|
250
|
+
}
|
251
|
+
|
252
|
+
// Handle interrupt requests
|
253
|
+
void processor::catch_it() {
|
254
|
+
// decode interrupt signal
|
255
|
+
irqvec_port.write(irl_port.read());
|
256
|
+
|
257
|
+
if (enableInterrupt_ && irl_port.read() != 0) {
|
258
|
+
cout << name() << " Got interrupt. Send ack and reset SubSystem Interrupt register" << endl;
|
259
|
+
intack_port.write(1);
|
260
|
+
}
|
261
|
+
if (!enableInterrupt_ || irl_port.read() == 0) {
|
262
|
+
// cout << name() << " intack low" << endl;
|
263
|
+
intack_port.write(0);
|
264
|
+
}
|
265
|
+
}
|
266
|
+
|
267
|
+
// Initialize local memory
|
268
|
+
void processor::init_local_memory()
|
269
|
+
{
|
270
|
+
for (unsigned long i=0; i < PROC_LOCALMEMORY_SIZE; i++) local_memory[i]=0;
|
271
|
+
for (unsigned long i=0; i < PROC_SIZE; i++) apb_memory[i]=0;
|
272
|
+
}
|
273
|
+
|
274
|
+
// the file name should have the .tbl extension
|
275
|
+
// the file format is (
|
276
|
+
// R Address Data <MASK>
|
277
|
+
// W Address Data
|
278
|
+
// I Clocks
|
279
|
+
// Note: address and data values in HEX comments start with --
|
280
|
+
void processor::read_testbench_file( const char *file_name ) {
|
281
|
+
ifstream fd ( file_name );
|
282
|
+
std::string line;
|
283
|
+
std::string token, token2;
|
284
|
+
if ( ! fd.is_open() ) {
|
285
|
+
cout << "[" << name() << "]: ERROR Cannot open file " << file_name << endl;
|
286
|
+
return;
|
287
|
+
}
|
288
|
+
int i=0;
|
289
|
+
while( !fd.eof() ) {
|
290
|
+
getline(fd ,line) ;
|
291
|
+
std::istringstream iss(line);
|
292
|
+
token = "";
|
293
|
+
iss>>token;
|
294
|
+
if (token=="" || (token[0]=='-' && token[1]=='-')) continue;
|
295
|
+
switch (token[0]) {
|
296
|
+
case 'R' :
|
297
|
+
tbData_[i].cmd = READ;
|
298
|
+
tbData_[i].cmdname = 'R';
|
299
|
+
iss >> token2; tbData_[i].addr = std::strtol(token2.c_str(),0,16);
|
300
|
+
iss >> token2; tbData_[i].data = std::strtol(token2.c_str(),0,16);
|
301
|
+
iss >> token2;
|
302
|
+
if (token2=="" || token2=="--" ) {
|
303
|
+
tbData_[i].mask = std::strtol("FFFFFFFF",0,16);
|
304
|
+
} else {
|
305
|
+
tbData_[i].mask = std::strtol(token2.c_str(),0,16);
|
306
|
+
}
|
307
|
+
i++;
|
308
|
+
break;
|
309
|
+
case 'W' :
|
310
|
+
tbData_[i].cmd = WRITE;
|
311
|
+
tbData_[i].cmdname = 'W';
|
312
|
+
iss >> token2; tbData_[i].addr = std::strtol(token2.c_str(),0,16);
|
313
|
+
iss >> token2; tbData_[i].data = std::strtol(token2.c_str(),0,16);
|
314
|
+
i++;
|
315
|
+
break;
|
316
|
+
case 'I' :
|
317
|
+
tbData_[i].cmd = IDLE;
|
318
|
+
tbData_[i].cmdname = 'I';
|
319
|
+
iss >> token2; tbData_[i].idle = std::strtol(token2.c_str(),0,10);
|
320
|
+
i++;
|
321
|
+
break;
|
322
|
+
case '-' :
|
323
|
+
tbData_[i].cmd = COMMENT;
|
324
|
+
tbData_[i].cmdname = 'C';
|
325
|
+
i++;
|
326
|
+
break;
|
327
|
+
}
|
328
|
+
}
|
329
|
+
tbData_[i++].cmd = END;
|
330
|
+
numTbCmds_ = i;
|
331
|
+
}
|
@@ -0,0 +1,121 @@
|
|
1
|
+
//
|
2
|
+
// Revision: $Revision: 1506 $
|
3
|
+
// Date: $Date: 2009-04-26 01:51:56 -0500 (Sun, 26 Apr 2009) $
|
4
|
+
//
|
5
|
+
// Copyright (c) 2005, 2006, 2007, 2008, 2009 The SPIRIT Consortium.
|
6
|
+
//
|
7
|
+
// This work forms part of a deliverable of The SPIRIT Consortium.
|
8
|
+
//
|
9
|
+
// Use of these materials are governed by the legal terms and conditions
|
10
|
+
// outlined in the disclaimer available from www.spiritconsortium.org.
|
11
|
+
//
|
12
|
+
// This source file is provided on an AS IS basis. The SPIRIT
|
13
|
+
// Consortium disclaims any warranty express or implied including
|
14
|
+
// any warranty of merchantability and fitness for use for a
|
15
|
+
// particular purpose.
|
16
|
+
//
|
17
|
+
// The user of the source file shall indemnify and hold The SPIRIT
|
18
|
+
// Consortium and its members harmless from any damages or liability.
|
19
|
+
// Users are requested to provide feedback to The SPIRIT Consortium
|
20
|
+
// using either mailto:feedback@lists.spiritconsortium.org or the forms at
|
21
|
+
// http://www.spiritconsortium.org/about/contact_us/
|
22
|
+
//
|
23
|
+
// This file may be copied, and distributed, with or without
|
24
|
+
// modifications; but this notice must be included on any copy.
|
25
|
+
|
26
|
+
/*------------------------------------------------------------------------------
|
27
|
+
* Simple TLM processor
|
28
|
+
* Note: this is a dummy implementation of a Leon2 processor.
|
29
|
+
* One should read this model as a simple testbench generator.
|
30
|
+
*------------------------------------------------------------------------------*/
|
31
|
+
|
32
|
+
#ifndef _PROCESSOR_H_
|
33
|
+
#define _PROCESSOR_H_
|
34
|
+
|
35
|
+
/*------------------------------------------------------------------------------
|
36
|
+
* Includes
|
37
|
+
*----------------------------------------------------------------------------*/
|
38
|
+
#include <systemc.h>
|
39
|
+
#include <string.h>
|
40
|
+
|
41
|
+
#include "pv_slave_base.h"
|
42
|
+
#include "pv_target_port.h"
|
43
|
+
#include "pv_initiator_port.h"
|
44
|
+
#include "user_types.h"
|
45
|
+
|
46
|
+
/*------------------------------------------------------------------------------
|
47
|
+
* Define device parameters (for APB slave)
|
48
|
+
*----------------------------------------------------------------------------*/
|
49
|
+
#define PROC_BASE_ADDR 0x0000 // in global systems, start at: 0x30006000
|
50
|
+
#define PROC_SIZE 0x1000 // 4Kb
|
51
|
+
/*------------------------------------------------------------------------------
|
52
|
+
* Define device parameters (for local memory)
|
53
|
+
*----------------------------------------------------------------------------*/
|
54
|
+
#define PROC_LOCALMEMORY_BASE_ADDR 0x10000000
|
55
|
+
#define PROC_LOCALMEMORY_SIZE 0x1000 // 4Kb
|
56
|
+
|
57
|
+
//#define LOCALMEMORYADDR 0x10000000
|
58
|
+
//#define LOCALMEMORYBITS 4 // number of address bits
|
59
|
+
//#define LOCALMEMORYSIZE 16 // number of memory locations
|
60
|
+
/*------------------------------------------------------------------------------
|
61
|
+
* testbench processor
|
62
|
+
*----------------------------------------------------------------------------*/
|
63
|
+
|
64
|
+
// the processor class
|
65
|
+
class processor :
|
66
|
+
public sc_module,
|
67
|
+
public pv_slave_base< ADDRESS_TYPE , DATA_TYPE >
|
68
|
+
{
|
69
|
+
public:
|
70
|
+
SC_HAS_PROCESS( processor );
|
71
|
+
processor( sc_module_name module_name , char* tb_file_name);
|
72
|
+
~processor();
|
73
|
+
|
74
|
+
// ports
|
75
|
+
pv_target_port<ADDRESS_TYPE,DATA_TYPE> apb_slave_port;
|
76
|
+
pv_initiator_port<ADDRESS_TYPE,DATA_TYPE> ahb_master_port;
|
77
|
+
sc_in<sc_logic> clk;
|
78
|
+
sc_in<bool> rst_an;
|
79
|
+
sc_in<int> irl_port;
|
80
|
+
sc_out<int> irqvec_port;
|
81
|
+
sc_out<bool> intack_port;
|
82
|
+
|
83
|
+
// APB slave
|
84
|
+
tlm::tlm_status write( const ADDRESS_TYPE &addr , const DATA_TYPE &data,
|
85
|
+
const unsigned int byte_enable = tlm::NO_BE,
|
86
|
+
const tlm::tlm_mode mode = tlm::REGULAR,
|
87
|
+
const unsigned int export_id = 0 );
|
88
|
+
tlm::tlm_status read( const ADDRESS_TYPE &addr , DATA_TYPE &data,
|
89
|
+
const unsigned int byte_enable = tlm::NO_BE,
|
90
|
+
const tlm::tlm_mode mode = tlm::REGULAR,
|
91
|
+
const unsigned int export_id = 0 );
|
92
|
+
|
93
|
+
private:
|
94
|
+
void ahbMaster();
|
95
|
+
void restart();
|
96
|
+
void catch_it();
|
97
|
+
void read_testbench_file(const char* fileName);
|
98
|
+
void end_of_elaboration();
|
99
|
+
void init_local_memory();
|
100
|
+
|
101
|
+
typedef enum {READ, WRITE, IDLE, COMMENT, END} cmd_t;
|
102
|
+
typedef struct {
|
103
|
+
cmd_t cmd;
|
104
|
+
char cmdname;
|
105
|
+
unsigned long addr;
|
106
|
+
unsigned int idle;
|
107
|
+
unsigned long data;
|
108
|
+
unsigned long mask;
|
109
|
+
char* comment;
|
110
|
+
} tb_cmd_t;
|
111
|
+
|
112
|
+
sc_pvector<DATA_TYPE> local_memory;
|
113
|
+
sc_pvector<DATA_TYPE> apb_memory;
|
114
|
+
sc_pvector<tb_cmd_t> tbData_;
|
115
|
+
int numTbCmds_;
|
116
|
+
int cmdIndex_;
|
117
|
+
bool enableInterrupt_;
|
118
|
+
};
|
119
|
+
|
120
|
+
|
121
|
+
#endif /* _PROCESSOR_H_ */
|