广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验二 Numbers and Displays

Laboratory Exercise 2 Numbers and Displays This is an exercise in designing combinational circuits that can perform binary-to-decimal number conversion and binary-coded-decimal(BCD)addition. PartI We wish to display on the 7-segment displays HEX3 to HEXO the values set by the switches SW 1 Create a roiect which will be ent the desired ci cuit on the altera de2 board The y simple VHDL assignment statements in your code and specify each logic function as a clude this ile DE2 poard The procedure for makinnassimnts is deseribed in the tutoral on theDnd theoof 3.Compile the project and download the compiled circuit into the FPGA chip. 4.Test the functionality of your design by toggling the switches and observing the displays PartII 一”网b 1 hat in thecorotsegment displays.You are tocompetthe design of thiscrt byreating VHDLnit nludes the comparaor muplexers.and circuit 4(do not include circuit B or the seg egment decoder a entity sho e the fou-bit input v. the four-bit output M an e0up2. .Your shoul not include any IF-ELSE,CASE.r smar statemens Binary value Decimal digits 0000 0 100 0 9 0 1101 1111 3 Table 1.Binary-to-decimal conversion values
Laboratory Exercise 2 Numbers and Displays This is an exercise in designing combinational circuits that can perform binary-to-decimal number conversion and binary-coded-decimal (BCD) addition. Part I We wish to display on the 7-segment displays HEX3 to HEX0 the values set by the switches SW15−0. Let the values denoted by SW15−12, SW11−8, SW7−4 and SW3−0 be displayed on HEX3, HEX2, HEX1 and HEX0, respectively. Your circuit should be able to display the digits from 0 to 9, and should treat the valuations 1010 to 1111 as don’t-cares. 1. Create a new project which will be used to implement the desired circuit on the Altera DE2 board. The intent of this exercise is to manually derive the logic functions needed for the 7-segment displays. You should use only simple VHDL assignment statements in your code and specify each logic function as a Boolean expression. 2. Write a VHDL file that provides the necessary functionality. Include this file in your project and assign the pins on the FPGA to connect to the switches and 7-segment displays, as indicated in the User Manual for the DE2 board. The procedure for making pin assignments is described in the tutorial Quartus II Introduction using VHDL Design, which is available on the DE2 System CD and in the University Program section of Altera’s web site. 3. Compile the project and download the compiled circuit into the FPGA chip. 4. Test the functionality of your design by toggling the switches and observing the displays. Part II You are to design a circuit that converts a four-bit binary number V = v 3v2v1v0 into its two-digit decimal equivalent D = d1d0. Table 1 shows the required output values. A partial design of this circuit is given in Figure 1. It includes a comparator that checks when the value of V is greater than 9, and uses the output of this comparator in the control of the 7-segment displays. You are to complete the design of this circuit by creating a VHDL entity which includes the comparator, multiplexers, and circuit A (do not include circuit B or the 7-segment decoder at this point). Your VHDL entity should have the four-bit input V , the four-bit output M and the output z. The intent of this exercise is to use simple VHDL assignment statements to specify the required logic functions using Boolean expressions. Your VHDL code should not include any IF-ELSE, CASE, or similar statements. Binary value Decimal digits 0000 0 0 0001 0 1 0010 0 2 ... ... ... 1001 0 9 1010 1 0 1011 1 1 1100 1 2 1101 1 3 1110 1 4 1111 1 5 Table 1. Binary-to-decimal conversion values. 1

Perform the following steps 1.Make a Quartus lI project for your VHDLentity. V,and the displays HEXI and HEYOto show the values of decimal digitsd and do.Make sure to include in your project the required pin assignments for the DE2 board. 4.Recompile the project,and then download the circuit into the FPGA chip. 5.Test your circuit by trying all possible values of Vand observing the output displays. Figure 1.Partial design of the binary-to-decimal conversion circuit. PartⅢ a circuit that adds two four-bit numbers.This type of circuit is usually called a ple-caadder.because of the way that the carry signals are passed fromo fulladder tothe nextWriteHLcodethat impemnhis circuit,as described below
Perform the following steps: 1. Make a Quartus II project for your VHDL entity. 2. Compile the circuit and use functional simulation to verify the correct operation of your comparator, multiplexers, and circuit A. 3. Augment your VHDL code to include circuit B in Figure 1 as well as the 7-segment decoder. Change the inputs and outputs of your code to use switches SW3−0 on the DE2 board to represent the binary number V , and the displays HEX1 and HEX0 to show the values of decimal digits d 1 and d0. Make sure to include in your project the required pin assignments for the DE2 board. 4. Recompile the project, and then download the circuit into the FPGA chip. 5. Test your circuit by trying all possible values of V and observing the output displays. 0 1 0 1 v2 0 v3 Circuit B 7 0 1 2 3 4 5 6 7-segment 7 0 1 2 3 4 5 6 0 1 v1 0 1 v0 Circuit A Comparator decoder d1 d0 m2 m3 m1 m0 z Figure 1. Partial design of the binary-to-decimal conversion circuit. Part III Figure 2a shows a circuit for a full adder, which has the inputs a, b, and c i, and produces the outputs s and co. Parts b and c of the figure show a circuit symbol and truth table for the full adder, which produces the two-bit binary sum cos = a + b + ci. Figure 2d shows how four instances of this full adder entity can be used to design a circuit that adds two four-bit numbers. This type of circuit is usually called a ripple-carry adder, because of the way that the carry signals are passed from one full adder to the next. Write VHDL code that implements this circuit, as described below. 2

D a)Full adder circuit b)Full adder symbol 99/18 样中的的 c)Full adder truth table d)Four-bit ripple-carry adder circuit Figure 2.A ripple-carry adder circuit. 2.Use switches sw and swao to represent the inputs A and B.respectively.Use sWa for the carry-in 发 3nasaenmsgmasrcDE2adcopkk6iaRaonndRo 4.Test your circuit by trying different values for numbersA.B,and PartIV In part II we discussed the conversion of binary numbers into decimal digits.It is sometimes useful to build 。mwm论C器起 You are to design a circuit that adds two BCD digits.The inputs to the circuit are BCD numbers A and B. 1.Create a new Quartus lI project for your BCD adder.You should use the four-bit adder circuit from part hich has a four-t binary-todecimal converter from part Write your HDL code using statements to specify the required logic functions-do not use other types of VHDL statements such as IF-ELSE or CASE statements for this part of the exercise
FA 0 1 ci a) Full adder circuit a b co s ci a b co s b) Full adder symbol FA a0 b0 s0 FA c1 a1 b1 s1 FA c2 a2 b2 s2 FA c3 a3 b3 s3 cout d) Four-bit ripple-carry adder circuit cin 0 0 c) Full adder truth table a ci b 0 0 0 1 0 0 1 0 1 1 100 1 1 0 1 1 0 111 0 0 c s o 0 1 0 1 1 0 0 1 1 1 0 0 1 1 Figure 2. A ripple-carry adder circuit. 1. Create a new Quartus II project for the adder circuit. Write a VHDL entity for the full adder subcircuit and write a top-level VHDL entity that instantiates four instances of this full adder. 2. Use switches SW7−4 and SW3−0 to represent the inputs A and B, respectively. Use SW8 for the carry-in cin of the adder. Connect the SW switches to their corresponding red lights LEDR, and connect the outputs of the adder, cout and S, to the green lights LEDG. 3. Include the necessary pin assignments for the DE2 board, compile the circuit, and download it into the FPGA chip. 4. Test your circuit by trying different values for numbers A, B, and c in. Part IV In part II we discussed the conversion of binary numbers into decimal digits. It is sometimes useful to build circuits that use this method of representing decimal numbers, in which each decimal digit is represented using four bits. This scheme is known as the binary coded decimal (BCD) representation. As an example, the decimal value 59 is encoded in BCD form as 0101 1001. You are to design a circuit that adds two BCD digits. The inputs to the circuit are BCD numbers A and B, plus a carry-in, cin. The output should be a two-digit BCD sum S1S0. Note that the largest sum that needs to be handled by this circuit is S1S0 = 9 + 9 + 1 = 19. Perform the steps given below. 1. Create a new Quartus II project for your BCD adder. You should use the four-bit adder circuit from part III to produce a four-bit sum and carry-out for the operation A + B. A circuit that converts this five-bit result, which has the maximum value 19, into two BCD digits S1S0 can be designed in a very similar way as the binary-to-decimal converter from part II. Write your VHDL code using simple assignment statements to specify the required logic functions–do not use other types of VHDL statements such as IF-ELSE or CASE statements for this part of the exercise. 3

nd sw for the e Sw foe th out produced by the operation A+B to the green lights LEDG.Display the BCD values of A and B on the 7-segment displays HEX6 and HEX4,and display the result S So on HEX/and HEXO. 4.Include the necessary pin assignments for the DE2 board,compile the circuit,and download it into the FPGA chip. 5.Test your circuit by trying different values for numbers A.B.andc Part V 一设o邮 rform the steps 1 Use switches Sw nt 2 digit BCD A.Aand R.R ively.The of o should be displayed gment displays HEX7andHE6,while BBo should be on HEX5 and HEX4.Display the BCD sum,S2SSo,on the 7-segment displays HEX2,HEXI and HEX0. 2.Make the necessary pin assignments and compile the circuit. 3.Download the circuit into the FPGA chip,and test its operation PartVI In part V you created VHDL code for a two-digit BCD adder by using two instances of the VHDL code for a one-digit BCD adde one Te the tollowing code is to specity an algorithm like the one represente 1T。三A+B 2 if(To>9)then 6 Zn.=0 9 10T=A1+B+c 14 else 67 1=0 19S2=c2
2. Use switches SW7−4 and SW3−0 for the inputs A and B, respectively, and use SW8 for the carry-in. Connect the SW switches to their corresponding red lights LEDR, and connect the four-bit sum and carryout produced by the operation A + B to the green lights LEDG. Display the BCD values of A and B on the 7-segment displays HEX6 and HEX4, and display the result S1S0 on HEX1 and HEX0. 3. Since your circuit handles only BCD digits, check for the cases when the input A or B is greater than nine. If this occurs, indicate an error by turning on the green light LEDG 8. 4. Include the necessary pin assignments for the DE2 board, compile the circuit, and download it into the FPGA chip. 5. Test your circuit by trying different values for numbers A, B, and c in. Part V Design a circuit that can add two 2-digit BCD numbers, A1A0 and B1B0 to produce the three-digit BCD sum S2S1S0. Use two instances of your circuit from part IV to build this two-digit BCD adder. Perform the steps below: 1. Use switches SW15−8 and SW7−0 to represent 2-digit BCD numbers A1A0 and B1B0, respectively. The value of A1A0 should be displayed on the 7-segment displays HEX7 and HEX6, while B1B0 should be on HEX5 and HEX4. Display the BCD sum, S2S1S0, on the 7-segment displays HEX2, HEX1 and HEX0. 2. Make the necessary pin assignments and compile the circuit. 3. Download the circuit into the FPGA chip, and test its operation. Part VI In part V you created VHDL code for a two-digit BCD adder by using two instances of the VHDL code for a one-digit BCD adder from part IV. A different approach for describing the two-digit BCD adder in VHDL code is to specify an algorithm like the one represented by the following pseudo-code: 1 T0 = A0 + B0 2 if (T0 > 9) then 3 Z0 = 10; 4 c1 = 1; 5 else 6 Z0 = 0; 7 c1 = 0; 8 end if 9 S0 = T0 − Z0 10 T1 = A1 + B1 + c1 11 if (T1 > 9) then 12 Z1 = 10; 13 c2 = 1; 14 else 15 Z1 = 0; 16 c2 = 0; 17 end if 18 S1 = T1 − Z1 19 S2 = c2 4

It is r code Lines esent adders.lines 2-8 and 1-17 cor and T>9 requires comparators.You are to write VHDL code that corresponds to this pseudo-code.Note that you can perform ad lition operations in your VHDL code instead of the subtrac ons shown in lines 9 and 18.The nF-ELSE ng more on the erfo epsen the 2.Use the Quartus II RTLViewer tool toexamine the circuit produced by compiling your VHDL code.Com- pare the circuit to the one you designed in Part V. 3.Download your circuit onto the DE2 board and test it by trying different values for numbers AAo and BBo. Part VII Desig 2terpHedHe0o display the decimal number.Implement your circton the DE2 board and demonstrate its functionality. Copyright006 Altera Corporation
It is reasonably straightforward to see what circuit could be used to implement this pseudo-code. Lines 1, 9, 10, and 18 represent adders, lines 2-8 and 11-17 correspond to multiplexers, and testing for the conditions T 0 > 9 and T1 > 9 requires comparators. You are to write VHDL code that corresponds to this pseudo-code. Note that you can perform addition operations in your VHDL code instead of the subtractions shown in lines 9 and 18. The intent of this part of the exercise is to examine the effects of relying more on the VHDL compiler to design the circuit by using IF-ELSE statements along with the VHDL > and + operators. Perform the following steps: 1. Create a new Quartus II project for your VHDL code. Use the same switches, lights, and displays as in part V. Compile your circuit. 2. Use the Quartus II RTL Viewer tool to examine the circuit produced by compiling your VHDL code. Compare the circuit to the one you designed in Part V. 3. Download your circuit onto the DE2 board and test it by trying different values for numbers A 1A0 and B1B0. Part VII Design a combinational circuit that converts a 6-bit binary number into a 2-digit decimal number represented in the BCD form. Use switches SW5−0 to input the binary number and 7-segment displays HEX1 and HEX0 to display the decimal number. Implement your circuit on the DE2 board and demonstrate its functionality. Copyright c 2006 Altera Corporation. 5
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验一 Switches, Lights, and Multiplexers.pdf
- 中国科学技术大学:《计算机图形学》课程教学资源(讲义)第六章 观察(主讲:黄章进).pdf
- 中国科学技术大学:《计算机图形学》课程教学资源(讲义)第四章 输入与交互.pdf
- 中国科学技术大学:《计算机图形学》课程教学资源(讲义)第五章 几何对象与变换.pdf
- 中国科学技术大学:《计算机图形学》课程教学资源(讲义)第二章 计算机图形系统.pdf
- 中国科学技术大学:《计算机图形学》课程教学资源(讲义)第三章 OpenGL编程.pdf
- 中国科学技术大学:《计算机图形学》课程教学资源(讲义)第一章 计算机图形学概述 Computer Graphics.pdf
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第九章 群体类和群体数据的组织.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第八章 多态性.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第七章 继承与派生.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第六章 数组、指针与字符串.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第五章 C++程序的结构.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第四章 类与对象.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第三章 函数.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第二章 C++简单程序设计.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第十二章 异常处理.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第十一章 流类库与输入/输出.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第十章 C++标准模板库.ppt
- 清华大学:《C++语言程序设计》课程教学资源(PPT课件)第一章 绪论(主讲:郑莉).ppt
- 中国科学技术大学:《C++语言程序设计》课程教学资源(讲义)第十二章 异常处理.pdf
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验三 Latches, Flip-flops, and Registers.pdf
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验四 Counters.pdf
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验五 Clocks and Timers.pdf
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验六 Adders, Subtractors, and Multipliers.pdf
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验七 Finite State Machines.pdf
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验八 Memory Blocks.pdf
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验九 A Simple Processor.pdf
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(实验指导)实验十 An Enhanced Processor.pdf
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)前言(负责人:张健).ppt
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)第1章 概述.ppt
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)第2章 可编程逻辑器件.ppt
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)第3章 集成开发平台QuartusII操作基础.ppt
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)第4章 VHDL编程基础.ppt
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)第5章 VHDL主要描述语句.ppt
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)第6章 VHDL设计共享.ppt
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)第7章 基本逻辑电路设计.ppt
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)第8章 有限状态机的VHDL设计.ppt
- 广东海洋大学:《VHDL程序设计语言》课程教学资源(PPT课件)第10章 EDA设计的仿真与测试.ppt
- 西安电子科技大学:《计算机网络 Computer Networks》课程教学资源(PPT课件讲稿)第二章 物理层.pptx
- 西安电子科技大学:《计算机网络 Computer Networks》课程教学资源(PPT课件讲稿)第三章 数据链路层.pptx