In manufacturing systems, a class of Discrete Event Systems (DES), plant behavior can be modeled through automata which serve as the basis for synthesizing controllers using Supervisory Control Theory (SCT). The present paper proposes the usage of Matlab Simulink Stateflow for modeling automata and for automated code generation. The usage of Matlab Simulink is encouraged by its widespread acceptance in industry providing, also, an intrinsic possibility of simulation and flexible automated code generation capability. The feasibility of the proposal is shown by preparing a testbed based on an embedded system target used to set up a hardware-in-the-loop simulation architecture.