blob: 06fd3753b305cfbb7514ecbf8617272a9d59dd47 [file] [log] [blame] [view]
lowRISC Contributors802543a2019-08-31 12:12:56 +01001# Reggen -- Register generator
2
3Reggen is a python3 tool to read register descriptions in hjson and
4generate various output formats. Currently it can output html
5documentation, standard json, compact standard json (whitespace
6removed) and hjson. The example commands
7assume $REPO_TOP is set to the toplevel directory of the repo.
8
9### Setup
10
11If packages have not previously been installed you will need to set a
12few 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
22To ensure things stay up to date, the register json format information
23is documented by the tool itself. Documentation can be generated by
24running 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
33Normally for documentation the docgen tool will automatically use
34reggen. See the examples in the docgen module.
35
36The regtool provides a standalone way to run reggen. In the future
37this will be used to generate other formats like verilog and header
38files.
39
40Note that the same example inputs are used here as for docgen.
41
42Generate html from the register description and be verbose. Since
43embeddable html is generated the css is not included so the output
44will look messy (TODO should the css be added for the standalone
45case?):
46
47```
48$ cd $REPO_TOP/util
49$ ./regtool.py -v -d docgen/examples/uartregs.hjson > /tmp/outuart.html
50```
51
52Generate 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
59Generate 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
66Generate 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
73Generate 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
81If target directory is not specified, tool creates `{module}_regs.sv` file under
82the `hw/ip/{module}/dv/` directory.