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

  1. BUSWIDTH = 32
  2.  
  3. # master0 setup
  4. Top.master0.busWidth BUSWIDTH
  5.  
  6. # slave 0 setup
  7. Top.slave0.busWidth BUSWIDTH

is possible, when following some rules:

  • First, make all comments in your config file start with two hashes, e.g.:

  1. BUSWIDTH = 32
  2.  
  3. ## master0 setup
  4. Top.master0.busWidth BUSWIDTH
  5.  
  6. ## slave 0 setup
  7. Top.slave0.busWidth BUSWIDTH

  • Then turn your variable definition into a standard c macro, e.g.:

  1. #define BUSWIDTH  32
  2.  
  3. ## master0 setup
  4. Top.master0.busWidth BUSWIDTH
  5.  
  6. ## slave 0 setup
  7. Top.slave0.busWidth BUSWIDTH

  • Afterwards you can make the c++ preprocessor do the job. I propose a script like this:

  1. #!/bin/sh
  2.  
  3. cp $1 $1.c
  4. g++ -E -o$1.prp $1.c
  5. 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.