The design is probably best explained in terms of the Makefile, which starts at the bottom and works it way to the top, solving dependencies along the way.
$(CLEANED_SVD); this removes some large areas of spaces from the SVD (I've no idea why they are there) and replaces '0x' with '$' which is the Forth convention for hexadecimal numbers.
$(UNFOLDED_SVD); SVD's come condensed with duplicate data removed for identical peripherals, this restores them.
$(ABS_ADDRESSES_SVD); rather than having the MCU calculate the address of registers by summing a 'base' and 'offset' I calculate it and add the absolute address of each register to the database.
$(DATABASE_DATA); transformed from the $(ABS_ADDRESSES_SVD) into a form compatible with SQlite to build the database.
$(DATABASE): creates the database
MCU = stm32f051
# Directories
STYLES_DIR = styles/
PATTERNS_DIR = patterns/
# Database
DATABASE = svd2db-rel.db
DATABASE_DATA = $(PATTERNS_DIR)database.data
# SVD's
SVD = $(MCU).svd
CLEANED_SVD = $(MCU).cleaned.svd
UNFOLDED_SVD = $(MCU).uf.svd
ABS_ADDRESSES_SVD = $(MCU).abs.svd
# XSLT Recipes
UNFOLDER_STY = $(STYLES_DIR)svduf.xsl
ABS_ADDR_STY = $(STYLES_DIR)process-hex2num.xsl
DB_STY = $(STYLES_DIR)db.xsl
# Patterns
DATABASE_PAT = $(PATTERNS_DIR)db.pat
STRIP_PAT = $(PATTERNS_DIR)strip.pat
# Programs
XSL-PROC = xsltproc
TEXT-PROC = gema
XMLLINT = xmllint
SQLITE = sqlite3
all: db
clean: $(CLEANED_SVD)
unfold: $(UNFOLDED_SVD)
abs: $(ABS_ADDRESSES_SVD)
dbdata: $(DATABASE_DATA)
db: $(DATABASE)
# Database Creation
$(DATABASE): $(DATABASE_DATA)
-rm $(DATABASE)
$(SQLITE) $(DATABASE) < $(DATABASE_DATA)
-rm $(DATABASE_DATA)
# Database data creation
$(DATABASE_DATA): $(ABS_ADDRESSES_SVD)
$(XSL-PROC) -o $(DATABASE_DATA) $(DB_STY) $(ABS_ADDRESSES_SVD)
-rm $(ABS_ADDRESSES_SVD)
# SVD ops start here
$(ABS_ADDRESSES_SVD): $(UNFOLDED_SVD)
$(XSL-PROC) -o $(ABS_ADDRESSES_SVD) $(ABS_ADDR_STY) $(UNFOLDED_SVD)
$(XMLLINT) --format $(ABS_ADDRESSES_SVD) > temp1.tmp && mv temp1.tmp $(ABS_ADDRESSES_SVD) || rm -f temp1.tmp
-rm $(UNFOLDED_SVD)
$(UNFOLDED_SVD): $(CLEANED_SVD)
$(XSL-PROC) -o $(UNFOLDED_SVD) $(UNFOLDER_STY) $(CLEANED_SVD)
-rm $(CLEANED_SVD)
# Cleaning transposes '$' for '0x' per Forth conventions, removes large spaces etc
$(CLEANED_SVD): $(SVD)
$(TEXT-PROC) -t -nobackup -line $(SVD) -f $(PATTERNS_DIR)svd_clean.pat -out $(CLEANED_SVD)