I have some tasks in verilog file. And I want to see them in simvision when they are triggered.
Is there any way to find task's triggered point in simvision?
Is this can not be able to visualize in simvision? I know that manner like using print or display statements. But I need to visualize to simvision. Does anyone know that way?
UPDATE
Use a breakpoint
If you don't have access to the source of the task, or cannot modify it, >you could set a breakpoint when the task is called, execute some TCL >commands, then continue the simulation. The TCL commands could toggle a >signal or increment a counter. This could be automated with a small TCL >script. Depending on your situation, this could cause a performance hit on >the simulation time.
I want to know more this manner, would you let me know this way how to make it? Please let me know even if simple I am OK.
I don't think there is a native way to do this, but you should check the documentation that Cadence provides. That said, there are a few options you could employ to get information into the waveform.
Add a counter
If you can modify the source for the task, you can add a global counter somewhere which increments each time the task is called. Then add the counter register to the waveform.
Toggle a bit
Similarly, you could use a single bit and toggle it when the task is called. Using a counter has the advantage that if the task can be called twice in the same time step, you will see the counter increment by 2, whereas the single bit would toggle twice and not be visible in the waveform, unless you have zero-time event capturing enabled.
Use a breakpoint
If you don't have access to the source of the task, or cannot modify it, you could set a breakpoint when the task is called, execute some TCL commands, then continue the simulation. The TCL commands could toggle a signal or increment a counter. This could be automated with a small TCL script. Depending on your situation, this could cause a performance hit on the simulation time.
Related
I'm developing a game in pyglet, that scheduled by a simple text file like :
0:00:01;event1
0:00:02;event2
0:00:03;event3
The fact is that, among these events, some might be blocking (for instance event2 might consist in displaying instructions until a key is pressed). As a consequence, event3 might not be executed at the proper time (i.e., during the event2). For now, my strategy is to schedule one event after the other :
Execute the first event
Once the first event is finished, compute the remaining duration between the first and the second event (delta_duration)
Schedule the second event with a delay of delta_duration
... and so on
For now, I did not succeed in implementing properly a blocking event with this strategy. It seems that anything blocking the event_loop (like a sleep call during event2) is preventing even the graphical elements of event2 (text instructions) to be displayed. On the other hand, if I do not put any blocking routine (sleep) in the event2, I'm able to see the vertices, but the scheduler keeps on scheduling (!), and so the event3 comes too soon.
My question is : what would be a general strategy, in pyglet, to articulate non-blocking to blocking events ? More precisely, is it possible (desirable) to use multiple clocks for that purpose ? The pyglet documentation mentions that multiple clocks can be used but it is not very well explained.
I don't want a solution that is specific to my events example but, rather, general indications about the way to go.
It's really up to your program on what blocks. If you are using input from Python for the console window, then yes that will block because it's blocking execution of Python in general. If you have a label popup in the window that is waiting for input from an on_key_press window event, then that is completely different as it's not blocking the pyglet loop, it was scheduled within it.
If your event is a 20 second long math calculation, then that should probably be ran in a thread. You will probably have to separate the types of events in order to differentiate how they should be ran. It's hard to say because without a runnable example or sample of code, I am just guessing at your intentions.
Although it sounds more like you are wanting some sort of callback system. When execution of func1 is declared done, go to func2. There is nothing built into pyglet like this, you would have to have a clever use of scheduling. There are examples of this using pure python though. I personally use Twisted Deferred's for this.
I am running a class that takes several minutes. There are many times that it is about halfway done when I realize that I would like to print something. Is there a way to add in a print statement without having to stop the run and add it in if the specific function has not run yet? All I have really been able to find is sleep statements, but those would need to have been added before the run and I can't edit the code using a sleep timer.
You cannot pause the execution of the code and overwrite the code to reflect the changes in the forthcoming execution steps. The python file is compiled into a .pyc file which is currently getting executed. Hence even if you manage to pause it somehow, the current execution will resume the execution of the previous executable itself. also the use of sleep function is not actually stopping the execution. The code is still executing.
A good way to go about doing this is to setup logical breakpoints in your code rather than using multiple print statements throughout. You may have a look at this or this to know how to set break points. Although I would recommend using the VsCode debugger for the task.
Thus in conclusion, you cannot pause the script and make edits such that they reflect upon resuming the script's execution. Technically you can stall the execution of the script but that would never allow you to achieve what you intend to do.
The print statement is not your logger; use logging instead
Here are the docs: https://docs.python.org/3/library/logging.html
Here's a good example on how to use Logging: https://realpython.com/python-logging/
Start putting logger statements throughout your code.
a way to pause the code mid-run
Yes, it's called a breakpoint. You'll need to set a breakpoint somewhere in your code. It can even be a conditional breakpoint in that the breakpoint only triggers when a certain condition is met.
You can then look at the variable values in your program's stack.
PyCharm is very good at all of this. I highly recommend it.
Is it possible to perform look ahead simulation in AnyLogic?
Specifically:
Simulate till time T.
Using 2 values of a variable, simulate for both values till T+t in parallel.
Evaluate the system state at T+t, choose the value of variable which leads to better performance.
Continue simulating from T using the selected value for the variable.
This is the basic functionality I am trying to implement. The variable values can be taken from decision tree, which should not affect the implementation.
Please let me know if someone has done something like this.
Yes, it is possible with some Java code. You may:
Pause parent experiment, save snapshot at time T;
Create two new experiments from parent experiment;
Load snapshots in two new experiments;
Continue execution of both experiments till time T + t;
Send notification to parent experiment, compare the results, assign the best value and continue simulation.
Some points can be done manually with UI controls or by code, some — by code only.
I am working on a big project that puts performance as a high priority. I have a little bit of experience using wxPython to create windows and dialog boxes for software, but I have no experience in getting processes to work in parallel during the course of a single program.
So basically, what I want to accomplish is the following:
I want one main class that controls the high level program. It sets up a configuration either from a config file or from user input. This much I have accomplished on my own.
I need PROCESS #1 to read in a file and a list of commands, execute the commands, and then pass the modified file to PROCESS #2 (this requires that PROCESS #2 is ready to accept new input.) Once the file is passed, PROCESS #1 would begin work on the next set of inputs and wait for PROCESS #2 to finish before the cycle repeats.
PROCESS #2 takes input from PROCESS #1 and writes output to a log file. Once the output is complete, it waits for the next set of output from PROCESS #1.
I know how to use wxTimers and the events associated with that, but what I have found is that a timer event will not execute if the program is otherwise occupied (like in the middle of a method.)
I have seen threads about "threading" and "Pool", but the terminology tends to go over my head, and I haven't gotten any of that sort of stuff to work.
If anybody can point me in the right direction, I would be greatly appreciative.
If you use threads, then I think this would be fairly easy to do. Here's what I would suggest:
Create a button (or some other widget) to execute process #1 in a thread. The thread itself will run BOTH processes. Here's some psuedo-code that might help:
# this is in your thread code:
result = self.call_process_1(args)
self.call_process_2(result)
This will allow you to start another process #1/2 with a new set of commands every time you press the button. Since the two processes are encapsulated in the thread, they don't have to wait for process #2 to finish. You will probably need to log to separate logs for the logs to make sense, but you can label the logs with a timestamp and a thread number or a uuid.
Depending on how many of these processes you need to do, you might need to look into setting up a cluster that's driven with celery or some such. But I think this is a good starting place.
Simply put, I want to manipulate two motors in parallel, then when both are ready, continue with a 3rd thread.
Below is image of what I have now. In two top threads, it sets motors B and C to "unlimited", then waits until both trigger the switches, then sets a separate boolean variable for both.
Then in 3rd thread, I poll these two variables with 1 second interval, until AND operation gives true to the loop termination condition.
This is embedded system and all, so it may be ok here, but in "PC programming", this kind of polling loop would be rather horrible thing to do.
Question: Can I do either of both of
wait for variable without this kind of polling loop?
wait for a thread to finish without using a variable at all?
Your question is a bit vague on what you actually want to achieve and using which language. As I understood you want to be able to implement a similar multithreaded motor control mechanism in Labview?
If so, then the answer to both of your questions is yes, you can implement the wait without an explicitly defined variable (other than the error cluster, which you probably would be passing around anyway). The easiest method is to pass an error cluster to both your loops and then use Merge errors to combine the generated errors once the loops are finished. Merge errors will wait until both inputs have data, merges the errors, and passes the merged error cluster on. By wiring the merged error cluster to your teardown function you effectively achieve the thread synchronization you described. If you require thread synchronization for the two control loops, you would however still have to use semaphores, rendezvous', notifiers, and other built-in synch methods.
In the image there's an init function that opens two serial devices (purple wire) and passes them to the control loops, which both runs until an error (yellow-black wire) occurs. The errors from both are merged and passed to the teardown function that releases the serial devices. Notice that in this particular example the synchronization would occur at the end of program as long as there's at least one wire coming from each loop to the teardown function.
Similar functionality in a text based programming language would necessitate the use of more elaborate mechanisms, though some specialised language for parallel programming might help here.