If your target hardware requires you to generate C and HDL code it is better to split your design into two subsystems or two models / model reference blocks (one for hardware and other for software). See this video for general guidance on such a workflow.
For subsystem targeting FPGA/ASIC you need to model the algorithm using HDL supported subset of MATLAB and Simulink constructs for HDL code generation.