The invention provides a Simulink
code generation method and device based on a hardware instruction, and relates to the technical field of embedded
code generation, the method comprises the following steps: obtaining an initial
data flow diagram of a model, and reconstructing the initial
data flow diagram based on a preset optimization rule to obtain a reconstructed target
data flow diagram; analyzing the topological structure of the reconstructed data flow diagram, determining an execution dependency relationship among the components, and deducing a
code translation sequence; respectively generating a
code snippet corresponding to each component in the
code translation sequence, and integrating the generated code snippets according to a
code translation sequence indicated by the code translation sequence to obtain a target code. According to the
code generation method and device, in the code
generation process, the candidate rules capable of maximizing
delay reduction can be selected to recognize the optimizable components, the corresponding hardware specific instructions are comprehensively generated for the optimizable components, and therefore efficient embedded codes capable of being directly deployed are generated.