-
Notifications
You must be signed in to change notification settings - Fork 81
Optimize opcode check #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Thanks for taking the time to create this pull-request Glenn! This seems to be a simple yet clever way to improve the performance of the simulator, a sort of quick-win. Have you tried comparing the speed of actual code (such as the blink example from the demo project)? What speed did you get and what browser/device have you used? |
Yes, i was just editing my PR to add that, you're too fast 😄 So i observed a ~7% difference using the demo after 5s of simulation time on Firefox 74 Without PR: With PR: |
Oh, I wasn't expecting such a massive difference between Firefox and Chromium performance. Just tested on Chromium 80 Without PR: With PR: |
Good job Glenn! I just released this as part of 0.6.1. Where do you teach embedded systems?
Yeah, that's the purpose of the If you are interested in further looking in these directions let me know, we can brainstorm together. |
Thank you for your reactivity ! I teach at a French university called Université de Bretagne Occidentale. It is not my main job, I only intervene as a substitute teacher for practical work on an introductory course. Practical work include teaching assembly basics, C and the use of some µController peripherals (GPIO, ADC, 7-segment display, LED, timers, buzzer). We teach using AVR libraries without Arduino abstractions to give an understanding of the low level interactions with the hardware. What is of interest to me is that we have custom boards with all our peripherals and an atmega 2560 sitting in the middle. Since school has gone full remote we have to find ways to teach these concepts to students at home. I stumble upon your project and saw the great potential to be able to create a virtual board, or at least part of it (Button and LED would be a good starting point). So I'm not an expert but I'll be glad to help ! I see that you have some interesting issues awaiting that may be easier for me to begin with than performance optimization 😄 |
Thanks for the explanation, that's great to hear! Any help with the open issues will be blessed. Which peripherals do you have on your atmega2560 board? |
👍 for the ADC! As far as the other hardware, here is some stuff we already have: LEDs are there, 7-seg, push buttons, USART, and I also see that you have an LCD there, which we have too. So apart from ADC, the missing pieces are the keypad, buzzer , and switches. If you want to check out the 7-seg, for instance, I created a small programming challenge that uses it, and would love to get your feedback on it: |
Keypad is not necessary, switches shoudn't be hard and I saw that you have an early buzzer implementation in your simon game example. That's a good challenge and a great website. |
Thanks for the feedback! What do you think about building this board page on top of the wokwi.com platform? I have just released a beta editor that actually allows you to tinker with both the code and the hardware / explanations in the page, you can get it to by adding https://wokwi.com/playground/blink?beta-editor=yeah This editor allows you to preview your change immediately, but it currently does not support saving the code. Once if have some code you are happy with, you can send a pull-request to the playgrounds repo, and it will go live shortly after being merged. |
I like the possibility to write lessons using markdown while including electronic components using html ! That's super neat. The dynamic reload is great too.
I'd like to know, do you own wokwi ? Is it intended to be a commercial platform in the future ? For the board I imagined an horizontally split window to fit the real board orientation. But this could be changed, i'll try to build a prototype. A little feedback, I don't personally feel that the "comment section" is useful for this type of content. Imagining lots of comments here would distract from the lesson i think. It's a massive ecosystem of tools you built here, that's amazing. |
Great! Yes, Wokwi is a project I started together with @AriellaE. The idea is to provide a platform where people can create Arduino, Electronics and IoT courses, both paid and free, and share them with the community. Good call about the comments section. We actually added it pretty early in the project, and so far it has only been used by a single person to report about an issue. We'll probably remove it or make it optional (so that they playground owner can decide if they want to have comments or not). Thanks :-) |
Hello,
First I'd like to thank you for this great project. I am teaching the basics of embedded systems and this could be a great resource for me in the future !
While I was taking a look at the source code I came along this quick optimization in the instruction code. I hope I didn't miss something obvious.
Simply replacing
if
withelse if
provides a welcomed performance boost.All these
if
on every opcode adds up, so addingelse if
reduces the amount of checks per opcode.However I liked the clear opcode separation by a line but the prettier doesn't allow this with
else if
so it is a bit ugly and condensed now.I am not too familiar with hardware simulators but my guess would be that use of a map of opcodes or switch statements would provide even greater benefits.
With this PR the last instruction still requires evaluation of all the preceding
if
andelse if
.Benchmarks
Before this PR:
With this PR: