Using while loop in c block

Altair Community Member
Updated by reza hakimi_20486
Hello
In a program, I want the C block to continuously read the input and change the output according to the input
Now I have a few questions
1. Should I put the whole program in a while loop?
2. If I put it in the while loop, the speed of the simulation will decrease drastically, what is the solution to this problem?
3. Is there any other tool in psim other than Block C that has the ability to generate code and do this for me
I will put the image of the program in the continuation of the question