OpenCores
URL https://opencores.org/ocsvn/openrisc_2011-10-31/openrisc_2011-10-31/trunk

Subversion Repositories openrisc_2011-10-31

[/] [openrisc/] [trunk/] [or1ksim/] [toplevel.c] - Blame information for rev 404

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 19 jeremybenn
/* toplevel.c -- Top level simulator source file
2
 
3
   Copyright (C) 1999 Damjan Lampret, lampret@opencores.org
4
   Copyright (C) 2008 Embecosm Limited
5
 
6
   Contributor Jeremy Bennett <jeremy.bennett@embecosm.com>
7
 
8
   This file is part of Or1ksim, the OpenRISC 1000 Architectural Simulator.
9
 
10
   This program is free software; you can redistribute it and/or modify it
11
   under the terms of the GNU General Public License as published by the Free
12
   Software Foundation; either version 3 of the License, or (at your option)
13
   any later version.
14
 
15
   This program is distributed in the hope that it will be useful, but WITHOUT
16
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17
   FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
18
   more details.
19
 
20
   You should have received a copy of the GNU General Public License along
21
   with this program.  If not, see <http://www.gnu.org/licenses/>.  */
22
 
23
/* This program is commented throughout in a fashion suitable for processing
24
   with Doxygen. */
25
 
26
 
27
/* Autoconf and/or portability configuration */
28
#include "config.h"
29
 
30
/* System includes */
31
#include <stdlib.h>
32
#include <unistd.h>
33
#include <signal.h>
34
 
35
/* Package includes */
36
#include "sim-config.h"
37
#include "toplevel-support.h"
38
#include "execute.h"
39
 
40
 
41
/*---------------------------------------------------------------------------*/
42
/*!Main function
43
 
44
   Set up the standalone simulation. Initialize the default configuration and
45
   register all the sections that may appear in a user configuration.
46
 
47
   Then attempt to parse the args, configure the system from any configuration
48
   file specified and print out the configuration used.
49
 
50
   Add a signal hander, so ctrl-C will drop the user into the CLI.
51
 
52
   The initialize the simulator, call the appropriate main simulator function
53
   and when it returns tidy up.
54
 
55
   @param[in] argc  The number of arguments to the command
56
   @param[in] argv  The vector of argument strings
57
 
58
   @return  The return code required from the simulator. This is actually
59
            achieved by calling exit() with the return code, rather than
60
            returning an explict value.                                      */
61
/*---------------------------------------------------------------------------*/
62
int
63
main (int   argc,
64
      char *argv[])
65
{
66
  srand (getpid ());
67
  init_defconfig ();
68
  reg_config_secs ();
69
 
70
  if (parse_args (argc, argv))
71
    {
72
      exit (-1);                /* Parse args will have printed any messages */
73
    }
74
 
75
  print_config ();
76
  signal (SIGINT, ctrl_c);
77
 
78
  do_stats         = config.cpu.superscalar ||
79
                     config.cpu.dependstats ||
80
                     config.sim.history     ||
81 202 julius
                     config.sim.exe_log     ||
82
                     config.sim.exe_bin_insn_log;
83 19 jeremybenn
 
84
  sim_init ();
85
 
86
#if DYNAMIC_EXECUTION
87
  dyn_main ();
88
#else
89
  exec_main ();
90
#endif
91
 
92
  sim_done ();
93
  exit (0);
94
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.