diff options
author | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-03 19:05:10 +0100 |
---|---|---|
committer | Alex AUVOLAT <alex.auvolat@ens.fr> | 2014-01-03 19:05:10 +0100 |
commit | 1ff268ab13dd299c4cdc1e379df5397bd6a394e3 (patch) | |
tree | 014db93062f26cdfe2d2639fd833afd554e94a66 /csim | |
parent | c46fe12e47c405fbb03f0c93121402d873bc470e (diff) | |
download | SystDigit-Projet-1ff268ab13dd299c4cdc1e379df5397bd6a394e3.tar.gz SystDigit-Projet-1ff268ab13dd299c4cdc1e379df5397bd6a394e3.zip |
Added simulator monitor tool.
Diffstat (limited to 'csim')
-rw-r--r-- | csim/Makefile | 2 | ||||
-rw-r--r-- | csim/main.c | 17 | ||||
-rw-r--r-- | csim/sim.c | 11 | ||||
-rw-r--r-- | csim/sim.h | 1 |
4 files changed, 22 insertions, 9 deletions
diff --git a/csim/Makefile b/csim/Makefile index 6827579..ae4cc4e 100644 --- a/csim/Makefile +++ b/csim/Makefile @@ -1,5 +1,5 @@ csim: main.o load.o sim.o util.o - gcc -o csim $^ + gcc -o $@ $^ %.o: %.c gcc -c $< -o $@ -O2 -g diff --git a/csim/main.c b/csim/main.c index 5689cb4..2a88fbc 100644 --- a/csim/main.c +++ b/csim/main.c @@ -14,18 +14,18 @@ void usage() { - printf ("\nUsage:\n\tcsim [options] <netlist_file>\n\n"); - printf("Available options:\n"); - printf("\n -rom <prefix> <file>\n\tLoad a filename as a ROM file for the machine\n"); - printf("\tA given ROM file is used for all ROM chips with variable name having given prefix\n"); - printf("\n -n <steps>\n\tOnly run #steps steps of simulation (0 = infinity)\n"); - printf("\n -in <in-file>\n\tRead inputs from given file (eg. named pipe). Defaults to STDIN.\n"); - printf("\n -out <out-file>\n\tWrite outputs to given file (eg. named pipe). Defaults to STDOut.\n"); + fprintf(stderr, "\nUsage:\n\tcsim [options] <netlist_file>\n\n"); + fprintf(stderr, "Available options:\n"); + fprintf(stderr, "\n -rom <prefix> <file>\n\tLoad a filename as a ROM file for the machine\n"); + fprintf(stderr, "\tA given ROM file is used for all ROM chips with variable name having given prefix\n"); + fprintf(stderr, "\n -n <steps>\n\tOnly run #steps steps of simulation (0 = infinity)\n"); + fprintf(stderr, "\n -in <in-file>\n\tRead inputs from given file (eg. named pipe). Defaults to STDIN.\n"); + fprintf(stderr, "\n -out <out-file>\n\tWrite outputs to given file (eg. named pipe). Defaults to STDOUT.\n"); exit(1); } // Arguments to be parsed -int steps = 12; +int steps = 0; char *filename = NULL; char *infile = NULL; char *outfile = NULL; @@ -88,6 +88,7 @@ int main(int argc, char **argv) { // Run t_machine *machine = init_machine(program); + machine_banner(machine, output); i = 0; while (i < steps || steps == 0) { read_inputs(machine, input); @@ -52,6 +52,17 @@ t_machine *init_machine (t_program *p) { return m; } +void machine_banner(t_machine *m, FILE *stream) { + int i; + fprintf(stream, "%d %d\n", m->prog->n_inputs, m->prog->n_outputs); + for (i = 0; i < m->prog->n_inputs; i++) { + fprintf(stream, "%d %s\n", + m->prog->vars[m->prog->inputs[i]].size, + m->prog->vars[m->prog->inputs[i]].name); + } + fprintf(stream, "\n"); +} + void read_inputs(t_machine *m, FILE *stream) { /* FORMAT : For each input in the list, *in the order specified*, @@ -124,6 +124,7 @@ void add_rom(const char *prefix, FILE *file); // Implemented in sim.c t_machine *init_machine(t_program *p); +void machine_banner(t_machine *m, FILE *stream); void read_inputs(t_machine *m, FILE *stream); void machine_step(t_machine *m); void write_outputs(t_machine *m, FILE *stream); |