This script parses a μC’s .SVD file and outputs all the peripherals register files.

Here is the link to the source code on github.
Short Description
This python script consists of four main functions.
XML_Parser:
This is the main function that checks for the user input “the name of the .SVD file” if the input is correct it goes to the next function, if not it displays an error message.
ParsePeripherals:
This function parse the file into different peripherals and passes each one to the next function.
ParsePeripheral:
This function gets the peripheral name and description into local variables to be used in the output file and then starts to pass each register to the next function.
ParseRegister:
This function gets the details of the register also to be used in the output file and then passes each field of the register to the next function.
ParseField:
This function gets the details of each field in the register and creates a “#define” mask for each field with specific names like Read_mask Get_mask,…..
At the end all the outputs from all these stages are put together in a file named “PeripheralName_register.h” for all the peripherals in the .SVD file.

Note: in the repo you can find two scripts the only difference is that one uses regex and the other uses an imported library called xmlparser.