One Big Roller Coaster

What My Brief Journey in the STEM World Has Taught Me So Far

A computer is a crucial daily tool for the majority of the youth. however, this technology is yet alien to a good part of our community. Growing up in a country with one of the least digitally literate people in the world, pursuing technology has always been a daunting dream for most students in Ethiopia. This dream of ours, however, is a necessity. An ambition that we could never give up on, knowing what transformative impact it can put forward.

So much potential and ability, yet so little technology to bring it all out.  So many enthusiastic learners to change this bitter truth of our country, yet so few resources and opportunities to help them make it happen. So much fresh energy and motive, yet so little access. The need to invest in the forthcoming generation’s potential, especially in the STEM sector, is prominent. Being fortunate enough to find myself in this fascinating world of endless innovations has drastically improved my outlook on the sector and my community. I now believe that STEM has the power to change and empower communities like mine. Technology has the potential to illuminate the darkness of illiteracy residing in our country. Ethiopia has 60% of people under the age of 25 that could benefit from the ample education opportunities of STEM whilst contributing to the development of our nation, and beyond, continent. Observing how eager the youth community is to transform the country’s unfortunate reality into prosperity, I understand that I should also be responsible for the overhaul of Ethiopia’s technological sector and not just the government I continually blame. Besides, to have my contribution in this area of advancement brings pleasure like no other. My country’s promising future that I caught a glimpse through the vast window of STEM is worth struggling for.

A Brief Dive into Programming

To New Beginnings

Admittedly, computer skill is indeed the new norm of literacy. Needless to mention, almost every profession nowadays needs a basic grasp of computers. Automation, social media marketing, e-commerce, GIS and remote sensing, big data, and many more are IT-based that are administered by professionals with intermediate to advanced IT skills. Among these, programming or coding is the element that allows users to communicate with machines and computers. It blends logical thinking with creativity to develop something that makes life easier and much more pleasurable. 

Programming can be easy to get the basics while being quite challenging to master it.  Coding might be puzzling at the beginning due to the different learning styles and techniques taken by others. The best way to tackle this problem is by crafting one’s own curriculum based on the type of learner one is. Following that, they may begin fishing in the enormous sea of resources. Not to add, remaining focused on developing one skill before moving on to the next is critical in learning how to code. Having far too many ideas simultaneously can be distracting and demotivating. 

There is a common perception that somewhere out there exists an ideal language for beginners in programming; this is in fact not true. A programming language is basically a tool that IT people use to code instructions for computers to operate. A web developer believes that JavaScript is the best-suited language for a newbie to learn. A data scientist favors Python over any other language. A game developer can be a big fan of C++. But, at the end of the day, what matters is what you’re attempting to do with your instrument. Loops, conditionals, functions, and other fundamental programming principles are all the same. The distinction is primarily syntactical. 

Although there are a lot of perks to becoming a qualified programmer, one must always update his or her competencies to keep up with the fast-changing competing world. In fact, there is a huge demand for programmers worldwide, which has resulted in an exponentially expanding number of people entering the industry. Because the competition is fierce, one must develop a cheerful attitude, task management skills, rapid learning capacity, and the ability to work well in a team to succeed.  

One Big Roller Coaster

An Introduction

Writing, to me, is simply thinking through my fingers.
-Issac Asimov

I am Amrot, a passionate learner and tech enthusiast. I am the co-founder of a youth tech platform, Technoelpis. Currently, in the process of assisting technophile youth get one step closer to their ultimate careers, I am also molding myself into an incredibly industrious computer operator. I believe that my small journey in the STEM world as a high schooler who is incredibly enthralled by the overall functioning of the digital world is worth sharing. My unanticipated transformation from not being familiar with a single concept about computers to discovering the joy of exploring the vast digital world in just a year. It was like unfolding a whole new chapter of adventures to thrive through. And, indeed, One big roller coaster.

In my bi-weekly blogs, I will be discussing affairs regarding the tech world, mainly focusing on the digital industries of Africa and Ethiopia. In addition to that, I will be sharing some of my personal experiences and reflecting on my perspectives on different issues concerning STEM. My ultimate goal is to inspire my audience whilst proposing positive ideas and solutions to our current quandaries in regard to scientific Africa. I profoundly believe that this will be a space where I can bring my candid outlooks on various areas in relation to STEM and interact with my audience well to come up with tangible conclusions and better content every time.

Should you have any questions, suggestions, or specific topics you would like me to write about, do not hesitate to let me know in the comments.

Would you like to know more about me?

https://gmt.tzg.mybluehost.me/.website_4544bb84/women-in-stem-spotlight-amrot-abiyu/

Women in STEM Spotlight: Ruth Asmamaw

As a kid, I’ve always found myself specifically drawn to studying natural science. For someone who loves solving problems, and being surrounded by stories of humanity, being a doctor seemed to be the only career path I could take. I never thought of studying software engineering because I have always imagined it as a man’s job and never thought I would fit in.  That was a couple of years ago but I am very positive that there are many girls out there who still have this stereotypical image of a software engineer.   It is not until I got introduced to Women in Tech, that I completely changed my perception. Although it’s clearly visible that there is a strong gender bias in the tech industry, I saw that there is space for people like me with values of solving problems and impacting humanity aligns.

 

In my first few weeks of school, things weren’t going my way. Being a girl with no prior programming knowledge surrounded by computer whizzes was tough. Frustration was taking me all in. But on the bright side, it was an eye-opening moment. Anxious to cope with my peers, I started devouring every piece of information that comes my way. I spent hours googling and asking the internet about programming and software tutorials. Since there isn’t a wrong way of learning things, I kept on exploring new methods that suit my learning style best. I was attending online courses and taking lessons via videos.  Thanks to the internet almost everything I needed was only a fingertip away.

Throughout my exploration, I have come across various subfields of software engineering. Digging into this diverse area has made me realize the ample opportunities it comes with and how one can choose a field to specialize in based on his/her interests, skills, and strengths.  I personally found myself leaning towards the web development area. The process of creating something tangible out of an abstract idea was so fascinating to learn. Web development gave me the ability to see the world from another perspective and has helped me solve problems that I face in my day-to-day life. Learning this new skill was constantly giving me the feeling of accomplishment, which in my case happened to be my number one motivator. Throughout the process, I also worked on bettering my communication and other soft skills.

 

I aspire to become a very significant figure in the tech industry. Living in a country that is still new to the technology era, I believe that there is a lot to be done. I also wish to give back to what the world has given to me. I am among the privileged ones, living in a city and having access to quality education, but I know that most of the girls out there have a handful of these opportunities. My dream is to help these bright girls free themselves from the meshed society had put them in and conquer their dreams.

Amrot Abiyu

Women in STEM Spotlight: Amrot Abiyu

I strongly believe in the power of hard work, for it is meant to enable us to achieve the unthinkable.
Let me introduce myself first. My name is Amrot Abiyu. Amrot is an Ethiopian high schooler living with her father and grandma in Addis, around Gulelle. She is a proud student of Nazareth School and the co-founder of Technoelpis- an association of young Ethiopian learners interested in the field of technology to share ideas/ experiences to help everyone discover and explore their ambitions through each other. We aim to influence people in a way that would change their lives for the better. She Carries a deep passion for sharing with others whatever type of knowledge and experience she comes across.
I have never in my entire life thought that there would be a single chance that I would get involved in the field of technology until last summer, when my amazing friend Nebus encouraged me to apply for a summer coding camp for high school students. I opposed at first. I didn’t like the idea and I thought the topic was not interesting at all because I didn’t have any understanding of the subject. That was until I got accepted and attended the program. In the process, I started falling in love with computer science. I found discovering the amusing complexions of programming delightful. Now that I think of it, it thought me that nothing but our way of thinking and perspectives stops us from exploring and enjoying our true selves. I wouldn’t have got the opportunity to discover my abilities and meet all those amazing people if I had decided not to apply just because I thought I wouldn’t make it.
Speaking of amazing people, I was lucky enough to make some great friends at the summer program, who are now my co-workers in the technology community we founded to make what we learned (programming/ computer science) accessible to every student. Technoelpis was founded by me and my four other colleagues in the January of 2022. We are now working on our virtual summer camp which consists of a coding course, self-development classes, and college application info sessions with student guests from top schools. From not knowing a single thing about computers to constructing a summer camp with over 50 students, it’s been quite a journey that wouldn’t have been true without the work and dedication of the team as well as our supporting members. I faced some challenges with some of the applicants for the program who were sometimes a bit ill-mannered and said unpleasant words or negative sentences on the comment sections of my Technoelpis social media posts. Despite these issues, I knew very well that what I am doing for myself as well as my community was much more than how a random individual tried to define it. I also had some difficulties managing my time at first, but now I can schedule everything and get my work done in a disciplined manner. I was able to understand that challenges were not there to stop me from accomplishing what I dream of or tear me down, but to shape me into the strong and hardworking young lady I aspire to become. Building this mindset helped me to focus on the numerous positive blessings I was granted and keep pushing forward.
I still have an extensive journey and countless experiences to live through. All that I am doing today wouldn’t have been true if it wasn’t for all the supportive and great people around me. I would very much like to thank every one of them.

Women in STEM Spotlight: Afrah Hussein

Who Am I?

 

I am Afrah Hussein, an Electrical and Computer Engineering student at AASTU. When I attended high school, I got the chance to participate in a summer training organized by STEMPower owing to my involvement in my school’s exhibition. In the summer training, I studied different electronic and programming courses. The lessons were exciting and helped develop my skills. But when it came to collaboration in group work, it was a bit challenging as I was not used to it. 

Lessons From My Experience

 

What girls need to know about project selection is this, you don’t have to be affected by negative feedback from anyone. From experience, my project consisted of two parts, the electrical and mechanical. I was getting lots of negative suggestions from students that I could not do the mechanical part alone. They said even if I did, it wouldn’t function. They concluded that I had to change my project to an easier one. But once I did my research, believed I could do it, and planned how negative feedback and suggestions didn’t affect me and the effort I was putting into implementing my project.  

 

Despite the negative feedback, I finished my project on time and got the first rank in the competition held after the training. Once you know and figure out a way to do something, you don’t have to give up on it. Especially if it is your dream. Other people might not see it the way you do. So, I say to prove them wrong. 

Aspiration

My motivation and dream are to take a substantial part in the technology revolution by adapting existing technologies and introducing new ones to the world. And to build (create) a better world to live in. 

Three things I advise girls who want to join STEM are:

  1.  First, be sure and clearly state what you want to do, and don’t let anyone change your mood for work.
  2. Take risks and engage with a specific field that inspires you the most.
  3. Use the opportunities in front of you properly because they will help you to accelerate achieving your dreams.

 

Projects I Worked on

 

  1. A stair-climbing balanced wheelchair with a distance notifier
      1. This project is a Self-stabilizing platform that automatically balances the wheelchair, fixing it with a defined axis. While climbing the stair, the center of mass of the wheelchair carrying the user changes. The accelerometer, with the help of the servo motors, fixes the wheelchair in a balanced state. It also includes the ultrasonic sensor and Sharp GP2Y0A21 Distance sensor to notify the distances and speed between the wheelchair and the nearby solid object following the wheelchair.
  2. ICU assistance software
      1. The main objective of this project is to develop a system that enables doctors to follow up with their patients distantly and to get notifications whenever there is an emergency case.

 

Conclusion

“If there’s a will, there’s a way!” There’s nothing we can’t do if we set our minds to it and dedicate ourselves.

 

Want to Get in Touch?

LinkedIn

Telegram Channel

Facebook

Instagram

Making a RISC-V Processor

Well, it has been a while.

A few months ago, I challenged myself to make a drone from scratch and wrote a blog where I laid out the plan for this goal. The uniqueness of the project was that the flight controller of the drone runs not on an Arduino or Raspberry PI as it is done in similar projects. Instead, I wanted to build a RISC-V-based processor on FPGA and use this processor to run the flight controller program. I hereby want to update you on my progress.

A detailed description of the project can be found in the first blog. At a high level, this project involves 1) making a soft RISC-V processor (implementing the RTL), 2) making a custom FPGA PCB board and successfully loading the RISC-V processor into the FPGA, and 3) developing a flight controller program using C language and running it using the RISC-V processor inside the FPGA, and finally, 4) constructing and testing the drone. So far, I have completed the first task; that is, I have implemented and verified (to a certain extent) a 32-bit RISC-V processor.

In this blog, I discuss my design of the processor (the design is mostly inspired by the content in one of David Patterson’s book). I will also share a link to a detailed design diagram and the source code itself. My goal is to inspire and equip my readers to take on the same or similar projects and succeed.

What is a Processor?

A processor is a machine; it is a digital machine with two types of input. Its inputs are data and instruction. The input instruction tells the processor what to do with the input data. After manipulating the input data, the processor can modify its internal state and/or generate output data.

Embedded system processors (which we will focus on in this blog series), typically work with two distinct memories. The first is the Program Memory (PMEM) which carries the sequence of instructions the processor need to execute. The other is the Data Memory (DMEM), which carries the input and output data of the processor. Based on the sequence of instructions in PMEM, the processor reads and modifies the contents of DMEM. This is illustrated in Figure 1.

Figure 1. Processor Input and Outputs

Composition of a Processor

The processor block is typically composed of the following elements. We will discuss each subsequently.

  1. Registers
  2. Arithmetic Logic Unit (ALU)
  3. Control Unit (CU)
  4. Immediate
  5. Program Counter (PC)
Registers

Registers are the internal memory of the processor. The processor can operate only on data that is stored in registers; the processor does not manipulate data directly at the DMEM. Instead, the data is first copied from DMEM to registers through load instructions. The direct output of a processor operation is written to one of the registers before it is copied to DMEM through store instructions.

RISC-V instruction set manual specifies the processor to have 32 registers. In the 32-bit version of the standard, each of these registers have 32-bit width. The first register is specified to contain 0 always. As shown in Figure 2, an instruction can read one or two registers (source_0_idx and source_1_idx) and can write to one register (dest_idx).

Figure 2. RISC-V Registers

Before we move forward, it may be good to see what a RISC-V instruction looks like. RISC-V is a processor following the RISC-V instruction set manual specification. The instruction manual outlines and defines a set of instructions to be supported by a RISC-V processor. In other words, a specification compliant RISC-V processor can correctly run a program that is generated by a RISC-V compiler.

There are multiple versions of RISC-V processors. The basic 32-bit RISC-V instruction set involves more than 40 instructions (see the full list). As shown in Figure 2, each instruction is represented by 32 bits; and within these 32 bits, the instruction packs the opcode (opcode and func3) which determines the function of the instruction, the index of register operands (rs1 and rs2) which determine the operands of the instruction, destination register index (rd) where the output is written to, and a constant (imm) which is an additional operand.

An instruction format defines how the different components of the instruction are arranged within the available 32 bits. As shown in Figure 3, 32-bit RISC-V instructions use one of the shown six formats.

Figure 3. RISC-V instruction formats

As an example, you may consider the RISC-V instruction ADDI rd, rs1, imm. This instruction adds the content of register rs1 with imm and stores the sum into register rd. If the actual instruction is ADDI 5,0,10, then the processor is instructed to add 10 to the contents of register 0 (which is always 0). After the processor finishes executing this instruction, we should find 10 at register 5.

ADDI follows the “I” (the second row in Figure 3) instruction format (see here). The opcode of ADDI is 0x13 (in hex), and the func3 value is zero. Accordingly, the 32 bit binary representation of ADDI 5,0,10 is construction in Table 1.

Table 1. Binary Representation of ADDI 5,0,10

Instruction Element Bit index Value (Hex) Value (Binary)
Opcode [6:0] 0x13 001 0011
rd [11:7] 0x5 0 0101
func3 [14:12] 0x0 000
rs1 [19:15] 0x0 0 0000
imm [31:20] 0x00B 0000 0000 1011
Full Instruction (Binary) 0000 0000 1011 0000 0000 0010 1001 0011
Immediate Block

The immediate block extracts the constant operand from an instruction (except for “R” instruction which does not contain imm). The immediate block first reads the opcode and func3 (which are at fixed bit locations regardless of instruction format (see Figure 3), and then based on the value of the opcode it infers the format and the bit locations of imm.

Arithmetic Logical Unit (ALU)

As discussed above, a RISC-V instruction contains an opcode, the list of operands, and a destination register address (if the instruction involves a register write). One of the operands is always a register and the other one can be a register or an immediate constant.

The ALU carries out arithmetic or logical operation on the operands. The opcode determines which type of arithmetic or logical operation the ALU should conduct. The ALU can perform adding, subtracting, anding, oring, xoring, logical shifting, and arithmetic shifting (see a complete list of instructions here). The ALU outputs the outcome of the operation and a set of flags.

Besides the main output, ALU generates a set of flags that indicate aspects of the operation outcome. The flags indicate if the output is zero, or negative, or positive, or if there was an overflow.

Figure 4. Contents of an Instruction and Interconnection between Registers, Immediate Block and ALU

Control Unit (CU)

The CU can be considered the master block in the processor. Its main task is to extract the opcode and func3 (if any) which are always located at the same bit locations regardless of instruction format (see Figure 2). This opcode is an input to the ALU and the immediate block. More importantly, the CU generates control signals that configure the processor according to the function of the input instruction.

For example, one RISC-V instruction is the load instruction. The load instruction copies the content of a DMEM address into one of the registers. Accordingly, when the CU sees a load instruction, it raises a register_wr_en (enable for writing into one of the registers). The other set of RISC-V instructions is the store instruction set. The store instructions do the opposite of what load instructions do; they copy the content of a register into a given DMEM location. Hence, when the CU sees a store instruction, it lowers register_wr_en and raises data_mem_wr_en (enable for writing into DMEM). Figure 4 shows some of the control signals generated by the CU.

Figure 5. Control Unit Input and Output (partially)

Program Counter (PC)

As discussed above, instructions are sequentially stored in PMEM. Obviously, the running program contains more than one instruction. Hence, the processor should know where from PMEM to read the next instruction. The Program Counter (PC) stores the next read address of the PMEM.

In 32-bit RISC-V, each instruction spans 32 bits (4 bytes). Therefore, the processor increments the PC by 4 at every instruction. However, if the program encounters a branch, the PC is overwritten with the landing address of the branch instruction.

Figure 6. Updating the Program Counter

Putting it Together and Pipelining

We are now ready to put all the elements together. Figure 7 shows a simplified version diagram of the processor we are building in this project. First, the instruction is read from PMEM. Then, this instruction is decoded inside the CU and the Immediate blocks. In parallel, register operands are read out from the register block. After register reads and instruction decode, the instruction is executed in ALU. The next stage involves DMEM read or write, and the final stage involves register write step.

Figure 7. Simplified sketch of a Full RISC-V Processor

As you can elude from Figure 7, the processor elements are intentionally organized into five stages; this is done so to allow pipelining. Pipelining allows the processor to start processing the next instruction before it finishes processing the current one. For example, when the current instruction is in stage 2 (Decoding stage), the processor can go ahead and read PMEM for the next instruction, without interfering with the execution of the current instruction. Otherwise, the PMEM read stage (stage1) unnecessarily remains idle until the current instruction goes through all the five stages – which leads to inefficiency and slowness.

Figure 8 illustrates the benefits of pipelining using two instructions. It shows that pipelining can provide a 40% reduction in cycle count. The performance difference between pipelining and not pipelining increases along with the total number of instructions. For example, if 1000 instructions are considered, the unpipelined design would take 5000 cycles to finish while pipelined design would take as small as 1004 instructions – a whapping 5x difference. Pipelining is a must in a processor design.

Figure 8. Benefits of Pipelining

Actual Design

Before discussing the intricacies of pipelining, I want to show the actual (fully detailed) design. You can find the lucid chart block diagrams here (free login to lucid chart is required to view them). One can understand the detailed (seemingly complicated) design easily after understanding the simplified sketch shown in Figure 7.

Below are listed highlights of the actual design. I will not attempt to describe the full detail here – one can get the complete detail by looking at the block diagrams and the source code.

Two Cycles per Stage

PMEM and DMEM are implemented using Block RAM IP from Xilinx. The read and write to this memory costs two clock cycles – this means the instruction fetch and DMEM RD/WR stages of the pipeline last two cycles (not only cycle as shown in the illustration in Figure 8). To make the pipeline consistent, all the other stages (Decode, ALU and Reg WR) are also designed to span two cycles.

Every Signal is Pipelined

Pipelining applies to all signals – a signal crossing from one stage to another should do so with two-cycle delay. To illustrate this point, consider the JAL rd, imm instruction. This instruction causes an unconditional jump to address PC + imm, and stores PC + 4 into register rd. PC originates from stage1, but it is written to rd at stage 5. The PC originates from stage1, but the writing to rd register happens at stage5. Hence, the PC signal must be propagated through the stages until it reaches stage5. Hence, as shown in Figure 9, the value that is written to rd is PC delayed from 6 cycles ago plus 4. Similarly, the rd address and the register write enable which are both obtained at stage2 need to be propagated through the pipeline.

Figure 9. Every signal must be pipelined

First Kind of Data Hazard

Pipelining becomes difficult if two consecutive instructions have dependencies on each other. For example, consider the following consecutive instructions:

  1. ADD 5,0,1 (Add contents of register 1 to 0 and store the result in register 5)
  2. ADD 6,0,5 (Add contents of register 5 to 0 and store the result in register 6).

The actual adding (in ALU) of the second instruction assumes register 5 to be already updated by the first instruction. As shown in Figure 10, the second instruction ALU occurs before the register update from the first instruction is fulfilled. Unaddressed, this would result in incorrect program behavior.

To detect a data hazard, the processor needs to check if the operand registers of the current instruction are the same as the destination register of the previous instruction. Accordingly, data hazards can be detected as soon as the instruction from the current instruction is fetched.   As shown in Figure 10, the solution to this kind of pipelining hazard is called forwarding (see here for further reading). Forwarding leverages the fact that the value to be written to register 5 is already available at the end of the ALU stage of the first instruction. It just must propagate through the pipeline to be written to the register. Accordingly, if the ALU operation of the second instruction takes the ALU out of the first instruction instead of the current register readout, it would use the correct content of register 5. This mechanism is called forwarding. When this kind of hazard is detected, the ALU takes its input from its own output (the ALU output of previous instruction).

Figure 10. First kind of data hazard, and addressing it using forwarding

Second Kind of Data Hazard

The first kind of hazard is (relatively) benign one for that it can be addressed without stalling the pipeline. The second kind of data hazard however requires a more elaborate mechanism to be addressed. The second kind of data hazard occurs if current ALU-using instruction depends on memory read in the previous instruction. For example, consider the following consecutive instructions:

  1. LW 5,0,10 (Read DMEM at address 10 and store the outcome in register 5)
  2. ADD 6,0,5 (Add contents of register 5 to 0 and store the result in register 6).

As shown in Figure 11, the value going to register 5 is not even available by the time the second instruction is ready to do the adding inside the ALU. Accordingly, forwarding is not possible. In this design, this hazard is handled by injecting no-operation (NoP) instruction followed by a repeat of the second instruction. Accordingly, this hazard slows down the pipeline by 2 stages (4 clock cycles).

Figure 11. Second kind of data hazard, and addressing it by instruction repeat

Control Hazard (Caused by Branching)

The other type of pipeline hazard is caused by conditionally branching instructions. In such instructions, the processor does not whether to take the branch until the ALU computes the branch condition and updates the flags. However, by then two other instructions would be already in the pipeline. If the branch is not taken, executing the processor can carry on without interrupting the pipeline. However, if the branch is to be taken, the processor should somehow stall the execution of the two following instructions which are already in the pipeline

Figure 12. Control hazards and how to address it

For example, consider the following instructions.

  1. BEQ 5,4,20 (If contents of register 5 and 4 are equal, branch to the instruction that is 20 bytes aways – or after 5 instructions )
  2. ADDI 6,0,5 (Put 5 in register 6).
  3. ADDI 7,0,5 (Put 5 in register 7).
  4. ADDI 8,0,5
  5. ADDI 9,0,5
  6. ADDI 6,0,8 (Put 8 in register 6).

While executing the first instruction, if the processor finds that the content of registers 5 and 4 are the same; then the processor in theory should execute the 6th instruction, not the second and the third. But the hazard is from the fact that the second and third instructions will already be in the pipeline. In this design, this hazard is handled by allowing the second and third instructions to carry on in the pipeline, but DMEM and register write in the last two stages are disabled for the following two instructions if the branch needs to be taken. The 6th instruction is fetched as soon as the ALU updates the flags in the branch instruction. Because of this hazard, the processor will waste 2 pipeline stages or 4 cycles – and that is so only if the branch needs to be taken.

Verification

The source code of this implementation can be found in our GitLab repository. After the implementation, the code is tested through a verification test bench which you may find under “tb” folder. All RISC-V instructions (except sync, system, and counter instructions) were tested individually with some randomized test tasks. In particular, the register operands and the immediate values used in the tests were randomized to improve test quality and coverage. In addition, 8 other tests were added to test data and control hazards handling logics. All these tests (45 in total) are now passing.

Next Steps

The next step in this project involves testing the processor with realistic codes originating from actual compilers. In addition, we will be making a PCB board for the FPGA which will be hosting the RISC-V processor. I will come back with an update once these steps are completed. It will all be exciting!!!

 

 

 

 

Digital Hardware Implementation: Let’s Make an Ethiopian Drone

By: Eyosias Yoseph Imana, PhD.

I was a middle-schooler when mobile phones were first introduced to Ethiopia, my home country. Besides feeling excited from seeing a mobile phone for the first time, I remember wondering if I will ever be able to understand how the thing works. I also wondered if I would be able to make one “when I grow up.”

If you are reading this blog, I bet you have had such kinds of thoughts at some point. You are not satisfied in being a mere consumer of technology, you want to join the makers club. Well, I hope this blog series will inspire and equip you to convert your ideas into prototypes – and possibly into a viable commercial product. My vision is to see many makers come out of sub-Saharan Africa – and hence, the target audience of this blog series are all the aspiring and current makers/entrepreneurs from the region.

A little about myself; my name is Eyosias Yoseph. I have been with the semiconductor industry in USA for almost 7 years. Before joining the industry, I was first a PhD student, and later a postdoc at Virginia Tech. I completed my MSc from Florida Tech, and BSc from Bahir Dar University. All my degrees are in electrical engineering, and my focus areas include wireless communications, signal processing, and digital system implementation.

In this blog series, I plan to chronicle the journey I am now starting to make a quadruple drone from scratch and teach what I know about digital implementation along the way. I note that making a drone from scratch is not new – folks have successfully built drones from scratch using Arduino (see here and here). The uniqueness of my effort will be in part because instead of Arduino I will be using a custom RISC-V processor implemented on a custom FPGA board. In fact, my goal (at least for now) is to learn and teach how to make things, not to contribute anything novel.

I am not sure if my drone will successfully fly, but I am sure that I will be learning quite a bit along the way and will be sharing those learnings in the upcoming blogs. Besides sharing my updates, I will include a video along with each blog where I cover important concepts/techniques/tools I use to do this project. Stay tuned!!

Block Diagram

The block diagram of the envisioned system is as follows. I plan to custom design and implement much of the yellow block in the middle of the diagram – that is, I will be making a PCB board for the FPGA, a RISC-V processor inside the FPGA, and a flight controller software to run on the processor.

This project involves hardware, software, and mechanical developments. A high-level roadmap of this project is as follows:

1. Hardware development
  • Processor design and implementation: I first plan to paper-design a RISC-V based processor and then implement its RTL using Vivado webpack from Xilinx (it is free). The RTL will be written using System Verilog.
  • RTL verification: I then plan to write unit and integrated testbenches (again using System Verilog) and test the processor design extensively using simulations. I will be using the simulator built in Vivado. To create randomized testing, and automation, I plan to use python scripts which call Vivado’s internal commands (called TCL).
  • Validation using real C program: Once the processor RTL is ready (passes most verification tests), I will make a simple C program and compile it with GNU RISC-V cross-compiler (download here). I will then load the executable binary generated by the compiler into the RTL simulator and run to see if the processor produces the expected results.
  • PCB design and fabrication: I will then make a PCB board containing an FPGA where the processor can be implemented. The PCB board is likely to contain a Xilinx’s Spartan-6 FPGA and will be designed using KiCad (download here).
  • PCB bring-up: Once the board is fabricated it needs to be brought up (may need two or three iterations to get a usable board)
2. Software development
  • Hardware model development: bare-metal programming is bug-prone because the programmer must deal with the hardware details which can be slipped up easily. To facilitate debug during flight controller software development, we will be first developing a C based model for the hardware. This model will be verified against RTL. Once verified, it will be used to bring up the final software.
  • Flight controller software development: The flight controller program will be developed in C on top of the hardware model first, and then on the actual hardware. As mentioned earlier I will be using GNU RISC-V cross-compiler.
  • Bring-up
  • Fly the drone!!!

It can be noted all the tools I plan to use in this project are open-source and/or free. Anyone can follow along and contribute to this project. I will be hosting the project in GitLab with public access. The only monetary expense in this project will be coming from PCB board fabrication, and the purchase of mechanical and electrical parts for the drone.

GitLab Repository

I named this project DESTINY, it is hosted at this GitLab.

Why RISC-V?

Say an Ethiopian company plans to make and sell a portable electronic device that can translate between the local languages in real-time (example, from Afan Oromo to Amharic and vice versa). Such device inevitably has a built-in processor – almost all electronic devices (ranging from a simple digital watch to a space shuttle are build with at least one processor).

The said company can choose one of the following routes to obtain a processor technology to put into its new device:

  1. Using another company’s processor chip: The company can choose to use a third-party processor chip (for example, from Intel, or Texas Instruments, or etc) which may be a good starting place but obviously expensive.
  2. Using another company’s processor IP: The company may license a processor design from a third party (for example, from ARM as every major companies including Apple and Qualcomm are doing) and customize and fabricate the processor chip. But this also comes with a hefty licensing fee.
  3. Making its own processor from scratch: Besides the riskiness of this route, it is not guaranteed to be cheaper than the first two. Making a new processor from scratch would also mean making a new build/compile toolbox which cannot be achieved without a significant Non-Recurring Expense (NRE).

Hence, all the above three options are expensive. The first two routes also indicate a perpetual technological dependence on western companies which may not be a wise choice in the current geopolitical environment. For example, what if a trade war makes it impossible for western companies to supply chip or IP to Ethiopia? Well, that is not an impossibility anymore.

RISC-V is a 4th alternative – and the most optimal choice in my opinion. RISC-V is an open processor instruction set standard. It is an open standard, which means, anyone can make a processor based on this instruction set without paying licensing fees to a third party. Furthermore, there exists GNU compiler toolbox for RISC-V already. It is also new and has the potential to grow and dethrone ARM from its prevalence in the embedded processor world in the coming years. If we are early players in RISC-V, not only we can use it to make our own products, but we may also become key RISC-V chip and IP suppliers for the global market (why not?). For these reasons, I think the nascent Ethiopian computer/software engineering community should take the RISC-V opportunity seriously.

Getting Started with RISC-V

Are you interested to know more about RISC-V? Below are important links to learn further about RISC-V.

Today’s Lesson: Building a Bare-metal C Program

Before I close today’s blog, I invite you to watch the following this video where I teach about bare-metal programming using GNU’s RISC-V toolbox.