Skip to content

Commit

Permalink
Fix hjson files that shall not use commas (esl-epfl#552)
Browse files Browse the repository at this point in the history
Some hjson files in X-HEEP use trailing comma after a "quoteless string"
which isn't valid in the standard (https://hjson.github.io/syntax.html):

> Do not add commas or comments as they would become part of the string.

This includes "barewords" such as `active: low,` but also (surprisingly)
hexadecimal values such as `address: 0x10000000,` which is technically
also interpreted as a string and not an integer value.
(`42,`, `true,`, `false,` and `"string",` are OK though.)

This fixes issue esl-epfl#552.
It also deprecates certain workarounds in the code that were using
`.split(',')` or `.strip(',')` to address this issue (but the issue was
really that the file format was wrong, not that the parser failed).
  • Loading branch information
cousteaulecommandant authored and Javier Mora committed Jul 13, 2024
1 parent 608691c commit 3e57007
Show file tree
Hide file tree
Showing 5 changed files with 115 additions and 115 deletions.
6 changes: 3 additions & 3 deletions docs/source/How_to/IntegratePeripheral.md
Original file line number Diff line number Diff line change
Expand Up @@ -153,14 +153,14 @@ II. The module must be instantiated in the peripheral subsystem:
- hw/ip/<peripheral>/<peripheral>.vlt
```
8. The MCU configuration (mcu_cfg.json) must be adapted:
8. The MCU configuration (mcu_cfg.hjson) must be adapted:
```diff
peripherals: {
<...>
+ <peripheral>: {
+ offset: 0x00060000,
+ length: 0x00010000,
+ offset: 0x00060000
+ length: 0x00010000
+ },
},
```
Expand Down
4 changes: 2 additions & 2 deletions hw/vendor/lowrisc_opentitan/hw/ip/i2c/data/i2c_testplan.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
tests: ["i2c_smoke"]
}
{
name: host_error_intr,
name: host_error_intr
desc: '''
Test error interrupts are asserted by the Host DUT due to
interference and unstable signals on bus.
Expand Down Expand Up @@ -158,7 +158,7 @@
tests: ["i2c_fifo_overflow"]
}
{
name: target_fifo_empty,
name: target_fifo_empty
desc: '''
Test tx_empty and tx_nonempty interrupt.

Expand Down
108 changes: 54 additions & 54 deletions mcu_cfg.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -8,136 +8,136 @@
cpu_type: cv32e20

linker_script: {
stack_size: 0x800,
heap_size: 0x800,
stack_size: 0x800
heap_size: 0x800
}

debug: {
address: 0x10000000,
length: 0x00100000,
address: 0x10000000
length: 0x00100000
},

ao_peripherals: {
address: 0x20000000,
length: 0x00100000,
address: 0x20000000
length: 0x00100000
soc_ctrl: {
offset: 0x00000000,
length: 0x00010000,
offset: 0x00000000
length: 0x00010000
path: "./hw/ip/soc_ctrl/data/soc_ctrl.hjson"
},
bootrom: {
offset: 0x00010000,
length: 0x00010000,
offset: 0x00010000
length: 0x00010000
},
spi_flash: {
offset: 0x00020000,
length: 0x00008000,
offset: 0x00020000
length: 0x00008000
},
spi_memio: {
offset: 0x00028000,
length: 0x00008000,
offset: 0x00028000
length: 0x00008000
},
dma: {
offset: 0x00030000,
length: 0x00010000,
ch_length: 0x100,
num_channels: 0x1,
offset: 0x00030000
length: 0x00010000
ch_length: 0x100
num_channels: 0x1
path: "./hw/ip/dma/data/dma.hjson"
},
power_manager: {
offset: 0x00040000,
length: 0x00010000,
offset: 0x00040000
length: 0x00010000
path: "./hw/ip/power_manager/data/power_manager.hjson"
},
rv_timer_ao: {
offset: 0x00050000,
length: 0x00010000,
offset: 0x00050000
length: 0x00010000
},
fast_intr_ctrl: {
offset: 0x00060000,
length: 0x00010000,
offset: 0x00060000
length: 0x00010000
path: "./hw/ip/fast_intr_ctrl/data/fast_intr_ctrl.hjson"
},
ext_peripheral: {
offset: 0x00070000,
length: 0x00010000,
offset: 0x00070000
length: 0x00010000
},
pad_control: {
offset: 0x00080000,
length: 0x00010000,
offset: 0x00080000
length: 0x00010000
},
gpio_ao: {
offset: 0x00090000,
length: 0x00010000,
offset: 0x00090000
length: 0x00010000
},
uart: {
offset: 0x000A0000,
length: 0x00010000,
offset: 0x000A0000
length: 0x00010000
path: "./hw/vendor/lowrisc_opentitan/hw/ip/uart/data/uart.hjson"
},
},

peripherals: {
address: 0x30000000,
length: 0x00100000,
address: 0x30000000
length: 0x00100000
rv_plic: {
offset: 0x00000000,
length: 0x00010000,
offset: 0x00000000
length: 0x00010000
is_included: "yes",
path: "./hw/vendor/lowrisc_opentitan/hw/ip/rv_plic/data/rv_plic.hjson"
},
spi_host: {
offset: 0x00010000,
length: 0x00010000,
offset: 0x00010000
length: 0x00010000
is_included: "yes",
path: "./hw/vendor/lowrisc_opentitan_spi_host/data/spi_host.hjson"
},
gpio: {
offset: 0x00020000,
length: 0x00010000,
offset: 0x00020000
length: 0x00010000
is_included: "yes",
path: "./hw/vendor/pulp_platform_gpio/gpio_regs.hjson"
},
i2c: {
offset: 0x00030000,
length: 0x00010000,
offset: 0x00030000
length: 0x00010000
is_included: "yes",
path: "./hw/vendor/lowrisc_opentitan/hw/ip/i2c/data/i2c.hjson"
},
rv_timer: {
offset: 0x00040000,
length: 0x00010000,
offset: 0x00040000
length: 0x00010000
is_included: "yes",
path: "./hw/vendor/lowrisc_opentitan/hw/ip/rv_timer/data/rv_timer.hjson"
},
spi2: {
offset: 0x00050000,
length: 0x00010000,
offset: 0x00050000
length: 0x00010000
is_included: "yes",
},
pdm2pcm: {
offset: 0x00060000,
length: 0x00010000,
offset: 0x00060000
length: 0x00010000
is_included: "no",
path: "./hw/ip/pdm2pcm/data/pdm2pcm.hjson"
},
i2s: {
offset: 0x00070000,
length: 0x00010000,
offset: 0x00070000
length: 0x00010000
is_included: "yes",
path: "./hw/ip/i2s/data/i2s.hjson"
},

},

flash_mem: {
address: 0x40000000,
length: 0x01000000,
address: 0x40000000
length: 0x01000000
},

ext_slaves: {
address: 0xF0000000,
length: 0x01000000,
address: 0xF0000000
length: 0x01000000
},

interrupts: {
Expand Down
Loading

0 comments on commit 3e57007

Please sign in to comment.