HDL Coder Java null pointer exception during automatic Fixed-Point conversion

18 Ansichten (letzte 30 Tage)
Xiaotong
Xiaotong am 28 Jan. 2026 um 8:37
Bearbeitet: Walter Roberson am 28 Jan. 2026 um 20:31
I was testing a design with HDL Coder and kept running into a Java NullPointerException. To debug the issue, I created several simple tests each involving matrix-wise power, matrix transpose, and complex numbers, HDL Coder still reports basically same errors for these operations.
Error code:
Exception in thread "AWT-EventQueue-0": java.lang.NullPointerException
at com.mathworks.toolbox.coder.model.MetadataTree.getFunctionNode(MetadataTree.java:59)
at com.mathworks.toolbox.coder.model.MetadataTree.getNode(MetadataTree.java:44)
at com.mathworks.toolbox.coder.model.MetadataTree.put(MetadataTree.java:27)
at com.mathworks.toolbox.coder.mi.ConversionUtils.convertRangesAndTypes(ConversionUtils.java:562)
at com.mathworks.toolbox.coder.mi.ConversionUtils.convertRangesAndTypes(ConversionUtils.java:500)
at com.mathworks.toolbox.coder.fixedpoint.FixedPointController.handleSimulationResults(FixedPointController.java:690)
at com.mathworks.toolbox.coder.fixedpoint.FixedPointController.access$1100(FixedPointController.java:71)
at com.mathworks.toolbox.coder.fixedpoint.FixedPointController$11.handleResult(FixedPointController.java:506)
at com.mathworks.toolbox.coder.mi.FevalCommand$1.run(FevalCommand.java:119)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:311)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:758)
at java.awt.EventQueue.access$500(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:709)
at java.awt.EventQueue$3.run(EventQueue.java:703)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:74)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:728)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:205)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:116)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:105)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:82)

Antworten (2)

Marie Anna Noviello
Marie Anna Noviello am 28 Jan. 2026 um 18:20
Bearbeitet: Walter Roberson am 28 Jan. 2026 um 20:31
1.Rewrite matrix operations explicitly
Instead of:
Y = (A.^2).';
Do:
for i = 1:N
Y(i) = real(A(i))*real(A(i)) - imag(A(i))*imag(A(i));
end
(or separate real/imag vectors explicitly)
2. Avoid complex numbers internally
HDL Coder works much better if you represent complex signals as:
A_re, A_im
and handle arithmetic manually.
3. Disable fixed-point conversion to confirm
To verify the root cause:
hdlcfg = coder.config('hdl');
hdlcfg.GenerateHDLCode = true;
If the error disappears, it confirms the crash is in fixed-point / range analysis, not your algorithm.
4. Use coder.extrinsic (last resort)
If the operation is only for simulation / testbench:
coder.extrinsic('power')
This excludes it from HDL generation.

Navan Ruthramoorthy
Navan Ruthramoorthy am 28 Jan. 2026 um 19:59
Hi Xiaotong,
Your test bench files do not seem to be calling the design files you have attached. For example, the function tb_hdl_matrix_power calls hdl_matrix_power which is not attached. But you have attached hdl_array_power.m.
Could you share which release you are using?
To see a working example you can type
>> mlhdlc_demo_setup sfir
This will create a temporary folder with sample design and testbench. You can use the files mlhdlc_sfir (design) and mlhdlc_sfir_tb (test bench) from the temporary directory that got created and try HDL code generation.

Kategorien

Mehr zu Code Generation finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by