From ea91afca8c2d56dce41d0f6bd9e615d439893924 Mon Sep 17 00:00:00 2001 From: Javier Mora Date: Sat, 13 Jul 2024 00:45:30 +0200 Subject: [PATCH] Fix hjson files that shall not use commas (#552) 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 #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). --- .github/workflows/simulate.yml | 2 +- docs/source/How_to/IntegratePeripheral.md | 6 +- .../hw/ip/i2c/data/i2c_testplan.hjson | 4 +- mcu_cfg.hjson | 108 +++++++++--------- mcu_cfg_minimal.hjson | 108 +++++++++--------- pad_cfg.hjson | 4 +- 6 files changed, 116 insertions(+), 116 deletions(-) diff --git a/.github/workflows/simulate.yml b/.github/workflows/simulate.yml index 8e11e0851..7626d9ef7 100644 --- a/.github/workflows/simulate.yml +++ b/.github/workflows/simulate.yml @@ -17,6 +17,6 @@ jobs: conda activate core-v-mini-mcu make clean-all sed 's/is_included: "no",/is_included: "yes",/' -i mcu_cfg.hjson - sed 's/num_channels: 0x1,/num_channels: 0x4,/' -i mcu_cfg.hjson + sed 's/num_channels: 0x1$/num_channels: 0x4/' -i mcu_cfg.hjson make mcu-gen MEMORY_BANKS=6 python3 .github/workflows/sim-apps-job/test_apps.py \ No newline at end of file diff --git a/docs/source/How_to/IntegratePeripheral.md b/docs/source/How_to/IntegratePeripheral.md index f39bdbd19..36e61bf59 100644 --- a/docs/source/How_to/IntegratePeripheral.md +++ b/docs/source/How_to/IntegratePeripheral.md @@ -153,14 +153,14 @@ II. The module must be instantiated in the peripheral subsystem: - hw/ip//.vlt ``` -8. The MCU configuration (mcu_cfg.json) must be adapted: +8. The MCU configuration (mcu_cfg.hjson) must be adapted: ```diff peripherals: { <...> + : { -+ offset: 0x00060000, -+ length: 0x00010000, ++ offset: 0x00060000 ++ length: 0x00010000 + }, }, ``` diff --git a/hw/vendor/lowrisc_opentitan/hw/ip/i2c/data/i2c_testplan.hjson b/hw/vendor/lowrisc_opentitan/hw/ip/i2c/data/i2c_testplan.hjson index 29e62e4f7..03f395edd 100644 --- a/hw/vendor/lowrisc_opentitan/hw/ip/i2c/data/i2c_testplan.hjson +++ b/hw/vendor/lowrisc_opentitan/hw/ip/i2c/data/i2c_testplan.hjson @@ -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. @@ -158,7 +158,7 @@ tests: ["i2c_fifo_overflow"] } { - name: target_fifo_empty, + name: target_fifo_empty desc: ''' Test tx_empty and tx_nonempty interrupt. diff --git a/mcu_cfg.hjson b/mcu_cfg.hjson index df55d1609..8d8fa3625 100644 --- a/mcu_cfg.hjson +++ b/mcu_cfg.hjson @@ -8,122 +8,122 @@ 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" }, @@ -131,13 +131,13 @@ }, flash_mem: { - address: 0x40000000, - length: 0x01000000, + address: 0x40000000 + length: 0x01000000 }, ext_slaves: { - address: 0xF0000000, - length: 0x01000000, + address: 0xF0000000 + length: 0x01000000 }, interrupts: { diff --git a/mcu_cfg_minimal.hjson b/mcu_cfg_minimal.hjson index 0be257d7b..9bce98d3e 100644 --- a/mcu_cfg_minimal.hjson +++ b/mcu_cfg_minimal.hjson @@ -8,135 +8,135 @@ 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: "no", 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: "no", path: "./hw/vendor/lowrisc_opentitan_spi_host/data/spi_host.hjson" }, gpio: { - offset: 0x00020000, - length: 0x00010000, + offset: 0x00020000 + length: 0x00010000 is_included: "no", path: "./hw/vendor/pulp_platform_gpio/gpio_regs.hjson" }, i2c: { - offset: 0x00030000, - length: 0x00010000, + offset: 0x00030000 + length: 0x00010000 is_included: "no", path: "./hw/vendor/lowrisc_opentitan/hw/ip/i2c/data/i2c.hjson" }, rv_timer: { - offset: 0x00040000, - length: 0x00010000, + offset: 0x00040000 + length: 0x00010000 is_included: "no", path: "./hw/vendor/lowrisc_opentitan/hw/ip/rv_timer/data/rv_timer.hjson" }, spi2: { - offset: 0x00050000, - length: 0x00010000, + offset: 0x00050000 + length: 0x00010000 is_included: "no", }, 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: "no", 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: { diff --git a/pad_cfg.hjson b/pad_cfg.hjson index 1cfa8c798..0bfa7ae88 100644 --- a/pad_cfg.hjson +++ b/pad_cfg.hjson @@ -33,7 +33,7 @@ }, rst: { num: 1, - active: low, + active: low driven_manually: True type: input }, @@ -55,7 +55,7 @@ }, jtag_trst: { num: 1, - active: low, + active: low type: input }, jtag_tdi: {