aboutsummaryrefslogtreecommitdiffstats
path: root/icepll
diff options
context:
space:
mode:
authorMichael Buesch <m@bues.ch>2019-05-26 16:58:13 +0200
committerMichael Buesch <m@bues.ch>2019-05-26 17:01:41 +0200
commit868d2ac08b82bf4ee52282bc33a46556c3d08ac9 (patch)
tree83aece7ea297bba1374824c1681f5ec352b3553f /icepll
parent710470f9d28891698aa015eb8c101d1cf75fc332 (diff)
downloadicestorm-868d2ac08b82bf4ee52282bc33a46556c3d08ac9.tar.gz
icestorm-868d2ac08b82bf4ee52282bc33a46556c3d08ac9.tar.bz2
icestorm-868d2ac08b82bf4ee52282bc33a46556c3d08ac9.zip
icepll: Add support for writing output data to stdout
Diffstat (limited to 'icepll')
-rw-r--r--icepll/icepll.cc48
1 files changed, 34 insertions, 14 deletions
diff --git a/icepll/icepll.cc b/icepll/icepll.cc
index 192eee6..f9ebecf 100644
--- a/icepll/icepll.cc
+++ b/icepll/icepll.cc
@@ -53,15 +53,16 @@ void help(const char *cmd)
printf("\n");
printf(" -f <filename>\n");
printf(" Save PLL configuration as Verilog to file\n");
+ printf(" If <filename> is - then the Verilog is written to stdout.\n");
printf("\n");
printf(" -m\n");
- printf(" Save PLL configuration as Verilog module (use with -f)\n");
+ printf(" Save PLL configuration as Verilog module (May use with -f)\n");
printf("\n");
printf(" -n <module name>\n");
printf(" Specify different Verilog module name than the default 'pll'\n");
printf("\n");
printf(" -q\n");
- printf(" Do not print PLL configuration to stdout\n");
+ printf(" Do not print information about the PLL configuration to stdout\n");
printf("\n");
exit(1);
}
@@ -83,8 +84,9 @@ int main(int argc, char **argv)
double f_pllin = 12;
double f_pllout = 60;
bool simple_feedback = true;
- char* filename = NULL;
- char* module_name = NULL;
+ const char* filename = NULL;
+ bool file_stdout = false;
+ const char* module_name = NULL;
bool save_as_module = false;
bool quiet = false;
@@ -122,9 +124,18 @@ int main(int argc, char **argv)
if (optind != argc)
help(argv[0]);
- // error: shall save as module, but no filename was given
+ // Shall save as module, but no filename was given.
+ // Write to stdout.
if (save_as_module && filename == NULL)
- help(argv[0]);
+ filename = "-";
+
+ // If filename is "-", then use stdout as output stream.
+ // That implies quiet mode.
+ if (filename != NULL && strcmp(filename, "-") == 0)
+ {
+ file_stdout = true;
+ quiet = true;
+ }
bool found_something = false;
double best_fout = 0;
@@ -238,17 +249,26 @@ int main(int argc, char **argv)
printf("\n");
}
- // save PLL configuration as file
- if (filename != NULL)
+ // save PLL configuration as file/stdout.
+ if (filename != NULL || file_stdout)
{
- // open file for writing
FILE *f;
- f = fopen(filename, "w");
- if (f == NULL)
+
+ if (file_stdout)
{
- fprintf(stderr, "Error: Failed to open output file '%s': %s\n",
- filename, strerror(errno));
- exit(1);
+ // use stdout as output stream.
+ f = stdout;
+ }
+ else
+ {
+ // open file for writing
+ f = fopen(filename, "w");
+ if (f == NULL)
+ {
+ fprintf(stderr, "Error: Failed to open output file '%s': %s\n",
+ filename, strerror(errno));
+ exit(1);
+ }
}
if (save_as_module)