1
0
mirror of https://github.com/cclassic/model-ghdl synced 2024-11-22 08:35: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 ### Additional commands
* -ghdl *param*: Supply these arguments directly to GHDL (can be used multiple times) * -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 * -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 ### Notes
* *cwd* is expected to be the source directory (used for .gtkw save path) * *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 sourcedir[1 K];
char *params = NULL; char *params = NULL;
char *simtime = NULL; char *simtime = NULL;
char *simExt = NULL;
char *outFileType = NULL;
char vhdlver[16] = ""; char vhdlver[16] = "";
FILE *fp; FILE *fp;
@ -299,6 +301,9 @@ int vsim(int argc, char **argv)
// free(ptr); DO NOT FREE, we still need it. // free(ptr); DO NOT FREE, we still need it.
// ptr = NULL; // ptr = NULL;
} }
else if (GETOPT("-type")) {
append_string(&simExt, argv[i]);
}
else if (GETOPT("-ghdl")) { else if (GETOPT("-ghdl")) {
append_string(&params, " "); append_string(&params, " ");
append_string(&params, argv[i]); 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); chdir(workdir);
if (gtkwPrefix == NULL) { if (gtkwPrefix == NULL) {
@ -334,12 +357,12 @@ int vsim(int argc, char **argv)
} }
printf("[I] Simulating...\n"); 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!"); fprintf(stderr, "[E] Simulation failed!");
showMessage(MESSAGE_ERROR, "Error! Simulation failed.", NULL, NULL); showMessage(MESSAGE_ERROR, "Error! Simulation failed.", NULL, NULL);
} }
else { 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!"); fprintf(stderr, "[E] Could not open GtkWave!");
showMessage(MESSAGE_ERROR, "Error! Could not open GtkWave!", NULL, NULL); showMessage(MESSAGE_ERROR, "Error! Could not open GtkWave!", NULL, NULL);
} }