Simulink HDL Coder error when generating

8 visualizaciones (últimos 30 días)
Mikel
Mikel el 20 de Feb. de 2025
Comentada: Steven Hatcher el 6 de Mzo. de 2025
HEllo,
It is my first time with Simulink's HDL Coder and I am trying to code a very simple program.
I have it ready, it simulates correctly but when I hit Generate HDL Code, it gives me this error:
Error:Error:signal:addDriver:invalidOutPortIndex: Error: Invalid output port index 3, hdl_test" RefNum="c31" UserName="If" RTTIClass ="class pir::NetworkInstComp" Network="n1"/> has 3 output port(s)
It is a simple counter that outputs 8 bits to toggle corresponding leds.
Can anyone give me some light on what can it be happening??
Thanks!!
  2 comentarios
Steven Hatcher
Steven Hatcher el 20 de Feb. de 2025
Editada: Steven Hatcher el 20 de Feb. de 2025
Hi Mikel,
Which release are you using? It will be helpful to reach out to technical support to help get the issue sorted out.
Can I ask what you are trying to do with this If Action Subsystem structure? It almost looks like lookup table logic if those are constants inside. If so, you can get much more efficient HDL code using the nD Lookup Table block and also reduce modeling overhead with a single block.
Steven
Mikel
Mikel el 20 de Feb. de 2025
Editada: Mikel el 20 de Feb. de 2025
I am using MAtlab R2023b
I am trying to implement a binary counter that, depending on the value of it, will turn on-off 8 leds.
the equivalent VHDL code would be:
MAIN: process(rst,clk)
begin
if (rst = '1') then
count <= (OTHERS => '0');
leds <= (OTHERS => '0');
elsif rising_edge(clk) then
count <= std_logic_vector(to_unsigned(to_integer(unsigned(count))+1,count'length));
if to_integer(unsigned(count)) <= 500000 then
leds <= std_logic_vector(to_unsigned(1,leds'length));
elsif to_integer(unsigned(count)) <= 1000000 then
leds <= std_logic_vector(to_unsigned(2,leds'length));
elsif to_integer(unsigned(count)) <= 1500000 then
leds <= std_logic_vector(to_unsigned(4,leds'length));
elsif to_integer(unsigned(count)) <= 2000000 then
leds <= std_logic_vector(to_unsigned(8,leds'length));
elsif to_integer(unsigned(count)) <= 2500000 then
leds <= std_logic_vector(to_unsigned(16,leds'length));
elsif to_integer(unsigned(count)) <= 3000000 then
leds <= std_logic_vector(to_unsigned(32,leds'length));
elsif to_integer(unsigned(count)) <= 3500000 then
leds <= std_logic_vector(to_unsigned(64,leds'length));
elsif to_integer(unsigned(count)) <= 4000000 then
leds <= std_logic_vector(to_unsigned(128,leds'length));
else
count <= (OTHERS => '0');
leds <= (OTHERS => '0');
end if;
end if;
end process MAIN;

Iniciar sesión para comentar.

Respuestas (1)

Kiran Kintali
Kiran Kintali el 20 de Feb. de 2025
This is an unexpected error handling the if/elseif control structure. Please reach to tech support or share your model here. We will provide a workaround and a patch as soon once we diagnose the issue.
  6 comentarios
Kiran Kintali
Kiran Kintali el 21 de Feb. de 2025
We are addressing the issue with the if-elseif blocks and will release an update patch shortly. For control structures such as if/elseif and switch/case, we recommend using the MATLAB function block. This approach enhances model readability and clarifies control logic. Nonetheless, we also fully support the Simulink representations, as it explicitly illustrates both the data flow and control flow.
Please note that HDL Coder unifies all these modeling/representations internally prior to code generation and attempts to optimizes the logic across those constructs. Ideally users should use what works best for them in terms of representing math in MATLAB, Simulink, Stateflow and Simscape.
We will see what else can be done to improve the nD-lookup support. This page has some guidance on best practices using LUT blocks
https://www.mathworks.com/help/hdlcoder/ug/getting-started-with-ram-and-rom-in-simulink.html
Steven Hatcher
Steven Hatcher el 6 de Mzo. de 2025
We've published a bug report on this issue. You can track when the fix gets ported to updates for older releases with it.

Iniciar sesión para comentar.

Etiquetas

Productos


Versión

R2023b

Community Treasure Hunt

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

Start Hunting!

Translated by