1
0
mirror of https://github.com/cclassic/model-ghdl synced 2024-11-21 08:25:05 +01:00

Added support for multiple wave file types

This commit is contained in:
Markus Koch 2016-05-20 20:34:32 +02:00
parent 5bb82eb499
commit 710ad3cb01
2 changed files with 26 additions and 2 deletions

View File

@ -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)

27
main.c
View File

@ -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(&params, " ");
append_string(&params, 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);
}