opentitan icon indicating copy to clipboard operation
opentitan copied to clipboard

Compilation error for prim_util a package in Xcelium

Open tunghoang290780 opened this issue 6 years ago • 9 comments

This issue relates to PR #2589 (already merged)

Currently, Xcelium raises the below error for I2C simulation when the vbits function of prim_util_pkg is used in the parameter list of prim_fifo_sync. I tested with uart ip and got the same error. Those are ips that instantiate prim_fifo_sync in their RTL

****BUILD:** default<br>**
**LOG:** $scratch_path/default/build.log<br>
xmelab: *E,CFNOSF (../src/lowrisc_prim_util_0.1/rtl/prim_util_pkg.sv,44|35): System function calls are not allowed in constant functions [10.3.5(IEEE)].
  localparam int          DepthW     = prim_util_pkg::vbits(Depth+1)                                                         
xmelab: *N,CFCALL (../src/lowrisc_prim_all_0.1/rtl/prim_fifo_sync.sv,15|58): Function prim_util_pkg::vbits treated as a constant function because of this call.

I replace DepthW = prim_util_pkg::vbits(Depth+1) by (Depth==0) ? 1 : $clog2(Depth+1) and i2c works. Perhaps a quick fix is to define a macro for (Depth==0) ? 1 : $clog2(Depth+1) which is suggsted by @sriyerg

tunghoang290780 avatar Jun 23 '20 23:06 tunghoang290780

My preferred fix is to `ifdef XCELIUM in the function definition and write out a definition of $clog2 (not using a system function) for that simulator. Probably with a note of the form "This looks silly, but is because XCelium doesn't support constant functions properly. Remove this code when it does".

rswarbrick avatar Jun 24 '20 07:06 rswarbrick

@tunghoang290780 I cannot reproduce this, what test are you running Tung?

rasmus-madsen avatar Jun 24 '20 08:06 rasmus-madsen

sorry I did not see the original message. I will look into it

rasmus-madsen avatar Jun 24 '20 08:06 rasmus-madsen

Since this one has already caused enough confusion, let's be as specific as we can.

@rasmus-madsen @tunghoang290780 what versions of Xcelium are you using?

@tunghoang290780 what command are you running exactly to get the error output?

imphil avatar Jun 24 '20 08:06 imphil

@imphil I can reproduce the issue yes. I will check the PR in a second

rasmus-madsen avatar Jun 24 '20 08:06 rasmus-madsen

My preferred fix is to `ifdef XCELIUM in the function definition and write out a definition of $clog2 (not using a system function) for that simulator. Probably with a note of the form "This looks silly, but is because XCelium doesn't support constant functions properly. Remove this code when it does".

@rswarbrick I think they are actually handling them correctly Verilog LRM: IEEE Std 1364-2001, section 10.3.5: All system function calls within a constant function shall be ignored.

Parameters and localparams are considered constants to my knowledge.

but it does seem that Cadence has decided to support this construct from 19.10.001 which is also in accordance with the latest sv spec image

rasmus-madsen avatar Jun 24 '20 08:06 rasmus-madsen

@rasmus-madsen: Maybe it depends on which spec the simulator supports? The IEEE 1800-2017 SystemVerilog spec explicitly writes that this should work. I don't have the 2012 version, so don't know whether it changed since then.

rswarbrick avatar Jun 24 '20 09:06 rswarbrick

@rasmus-madsen: Maybe it depends on which spec the simulator supports? The IEEE 1800-2017 SystemVerilog spec explicitly writes that this should work. I don't have the 2012 version, so don't know whether it changed since then.

@rswarbrick I agree I also updated my response a few minutes ago :D

rasmus-madsen avatar Jun 24 '20 09:06 rasmus-madsen

@imphil U can run Uart tests now - the build didn't work before this update

rasmus-madsen avatar Jun 24 '20 10:06 rasmus-madsen