Available online at www.sciencedirect.com
ScienceDirect Procedia - Social and Behavioral Sciences 180 (2015) 1507 – 1513
The 6th International Conference Edu World 2014 “Education Facing Contemporary World Issues”, 7th - 9th November 2014
Digital Logic Introduction Using FPGAs Ionel Petrescu, Ionel-Bujorel Păvăloiu*, George Drăgoi University POLITEHNICA of Bucharest, Spl. Independenţei 313, Bucharest 060042, Romania
Abstract The paper describes the adaptation of the Computer Architecture laboratory works given at the Faculty of Engineering in Foreign Languages from the University POLITEHNICA of Bucharest to the new trends in digital logic design. The laboratories are given in a gradual approach, starting with simulation, continuing with breadboard design and finishing with circuits made on perfboard. We are preparing now to complement the practical side of the laboratory with Field-Programmable Gate Array (FPGA) design, where the students will conceive, simulate, synthesize and implement the circuits already studied in the initial approach that used simulation followed by integrated circuits practical design. ©©2015 Published by by Elsevier Ltd.Ltd. This is an open access article under the CC BY-NC-ND license 2015The TheAuthors. Authors. Published Elsevier (http://creativecommons.org/licenses/by-nc-nd/4.0/). Peer-review under responsibility of The Association “Education for tomorrow” / [Asociatia “Educatie pentru maine”]. Peer-review under responsibility of The Association “Education for tomorrow” / [Asociatia “Educatie pentru maine”]. Keywords: digital logic; gradual approach; simulation; digital integrated circuits; FPGA
1. Introduction 1.1. Teaching digital logic design Digital Logic Design is a basic course and an introductory part in advanced subjects for many engineering and computer science students. The lectures are accompanied by laboratory works and projects in which students learn the practical things about digital logic and digital ICs (integrated circuits). In the Faculty of Engineering in Foreign Languages (FILS) from the University POLITEHNICA of Bucharest (UPB), the teaching is done in of the English, French or German languages. There are two specializations in the
* Ionel-Bujorel Păvăloiu; Tel.: +40 21 402 9590; fax: +40 21 402 9111. E-mail address:
[email protected]
1877-0428 © 2015 The Authors. Published by Elsevier Ltd. This is an open access article under the CC BY-NC-ND license (http://creativecommons.org/licenses/by-nc-nd/4.0/). Peer-review under responsibility of The Association “Education for tomorrow” / [Asociatia “Educatie pentru maine”]. doi:10.1016/j.sbspro.2015.02.299
1508
Ionel Petrescu et al. / Procedia - Social and Behavioral Sciences 180 (2015) 1507 – 1513
English and French Streams regarding Computers and Information Technology, respectively Electronic Engineering and Telecommunications. An important accent is given to e-learning (Dascalu, Bodea, Lytras, de Pablos & Burlacu, 2014) and simulation (Mustata, 2014), but all the aspects of engineering learning, including the practical side, are considered carefully, with offsets at UPB level (Radovici & Culic, 2014). Digital Logic design is given to the students in the first year of study, many of them coming from abroad. They have a large variety of backgrounds and teaching them directly advanced FPGA (Field-Programmable Gate Array) and EDA (Electronic Design Automation) with Multisim homework assignments, Xilinx ISE computer design and simulation and FPGA board verification, as suggested in (Noga, 2010) and (Wang, 2011) is too difficult. They are preparing now in the introduction to Computer Architecture with laboratory works that follows a gradual approach of learning through experimentation (Pavaloiu, Stoica, Nedelcu, Dragoi & Petrescu, 2014). 1.2. Learning through experimentation One of the problems of education is that theory fails to be application oriented and this can be a dreadful menace for engineering instruction. We believe that students learn computer hardware fundamentals better if they are given practical learning exercises that illustrate the theoretical concepts. Intensifying the combination of textbook and engineering practical use, so as to improve teaching effectiveness, develop students' interest and enhance their comprehensive practical ability (Zhao & He, 2012). Clive Maxfield, a distinguished contributor to Multimedia Logic, and Brown remark that one of the best ways to learn something and remember it afterward is by means of hands-on (“fumble and stumble”) experience (1995). Combining a simulation system and a tutoring system can alleviate the disadvantages of having each system operating by itself (Sidhu, 2010). Because experiential learning is often equated with high levels of learner activity, simulation-based learning is thought to be ideal especially for those who may be less motivated to learn with traditional materials. The contextual content of simulations allows the learner to “learn by doing” (Kluge, 2007). We believe student learning can be accelerated and enhanced by the effective use of simulation software. A student can connect an integrated circuit in the lab and observe its functionality by flipping switches and observing LEDs without understanding how each logic gate is working. Logic simulation software enhances learning by allowing the student to watch the logic state (high or low) of each input and output of a device and come to a better understanding of how any component in the circuit working (Wang & all, 2013). They can afford to make mistakes and to experiment any alternative they see fit or interesting for a given problem. They start to become familiar with debugging a circuit, since here it is very simple to analyze the logical values in any part of it. The last step is to transfer what was obtained in simulation to the real life. The student should be able not just to design and test on computer a specific entity, but to obtain it as a final product. The students are using breadboards first to test their design. After a circuit is investigated and it is proven its value, it is soldered on perfboard. This concludes the learning process and proves the capacity to operate with the acquired knowledge. The development boards are another way to create circuits, this time solderless. They are used to make “real” electric powered circuits and can “burn” in the case of short-circuits or lack of loads. The students can be unforthcoming in working with this kind of circuits, so the simulation is a good preparing step, prior to start working with the genuine devices (Noga & Radwanski, 2012). Unlike working with chips and wires, the design, prototyping and debugging phases of a project using FPGAs are very fast, because instead of working with wires and components, the students write code like in a programming language, being able to reuse and update the designs. 1.3. Gradual Stages for Circuit Design The lectures of Computer Architecture are given at FILS to the students from the first year of study in the fields of Information Engineering and Applied Electronics, in the series where the subjects are given in English and in French. The peculiarities include the position of the subject in the first year and the wide-ranging backgrounds of the students, which come from a large number of countries, as well as the different careers envisaged for the recipients. For the time being, the laboratory initial part relies on simulation software, while the later stages offer the possibility to obtain practical (semi) permanent products. Digital logic circuits, combinational and sequential, are designed and simulated using “Multimedia Logic”, a free capture tool developed by Softronics. The next stage is the practice with
Ionel Petrescu et al. / Procedia - Social and Behavioral Sciences 180 (2015) 1507 – 1513
“Java Breadboard”, a free circuit simulator replicating the breadboard hardware development environment. When the students are familiar with the breadboards and with the digital integrated circuits, they get to the hardware practice, making simple digital circuits on breadboards. The next stage is to learn how to solder electronic components and how to make simple circuits on perfboard. In this chapter we will present briefly the actual laboratory stages used in helping the students to learn digital logic and digital design in a gradual and enjoyable fashion. We will follow a simple sequential circuit, which simulates the functioning of the traffic lights. In Fig. 1 it is presented the implementation of this circuit in the digital simulation program Multimedia Logic. The D type flip-flop units are serially connected and change the state successively.
Fig. 1. Traffic lights circuit implemented on Multimedia-Logic
The degree of abstracting for the simulator is outsized. It ignores ICs pins, power for the circuits, ground signals, etc…, concentrating on the logical side of the circuits. To start creating true digital logic circuits, a new level of realism is necessary, by using breadboard circuit simulators. In this phase the student verify the virtually correct functioning of the application. For simulation, the traffic lights circuit is implemented in Java Breadboard (JBB), like in Fig. 2.
Fig. 2. Traffic lights circuit implemented on Java Breadboard
Real breadboard designs are a little more complicated than the ones made using JBB, because they get rid of the last layers of abstraction and simplification. The circuit is made by standard integrated circuits, is powered by a battery through a voltage stabilizer and shows the states using real LEDs. In Fig. 3 it is shown the breadboard implementation of the traffic lights circuit.
Fig. 3. Traffic lights reusable circuit implemented on breadboard
1509
1510
Ionel Petrescu et al. / Procedia - Social and Behavioral Sciences 180 (2015) 1507 – 1513
If the circuit is functioning properly, it can be soldered on a perfboard for a (semi)permanent application, like in Fig 4.
Fig. 4. Traffic lights semi-permanent circuit implemented on perfboard
2. FPGA Circuits The classical digital logic design labs given at FILS are complemented these days with some laboratory works where the design and simulation is done on FPGA boards. In this chapter we will present briefly the steps that help the students to complete their training in digital logic and to make the introduction to logical design. It is just an introduction to the field, closing the circle for digital design and opening the field of FPGA circuit studies in the years to come. 2.1. Digilent BASYS2 We will use Digilent Basys2 board as a demonstration tool for the laboratory works. In Fig. 5 it is shown the BASYS2 board, a circuit design and implementation platform that anyone can use to gain experience building real digital circuits. Built around a Xilinx Spartan-3E Field Programmable Gate Array and Atmel AT90USB2 USB controller, the Basys2 board provides complete, ready-to-use hardware suitable for hosting circuits ranging from basic logic devices to complex controllers. A large collection of on-board I/O devices and all required FPGA support circuits are included, so a large number of circuit designs can be created without the need for any other components (Digilent inc., 2007).
Fig. 5. BASYS2 FPGA board
Ionel Petrescu et al. / Procedia - Social and Behavioral Sciences 180 (2015) 1507 – 1513
The Basys2 board can draw power and be programmed via its on-board USB2 port. Digilent’s freely available PC-based Adept software automatically detects the Basys2 board, provides a programming interface for the FPGA and Platform Flash ROM, and allows user data transfers. The Basys2 board is designed to work with the free ISE WebPack CAD software from Xilinx. WebPack can be used to define circuits using schematics or HDLs, to simulate and synthesize circuits, and to create programming files. VHDL was introduced as a mean to provide a detailed design specification of a digital circuit, with little thought given to how a circuit might be implemented based on that specification (the assumption was the requirements in the source file would be captured as a schematic by a skilled engineer) (Nath S et all). Instead of using a graphics interface to add gates and wires to a schematic, HDLs editors use a text editor to add structural or behavioral descriptions to a text file. Digilent’s PC-based program called Adept can be used to configure the FPGA with any suitable bit file stored on the computer. Adept uses the USB cable to transfer a selected bit file from the PC to the FPGA (via the FPGA’s JTAG programming port). Adept can also program a bit file into an on-board non-volatile ROM called “Platform Flash”. Once programmed, the Platform Flash can automatically transfer a stored bit file to the FPGA at a subsequent power-on or reset event if the Mode Jumper (JP3) is set to ROM. The FPGA will remain configured until it is reset by a power-cycle event. The Platform Flash ROM will retain a bit file until it is reprogrammed, regardless of power-cycle events. 2.2. ISE WebPack One of the important features of simulation is the proof of theoretical concepts. The students can verify by simulation the Boolean laws, like de Morgan’s Laws or the equivalence of circuits using this time the FPGA framework. In the laboratory works, several combinational and sequential circuits can be designed and simulated, following the lectures development plan. We use ISE® WebPACK™ design software, a fully featured front-to-back FPGA design solution. It is a solution for FPGA and CPLD design offering HDL synthesis and simulation, implementation, device fitting, and JTAG programming. ISE WebPACK delivers a complete, front-to-back design flow providing instant access to the ISE features and functionality at no cost. Xilinx has created a solution that allows convenient productivity by providing a design solution that is updated regularly and has a single file installation. 3. Digital Logic Introduction using FPGA Circuits We will present in this chapter the practical implementation on FPGA of two circuits, the XOR gate made using 4 NAND gates and the traffic lights sequential circuit made using D-type flip-flops for which we followed the gradual study in Chapter 2. 3.1. XOR with 4 NAND gates The first circuit is a XOR function made with 4 NAND gates (Even & Medina, 2012), as in Fig. 6. The ports A and B are for signals IN and the port Y is for signal OUT. The circuit is drawn in ISE WebPack Schematics.
Fig. 6: Waveforms for the XOR circuit
The circuit is coded in VHDL and the program is run. In Fig. 7 it is shown the graph of the signal waveform. Note that the output waveform is in accordance with the truth table of the XOR function.
1511
1512
Ionel Petrescu et al. / Procedia - Social and Behavioral Sciences 180 (2015) 1507 – 1513
Fig. 7. Waveforms for the XOR combinational circuit
3.2. Traffic lights circuit on FPGA The second circuit is a simulation of a simple traffic lights made with D type flip-flop (Wang & all, 2013) and it is shown in Fig. 8. The circuit has 2 inputs, SW and CLK, and 3 outputs corresponding to the 3 LEDs, named LED1, LED2 and LED3. The CLK input sets the lighting time for each LED. The lighting times are equal for all LEDs. The SW input starts the circuit. The configuration uses the functionality of the CMOS D flip-flop, 4013 series.
Fig. 8. Traffic lights circuit schematics using ISE WebPack Schematics
In the initial state, SW = '1', actually the S pin of the first flip-flop chip, and in conformity with the truth table of the D type flip-flop the output Q is permanently in '1', insensitive to CLK and the state of the pin D, so the LED1 is permanently ON and the others LEDs are OFF. The R pin of the all flip-flop chips and the S pin of second and third flip-flop chips, are permanently held on '0'. So, the circuit start with the Q1 = D2 = '1', LED1 is ON and Q2 = D3 = Q3 = D1 = '0', LED2 and LED3 are OFF. When SW='0', the S pin is '0' and in conformity with the truth table of the D type flip-flop, the output Q depend on the CLK and the state of the pin D, so the circuit enter in normally running state. On the every CLK transition from '0' to '1' the data from D pin is transferred to Q pin, so the LED is turning ON or OFF depending by the data. Hence, on the first transition of the CLK the Q1 = D1 = Q3 = '0' and LED1 is OFF, Q2 = D2 = '1' and LED2 is ON, Q3 = D3 = Q2 = '0' and LED3 is OFF. On the next transition of the CLK the Q1 = D1 = Q3 = '0' and LED1 is OFF, Q2 = D2 = '0' and LED2 is OFF, Q3 = D3 = Q2 = '1' and LED3 is ON. And so on until SW is turned to '1'. The lighting time can be modified by setting the CLK period. The traffic light application is a good way to study the functioning of the sequential logic circuits. In Fig. 9 is shown the diagram of the waveforms from the circuit. The design was coded with VHDL, also.
Fig. 9. Waveforms for the traffic lights circuit
Ionel Petrescu et al. / Procedia - Social and Behavioral Sciences 180 (2015) 1507 – 1513
3.3. Advantages of FPGA design The electronics applications are becoming increasingly complex and also the hardware design. The mistakes in hardware lead to higher remediation costs. In the meantime, the modeling software is less expensive and easier to fix. It is therefore more appropriate for students to learn the modeling software (Haroldsen, Nelson & White Haroldsen, 2013). Some advantages of the FPGA design are listed below: x fault-tolerant - the possibility to make mistakes without damaging the equipment, making it suitable for students x reusability of code – the code can be re-used for more complicated circuits x flexibility - ease to use x easy interface with peripherals x reduced size x accurate simulation 4. Conclusions We presented in this paper some key issues of the FPGA learning process in general and some specific problems from our teaching environment in particular. It continues the gradual teaching method that is applied now with the introduction of FPGA circuits from the first year of studies. We propose the bringing of modern design methodology into course teaching, based on practical experience, from the first year of study, opening a vast horizon of future development to the students. As an actual strategy to deal with the current problems of FPGA course in higher education, this method has already made certain accomplishment in both teaching and experiment. References Dascalu M.-I., Bodea C-N, Lytras M., de Pablos P.O., & Burlacu A., (2014). Improving e-learning communities through optimal composition of multidisciplinary learning groups, Computers in Human Behavior, Volume 30, January 2014 Digilent inc. (2007), Digilent Basys Board Reference Manual, available at http://www.digilentinc.com/data/products/basys/basys_e_rm.pdf Even G. & Medina M., (2012). Digital Logic Design: A Rigorous Approach., Cambridge University Press. ISBN-13: 978-1107027534, Haskell R. E., & Hanna, D. M. (2009) Digital Introduction to Digital Design Using Digilent FPGA Boards - VHDL Edition. LBE Books, ISBN13: 978-0980133769 Haroldsen, T., Nelson, B., & White, B., (2013). Rapid FPGA design prototyping through preservation of system logic: A case study, 2013 23rd International Conference on Field Programmable Logic and Applications (FPL), pp. 1 - 7, DOI:10.1109/FPL.2013.6645539 Kluge, A., (2007). Experiential learning methods, simulation complexity and their effects on different target groups. Journal of educational computing research, 36(3), 27. Maxfield, C., & Brown A., (2005). The Definitive Guide to How Computers Do Math: Featuring the Virtual DIY Calculator. Wiley-Interscience, ISBN-13: 978-0471732785 Mustata, C. (2014) Case Study: The "General Management II" Business Simulation Game in Classroom, Proceedings of the 10th International Scientific Conference "eLearning and Software for Education" Bucharest, April 24 - 25, 2014 Nath, S., Pal, C. , Sau,S., Mukherjee, S.; Roy A., Guchhait A., & Kandar, D., Design of an FPGA based intelligence traffic light controller with VHDL, 2012 International Conference on Radar, Communication and Computing (ICRCC), pp. 92 - 97, DOI:10.1109/ICRCC.2012.6450554 Noga, K. M., & Radwanski, M., (2010). Modern Improvements in the Digital Logic Laboratory. Technological Developments, in Networking, Education and Automation, Springer Netherlands, DOI: 10.1007/978-90-481-9151-2_19, pp. 109-114 Pavaloiu, I.-B., Stoica D., Nedelcu A., Dragoi G., & Petrescu, I., (2014). Digital Logic Introduced in a Gradual Approach. Proceedings of ELSE 2014, The 10th International Scientific Conference eLearning and Software for Education, Bucharest, April 24-25, 2014 Radovici, A., Culic, I., (2014), Online Platform for Embedded Devices, Proceedings of ELSE 2014, The 10th International Scientific Conference eLearning and Software for Education, Bucharest, April 24-25, 2014 Sidhu, M. S., (2010). Technology-assisted problem solving for engineering education: interactive multimedia applications, IGI Global, ISBN 978-1-60566-765-2 Wang, G., (2011). Bridging the gap between textbook and real applications: A teaching methodology in digital electronics education. Computer Applications in Engineering Education, Volume.19, Issue.2, 2011, ISSN: 10613773, pp.268 Wang S., Zhang P., Dai Z., Wang Y., Tao R., & Sun S., (2013). Research and Practice of Traffic Lights and Traffic Signs Recognition System Based on Multicore of FPGA, Communications and Network, 2013, 5, pp. 61-64, doi:10.4236/cn.2013.51B014 Published Online February 2013 (http://www.scirp.org/journal/cn) Zhao, Y., & He, Y. (2012). Some Key Issues of Teaching Reform about Digital Logic, Services Computing Conference (APSCC), 2012 IEEE Asia-Pacific Conference, 6-8 Dec. 2012, DOI: 10.1109/APSCC.2012.62, pp.406-409
1513