1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
/* $Id$
*
* C-Code kernel / runtime library..
*
* Copyright (C) 2010 FAUmachine Team <info@faumachine.org>.
* This program is free software. You can redistribute it and/or modify it
* under the terms of the GNU General Public License, either version 2 of
* the License, or (at your option) any later version. See COPYING.
*/
#include <unistd.h>
#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#include <getopt.h>
#undef _GNU_SOURCE
#else /* _GNU_SOURCE already defined */
#include <getopt.h>
#endif /* _GNU_SOURCE not defined? */
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <pthread.h>
#include "mangle_names.h"
#include "basetypes.h"
#include "runtime.h"
/* init routine as defined by the c-file */
extern int
vhdl_call_by_name(struct vhdl_kernel *kernel, const char *name);
#if 0 /* FIXME */
static int
simulation_cycle(void)
{
for (;;) {
/* advance simulation time to next event */
/* update signals from driving values */
/* wake up all processes with events */
/* resume all processes with events */
/* check for delta cycle, if so back to start */
/* here's a good place to call the tracer */
}
}
#endif
static int
start_simulation(const char *top_entity)
{
char buf[2048];
int ret;
ret = mangle_name(top_entity, buf, sizeof(buf));
assert(0 <= ret);
assert((size_t)ret < sizeof(buf));
#if 0 /* FIXME */
ret = vhdl_call_by_name(buf);
/* TODO */
#endif
return ret;
}
static void
usage(const char *prog)
{
fprintf(stderr, "%s [options]\n", prog);
fprintf(stderr, " Generated VHDL Simulator.\n");
fprintf(stderr, "Options:\n");
fprintf(stderr, " -s ENTITY, --simulate=ENTITY Start simulation "
"with ENTITY as top entity.\n");
fprintf(stderr, " -o VCDFILE, --output=VCDFILE Output trace to ");
fprintf(stderr, "VCDFILE.\n");
fprintf(stderr, " -t, --trace=ENTITY Trace all signals "
"in ENTITY\n");
fprintf(stderr, " -h, --help Show this help.");
fprintf(stderr, "\n");
}
int
main(int argc, char **argv)
{
int c;
int ret;
const char *top_entity = NULL;
const char *trace_file = NULL;
const struct option l_opts[] = {
{"simulate", 1, NULL, 's'},
{"output", 1, NULL, 'o'},
{"trace", 1, NULL, 't'},
{"help", 0, NULL, 'h'},
{0, 0, 0, 0}
};
for (;;) {
c = getopt_long(argc, argv, "s:o:t:h", l_opts, NULL);
if (c == -1) {
break;
}
switch (c) {
case 's':
top_entity = optarg;
break;
case 'o':
trace_file = optarg;
break;
case 't':
assert(0);
/* FIXME */
break;
case 'h':
usage(argv[0]);
return EXIT_SUCCESS;
default:
usage(argv[0]);
return EXIT_FAILURE;
}
}
if (argc - optind != 0) {
usage(argv[0]);
return EXIT_FAILURE;
}
/* FIXME tracer... */
ret = start_simulation(top_entity);
return ret;
}
|