lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 1 | # Reggen -- Register generator |
| 2 | |
| 3 | Reggen is a python3 tool to read register descriptions in hjson and |
| 4 | generate various output formats. Currently it can output html |
| 5 | documentation, standard json, compact standard json (whitespace |
| 6 | removed) and hjson. The example commands |
| 7 | assume $REPO_TOP is set to the toplevel directory of the repo. |
| 8 | |
| 9 | ### Setup |
| 10 | |
| 11 | If packages have not previously been installed you will need to set a |
| 12 | few things up. First use `pip3` to install some required packages: |
| 13 | ``` |
| 14 | $ pip3 install --user hjson |
| 15 | $ pip3 install --user mistletoe |
| 16 | $ pip3 install --user mako |
| 17 | ``` |
| 18 | |
| 19 | |
| 20 | ### Register JSON Format |
| 21 | |
| 22 | To ensure things stay up to date, the register json format information |
| 23 | is documented by the tool itself. Documentation can be generated by |
| 24 | running the tool to produce markdown and processing that into html. |
| 25 | |
| 26 | ``` |
| 27 | $ cd $REPO_TOP/util |
| 28 | $ python3 reggen/regtool.py --doc | python3 docgen/docgen.py -c > /tmp/outdoc.html |
| 29 | ``` |
| 30 | |
| 31 | ### Examples using standalone regtool |
| 32 | |
| 33 | Normally for documentation the docgen tool will automatically use |
| 34 | reggen. See the examples in the docgen module. |
| 35 | |
| 36 | The regtool provides a standalone way to run reggen. In the future |
| 37 | this will be used to generate other formats like verilog and header |
| 38 | files. |
| 39 | |
| 40 | Note that the same example inputs are used here as for docgen. |
| 41 | |
| 42 | Generate html from the register description and be verbose. Since |
| 43 | embeddable html is generated the css is not included so the output |
| 44 | will look messy (TODO should the css be added for the standalone |
| 45 | case?): |
| 46 | |
| 47 | ``` |
| 48 | $ cd $REPO_TOP/util |
| 49 | $ ./regtool.py -v -d docgen/examples/uartregs.hjson > /tmp/outuart.html |
| 50 | ``` |
| 51 | |
| 52 | Generate standard json from the register description: |
| 53 | |
| 54 | ``` |
| 55 | $ cd $REPO_TOP/util |
| 56 | $ ./regtool.py -v -j docgen/examples/uartregs.hjson > /tmp/outuart.json |
| 57 | ``` |
| 58 | |
| 59 | Generate compact json and use it to generate html: |
| 60 | |
| 61 | ``` |
| 62 | $ cd $REPO_TOP/util |
| 63 | $ ./regtool.py -v -c docgen/examples/uartregs.hjson | python3 reggen/regtool.py -v -d > /tmp/outuart.html |
| 64 | ``` |
| 65 | |
| 66 | Generate RTL from register definition: |
| 67 | ``` |
| 68 | $ cd $REPO_TOP/util |
| 69 | $ mkdir /tmp/rtl |
| 70 | $ ./regtool.py -r -t /tmp/rtl ../hw/ip/uart/doc/uart_reg.hjson |
| 71 | ``` |
| 72 | |
| 73 | Generate DV UVM class from register definition: |
| 74 | |
| 75 | ```console |
| 76 | $ cd $REPO_TOP/util |
| 77 | $ mkdir /tmp/dv |
| 78 | $ ./regtool.py -s -t /tmp/dv ../hw/ip/uart/doc/uart_reg.hjson |
| 79 | ``` |
| 80 | |
| 81 | If target directory is not specified, tool creates `{module}_regs.sv` file under |
| 82 | the `hw/ip/{module}/dv/` directory. |