In my last post I mentioned a hard week at school. I think it is time to post some computer science on this blog. I am taking an embedded system course and I had to make a ball bounce on a screen. Something that doesn’t sound that hard unless you know that I can’t program on the computer that I am using to display the ball. The second catch was that the ball had to be drawn from a FPGA peripheral. I will stop the tech speak now and just show you some pretty pictures.
My first attempt at drawing a circle on the screen wasn’t quite right but to be far there are circles…
My next attempt was a little less mind bending. At this point I was going insane from the 90 degree room I had to work in but somehow I kept going although I admit I did look at how much of my final grade this lab was worth (10% for anyone wondering).
Once I finally got a circle on the screen I just had to figure out how to draw it different places and so to help with that I decided to make a grid along with my circle.
At this point I was finished with the hardware design (which wasn’t that hard) now just to get software to talk to this lovely ball drawer.
My first attempt at getting the ball to move from software I was pretty sure I was going to fail and so the result did not surprise me. The basic code for moving the ball seemed to work but it was obvious I was having an overflow problem as the ball would only go in the top left corner in the screen. The weird motion of it getting stuck though I wasn’t sure about though.
I went back to my hardware and found the problem was the stupid software that generated the hardware files automatically so I ran the whole 15 minute process again and had the hardware connect the right amount of bits to my little ball drawer. I was not optimistic when I finally ran the software again but the resulting empty screen was a little more than I could bare after so many hours of working on this and the very few ideas of what to do next to solve my problem.
It was apparent that the problem was on the software end though since the hardware default put the ball nicely in the middle of the screen. I started to figure out how the device driver I was given actually communicated with the FPGA figuring that was where my trouble was. I was in an abysmal mood when I saw it. The example hardware had only needed 8 bits, a byte, so the next address when sending information was just the offset away. In my hardware I needed 16 bits so I could send addresses over 128 to the drawer which is 2 bytes. All I had to do to fix my problem was change “+offset” to “+offset*2”. It was too good to be true. I was so nervous testing it because if this didn’t work I really had no idea where to go from there. I cringed as I installed the device driver into the kernel and then as I ran my little test program. To my relief and sanity it worked!!! I had a ball bouncing nicely around my screen. After a few quick adjustments on where the edges where I was finished!
I want to say I was triumphant and overjoyed I had accomplished my lab but mostly I was just relieved. It was due the next day and I hadn’t eaten all day and by the time I was finished it was past 8pm.
In case anyone wonders the specific technologies I was using were an Altera SoCKit FPGA board with Quartus II and Qsys. It is some pretty cool technology and I am looking forward to working with it some more… just not in a 100 degree lab right before a deadline…