Experiences Teaching an FPGA-Based Embedded Systems Class
Total Page:16
File Type:pdf, Size:1020Kb
Experiences Teaching an FPGA-based Embedded Systems Class Stephen A. Edwards Department of Computer Science Columbia University New York, NY 10027 Email: [email protected] Abstract— I describe a two-year-old embedded systems design course I teach at Columbia University. In it, the students learn low-level C programming and VHDL coding to design and implement a project of their own choosing. The students implement their projects using Xilinx FPGAs and tools running on Linux workstations. The main challenges the students face are understanding and complying with complex and often poorly-documented interfaces and protocols, personal time management, and teamwork. While all real-world challenges, this class is often the first time the students encounter them, which makes the class quite challenging, but very practical. In this paper, I describe the structure of the class, the configuration of our teaching laboratory, some of the more successful projects, and give suggestions to instructors wishing to implement the class elsewhere. (a) (b) Fig. 1. The two boards used in different incarnations of the class. (a) The I. INTRODUCTION XESS XSB–300E board, centered around a Xilinx Spartan IIE (XC2S300E). (b) The Digilent Spartan 3 Starter Kit board, centered around a Xilinx Spartan Embedded system design is a challenging problem that III (XC3S400). represents the future of digital system design. Moore's law and the relentless downward-spiraling cost of integrated circuits has made it possible to price very powerful computing artifacts The class focuses on the design of a fairly complex hard- at consumer levels, as the ubiquity of devices such as DVD ware/software system, which the students implement on an players, digital cameras, and cell phones attest. FPGA board. This is consistent with the role of the course as We in academia must follow this trend. As recently as fifteen a “capstone lab” in the Columbia Electrical Engineering and years ago, wire-wrapping TTL parts was a sufficient intro- Computer Engineering programs. As I describe below, the first duction to state-of-the-art system design techniques; today's half of the class consists of cookbook-style lab assignments systems are orders of magnitude more complex. Teaching that teach the students the design tools. The second half of the students to handle this complexity is the central challenge. class is devoted to the project. In this paper, I describe an FPGA-based embedded systems As of September 2005, I have taught the class three course I developed and teach at Columbia University. Follow- times: twice at Columbia, and once at National Chaio Tung ing the suggestion of Frank Vahid, whose book [1] I used for University (NCTU) in Hsinchu, Taiwan. At Columbia, the the first year, I created this course to replace a microprocessor majority of students are fourth-year undergraduates completing system design course that until 2003, had students assemble an Electrical Engineering or Computer Engineering degree. systems using Z80-based trainers with breadboards1. The Taiwan group consisted of sixteen students, most of whom I wanted the students to learn hardware/software codesign, were Master's-level, and many of whom had worked or were specifically the design of microprocessor systems and their working full-time in the electronics industry. peripherals. Students taking the course have experience with Java and C, know basic digital design, and have taken com- II. HARDWARE puter organization, which should have familiarized them with Just as embedded hardware/software systems can take many assembly language, but few have any experience integrating forms, there are many possible vehicles for teaching a practical these skills. embedded systems class. At one point, I considered having the students only build simulations, a practical approach used in Edwards is supported by an NSF CAREER award, an award from the SRC, and by New York State's NYSTAR program. computer architecture courses, but I wanted the students to 1To emphasize their antiquity, these trainers were labeled “Copyright 1985.” experience real hardware. 56 2004 2005 Count in decimal on 7-segment LEDs C Count in decimal on 7-segment LEDs C Display “Hello world” using framebuffer C Terminal emulator using supplied video controller C TV typewriter C Reverse-engineer some VHDL drawings Count in hex on 7-segment LEDs VHDL Sum the contents of a memory VHDL Make framebuffer display characters VHDL Complex multiplier as OPB peripheral VHDL TV typewriter using character display C & VHDL SRAM controller for OPB (omitted at NCTU) C & VHDL Fig. 2. The six lab assignments. One standard approach is to use a microprocessor devel- and ideas it contains are good, but the students do not find it opment board. Frank Vahid has taken this approach with terribly relevant to the project construction task. his course at University of California, Riverside [1], using Many texts are software-centric. Wolf [2], for example, dis- the 8051. While this is a practical option, it tends to lead cusses things such as the ARM instruction set and operating- to software-centric thinking that does not consider hard- system-level concepts such as processes. Simon [3] is even ware/software trade-offs. more focused on software, although a bit more practical than Modern field-programmable gate arrays (FPGAs) offer Wolf. Heath [4] is similar. Brown [5] has a more industrial many advantages for instruction, including flexibility, fast focus and includes a large avionics example. reprogrammability, and the capacity to implement large, fast Many books are specific to a particular processor. Although digital designs. The two leading FPGA companies—Xilinx practical, I find such an approach focuses too much on the and Altera—offer comparable technology. Xilinx, however, idiosyncrasies of a particular instruction set. Books in this appears to have the superior university program, so I decided vein include Morton [6], which focuses on the Motorola to use Xilinx FPGAs for this course. 68HC11 series of microcontrollers. Lewis [7] targets the x86 Many FPGA development boards are available, but most architecture and ordinary PCs, which makes acquiring suitable are designed for industrial use (and budgets) and can cost as hardware easy: most departments have a collection of old much as US $5000 per board—beyond our price range. PCs that make suitable embedded targets. Barr [8] chooses an At Columbia, my TA and I selected a board built by 80188-based board, although focuses mostly on C and C++. XESS Corporation: the XSB–300E (Figure 1a), which sells for Pont's book [9] should have been titled Embedded C on the about $900. Centered around a Xilinx Spartan IIE FPGA—the 8051. Peatman [10], by contrast, makes it clear that he focuses XC2S300E—with a raw capacity of roughly 300k gates, the on the PIC18F452 processor. Incidentally, is is the only book board also has a wide variety of peripheral chips, including I know of that comes with a (bare) PC board. video input and output; Ethernet; USB 2.0; a serial port; There is another family of texts that are more concept- SRAM, DRAM, and flash memory; and an audio CODEC. The oriented and targeted at graduate students. These are even more peripherals were particularly attractive; using these peripherals abstract that Vahid and Givargis and would probably frustrate would be a focus of the projects. my students. Examples include Gajski et al. [11], Jantsch [12], In Taiwan, we used a newer, smaller board made by Marwedel [13], and the volume edited by Jerraya et al [14]. Digilent (the Spartan 3 starter kit board, Figure 1b). This was Noergaard's sprawling volume [15] tries to discuss just satisfactory, especially given its $120 price, but greatly limited about everything, ranging from the difference between the range of projects as its peripherals are limited to an 8-color enhancement- and depletion-mode MOSFETs to HTTP meth- VGA port, a PS/2 keyboard interface, and an RS-232 port. This ods. While a very interesting reference, it is too long to particular board comes in a few different configurations. The consider in its entirety in a single semester. most common has an XC3S200 part, but this is too small to IV. LAB ASSIGNMENTS accommodate the Microblaze soft processor core, which every project has used. Instead, we paid a bit more and got boards As I mentioned above, I divide the class into two: during with the larger XC3S400 part. the first half, the students follow cookbook lab assignments meant to teach them how to use the design tools. During the III. TEXTBOOKS second half, they design and implement projects of their own devising. I have not found a satisfactory text for the class. In the Figure 2 lists the six labs I have given over the last two first year, I used Vahid and Givargis [1], partially because years and the main language they need to use in each. The Vahid had originally suggested the idea of the class to me and goal of these labs was to get the students familiar with using because the text embodies the philosophy of functions being the tools through a sort of tutorial style. I provided detailed implementable in either hardware or software. But the students explanations of what to do as well as collections of files as a and I found the book disappointing. It deliberately shies away starting point. The results were mixed. from talking about any particular languages or platforms, mak- In the spring of 2004, I made the mistake of trying to ing it useless as reference manual. The background material balance software and hardware labs, making