source: sources/src/sc_main.cc @ 40

Last change on this file since 40 was 38, checked in by buchmann, 15 years ago

Now detects if SystemCASS correctly handles runtime compilation with the current architecture. SystemCASS exits if runtime compilation is not supported. Use --nodynamiclink options if it exits. This may occur on 64 bits machines.

Usage help is more readable.

Code cleanup.

Add some code for the coming soon openMP feature.

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