pulp-platform / riscv-dbg

RISC-V Debug Support for our PULP RISC-V Cores
Other
198 stars 70 forks source link

Genus can't synthesize V0.2 (currently used in PULPissimo) #107

Open abettati opened 3 years ago

abettati commented 3 years ago

Hi to you all, I'm working on a project based on PULPissimo. We use Genus to synthesize the design and had problem with the verison of riscv-dbg used in PULPissimo (tag v0.2).

Genus throws the following error:

Warning : Index out of bounds. [CDFG-287]
        : Index 32 is out of bounds for array 'halted_reshaped0[31:0]' in file '/home/abettati/wb/debug_synth_warnings/ismartx/ips/riscv-dbg/src/dm_csrs.sv' on line 116.
        : Ensure that the desired index is specified correctly in the HDL.
Warning : Index out of bounds. [CDFG-287]
        : Index 32 is out of bounds for array 'halted_reshaped0[31:0]' in file '/home/abettati/wb/debug_synth_warnings/ismartx/ips/riscv-dbg/src/dm_csrs.sv' on line 116.
Error   : Could not resolve complex expression. [CDFG-200] [elaborate]
        : Expression 'halted_reshaped0' in module 'dm_csrs_NrHarts1024_BusWidth32_SelectableHartsx0000000100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000' in file '/home/abettati/wb/debug_synth_warnings/ismartx/ips/riscv-dbg/src/dm_csrs.sv' on line 116.
        : Error during elaboration.
Info    : Unable to elaborate the design. [ELAB-4]
        : Module 'pulpissimo' contains errors and cannot be elaborated.

I solved this updating the module with some changes taken from the most recent version of riscv-dbg. I redefined the signals:

    logic [((NrHarts-1)/2**5 + 1) * 32 - 1 : 0] halted;
    logic [(NrHarts-1)/2**5:0][31:0] halted_reshaped0;
    logic [(NrHarts-1)/2**10:0][31:0] halted_reshaped1;
    logic [(NrHarts-1)/2**15:0][31:0] halted_reshaped2;
    logic [((NrHarts-1)/2**10+1)*32-1:0] halted_flat1;
    logic [((NrHarts-1)/2**15+1)*32-1:0] halted_flat2;

And fixed some for-loops limits:

    // haltsum1
    always_comb begin : p_reduction1
        halted_flat1 = '0;
        for (int k=0; k<((NrHarts-1)/2**5)+1; k++) begin
            halted_flat1[k] = |halted_reshaped0[k];
        end
        halted_reshaped1 = halted_flat1;
        haltsum1         = halted_reshaped1[hartsel_o[19:10]];
    end
    // haltsum2
    always_comb begin : p_reduction2
        halted_flat2 = '0;
        for (int k=0; k<(NrHarts-1)/2**10+1; k++) begin
            halted_flat2[k] = |halted_reshaped1[k];
        end
        halted_reshaped2 = halted_flat2;
        haltsum2         = halted_reshaped2[hartsel_o[19:15]];
    end

Now genus does run to the end, but I wonder if my updates are correct and if others may be needed? For example I noticed the for-loop in p_reduction3 has not been updated even in the master branch:

is this intentional?