During my first week in my company, I was very excited and eager to choose my very own project. However I am very new to the work that I am going to do. I have only very basic experience in C programming, minimal knowledge in assembly language and almost zero Verilog/VHDL. I doubt my ability to program something from scratch. Luckily I am allowed to modify an existing open source code.
I am interested in working on making an instruction simulator (ISS) for the AEMB processor. I am interested in ISS as I like modeling and simulations. The suggested open source code for me to start with is QEMU, Icarus verilog, Gem5 and GPL Cver.
I searched every one of these projects. But I was frightened by the length and complexity of these projects. These codes have either hundreds of coding files or megabytes worth of codes. I knew that if I worked on these projects, I will ended achieving nothing by the end of my internship.
My first week was almost over, desperately, I tried to search for other similar open source projects. To my surprise, I found a MicroBlaze Cycle Accurate Instruction Set Simulator. The code has only a few files and the code itself is not that long (although it still consists of thousands of lines). It has a MakeFile which makes my compiling easier. Happily I suggested this project.
I faced problems compiling the program. I knew that it has something to do with the non-existing header file. I spent quite some time searching for the appropriate library file. I made a mistake searching for the header file in the Apple’s site (we are running Ubuntu). My actions irritated my supervisor. He helped me installed the appropriate library file, libelf0-dev on Ubuntu within seconds, the code compiled successfully.
Being able to compile is not the end of the story. The program failed with a segmentation fault. Segmentation fault has something to do with the memory allocations. It would have taken me forever to solve this, again, marvelously, my supervisor helped me to solve this in seconds. Then, there are errors in loading the executable, branching operation, assertion error, wrongly interpreted instructions, etc.
It took me weeks just to debug and make this program executing without errors. Now, the program is executing without error, I need to check whether it is working properly (executing instructions in accordance to its algorithm). There are still dozens of warnings while compiling that I will need to attend in the future.
The main weakness of the source code that I am working on is that it does not have proper comments regarding its algorithm. I spent a lot of time trying to understand it. A lot of time was wasted just to make the simulator simulate the Microblaze architecture, let alone porting it to simulate the AEMB architecture.
As a Chinese saying goes “a good start accounts for half the success”. This is true for my case in a brutal manner. Although I have wasted a lot of my time debugging, but at least I am getting to understand the flow of the program. Sam and my supervisor have helped me greatly.