GreenConfig Configuration File Macros
Configuration File Macros
This is a short tutorial about how to use macros in GreenConfig configuration files.
Setting a variable like this
- BUSWIDTH = 32
- # master0 setup
- Top.master0.busWidth BUSWIDTH
- # slave 0 setup
- Top.slave0.busWidth BUSWIDTH
is possible, when following some rules:
- First, make all comments in your config file start with two hashes, e.g.:
- BUSWIDTH = 32
- ## master0 setup
- Top.master0.busWidth BUSWIDTH
- ## slave 0 setup
- Top.slave0.busWidth BUSWIDTH
- Then turn your variable definition into a standard c macro, e.g.:
- #define BUSWIDTH 32
- ## master0 setup
- Top.master0.busWidth BUSWIDTH
- ## slave 0 setup
- Top.slave0.busWidth BUSWIDTH
- Afterwards you can make the c++ preprocessor do the job. I propose a script like this:
- #!/bin/sh
- cp $1 $1.c
- g++ -E -o$1.prp $1.c
- rm $1.c
This takes the config file as a parameter (e.g. myConfig.cfg) and will produce a preprocessed version of it (e.g. myConfig.cfg.prp). Note that it does not replace the original config file, since all macros have been expanded, and so the #define has vanished.
Your system should then use the '.prp' config file.
- Printer-friendly version
- Login or register to post comments
Posted February 20th, 2008 by ChristianSchroeder