Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Default Value of a Read-Only Field is Generated as a Constant #71

Closed
kdstrike opened this issue Oct 24, 2023 · 1 comment
Closed

Default Value of a Read-Only Field is Generated as a Constant #71

kdstrike opened this issue Oct 24, 2023 · 1 comment
Assignees
Labels
bug Something isn't working

Comments

@kdstrike
Copy link

kdstrike commented Oct 24, 2023

Defining a field as read-only and assigning it a default value in System RDL leads to the generated System Verilog files assigning the default value to the readback signal as a constant. This produces an error in Questa when the field width is larger than the access width because bit splicing is necessary but cannot be done on constant values.

Example System RDL file myFile.rdl

addrmap myAddrMap {
    default accesswidth = 32;

    reg
    {
        name = "64 Bit Register";
        desc = "Example of a 64-bit register used with a 32-bit access bus.";
        regwidth = 64;

        field
        {
            name = "64 Bit Field";
            sw=r; hw=r;
        } myField[64] = 64'hDEADBEEFDEADBEEF;
    } myRegister;
};

Executing peakrdl regblock -o ./ myFile.rdl generates myAddrMap_pkg.sv and myAddrMap.sv. The last two lines in the following section from myAddrMap.sv are what cause the error. That is, the constant deadbeef being spliced to access bits [31:0] and [63:32] separately.

//--------------------------------------------------------------------------
// Readback
//--------------------------------------------------------------------------

logic readback_err;
logic readback_done;
logic [31:0] readback_data;
    
// Assign readback values to a flattened array
logic [31:0] readback_array[2];
assign readback_array[0][31:0] = (decoded_reg_strb.myRegister[0] && !decoded_req_is_wr) ? 64'hdeadbeefdeadbeef[31:0] : '0;
assign readback_array[1][31:0] = (decoded_reg_strb.myRegister[1] && !decoded_req_is_wr) ? 64'hdeadbeefdeadbeef[63:32] : '0;

The error Questa shows as follows and relates to the lines described above.

myAddrMap.sv(139): near "[": syntax error, unexpected '['.
myAddrMap.sv(140): near "[": syntax error, unexpected '['.
@amykyta3 amykyta3 self-assigned this Oct 25, 2023
@amykyta3 amykyta3 added the bug Something isn't working label Oct 25, 2023
amykyta3 added a commit that referenced this issue Oct 25, 2023
…iddling operations. Fix invalid bit-slicing of literals if field reset value is a constant. #71
@amykyta3
Copy link
Member

Thanks for finding and reporting this edge case!

Implemented a fix which will be in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants