MATLAB: Is there any way to tell HDL Coder to produce less files

HDL Codersimulinkvhdl

Hello, I have many subsystems in my Simulink model which are exactly the same, just different names. However, HDL Coder produces a VHDL file for each and every one. Is there any way to tell Simulink/HDL coder to produce only one file and then use multiple instances? Thanks

Best Answer

Yes, there is. Identical atomic subsystems will only generate one module/entity that will be multiply instantiated. The subsystems need to be structurally identical, have the same data types, signal rates, etc.
So, all you need to do is convert each instance of your shared subsystem to be atomic. An easy way to guarantee this is to place your atomic subsystem in a library, and instantiate the library block wherever necessary. This will also make your Simulink model more compact, removing the subsystem duplication.