Repository navigation
Conversation
|
Hi @Xeratec, this is an unprompted comment but I did something similar (but much more reduced in scope and quick and dirty) some time ago: 54f4350. I don't know if something can be complementary or be saved from it, for example it could be likely possible to have a unified |
bd4c2db to
6fbe675
Compare
- Cleanup - Add AXI Cut
Hi @ricted98, thanks for sharing this. I adopted some changes from you, cleaned the PR up a bit, and rebased it to |
Applies the reviewable parts of ricted98's variable-XLEN prototype (54f4350) on top of the 32-bit support branch. - bootrom: guard on the compiler-provided `__riscv_xlen` instead of a never-defined `XLEN` macro. `#if XLEN==64` evaluated to false in every build, so the RV64 bootrom silently dropped the SCRATCH[5] high-word store and the boot address reconstruction. Also move the RV64-only `lwu` inside the guard and use `lw` on RV32. - crt0: reunify `sw/lib/{32,64}/crt0.S` into a single `sw/lib/crt0.S` using LREG/SREG/REGBYTES and an `__riscv_flen` guard around FP init. Verified byte-identical codegen for RV64. Fixes three bugs that had crept into the duplicated 32-bit copy: a `-64`/`+128` stack imbalance in the trap epilogue, missing `.align 4` on `_start`, `_exit`, and `trap_vector`, and an unconditional RV64 D-extension FP init that could not assemble for RV32. - sw.mk: collapse the duplicated per-XLEN toolchain blocks into a single `CHS_SW_GCC_TRIPLE`/`CHS_SW_MARCH`/`CHS_SW_MABI` parametrization, which also restores the `CHS_SW_DTC` assignment lost in the split and the `?=` override semantics of `CHS_SW_FLAGS`. Add `_zicsr_zifencei` to the RV32 march string, required by GCC >= 12. - cheshire.mk: add `CHS_CVA6_CONFIG` and derive `CHS_XLEN` from it so the RTL target and the SW build cannot disagree. - vip: replace the magic dm::Command constants with a named-field concatenation; drop a leftover per-byte UART debug $display. - cheshire_soc: drop a stray blank line. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
6fbe675 to
5f91ea6
Compare
TbCheshireConfigs gained a fifth entry but NumCheshireConfigs stayed at 4, so the concatenation was wider than the [3:0] target and truncated from the MSB end. That silently dropped gen_cheshire_emb_cfg(), leaving the embedded 32-bit configuration unreachable via SelectedCfg. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
5409441 to
57fe3e2
Compare
8995afd to
4d5ee80
Compare
creinwar
left a comment
There was a problem hiding this comment.
Thanks! Looks already quite nice, but I left a few comments/questions :)
|
|
||
| SECTIONS { | ||
| __stack_pointer$ = ORIGIN(spm) + LENGTH(spm) - 8; | ||
| __stack_pointer$ = __stack_start - 8; |
There was a problem hiding this comment.
Since we're touching this line, we could fix it to follow the actual RISC-V ABI (https://github.com/riscv-non-isa/riscv-elf-psabi-doc) which states:
The stack grows downwards (towards lower addresses) and the stack pointer shall be aligned to a
128-bit boundary upon procedure entry. The first argument passed on the stack is located at offset
zero of the stack pointer on function entry;
So therefore this should probably just become __stack_pointer$ = __stack_start; at which point we could drop either symbol.
| .boot_addr_i ( BootAddr ), | ||
| .hart_id_i ( 64'(i) ), | ||
| .boot_addr_i ( BootAddr[riscv::XLEN-1:0] ), | ||
| .hart_id_i ( riscv::XLEN'(i) ), |
There was a problem hiding this comment.
Any reason to have both RiscvWordWidth and riscv::XLEN in the code? Could we agree on one?
| } | ||
|
|
||
| static inline int __uart_write_ready(void *uart_base) { | ||
| static int __uart_write_ready(void *uart_base) { |
There was a problem hiding this comment.
Was the inline dropped intentionally? I assume most compilers would do it already automatically, but IMHO it doesn't hurt to explicitly mark it inline.
| char str[] = "Hello World!\r\n"; | ||
| uint32_t rtc_freq = CHS_REGS->rtc_freq.f.ref_freq; | ||
| uint64_t reset_freq = clint_get_core_freq(rtc_freq, 2500); | ||
| uint64_t reset_freq = clint_get_core_freq(rtc_freq, 2048); |
There was a problem hiding this comment.
Is there a reason beyond "power-of-two == better"? 😂
| vivado* | ||
|
|
||
| # Emacs undo-tree files | ||
| *undo-tree* |
| AxiUserWidth : 2, // AMO(2) | ||
| AxiMstIdWidth : 2, | ||
| TFLenWidth : 32, | ||
| AxiSlvIdWidth : 3, |
There was a problem hiding this comment.
Where is AxiSlvIdWidth used? That should be a computed parameter.
Follows up on @creinwar's review of #287. - cheshire_pkg: drop the unused `AxiSlvIdWidth` config field; the value is already computed in `cheshire_soc` as `AxiMstIdWidth + $clog2(AxiIn.num_in)` and every use site reads that localparam. Drop `TFLenWidth` on the same grounds: `cheshire_idma_wrap` uses its own local `TfLenWidth`, so the config field was never read either. Both restore `cheshire_pkg.sv` to upstream. - cheshire_soc: settle on `riscv::XLEN` instead of carrying both it and a `RiscvWordWidth` localparam that merely aliased it. - Linker scripts: drop the `- 8` from `__stack_pointer$` in both `cheshire_bootrom.ld` and `dram.ld`. The RISC-V psABI requires sp to be 128-bit aligned on procedure entry; the offset left it 8-mod-16. Now 0x10010000 and 0x80800000 respectively, both 16-byte aligned. - crt0: round the entry frame up to a 16-byte multiple for the same reason. `4*REGBYTES` yields 32 B on RV64 and 16 B on RV32; the three saved registers keep their slots and the fourth is padding. `_exit` needs no change since it reloads the caller's sp from the frame rather than deallocating. - uart: restore `inline` on `__uart_write_ready` and `__uart_write_idle`. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Generic (non-Chimera) changes extracted from the
wiesep/chimera-mainintegration branch,proposed for upstream. Generalizes Cheshire so it can be instantiated with a 32-bit core
(
riscv::XLEN == 32), today hardcoded to 64. No functional change intended for the default64-bit configuration.
HW
RiscvWordWidthfromriscv::XLENinstead of hardcoding 64 in everyaxi_riscv_atomicswrapper (reg, LLC, debug, DMA-conf).boot_addr_i/hart_id_itoriscv::XLEN.TFLenWidthandAxiSlvIdWidth.Bootrom
__riscv_xlen.The RV64-only
lwuis now inside that guard, withlwon RV32.SW / build
crt0.Sstays a single file, parametrized over__riscv_xlenviaLREG/SREG/REGBYTES,with FP init guarded on
__riscv_flen. Verified to produce byte-identical RV64 code tomain, and to assemble forrv32imc/ilp32andrv32imafc/ilp32f.sw.mk:CHS_XLENselectsCHS_SW_GCC_TRIPLE/CHS_SW_MARCH/CHS_SW_MABI. SetCHS_SW_GCC_TRIPLE=riscv64-unknown-elfto build 32-bit SW with a multilib 64-bit toolchain.cheshire.mk: newCHS_CVA6_CONFIGfeedsCHS_BENDER_RTL_FLAGS, andCHS_XLENis derivedfrom it, so the RTL target and the SW build cannot disagree.
common.ldh; widths indif/uartchanged fromuint64_ttouint32_t(valid on both XLENs).Sim
vip_cheshire_soc:sbaccessand the SBA read stride followriscv::XLEN, and thedm::Commandwrite for repointing execution selectsaarsizeaccordingly.tb_cheshire_pkg: new embedded 32-bit configuration, selectable asSELCFG=4.Draft: split out of the Chimera 64-bit upgrade work (pulp-platform/chimera#84).
Thanks to @ricted98 for the variable-XLEN prototype (54f4350) that the unified
crt0.S,the
__riscv_xlenbootrom guards, andCHS_CVA6_CONFIGare based on.