source: latest/src/sc_main.cc @ 1

Last change on this file since 1 was 1, checked in by buchmann, 17 years ago

Initial import from CVS repository

File size: 10.9 KB
Line 
1/*------------------------------------------------------------\
2|                                                             |
3| Tool    :                  systemcass                       |
4|                                                             |
5| File    :                   sc_main.cc                      |
6|                                                             |
7| Author  :                 Buchmann Richard                  |
8|                           Taktak Sami                       |
9|                                                             |
10| Date    :                   09_07_2004                      |
11|                                                             |
12\------------------------------------------------------------*/
13
14/*
15 * This file is part of the Disydent Project
16 * Copyright (C) Laboratoire UPMC/LIP6
17 * Universite Pierre et Marie Curie
18 *
19 * Home page          : http://www-asim.lip6.fr/disydent
20 * E-mail             : mailto:richard.buchmann@lip6.fr
21 *
22 * This library is free software; you  can redistribute it and/or modify it
23 * under the terms  of the GNU Library General Public  License as published
24 * by the Free Software Foundation; either version 2 of the License, or (at
25 * your option) any later version.
26 *
27 * Disydent is distributed  in the hope  that it  will be
28 * useful, but WITHOUT  ANY WARRANTY; without even the  implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
30 * Public License for more details.
31 *
32 * You should have received a copy  of the GNU General Public License along
33 * with the GNU C Library; see the  file COPYING. If not, write to the Free
34 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
35 */
36
37#include<sstream>
38#include<string>
39#include<list>
40#include<set>
41#include"internal.h"
42#include"global_functions.h"
43#include"sc_ver.h"
44#include"sc_module.h"
45#include"sc_signal.h" // pending_write_vector
46#include"dump_dot.h"
47#include"dump_used_options.h"
48#include"dump_used_env.h"
49#include"assert.h"
50
51//
52using namespace std;
53//
54typedef list<sc_module* >         module_list_t;
55
56//
57namespace sc_core {
58
59bool        check_port_dependencies = false;
60bool        dynamic_link_of_scheduling_code = true;
61bool        dump_netlist_info       = false;
62bool        dump_funclist_info      = false;
63bool        dump_stage              = false;
64bool        dump_all_graph          = false;
65const char* dump_module_hierarchy   = NULL;
66bool        edit_schedule           = false;
67bool        keep_generated_code     = false;
68bool        nobanner                = false;
69bool        noinitialization        = false;
70bool        nosimulation            = false;
71bool        notrace                 = false;
72bool        print_schedule          = false;
73bool        print_user_resources    = false;
74char*       save_on_exit            = NULL;
75int         scheduling_method       = NO_SCHEDULING;
76bool        use_sensitivity_list    = false;
77bool        use_port_dependency     = false;
78
79static
80void 
81print_splash_screen ()
82{
83  // Display once
84  if (nobanner == false)
85        cerr << get_splash_screen ();
86  nobanner = true;
87}
88
89static
90void
91check_parameters ()
92{
93  if (dump_all_graph) {
94    if (use_port_dependency)
95      cerr << "SystemCASS will dump signal dependency graph.\n";
96    else
97      cerr << "SystemCASS will dump module dependency graph.\n";
98  }
99  if (!use_port_dependency && check_port_dependencies)
100    cerr << "Warning : unable to check port dependencies.\n";
101  if (!use_port_dependency)
102  {
103    use_sensitivity_list = true;
104    scheduling_method = CASS_SCHEDULING;
105  }
106  switch (scheduling_method) {
107  case CASS_SCHEDULING :
108    ASSERT(use_port_dependency == false);
109    break;
110  case BUCHMANN_SCHEDULING :
111  case MOUCHARD_SCHEDULING :
112    if (!use_port_dependency) {
113    cerr << "Error : "
114            "The choosen scheduling needs port dependencies informations\n";
115    exit (31);
116    }
117    break;
118  default :
119    cerr << "Error : You need to choose one of the available scheduling :\n"
120         << "- Almost static scheduling like CASS (use sensitivity list)\n"
121         << "- Simple static scheduling (use port dependencies)\n"
122         << "- Entirely static scheduling (use port dependencies)\n";
123    exit (33);
124  }
125  ASSERT(use_port_dependency || use_sensitivity_list);
126}
127
128void
129apply_parameters (int &argc, char ** &argv)
130{
131#ifdef KEEP_GENERATED_CODE // supprimer scheduling-XXXXXX.cc
132  keep_generated_code = true;
133#endif
134#ifdef DUMP_NETLIST_INFO
135  dump_netlist_info = true;
136#endif
137#ifdef DUMP_FUNCLIST_INFO
138  dump_funclist_info = true;
139#endif
140#ifdef DUMP_STAGE
141  dump_stage = true;
142#endif
143#ifdef DUMP_COMBINATIONAL_LIST2DOT
144  dump_all_graph = true;
145#endif
146#ifdef PRINT_SCHEDULE
147  print_schedule = true;
148#endif   
149#ifdef USE_PORT_DEPENDENCY
150  use_port_dependency = true;
151#endif
152  // parse the command line
153  int i;
154  for (i = 1; i < argc; ++i)
155    {
156    if (argv[i][0] == '-')
157      {
158      if (argv[i][1] == '-')
159        {
160        switch (argv[i][2])
161          {
162          case 'h' : 
163            print_splash_screen ();
164            cerr << "Usage : " 
165                 << argv[0] << " [--c] [--edit] [--d] [--f] [--h] [--i] [--k] [--modules filename] [--nobanner] [--nodynamiclink] [--nosim] [--notrace] [--s] [--t] [--tracestart n] [--usage] [--v] [--p|m|a] [others parameters processed by sc_main]\n"
166                 << "Thoses options are processed by SystemCASS library. All the remaining options are passed to sc_main.\n"
167                 << "sc_main function retrieves last parameters.\n"
168                 << "a       : almost static scheduling (use sensitivity list instead of port dependency information)\n"
169                 << "c       : print schedule at simulation time (stderr)\n"
170                 << "d       : check port dependencies (stderr)\n"
171                 << "edit    : edit schedule before simulation (run $EDITOR or vim by default)\n"
172                 << "f       : print function list (stderr)\n"
173                 << "h       : display help screen and exit (stdout)\n"
174                 << "i       : print instances list, signals list and statistics if available (stderr)\n"
175                 << "k       : dump generated scheduling code (generated_by_systemcass/scheduling-xx.cc)\n"
176                 << "m       : Mouchard's static scheduling (use port dependency information instead of sensitivity list)\n"
177                 << "modules filename : dump module hierarchy graph into specified dot file (tons of bugs inside)\n"
178                 << "nobanner: do not print SystemCASS splash screen\n"
179                 << "nodynamiclink: do not link dynamically scheduling code\n"
180                 << "nosim   : run until elaboration stage. Don't simulate\n"
181                 << "notrace : disable all tracing functions\n"
182                 << "p       : entirely static scheduling (use port dependency information instead of sensitivity list)\n"
183                 << "s       : print stage (stderr)\n"
184                 << "save_on_exit <name> : save simulation state saved into <name> file when SystemCASS exits (SOCVIEW format)\n"
185            /* WARNING : we can't avoid destructors execution before saving */
186                 << "t       : dump either module graph, or signal dependency graph, signal order, and module evalutation order into dot files\n"
187                 << "tracestart n : start tracing functions at #n cycle\n"
188                 << "usage   : print user time elapsed (sec), simulation cycles done (cycles), and simulator performance (cycles/second) (stderr)\n"
189                 << "v       : print internal SystemCASS kernel options (stderr)\n";
190            noinitialization = true;
191            nosimulation = true;
192            continue;
193          case 'v' : 
194            print_splash_screen ();
195            cerr << get_used_options  () << "\n";
196            cerr << get_used_env () << "\n";
197            continue;
198          case 'u' : 
199            if (strcmp (argv[i]+2, "usage") == 0)
200              print_user_resources = true;
201            else
202              break;
203            continue;
204          case 'i' :
205            dump_netlist_info = true;
206            continue;
207          case 'f' :
208            dump_funclist_info = true;
209            continue;
210          case 's' :
211            if (strcmp (argv[i]+2, "save_on_exit") == 0)
212              save_on_exit = argv[++i];
213            else
214              dump_stage = true;
215            continue;
216          case 'c' :
217            print_schedule = true;
218            continue;
219          case 'e' :
220            if (strcmp (argv[i]+2, "edit") == 0)
221              edit_schedule = true;
222            else
223              break;
224            continue;
225          case 'k' :
226            keep_generated_code = true;
227            continue;
228          case 't' :
229            if (strcmp (argv[i]+2, "tracestart") == 0) {
230              ++i;
231              istringstream iss (argv[i]);
232              iss >> trace_start;
233              trace_start <<= 1;
234//              trace_start = strtoll (argv[i],0,10) << 1;
235//              trace_start = atoll (argv[i]) << 1;
236            } else {
237              dump_all_graph = true;
238            }
239            continue;
240          case 'm' :
241            if (strcmp (argv[i]+2, "modules") == 0) {
242              ++i;
243              dump_module_hierarchy = argv[i];
244              continue;
245            } else if (strcmp (argv[i]+2, "m") == 0) {
246              use_port_dependency = true;
247              scheduling_method = MOUCHARD_SCHEDULING;
248              continue;
249            }
250            break;
251          case 'n' :
252            if (strcmp (argv[i]+2, "nobanner") == 0) {
253              nobanner = true;
254            } else if (strcmp (argv[i]+2, "nodynamiclink") == 0) {
255              dynamic_link_of_scheduling_code = false;
256            } else if (strcmp (argv[i]+2, "nosim") == 0) {
257              nosimulation = true;
258            } else if (strcmp (argv[i]+2, "notrace") == 0) {
259              notrace = true;
260            } else
261              break;
262            continue;
263          case 'a' :
264            use_sensitivity_list = true;
265            scheduling_method = CASS_SCHEDULING;
266            continue;
267          case 'p' :
268            use_port_dependency = true;
269            scheduling_method = BUCHMANN_SCHEDULING;
270            continue;
271          case 'd' :
272            check_port_dependencies = true;
273            continue;
274          default :
275            break;
276          }
277        break;
278        }
279      } 
280      break;
281    }
282 
283  // erase SystemCASS options from the command line and give it to the sc_main
284  if (i != 1)
285    {
286    int j = 1;
287    while (i < argc)
288      {
289      argv[j++] = argv[i++];
290      }
291    argc = j;
292    }
293#if 0
294  cerr << "The user command line length is " << argc << ".\n";
295#endif
296}
297
298
299} // end of namespace
300
301using namespace sc_core;
302
303int 
304main(int   argc, 
305     char* argv[])
306{
307  apply_parameters    (argc, argv);
308  print_splash_screen ();
309  check_parameters ();
310  if (noinitialization)
311  {
312    return 255;
313  }
314  int ret = sc_main(argc, argv);
315        free (pending_write_vector);
316  close_systemcass ();
317  if (have_to_stop)
318  {
319    cerr << "'sc_stop' function was called. Exit code : 1\n";
320    return 1;
321  }
322  return ret;
323}
324
Note: See TracBrowser for help on using the repository browser.