ParaNut SystemC Model
A SystemC Model of the ParaNut architecture
paranutsystem.h
Go to the documentation of this file.
1 /*************************************************************************
2 
3  This file is part of the ParaNut project.
4 
5  Copyright (C) 2020 Alexander Bahle <alexander.bahle@hs-augsburg.de>
6  Hochschule Augsburg, University of Applied Sciences
7 
8  Description:
9  This is the top-level SystemC model of a complete ParaNut system including
10  the ParaNut itself, a Wishbone interconnect and the main memory.
11 
12  Redistribution and use in source and binary forms, with or without modification,
13  are permitted provided that the following conditions are met:
14 
15  1. Redistributions of source code must retain the above copyright notice, this
16  list of conditions and the following disclaimer.
17 
18  2. Redistributions in binary form must reproduce the above copyright notice,
19  this list of conditions and the following disclaimer in the documentation and/or
20  other materials provided with the distribution.
21 
22  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25  DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 
33  *************************************************************************/
34 
35 #ifndef _PARANUTSYSTEM_H
36 #define _PARANUTSYSTEM_H
37 
38 
41 
42 
43 #include "base.h"
44 #include "paranut-config.h"
45 #include "nut.h"
46 #include "memory.h"
47 #include "interconnect.h"
48 #include "remote_bitbang.h"
49 #include "jtag_dtm.h"
50 
51 
69 
70 
85 public:
86 
87  // TBD: Make signals private? Do we have a use case for leaving these public?
88  // **************** Signals *********************
91  sc_signal<bool> clk, reset;
92  sc_signal<bool> wb_stb, wb_cyc, wb_we, wb_ack, wb_err, wb_rty;
93  sc_signal<sc_uint<3> > wb_cti;
94  sc_signal<sc_uint<2> > wb_bte;
95  sc_signal<sc_uint<CFG_MEMU_BUSIF_WIDTH/8> > wb_sel;
96  sc_signal<sc_uint<32> > wb_adr;
97  sc_signal<sc_uint<CFG_MEMU_BUSIF_WIDTH> > wb_dat_w, wb_dat_r;
101  // Interrupt:
102  sc_signal<bool> ex_int[CFG_NUT_EX_INT];
103  // JTAG
104  sc_signal<bool> tck, tms, tdi, tdo;
106 
110 
121  MParaNutSystem(const int argc, char *argv[]);
126  ~MParaNutSystem();
128 
129 
130  // Functions...
133 
150  void AddSlave(TWord start_adr, size_t size, MPeripheral *slave) {interconnect->AddSlave (start_adr, size, slave);}
151  void AddSlave(TWord start_adr, size_t size,
152  sc_in_clk *wb_clk_i, sc_in<bool> *wb_rst_i, sc_in<bool> *wb_stb_i,
153  sc_in<bool> *wb_cyc_i, sc_in<bool> *wb_we_i, sc_in<sc_uint<3> > *wb_cti_i,
154  sc_in<sc_uint<2> > *wb_bte_i, sc_in<sc_uint<WB_PORT_SIZE/8> > *wb_sel_i,
155  sc_out<bool> *wb_ack_o, sc_out<bool> *wb_err_o, sc_out<bool> *wb_rty_o,
156  sc_in<sc_uint<32> > *wb_adr_i, sc_in<sc_uint<WB_PORT_SIZE> > *wb_dat_i,
157  sc_out<sc_uint<WB_PORT_SIZE> > *wb_dat_o)
158  {interconnect->AddSlave (start_adr, size, wb_clk_i, wb_rst_i, wb_stb_i, wb_cyc_i, wb_we_i,
159  wb_cti_i, wb_bte_i, wb_sel_i, wb_ack_o, wb_err_o, wb_rty_o, wb_adr_i, wb_dat_i, wb_dat_o);}
168  void AddInterrupt(TWord index, sc_out<bool> *port);
170 
173 
183  void Run ();
185 
188 
193  void Usage ();
200  void PrintConfig ();
202 
203 private:
204  MWBMemory *mmemory;
205  MInterconnect *interconnect;
206  MParanut *paranut;
207  sc_trace_file *tf; // trace file
208 
209  // Simulation debugging:
210  jtag_dtm_t *jtag_dtm;
211  remote_bitbang_t *rbb;
212 
213  // Configuration options
214  const char *cfg_elf_filename;
215  int cfg_dump_from, cfg_dump_to;
216  int cfg_perf_lvl = 0;
217  bool cfg_dump_VHDL, cfg_dump_signature;
218 
219 
220  void RunCycles (const int n = 1);
221  void SimHost ();
222 };
223 
225 
226 #endif // _PARANUTSYSTEM_H
Helpers, Makros and performance measuring Classes used in most ParaNut files.
Definition: interconnect.h:49
void AddSlave(TWord start_adr, size_t size, MPeripheral *slave)
Definition: interconnect.cpp:128
Complete ParaNut System ready for simulation.
Definition: paranutsystem.h:84
sc_signal< bool > tdi
Definition: paranutsystem.h:104
sc_signal< bool > wb_err
Definition: paranutsystem.h:92
sc_signal< bool > tms
Definition: paranutsystem.h:104
sc_signal< bool > wb_we
Definition: paranutsystem.h:92
sc_signal< bool > wb_cyc
Definition: paranutsystem.h:92
sc_signal< bool > wb_stb
Definition: paranutsystem.h:92
sc_signal< bool > wb_rty
Definition: paranutsystem.h:92
sc_signal< bool > tck
Definition: paranutsystem.h:104
sc_signal< sc_uint< 2 > > wb_bte
Definition: paranutsystem.h:94
sc_signal< sc_uint< CFG_MEMU_BUSIF_WIDTH > > wb_dat_r
Definition: paranutsystem.h:97
sc_signal< bool > wb_ack
Definition: paranutsystem.h:92
sc_signal< bool > tdo
Definition: paranutsystem.h:104
sc_signal< sc_uint< CFG_MEMU_BUSIF_WIDTH > > wb_dat_w
Definition: paranutsystem.h:97
sc_signal< sc_uint< 3 > > wb_cti
Definition: paranutsystem.h:93
sc_signal< bool > ex_int[CFG_NUT_EX_INT]
Definition: paranutsystem.h:102
sc_signal< bool > reset
Definition: paranutsystem.h:91
sc_signal< bool > clk
Definition: paranutsystem.h:91
sc_signal< sc_uint< 32 > > wb_adr
Definition: paranutsystem.h:96
sc_signal< sc_uint< CFG_MEMU_BUSIF_WIDTH/8 > > wb_sel
Definition: paranutsystem.h:95
Definition: nut.h:60
Class containing the interface for Wishbone slave peripherals.
Definition: paranut-peripheral.h:75
Simulation ready configurable Wishbone slave memory.
Definition: memory.h:159
Definition: remote_bitbang.h:41
#define CFG_NUT_EX_INT
Number of external interrupt lines.
Definition: paranut-config.h:125
#define CFG_MEMU_BUSIF_WIDTH
Busif Data Width.
Definition: paranut-config.h:228
unsigned TWord
Word type (32 Bit).
Definition: base.h:147
void Run()
Start the SystemC simulation and wait for the ParaNut to HALT.
Definition: paranutsystem.cpp:342
void PrintConfig()
Print the current configuration to stderr.
Definition: paranutsystem.cpp:89
~MParaNutSystem()
Destructor destroying all runtime objects.
Definition: paranutsystem.cpp:334
void AddSlave(TWord start_adr, size_t size, MPeripheral *slave)
Add a slave peripheral to the ParaNut System.
Definition: paranutsystem.h:150
void AddInterrupt(TWord index, sc_out< bool > *port)
Add a slave port to the ParaNut Systems internal interrupt input signals.
Definition: paranutsystem.cpp:82
void AddSlave(TWord start_adr, size_t size, sc_in_clk *wb_clk_i, sc_in< bool > *wb_rst_i, sc_in< bool > *wb_stb_i, sc_in< bool > *wb_cyc_i, sc_in< bool > *wb_we_i, sc_in< sc_uint< 3 > > *wb_cti_i, sc_in< sc_uint< 2 > > *wb_bte_i, sc_in< sc_uint< WB_PORT_SIZE/8 > > *wb_sel_i, sc_out< bool > *wb_ack_o, sc_out< bool > *wb_err_o, sc_out< bool > *wb_rty_o, sc_in< sc_uint< 32 > > *wb_adr_i, sc_in< sc_uint< WB_PORT_SIZE > > *wb_dat_i, sc_out< sc_uint< WB_PORT_SIZE > > *wb_dat_o)
Definition: paranutsystem.h:151
void Usage()
Print usage of the command line options to stdout.
Definition: paranutsystem.cpp:66
MParaNutSystem(const int argc, char *argv[])
Create and elablorate the System.
Definition: paranutsystem.cpp:152
Configuration Makros used in most ParaNut files.