source: branches/with_autoconf/src/sc_main.cc @ 8

Last change on this file since 8 was 8, checked in by nipo, 16 years ago

Checkin autotools magic

File size: 11.1 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 <cassert>
50#ifdef HAVE_CONFIG_H
51#include "config.h"
52#endif
53
54//
55using namespace std;
56using namespace sc_core;
57//
58typedef list<sc_module* >         module_list_t;
59
60//
61namespace sc_core {
62
63bool        check_port_dependencies = false;
64#ifdef CONFIG_DEFAULT_RUNTIME_COMPILATION
65bool        dynamic_link_of_scheduling_code = true;
66#else
67bool        dynamic_link_of_scheduling_code = false;
68#endif
69bool        dump_netlist_info       = false;
70bool        dump_funclist_info      = false;
71bool        dump_stage              = false;
72bool        dump_all_graph          = false;
73const char* dump_module_hierarchy   = NULL;
74bool        edit_schedule           = false;
75bool        keep_generated_code     = false;
76bool        nobanner                = false;
77bool        noinitialization        = false;
78bool        nosimulation            = false;
79bool        notrace                 = false;
80bool        print_schedule          = false;
81bool        print_user_resources    = false;
82char*       save_on_exit            = NULL;
83int         scheduling_method       = NO_SCHEDULING;
84bool        use_sensitivity_list    = false;
85bool        use_port_dependency     = false;
86
87static
88void 
89print_splash_screen ()
90{
91  // Display once
92  if (nobanner == false)
93        cerr << get_splash_screen ();
94  nobanner = true;
95}
96
97static
98void
99check_parameters ()
100{
101  if (dump_all_graph) {
102    if (use_port_dependency)
103      cerr << "SystemCASS will dump signal dependency graph.\n";
104    else
105      cerr << "SystemCASS will dump module dependency graph.\n";
106  }
107  if (!use_port_dependency && check_port_dependencies)
108    cerr << "Warning : unable to check port dependencies.\n";
109  if (!use_port_dependency)
110  {
111    use_sensitivity_list = true;
112    scheduling_method = CASS_SCHEDULING;
113  }
114  switch (scheduling_method) {
115  case CASS_SCHEDULING :
116    assert(use_port_dependency == false);
117    break;
118  case BUCHMANN_SCHEDULING :
119  case MOUCHARD_SCHEDULING :
120    if (!use_port_dependency) {
121    cerr << "Error : "
122            "The choosen scheduling needs port dependencies informations\n";
123    exit (31);
124    }
125    break;
126  default :
127    cerr << "Error : You need to choose one of the available scheduling :\n"
128         << "- Almost static scheduling like CASS (use sensitivity list)\n"
129         << "- Simple static scheduling (use port dependencies)\n"
130         << "- Entirely static scheduling (use port dependencies)\n";
131    exit (33);
132  }
133  assert(use_port_dependency || use_sensitivity_list);
134}
135
136void
137apply_parameters (int &argc, char ** &argv)
138{
139#ifdef KEEP_GENERATED_CODE // supprimer scheduling-XXXXXX.cc
140  keep_generated_code = true;
141#endif
142#ifdef DUMP_NETLIST_INFO
143  dump_netlist_info = true;
144#endif
145#ifdef DUMP_FUNCLIST_INFO
146  dump_funclist_info = true;
147#endif
148#ifdef DUMP_STAGE
149  dump_stage = true;
150#endif
151#ifdef DUMP_COMBINATIONAL_LIST2DOT
152  dump_all_graph = true;
153#endif
154#ifdef PRINT_SCHEDULE
155  print_schedule = true;
156#endif   
157#ifdef USE_PORT_DEPENDENCY
158  use_port_dependency = true;
159#endif
160  // parse the command line
161  int i;
162  for (i = 1; i < argc; ++i)
163    {
164    if (argv[i][0] == '-')
165      {
166      if (argv[i][1] == '-')
167        {
168        switch (argv[i][2])
169          {
170          case 'h' : 
171            print_splash_screen ();
172            cerr << "Usage : " 
173                 << 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"
174                 << "Thoses options are processed by SystemCASS library. All the remaining options are passed to sc_main.\n"
175                 << "sc_main function retrieves last parameters.\n"
176                 << "a       : almost static scheduling (use sensitivity list instead of port dependency information)\n"
177                 << "c       : print schedule at simulation time (stderr)\n"
178                 << "d       : check port dependencies (stderr)\n"
179                 << "edit    : edit schedule before simulation (run $EDITOR or vim by default)\n"
180                 << "f       : print function list (stderr)\n"
181                 << "h       : display help screen and exit (stdout)\n"
182                 << "i       : print instances list, signals list and statistics if available (stderr)\n"
183                 << "k       : dump generated scheduling code (generated_by_systemcass/scheduling-xx.cc)\n"
184                 << "m       : Mouchard's static scheduling (use port dependency information instead of sensitivity list)\n"
185                 << "modules filename : dump module hierarchy graph into specified dot file (tons of bugs inside)\n"
186                 << "nobanner: do not print SystemCASS splash screen\n"
187                 << "nodynamiclink: do not link dynamically scheduling code\n"
188                 << "nosim   : run until elaboration stage. Don't simulate\n"
189                 << "notrace : disable all tracing functions\n"
190                 << "p       : entirely static scheduling (use port dependency information instead of sensitivity list)\n"
191                 << "s       : print stage (stderr)\n"
192                 << "save_on_exit <name> : save simulation state saved into <name> file when SystemCASS exits (SOCVIEW format)\n"
193            /* WARNING : we can't avoid destructors execution before saving */
194                 << "t       : dump either module graph, or signal dependency graph, signal order, and module evalutation order into dot files\n"
195                 << "tracestart n : start tracing functions at #n cycle\n"
196                 << "usage   : print user time elapsed (sec), simulation cycles done (cycles), and simulator performance (cycles/second) (stderr)\n"
197                 << "v       : print internal SystemCASS kernel options (stderr)\n";
198            noinitialization = true;
199            nosimulation = true;
200            continue;
201          case 'v' : 
202            print_splash_screen ();
203            cerr << get_used_options  () << "\n";
204            cerr << get_used_env () << "\n";
205            continue;
206          case 'u' : 
207            if (strcmp (argv[i]+2, "usage") == 0)
208              print_user_resources = true;
209            else
210              break;
211            continue;
212          case 'i' :
213            dump_netlist_info = true;
214            continue;
215          case 'f' :
216            dump_funclist_info = true;
217            continue;
218          case 's' :
219            if (strcmp (argv[i]+2, "save_on_exit") == 0)
220              save_on_exit = argv[++i];
221            else
222              dump_stage = true;
223            continue;
224          case 'c' :
225            print_schedule = true;
226            continue;
227          case 'e' :
228            if (strcmp (argv[i]+2, "edit") == 0)
229              edit_schedule = true;
230            else
231              break;
232            continue;
233          case 'k' :
234            keep_generated_code = true;
235            continue;
236          case 't' :
237            if (strcmp (argv[i]+2, "tracestart") == 0) {
238              ++i;
239              istringstream iss (argv[i]);
240              iss >> trace_start;
241              trace_start <<= 1;
242//              trace_start = strtoll (argv[i],0,10) << 1;
243//              trace_start = atoll (argv[i]) << 1;
244            } else {
245              dump_all_graph = true;
246            }
247            continue;
248          case 'm' :
249            if (strcmp (argv[i]+2, "modules") == 0) {
250              ++i;
251              dump_module_hierarchy = argv[i];
252              continue;
253            } else if (strcmp (argv[i]+2, "m") == 0) {
254              use_port_dependency = true;
255              scheduling_method = MOUCHARD_SCHEDULING;
256              continue;
257            }
258            break;
259          case 'n' :
260            if (strcmp (argv[i]+2, "nobanner") == 0) {
261              nobanner = true;
262            } else if (strcmp (argv[i]+2, "nodynamiclink") == 0) {
263              dynamic_link_of_scheduling_code = false;
264            } else if (strcmp (argv[i]+2, "nosim") == 0) {
265              nosimulation = true;
266            } else if (strcmp (argv[i]+2, "notrace") == 0) {
267              notrace = true;
268            } else
269              break;
270            continue;
271          case 'a' :
272            use_sensitivity_list = true;
273            scheduling_method = CASS_SCHEDULING;
274            continue;
275          case 'p' :
276            use_port_dependency = true;
277            scheduling_method = BUCHMANN_SCHEDULING;
278            continue;
279          case 'd' :
280            check_port_dependencies = true;
281            continue;
282          default :
283            break;
284          }
285        break;
286        }
287      } 
288      break;
289    }
290 
291  // erase SystemCASS options from the command line and give it to the sc_main
292  if (i != 1)
293    {
294    int j = 1;
295    while (i < argc)
296      {
297      argv[j++] = argv[i++];
298      }
299    argc = j;
300    }
301#if 0
302  cerr << "The user command line length is " << argc << ".\n";
303#endif
304}
305
306
307} // end of namespace
308
309using namespace sc_core;
310
311int 
312main(int   argc, 
313     char* argv[])
314{
315  apply_parameters    (argc, argv);
316  print_splash_screen ();
317  check_parameters ();
318  if (noinitialization)
319  {
320    return 255;
321  }
322  int ret = sc_main(argc, argv);
323        free (pending_write_vector);
324  close_systemcass ();
325  if (have_to_stop)
326  {
327    cerr << "'sc_stop' function was called. Exit code : 1\n";
328    return 1;
329  }
330  return ret;
331}
332
Note: See TracBrowser for help on using the repository browser.