mirror of
https://github.com/openhwgroup/cve2.git
synced 2025-04-22 13:07:46 -04:00
[icache] Define some fake DPI functions to simplify linking
This is triggered by the fact that if the ICache parameter is false then we don't instantiate the ibex_icache module. For verilator simulations, the module is then discarded entirely, which means that its two DPI functions are not defined. That's unfortunate because we're also compiling the code in scrambled_ecc32_mem_area.cc, which expects the functions to be defined. The obvious solution (don't include scrambled_ecc32_mem_area.cc if you don't have an icache) isn't easy to do, because FuseSoc doesn't currently allow us to use parameters to configure its dependency tree (see fusesoc issue 438 for a discussion). The super-clever solution that I came up with before(!) was to declare these symbols as weak in the C++ code. That way, we can do a runtime check to make sure that no-one is silly enough to call them without an icache, but everything will still build properly either way. Unfortunately, that doesn't work well with xcelium simulations. Xcelium turns out to compile all the C++ code into one .so library and generate functions for exported DPI functions in another. These two solibs then get loaded at runtime with dlopen(). But this doesn't work with weak symbols: in fact, it seems you end up with the C++ version every time. Boo! So let's be stupider about it and define (bogus) versions of the DPI functions in this case. Fortunately, both of them are designed to return zero on failure so we can just return zero and needn't worry too much. The idea is that when this lands, we can revert the OpenTitan change that switched the C++ code to using weak symbols and Xcelium simulations will start working.
This commit is contained in:
parent
bdf2f2b440
commit
c15f3b8888
1 changed files with 17 additions and 0 deletions
|
@ -301,6 +301,23 @@ module ibex_if_stage import ibex_pkg::*; #(
|
|||
assign ic_data_write_o = 'b0;
|
||||
assign ic_data_addr_o = 'b0;
|
||||
assign ic_data_wdata_o = 'b0;
|
||||
|
||||
`ifndef SYNTHESIS
|
||||
// If we don't instantiate an icache and this is a simulation then we have a problem because the
|
||||
// simulator might discard the icache module entirely, including some DPI exports that it
|
||||
// implies. This then causes problems for linking against C++ testbench code that expected them.
|
||||
// As a slightly ugly hack, let's define the DPI functions here (the real versions are defined
|
||||
// in prim_util_get_scramble_params.svh)
|
||||
export "DPI-C" function simutil_get_scramble_key;
|
||||
export "DPI-C" function simutil_get_scramble_nonce;
|
||||
function automatic int simutil_get_scramble_key(output bit [127:0] val);
|
||||
return 0;
|
||||
endfunction
|
||||
function automatic int simutil_get_scramble_nonce(output bit [319:0] nonce);
|
||||
return 0;
|
||||
endfunction
|
||||
`endif
|
||||
|
||||
end
|
||||
|
||||
assign unused_fetch_addr_n0 = fetch_addr_n[0];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue