From 710ad3cb0130dbe051f8411004fde1c6a05801d1 Mon Sep 17 00:00:00 2001 From: Markus Koch Date: Fri, 20 May 2016 20:34:32 +0200 Subject: [PATCH] Added support for multiple wave file types --- README.md | 1 + main.c | 27 +++++++++++++++++++++++++-- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 22ac467..3f91162 100644 --- a/README.md +++ b/README.md @@ -37,6 +37,7 @@ VSIM ### Additional commands * -ghdl *param*: Supply these arguments directly to GHDL (can be used multiple times) * -gtkwprefix *prefix*: Prefix for the .gtkw save file. Path will be $cwd/$prefix$toplevel.gtkw +* -type *extension*: Set simulation output file type. Can be: ghw (default), vcd or fst ### Notes * *cwd* is expected to be the source directory (used for .gtkw save path) diff --git a/main.c b/main.c index 885af1e..213ed51 100644 --- a/main.c +++ b/main.c @@ -241,6 +241,8 @@ int vsim(int argc, char **argv) char sourcedir[1 K]; char *params = NULL; char *simtime = NULL; + char *simExt = NULL; + char *outFileType = NULL; char vhdlver[16] = ""; FILE *fp; @@ -299,6 +301,9 @@ int vsim(int argc, char **argv) // free(ptr); DO NOT FREE, we still need it. // ptr = NULL; } + else if (GETOPT("-type")) { + append_string(&simExt, argv[i]); + } else if (GETOPT("-ghdl")) { append_string(¶ms, " "); append_string(¶ms, argv[i]); @@ -311,6 +316,24 @@ int vsim(int argc, char **argv) } } + if (simExt == NULL) + append_string(&simExt, "ghw"); + + if (!strcmp(simExt,"ghw")) { + append_string(&outFileType, "wave"); + } + else if (!strcmp(simExt,"vcd")) { + append_string(&outFileType, "vcd"); + } + else if (!strcmp(simExt,"fst")) { + append_string(&outFileType, "fst"); + } + else { + fprintf(stderr, "[E] Unknown output file type!"); + showMessage(MESSAGE_ERROR, "Error! Unknown output file type.", NULL, NULL); + return 127; + } + chdir(workdir); if (gtkwPrefix == NULL) { @@ -334,12 +357,12 @@ int vsim(int argc, char **argv) } printf("[I] Simulating...\n"); - if (run_simulation("%s/%s --stop-time=%s --wave=%s.ghw", workdir, toplevel, simtime, toplevel)) { + if (run_simulation("%s/%s --stop-time=%s --%s=%s.%s", workdir, toplevel, simtime, outFileType, toplevel, simExt)) { fprintf(stderr, "[E] Simulation failed!"); showMessage(MESSAGE_ERROR, "Error! Simulation failed.", NULL, NULL); } else { - if (run_gtkwave(toplevel, "gtkwave %s/%s.ghw --save=\"%s/%s%s.gtkw\"", workdir, toplevel, sourcedir, gtkwPrefix, toplevel)) { // TODO: PATH FOR Savefile + if (run_gtkwave(toplevel, "gtkwave %s/%s.%s --save=\"%s/%s%s.gtkw\"", workdir, toplevel, simExt, sourcedir, gtkwPrefix, toplevel)) { fprintf(stderr, "[E] Could not open GtkWave!"); showMessage(MESSAGE_ERROR, "Error! Could not open GtkWave!", NULL, NULL); }