Archive for the ‘Hardware’ category

VisualTouch Music Game — blending HW & SW

July 1, 2015

Embedded systems are everywhere.  A digital watch, microwave oven, electronic toy, and your car dashboard are a few disparate examples.  The characteristics of an embedded system are:

  • Made from a combination of hardware and software
  • Task specific. They’re designed to perform one specialized task as opposed to general purpose computers
  • Usually reactive or feedback-oriented.  E.g. most home or kitchen appliances only function when you interact with them.
  • Built with efficiency and frugality.  Your toaster needs a timer and heat control, but it really doesn’t need a full-fledged CPU
  • Should be reliable and stable.  Because they are simple, we expect these machines to work. They shouldn’t require maintenance because it’s often easier and cheaper to buy a new one.

For my required EE Hardware design project, my team developed an embedded system on an Atlys Spartan-6 Development Board.  This board constructs your hardware specification, like an FPGA, but then it can also run C software that you place on top of the hardware.

StanleyFPGA

My brother’s Flat Stanley visited me while I was working in the EE lab.  Sadly, I couldn’t find a photo of our finished project, but this is our Spartan-6 Development Board

We hooked up a webcam, a screen, and speakers to our Board.  We had the screen display the camera’s output.  Our game consisted of these playable modes:

  1. Changes the chord’s duration based on the red/blue/green content of the overall pixel count.
  2. Changes the chord based the amount of movement detected by the camera.
  3. A grid is overlaid on the screen. When a user in front of the camera covers a square of the grid with their hand, the board plays a song.

Skills:

  •  Verilog code in Xilinx Platform Studio configures the processor-based system.  [The hardware platform managed the transfer of data from the camera to the screen.  All the song data was also implemented in hardware.]
  •  C programming in Xilinx Software Development Kit.  [Everything else:  the music player, game controls, game logic, pixel computations were done in software.]

Key Takeaway:    This project was a turning point: creating the hardware infrastructure was important, but the software was the crux of the game! My specialty was more on the hardware side and I realized that I shouldn’t leave college without delving into the software domain.

Screen Shot 2015-07-01 at 8.00.14 PM

DJ mode allows user to mash these pop songs together based on where one’s hand is positioned in the screen’s grid.

Graphics Accelerator Chip

July 1, 2015

How often do you watch animated movies, play video games, or run graphical simulations on your computer?  Computer graphics is the science of converting 1’s and 0’s into colored pixels on your screen.  While many applications can do this work entirely on the CPU, high end real-time applications require specialized hardware.

For the final project of EE271: VLSI (Very Large Scale Integration) Systems, we had to increase the performance of a graphics chip to the requested throughput while minimizing chip area and power consumption.  One acceleration technique that we implemented that is easy to visualize is to change the rendering algorithm.  Compare different algorithms in this figure:

Screen Shot 2015-07-01 at 6.05.30 PM

Juan Pineda. 1988. A parallel algorithm for polygon rasterization.

Navigating the stages of this project was very challenging with lots of scary moments and meticulous deliberations. Whenever we attempted to optimize anything, the first step usually broke the system.  But near the end, it felt like a miracle when images rendered properly and quickly.

Screen Shot 2015-07-01 at 7.04.51 PM

One of the images we had to render. He kinda looks like Baymax from the Disney movie.

New Skills:  Graphic acceleration techniques in SystemVerilog and C++

Key Takeaway:  I was inspired when working on this graphics accelerator chip because I felt like I was treading (ok, more like ‘limping’) in the footsteps of my Filipino engineering hero, Dado Banatao.  He started a company around a similar technology.

CPU Optimization — a neverending story

July 1, 2015

EE282 Computer Systems Architecture introduced me to more complex CPUs (microprocessors are named Central Processing Units when packaged within complete computers) and to more advanced techniques for architects building CPUs.  There were two big optimization projects:

  1. Optimize Matrix Multiplication:  We had to implement optimization techniques in C to achieve faster matrix multiplication.  A very effective technique is loop unrolling which basically puts more work in each loop iteration to reduce the number of iterations. For example, a for-loop executing a single multiplication needs 100 iterations; the optimized version only need 10 iterations, but each iteration grabs a bigger chunk of data and does 10 multiplications in each loop around.
  2. Optimize Mystery Computer:  There’s a dynamic mystery computer that executes large mystery computations.  We could remotely control the computer’s number of processors, processor speed, and cache system.  We then had to explore paths to an optimal computer configuration among thousands of possibilities.  My partner and I were like Sherlock and Watson; discovering new clues, having eureka moments, and then surmising explanations afterwards.

New Skills:  C programming, performance analysis, and optimization techniques

Key Takeaway:  The official Olympic motto is Citius, Altius, Fortius which is Latin for ‘faster, higher, stronger’.  I think this motto’s underlying sentiment isn’t to celebrate the fastest, highest, strongest but to spur athletes toward continuous improvement.  If CPU development had its own motto it would be faster, smaller, less energy.

Ever since their invention, new CPUs are released that are more powerful, with smaller transistors, and more energy efficient.  And just like there’s no perfect athlete or sports team, there’s no ultimate computer because progress in one area comes at the expense of others.

Microprocessor Design – managing a lifetime of work each second

June 30, 2015

In a series of lab projects, my partner and I completed the design of a pipelined processor and memory system.  No, we didn’t connect every wire in the microchip by hand.  We designed the system with a hardware language that recreates the microprocessor on an FPGA.  [Field-programmable gate array is a microchip with programmable fabric that can be continually redesigned into new microchips.  More on this in a later post…]

The microprocessor chip is the heart of any computer.  It’s the workhorse that grabs data, performs logic on it, and spits out the new data to where it belongs.  One factor that determines computation power is the speed/frequency of its processor.  The computer I’m typing on uses an Intel i5 Processor at 1.8 GHz.  That means every second, it can perform 1.8 billion cycles of computer busywork.

Estimating the average human’s cardiac cycles over a 60-year lifetime: a person will experience (60 heartbeats per minute)*(1440 minutes per day)*(365 days per year)*(60 years) = 1.89 billion heartbeats.  In essence, computers can do great things mostly because humans designed them to manage a lifetime of busywork in each second.

New skills:  Processor design in Verilog code using Xilinx ISE synthesis and analysis tools.

Key Takeaway:  Forget final exam scores; a class should be measured by the number of times a student is stunned with realization, making him see the world a little differently.  For me, this was such a course:  where the perfect blend of lectures, assigned reading, homework problems, and final design project blended perfectly into a world-expanding experience.

Screen Shot 2015-06-30 at 7.33.47 PM

My handwritten diagram of our cache system! Caches store recently used (or spatially close) data for easy-access because the processor is likely to use that data again. Similar to why a browser’s cache will locally store website elements that you commonly visit, so the browser doesn’t have to re-download them over the Internet every time.

Arduino Music Box

June 30, 2015

In my first year, I took an introductory electronics course that gave us access to

  • analog circuits:  circuits are closed loops featuring electronic components (such as resistors, transistors, LEDs, transistors, amplifiers);  there’s also a power source that raises the voltage, pumps current, putting all the components in action.
  • sensors:  interactive devices (such as buttons, wheels, temperature sensor etc. ) that can sense their surroundings
  • microcrontrollers:  named ‘micro’ because they are small, simple, cheap computers; ‘controller’ because they are mainly are used to run simple logic to control other devices.  Though it can execute code like any computer, it doesn’t have the computing power to run your laptop or phone.

After training us with all these parts and more, we were then let loose to build our own final project.  I had the most fun running simple code on an Arduino Nano microcrontroller.    Using an empty cigar box, I made a music box that plays mp3s from an SD card and displays its song name on a tiny screen.

This was filmed in 2011 when my phone was technologically more similar to a potato than a modern smartphone.

New skills:

  • First time constructing non-trivial circuits and using equations like Ohm’s Law in real life instead in a notebook.
  • C++ programming in using Arduino Integrated Development Environment (IDE) which runs the code.

Followup Questions:  How does the microcontroller work?  How did it interpret the mp3 file and decode into playable sounds? How to organize circuit wirings so it’s not a hot mess?

Key Takeaway:  An auspicious introduction to electronics where I quickly learned that digital domain (running code on microcrontroller) is friendlier than analog domain (soldering little wires and devices together and measuring with oscilloscope).

In retrospect, this key takeaway became a catalyst for a lot of other things.  First impressions DO count!