Tobias Wölfel | 0da769d | 2020-06-09 14:59:46 +0200 | [diff] [blame] | 1 | --- |
| 2 | title: "Top Earlgrey" |
| 3 | --- |
| 4 | |
| 5 | ## Specification |
| 6 | |
Srikrishna Iyer | 5cddaf8 | 2020-04-24 14:19:49 -0700 | [diff] [blame] | 7 | The specification of Earlgrey is located [here]({{< relref "doc" >}}). |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 8 | |
| 9 | ## Tool: TopGen |
| 10 | |
| 11 | Top Earlgrey is being generated by the integration tool, topgen |
| 12 | (`util/topgen.py`). Please do not revise `rtl/top_earlgrey.sv`, the crossbar |
| 13 | modules, and the interrupt controller directly. Those files are auto-generated |
Philipp Wagner | 14a3fee | 2019-11-21 10:07:02 +0000 | [diff] [blame] | 14 | and sit in the repository for browsing purpose. |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 15 | |
| 16 | ### How to create top module |
| 17 | |
| 18 | Top module `rtl/top_earlgrey.sv` is created by `topgen.py`. Current top module |
| 19 | is created with below command. |
| 20 | |
| 21 | ```console |
Philipp Wagner | fb443ab | 2021-03-05 11:10:28 +0000 | [diff] [blame] | 22 | ../../util/topgen.py -t data/top_earlgrey.hjson -o . -v |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 23 | ``` |
| 24 | |
| 25 | It generates files below: |
| 26 | |
| 27 | - `rtl/top_earlgrey.sv`: Top module generated from the template |
Michael Schaffner | 7f13496 | 2019-11-03 12:44:50 -0800 | [diff] [blame] | 28 | `data/top_earlgrey.sv.tpl` with the configuration file |
| 29 | `data/top_earlgrey.hjson` |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 30 | - `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 Schaffner | 7f13496 | 2019-11-03 12:44:50 -0800 | [diff] [blame] | 33 | - `rtl/rv_plic*.sv` and `data/rv_plic.hjson`: Interrupt controller module. |
Tobias Wölfel | c3fabe6 | 2019-10-24 08:09:48 +0200 | [diff] [blame] | 34 | `hw/ip/rv_plic/util/reg_rv_plic.py` tool is used to create RV_PLIC having |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 35 | the number of interrupts specified in the hjson. |
| 36 | |
| 37 | ### Adding new blocks into top level |
Michael Schaffner | 7f13496 | 2019-11-03 12:44:50 -0800 | [diff] [blame] | 38 | Modify `data/top_earlgrey.hjson` to include new module |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 39 | - If new block has interrupts, also add to the `interrupt_module` definition |
| 40 | |
| 41 | Modify `xbar_main.hjson` for the host / device connectivity |
| 42 | |
| 43 | ### Modify configurations |
| 44 | |
Michael Schaffner | 7f13496 | 2019-11-03 12:44:50 -0800 | [diff] [blame] | 45 | Main configuration for Top Earlgrey is in `data/top_earlgrey.hjson`. The users |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 46 | need to specify the list of peripherals, memories, crossbars, and the interrupts |
| 47 | in the configuration file. The tool then reads relavant information from the |
| 48 | each peripheral blocks' configuration. For instance, if `uart` module is used, |
Tobias Wölfel | 4c5fbec | 2019-10-23 12:43:17 +0200 | [diff] [blame] | 49 | the tool reads `hw/ip/uart/data/uart{_reg}.hjson` and parses the information such |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 50 | as input/output, the size of its register space, and interrupts. |
| 51 | |
| 52 | For the memories, the tool utilizes the `type` and instantiates relavant modules |
| 53 | including the converter from TL-UL interface to the native interfaces (SRAM, |
| 54 | ROM, eFlash). The user only needs to describe the base address and the memory |
| 55 | size. |
| 56 | |
| 57 | The crossbar should be defined in the separate file. Please take a look at |
Michael Schaffner | 7f13496 | 2019-11-03 12:44:50 -0800 | [diff] [blame] | 58 | `data/xbar_main.hjson` as an example. In the top configuration, it needs to |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 59 | define the xbar and the clock, then the tool calls tlgen library to create the |
| 60 | crossbar design. Please remind that the instance name in the crossbar and that |
| 61 | in the module field should be matched for topgen to create fields that tlgen |
| 62 | uses. |
| 63 | |
| 64 | ### Modify the template |
| 65 | |
Michael Schaffner | 7f13496 | 2019-11-03 12:44:50 -0800 | [diff] [blame] | 66 | Main top template file is `data/top_earlgrey.sv.tpl`. In most cases, it isn't |
lowRISC Contributors | 802543a | 2019-08-31 12:12:56 +0100 | [diff] [blame] | 67 | require to modify the template file. For instance, to add new IP into the top, |
| 68 | the user just needs to add the IP to the `module` field and revise the crossbar |
| 69 | connections in the crossbar configuration. |
| 70 | |
| 71 | There might be some cases that needs to revise the template. As of now, a few |
| 72 | modules are hard-coded such as RISC-V core and the debug module. If any of these |
| 73 | modules need to be revised or some new modules not matching to the |
| 74 | comportability spec, it needs to be manually instantiated in the template file. |