Açık kaynak kodlu OpenRISC tabanlı kırmık üstü sistemlerin gerçeklenmesi ve uygulamaları
Implementation and applications of open source OpenRISC based SOC's
Yazar: LATİF AKÇAY
Danışman: DOÇ. DR. SIDDIKA BERNA ÖRS YALÇIN
İstanbul Teknik Üniversitesi / Fen Bilimleri Enstitüsü / Elektronik ve Haberleşme Mühendisliği Ana Bilim Dalı / Elektronik Mühendisliği Bilim Dalı
Derece: Yüksek Lisans, 2015
Konu: Elektrik ve Elektronik Mühendisliği = Electrical and Electronics Engineering
Dizin: Bilgisayar donanımları = Hardware ; Mikroişlemciler = Microprocessors ; Milli güvenlik stratejisi = National security strategy ; Savunma ve askeri iş birliği = Military deference collaboration ; Ulusal güvenlik politikası =

Özet:
Günümüz teknolojisinin hemen her alanda karmaşık elektronik sistemler hayati rol oynamaktadır. Bilgi çağının en önemli alanlarından birisi de elektronik mühendisliği ve çeşitli uygulamalarıdır. Elektronik sistemler söz konusu olduğunda en önemli bileşenlerden birisinin de sistemlerin beynini oluşturan, çeşitli birimleri uyumlu halde çalıştıran, sistemin işlevsel görevlerini yerine getirmesini sağlayan ve tüm işleyişini kontrol edip yöneten mikroişlemci (yada mikrodenetleyici) olduğu görülmektedir.
Sistem tasarımcısı açısından en önemli parametrelerden biri tüm sistemi yönlendirecek olan işlemcinin doğru tasarlanması veya doğru seçilmesidir.İhtiyaca yönelik işlemci tasarımı yapılabilir ancak günümüz şartlarında bu hiç kolay bir iş değildir. İşlemci tasarımı ve üretiminin oldukça karmaşık ve yüksek maliyetli bir süreç olması ihtiyaca özel işlemci tasarımını zorlaştırmaktadır\cite{ilk}. Ayrıca yalnızca bir sistem için tasarlanan bir işlemcinin başka bir iş için kullanımı söz konusu olmayacaksa sırf bir veya birkaç defaya mahsus işlemci tasarımı yapmak maliyet açısından mantıklı bir yaklaşım değildir.
Tüm bu durumlar göz önüne alındığında gerçeklenebilir işlemci çözümlerinin çok önemli faydalar sunduğu görülmektedir. Gerçeklenebilir işlemciler kaynak kodları bir donanım tanımlama dili ile yazılmış ve FPGA veya Uygulamaya Özel Tümleşik Devre (ASIC) platformlarda gerçeklenebilen, yapısı ve çevresel birimleri üzerinde değişklikler yapamaya imkan veren tasarımlardır\cite{tanim}. Kullanıcı lisans durumuna göre tasarımın kaynak kodlarını ya hiç göremez veya tamamen görebilir ve değiştirebilir. Ancak tüm gerçeklenebilir işlemciler ihtiyaca göre değişik kombinasyonlarda yeniden tasarlanıp kullanılabilir. Bu özellikleri ile yukarıda sözü edilen birçok sorunun aşılması adına iyi bir seçenek olarak değerlendirilebilir.
Dünya üzerinde gerçeklenebilir işlemci geliştiren firmalar ve tasarım grupları bulunmakta ve dolayısıyla birden fazla sayıda çözüm bulunmaktadır. Bu çalışmada özellikle bu çözümlerin lisans farklılıkları ve bundan kaynaklı avantajlar üzerinden hareket edilerek açık kaynak kodlu tasarımların avantajları aktarılmıştır. Zira gerçeklenebilir işlemcilerin bazıları Xilinx veya Altera gibi ticari şirketler tarafından tasarlanmıştır ve kaynak kodları gizlidir. Bu işlemcileri ticari anlamda kullanmanın bir takım kısıtlamaları vardır. Bazı gerçeklenebilir işlemciler ise kaynak kodları açık olmasına rağmen ticari anlamdaki kullanımları ücret ödemeyi gerektirmektedir. 
OpenRISC gerçeklenebilir işlemci ailesi ise diğer gerçeklenebilir işlemcilerden farklı olarak tüm kaynak kodları açık ve aynı zamanda ticari olsun olmasın tüm kullanımların tamamen ücretsiz olduğu bir platformdur. Bu zamana kadar çeşitli gerçeklemeleri FPGA (Field Programmable Gate Array - Alanda Programlanabilir Kapı Dizileri) ve ASIC (Application Specific Integrated Circuit - Uygulamaya Özel Tümleşik Devre) ortamlarında yapılmış ve  geliştirilmeye devam edilmektedir. Tamamen gönüllülerden oluşan bir ekibin katkılarıyla geliştirilen bu sistemler gerçeklenebilir işlemciler içerisinde önemli bir yer bulmuştur. Ayrıca bu sistemler için yazılım desteği de sunulmaktadır. GNU GCC  derleyicisi sisteme uyarlanmış ve böylece kolayca yazılım geliştirmek mümkün hale getirilmiştir. 
Bu çalışmada gerçeklenebilir işlemci ve kırmıküstü sistem olarak OpenRISC tabanlı platformlar tercih edilmiştir. Yapılan çalışmalar ve teknik detayları FPGA üzerinde test edilmiş ve sonuçlar paylaşılmıştır.
Bu çalışma işlemci tasarımı ve bilgisayar mimarisi konusunda meraklı olan araştırmacılara iyi bir örnek olması, ülkemizde milli çip tasarımına olan ilgiyi artırması ve gerçeklenebilir işlemci çözümlerinin tanınması noktalarında bir katkı sunması ümidi ile yapılmıştır.

Abstract:
In todays world, almost in every part of technology microprocessors and microcontrollers are widely used. Because of complexity of information systems and advanced software uses all such systems need a brain part which consist of one or more integrated circuits for managing the whole system or a particular issue related to the system. 
It is possible to make many types of classifications about the processor technology. In this work, we just deal with a basic diversity which is called as softcore and hardcore processors. Hardcore processors are actually the well known element of this basic classification. As one can easily understand, the hardcore processor is a device that had been implemented and produced and ready to use it with an application. Despite that the softcore processor is a package that includes rtl code files which were written by using a hardware description language. A soft microprocessor (also called softcore microprocessor or a soft processor) is a microprocessor core that can be wholly implemented using logic synthesis tools. It can be implemented via different semiconductor devices containing programmable logic (e.g. ASIC, FPGA, CPLD), including both high-end and commodity variations. Only few years ago, most systems, if they were using a soft processor at all, could only use a single soft processor. However in recent years, designers manage to map as many softcores as possible onto an FPGA.
There are many advantages and fidelities of using a softcore processor for a system thanks to its natural properties. Maybe the most important feature of softcore processors is that the flexibility of the architecture. Designers can change, add or subtract some of peripherals or size of different units and more about the processor. In addition to this, softcore processors can be easily tested by using an FPGA. Every single part of design can be controlled by using an application and wherby all real life reactans of processor can be seen. This is something more than a simulation which is also the only way to understand the behaviors of a hardcore processor. Another important advantage of a softcore processor is the platform diversity. Many producers have softcore processor designs and advanced tools to implement and test designs.
Sometimes using of only one processor is not eanough especially for large systems such as a warplane. For this kind of situations desining a new processor or microcontroller is something so expensive and so much waste of time. Soft core processors and FPGA (Field Programmable Gate Array) provide a very effective  solution to this issue. Because FPGA's are reconfigurable integrated circuits and can be used as a microcomputer by using  a softcore processor on it. 
Security is one of the most critical parameter during a system design especially for defence industry. By risng of advanced technology, there has been a new war concept which is called as electronic warfare. For this reason the security parameter has become the most impartan factor for military electronic systems. So that it is as least impartan as having these kinds of systems for countries and for armies. If imported integrated circuits were used in military electronic systems of a country, then the security concern would be a problem for everytime. Therefore armies are desired to have military systems which are wholly produced with their national devices and also designed and tested in their country by a national company.
Turkey, after Cyprus Peace Operation, decided to produce national defence systems. As an importer counrty, after the embargo applied by foreign countries, Turkey had realised that to be depentent to other countries in war technologies is very dangerous and risky. Then many defence technology companies were established and supported from Turkish state and foundations. Particularly in recent years, Turkish defence industry has been growing rapidly. Many types of electronic and mechanic weapons are designed and produced by national firms. Currently,  there are billon dolars worth of projects which are on-going or at the planning stage such as national tank, national warplane or long rage missile defence system. In addition to this conditions, Turkey wants to become an important exporter country in the field defence industry on the world. 
Like many other countries, Turkey is still also an imported country in the field of microcontroller and microprocessor. Because, there are few dominant companies which produce these devices and they have a very colossal knowledge and many precious patents rigths. Additionally, produce and investment costs are at extraordinary high levels. Competition diffuculty with dominat companies is also such a big problem for this industry. Perhaps the most important missing thing is that lack of trained engineer and technician. Because of all these reasons, we can say that the idea of self-design and self-produce is mandatory but not close to perform in near future for microprocessors and microcontrollers.
We hope that this work will become a small but an important step through to the national microprocessor target of our country. Even if the hdl codes don't belong to us, this work may be a good guide for a new design. Thanks to open source feature of OpenRisc project, one can examine and learn how to design a processor, how to prepare a toolchain, how to port it to a operating system etc. Therefore, we believe in that this work will be a guide for newbies of softcore processor design.
OpenRisc processor family is one of the most famous architecture in open source world. It is a project to develop and open source instruction set architecture (ISA) based on reduced instruction set computing (RISC) methodology. 
So many advanced properties about the  OpenRisc architecure were explained in this thesis work. But the key feature about the OpenRisc is related with the license status. OpenRisc implemantations are wholly open source and it is free to use, change, sell or distribute all of the details. That makes OpenRisc very useful acccording to the other softcore processor solutions. Nobody has to pay for any of the project tools or any type of usage. Therefore OpenRisc has become the prefered platform for this work. Because our aim is to learn about architecture of processor design and suggest an open and free system-on-chip solution for national projects and also to be a guide for people who wants to improve their skills on processor desing and implementation.
There have been several implemantation of OpenRisc1000 architecture. The most popular ones are the or1200 cpu and the new mor1kx cpu. During this work, both or1200 and mor1kx processor are used to try different application on FPGA. 
For this work, Digilent Atlys board was choosen for trials done by using Orpsoc-v2 and Orpsoc-v3. Orpsoc(OpenRisc Referece Platform System-on-Chip) is a paltform that contains an OpenRisc processor and many different peripherals such as ethernet, usb, spi, i2c, uart, gpio, debugger and so on. During the work, different applications are made for using these peripherals and for testing whether such a big open source project is usefull or not enough for an industrial usage.
For a microprocessor work, the first thing needed is a compiler. Because if we can not compile an application then it does not make sense to have a procossor. GNU GCC toolchain had been ported for OpenRisc 1000 family with different C libraries. There are different solutions shared for  bare metal and for Linux systems. The first thing done was the installing the toochain which is for bare metal systems. After that, we have also installed a good simulator which was designed for OpenRisc processors. So, we were able to compile codes for used platforms.
After finishing works for toolchain issue, we have downloaded orpsoc-v2 project files and started to work on it. We have made many applications using orpsoc-v2 platform. These applications were sometimes as easy as a simple hello world code. But we have also tried complex applications like U-Boot and Linux. The hard challenge was the modification process. We have added new costum designed peripherals to the wishbone network of platform. The new peripherals were tested by using them during applications.
During the work, all issues about the hardware design and implemantation such as synthesis , place and route or bitstream file production, we have used Xilinx ISE Desing Suite programs.  There are many extra tools provided with this package.  For example, we have made some kind of simulations by using ISIM simulator which was installed together with Xilinx ISE webpack. 
We have done similar steps also for orpsoc-v3 platform. The difference between these two platforms were explained in details in this thesis work. 
We have also added our future plans about the work. We have good plans about getting platforms more independent from any other companies tools. In addition to this, there is an intention for designing an ASIC model of OpenRisc 1000 family processor based system-on-chip. We will try to add encryption and decryption peripherals to the wishbone network so that the chip will be able to use in the field of security system designs.