blob: e50ff36d43d708f7533e333c7dcc1b45b3f32dab [file] [log] [blame] [view]
Tobias Wölfel0da769d2020-06-09 14:59:46 +02001---
2title: "Top Earlgrey"
3---
4
5## Specification
6
Srikrishna Iyer5cddaf82020-04-24 14:19:49 -07007The specification of Earlgrey is located [here]({{< relref "doc" >}}).
lowRISC Contributors802543a2019-08-31 12:12:56 +01008
9## Tool: TopGen
10
11Top Earlgrey is being generated by the integration tool, topgen
12(`util/topgen.py`). Please do not revise `rtl/top_earlgrey.sv`, the crossbar
13modules, and the interrupt controller directly. Those files are auto-generated
Philipp Wagner14a3fee2019-11-21 10:07:02 +000014and sit in the repository for browsing purpose.
lowRISC Contributors802543a2019-08-31 12:12:56 +010015
16### How to create top module
17
18Top module `rtl/top_earlgrey.sv` is created by `topgen.py`. Current top module
19is created with below command.
20
21```console
Philipp Wagnerfb443ab2021-03-05 11:10:28 +000022../../util/topgen.py -t data/top_earlgrey.hjson -o . -v
lowRISC Contributors802543a2019-08-31 12:12:56 +010023```
24
25It generates files below:
26
27- `rtl/top_earlgrey.sv`: Top module generated from the template
Michael Schaffner7f134962019-11-03 12:44:50 -080028 `data/top_earlgrey.sv.tpl` with the configuration file
29 `data/top_earlgrey.hjson`
lowRISC Contributors802543a2019-08-31 12:12:56 +010030- `rtl/xbar_main.sv` and `rtl/tl_main_pkg.sv`: Crossbar module. As of now,
31 earlgrey has only one main crossbar. tlgen library is used to generate
32 these files.
Michael Schaffner7f134962019-11-03 12:44:50 -080033- `rtl/rv_plic*.sv` and `data/rv_plic.hjson`: Interrupt controller module.
Tobias Wölfelc3fabe62019-10-24 08:09:48 +020034 `hw/ip/rv_plic/util/reg_rv_plic.py` tool is used to create RV_PLIC having
lowRISC Contributors802543a2019-08-31 12:12:56 +010035 the number of interrupts specified in the hjson.
36
37### Adding new blocks into top level
Michael Schaffner7f134962019-11-03 12:44:50 -080038Modify `data/top_earlgrey.hjson` to include new module
lowRISC Contributors802543a2019-08-31 12:12:56 +010039- If new block has interrupts, also add to the `interrupt_module` definition
40
41Modify `xbar_main.hjson` for the host / device connectivity
42
43### Modify configurations
44
Michael Schaffner7f134962019-11-03 12:44:50 -080045Main configuration for Top Earlgrey is in `data/top_earlgrey.hjson`. The users
lowRISC Contributors802543a2019-08-31 12:12:56 +010046need to specify the list of peripherals, memories, crossbars, and the interrupts
47in the configuration file. The tool then reads relavant information from the
48each peripheral blocks' configuration. For instance, if `uart` module is used,
Tobias Wölfel4c5fbec2019-10-23 12:43:17 +020049the tool reads `hw/ip/uart/data/uart{_reg}.hjson` and parses the information such
lowRISC Contributors802543a2019-08-31 12:12:56 +010050as input/output, the size of its register space, and interrupts.
51
52For the memories, the tool utilizes the `type` and instantiates relavant modules
53including the converter from TL-UL interface to the native interfaces (SRAM,
54ROM, eFlash). The user only needs to describe the base address and the memory
55size.
56
57The crossbar should be defined in the separate file. Please take a look at
Michael Schaffner7f134962019-11-03 12:44:50 -080058`data/xbar_main.hjson` as an example. In the top configuration, it needs to
lowRISC Contributors802543a2019-08-31 12:12:56 +010059define the xbar and the clock, then the tool calls tlgen library to create the
60crossbar design. Please remind that the instance name in the crossbar and that
61in the module field should be matched for topgen to create fields that tlgen
62uses.
63
64### Modify the template
65
Michael Schaffner7f134962019-11-03 12:44:50 -080066Main top template file is `data/top_earlgrey.sv.tpl`. In most cases, it isn't
lowRISC Contributors802543a2019-08-31 12:12:56 +010067require to modify the template file. For instance, to add new IP into the top,
68the user just needs to add the IP to the `module` field and revise the crossbar
69connections in the crossbar configuration.
70
71There might be some cases that needs to revise the template. As of now, a few
72modules are hard-coded such as RISC-V core and the debug module. If any of these
73modules need to be revised or some new modules not matching to the
74comportability spec, it needs to be manually instantiated in the template file.