Triggering the simulation is the task I am working on lately. I will try this time to sum up what I have done to fulfil this task. To recall, we need to read the addresses to which data are stored, and addresses from where data are loaded, then, trigger the corresponding I/O device. In other words, when the line-by-line simulation is running on the editor side, we need to check the addresses when Load/Store operations occur, if the address is related to a device that is on the schematic, then, we trigger that device.

First of all, I have preferred to work only on the schematic side or JavaScript side where I already can receive the hard-coded data that are coming from HTTP requests which I explained before. I already was able to blink wires in a simple example I have built while I was learning JointJs. I could do it by setting the signal property of the wire into ‘1’ whenever the read address is related to the hardware on the schematic side, furthermore, there is an event listener to the signal values of all the wires, hence, if there is a change on the signal property of any wire, a callback function will be called with the wire object as an argument so we can edit on the set wire whatever we want, I chose to only change the color of the wire into blue as a sign that it has an active signal. However, I need now to figure out a way to do it on the circuit schematic of the project I am working on. I was confused how I can access the elements of the graph that was already defined. I was trying to make a clone of the graph and its content directly after it was defined, then, send it as an argument to a function where I can perform the changes I need, however, I then realized that I actually can access the paper, graph and all of the elements of the schematic any where on the JavaScript side. Then, I created a function that I called triggerSimulation(), and there I tried to blink the wires. As you noticed, the names of variables and functions that we make have to be meaningful so it can help other developers who are contributing to the project understand the purpose of the variables and functions that you create. Anyway, I could finally blink the wires. After that, Dr Shawn asked me to blink the module itself instead of the wire. To do that, we follow a very similar way, however, we only change the colour of the module itself instead of its wires. Since the modules are SVG elements, I had some difficulties to access their CSS properties, so I decided to access their properties and add up an extra layer with purple colour on the top of the module, and I remove this layer if I want to set the module OFF. This can be done through the id of the module. All we need is the id of the element so we can have an access to change its properties. There is a problem that I have faced which is that if the user restart the page while running the simulation, some modules would still be having the ON state which means the effect of signals from previous simulation session still exists. I could solve this issue by making an initializer function that set all modules on the schematic OFF immediately after the schematic is loaded to the page.

Second, we must now get real data that are retrieved from the kernel. To do that, I sent GET request to the back-end whenever there is a Load or Store operation. The content of the request is the read address. The back-end runs gdb, then, runs the command “info symbol <address>” to get the corresponding symbol of the address and send it back as a response to the JavaScript side where I take the symbol and compare with last two letters of all the ids of the elements.

When I showed my progress to Dr Shawn, he told me that the code is not robust, and he proved it to me. When he changed the code on the Codemirror side, it did not work and there was no triggering or triggering to wrong modules because I did not put in mind that the variable names are set by the users and they can be anything. I assumed that variable names consist of two letters and starts with capital K, and this is definitely wrong. Thus, Dr Shawn recommended me with two ways to complete this task the right way. So, my progress so far is alright, but it is not fully completed yet since there is more work to be done. I decided to do both ways Dr Shawn suggested, and then compare how robust and how well both methods can perform, then, choose the better one to fulfil this task. Since I already talked a lot, I will tell you more about the two methods, what they are, how they can be done and the comparison next week. Stay tuned!


0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.