Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Introduction to Counters and CPLDs - Lecture Notes | ECE 238L, Lab Reports of Electrical and Electronics Engineering

Material Type: Lab; Class: Computer Logic Design; Subject: Electrical & Computer Engineer; University: University of New Mexico; Term: Summer 2004;

Typology: Lab Reports

Pre 2010

Uploaded on 09/17/2009

koofers-user-gk5-1
koofers-user-gk5-1 🇺🇸

10 documents

1 / 8

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ECE 238 Laboratory Manual – University of New Mexico
Introduction to Counters and CPLDs
Introduction
This lab will introduce concepts on digital counters, modular design and we will explore more
capabilities of the XCR board. The systems we will implement are divided in subsystems or
modules described on independent VHDL files. We will use the concepts learn in previous labs to
create, synthesize and download to a CPLD a project.
Goals
After completing this lab, you will be able to:
Creating a project that utilizes multiple VHDL files.
Routing signals in and out of the device to facilitate I/O.
Designing and implementing counters.
Understand clocks and 7 segment display circuits on the XCR board.
Design Description : Counter
The counter we will design must:
Have a pause, reset and increasing count state.
Must count from 0 to a maximum of 15.
Must display its count using the 7 segment display provided by the XCR board.
Design Analisis
Counter
The counter we were asked to design is more complex than the one you saw in the lecture notes,
it has three states and it is represented by the state diagram in figure 1. A proposed block
diagram is show in figure 2.
7 Segment display (from XCR datasheet, Digilent Inc.)
From the lecture notes is understood that we need a display controller to implement the
translation table (figure 2.d from lecture notes) and the timing diagram (figure 3 from lecture
notes) for the dual-digit seven segment display on the XCR board. A proposed block diagram of
such a system is given in figure 3.
V1.0b @alnz 1
pf3
pf4
pf5
pf8

Partial preview of the text

Download Introduction to Counters and CPLDs - Lecture Notes | ECE 238L and more Lab Reports Electrical and Electronics Engineering in PDF only on Docsity!

Introduction to Counters and CPLDs

Introduction

This lab will introduce concepts on digital counters, modular design and we will explore more capabilities of the XCR board. The systems we will implement are divided in subsystems or modules described on independent VHDL files. We will use the concepts learn in previous labs to create, synthesize and download to a CPLD a project.

Goals

After completing this lab, you will be able to:

  • Creating a project that utilizes multiple VHDL files.
  • Routing signals in and out of the device to facilitate I/O.
  • Designing and implementing counters.
  • Understand clocks and 7 segment display circuits on the XCR board.

Design Description : Counter

The counter we will design must:

  • Have a pause, reset and increasing count state.
  • Must count from 0 to a maximum of 15.
  • Must display its count using the 7 segment display provided by the XCR board.

Design Analisis

Counter

The counter we were asked to design is more complex than the one you saw in the lecture notes, it has three states and it is represented by the state diagram in figure 1. A proposed block diagram is show in figure 2.

7 Segment display (from XCR datasheet, Digilent Inc.)

From the lecture notes is understood that we need a display controller to implement the translation table (figure 2.d from lecture notes) and the timing diagram (figure 3 from lecture notes) for the dual-digit seven segment display on the XCR board. A proposed block diagram of such a system is given in figure 3.

reset = 1

reset

count pause

reset = 0

reset = 0 ; pause = 0

pause = 1

pause = 0

pause = 1

clock reset pause

out(3 downto 0) counter 4

Figure 1; three state counter Figure 2; counter block diagram

MSD : Maximum significative digit LSD : Minimum significative digit

7 7

7

CAT CAT

(anodes AA through AG)

clk

MSD LSD 4 converter

clk CAT CAT anodes msblsb^ msb^ lsb^ msb^ lsb

Display controller

selector

sel

Figure 3; Display controller block diagram

The design of the whole system will follow a modular schema. We will first describe and simulate a counter, then a display controller, and finally the whole system. A block diagram of the whole system is shown in figure 4.

7 7

7

CAT CAT

(anodes (6 downto 0): AA through AG)

clk

MSD : count(4 downto 0) LSD converter

Display controller: disp_controller.vhd

counter: counter.vhd

clk reset pause

top_counter.vhd

4

selector

sel

Figure 4; Complete system to be implemented in this lab

Figure 6; Simulation output.

Adding the Display Controller to the Project Step 3

  1. Acquire files; Download the files disp_controller.vhd, converter.vhd, selector.vhd, inv_v.vhd and disp_controller_tb.vhd provided at the lab website and save them in the directory C:/summer04/student_name/counter. Make sure you are saving them without a “.txt” extension but a “.vhd” extension.
  2. Add VHDL code to the project; Go to Project → Add source , select the disp_controller.vhd, converter.vhd, inv_v.vhd, selector.vhd (vhdl modules) and disp_controller _tb.vhd (test bench associated to disp_controller.vhd).
  3. Analyzing controller description; Open the file disp_controller.vhd by double clicking on it under Sources in Project window. Note that the description is structural and is not complete.
  4. Declaring components or subsystems; Every component or subsystem use in the description of a system using structural level of abstraction, must be declared. The display controller we are implementing has three components: a selector, a converter and an inverter. The declaration area for components is under the comment – Components declarations – in the disp_controller.vhd file. Use the inverter declaration as an example, to complete the declarations of the selector and the converter.
  5. Components instantiations; Once the components are declared, they must be instantiated. This means the connections between components and/or signals inside the system must be declared. The declaration area for components instantiations is under the comment – Components Instantiations – in the disp_controller.vhd file. Use the inverter instantiation as an example. Use the block diagram in figure 5 as a map to complete the connections.
  6. Synthesize the project; Highlight the file disp_controller.vhd under Sources in Project , and double click Synthesize under Processes for current sources window. Make sure the process doesn’t generate any error. If it does, read the comment under the Console window. It will specify the line where the error is and the reason for it.
  7. Simulate the project; Highlight the file disp_controller_tb.vhd under Sources in Project and double click Simulate Behavioral VHDL model under Processes for current source window. Make sure the simulation produces a waveform similar to figure 7.

Implementing and testing the Display Controller Step 4

  1. Acquire files for the project; Download the file disp_controller.ucf provided at the lab website and save it in the directory C:/summer04/student_name/counter. Make sure you are saving them without a “.txt” extension but an “.ucf” extension.
  2. Add VHDL code to the project; Go to Project → Add source , select the disp_controller.ucf (User constraint file associated to disp_controller.vhd).
  1. Completing User Constraint File; Highlight disp_controller.ucf file under Sources in Project window. Double click on Edit Constraints (text) under Processes for current sources window. Using table 3 of the XCR datasheet complete the information missing on the disp_controller.ucf file.

Figure 7; Display controller simulation

  1. Create programming file; Highlight disp_controller.vhd file in the Sources in Project window and double click in Generate Programming File in the Processes for Current Source window.
  2. Launching iMPACT; Highlight disp_controller.vhd in Sources in Project window; Expand Generate Programming File tasks on the Processes for Current Source window and double click on Configure Device (iMPACT). Choose Configure Devices → Next → Boundary-Scan Mode → Next → Automatically connect to cable and identify Boundary-Scan chain → Finish → Ok. An Assign New Configuration File window must be the result of this operation.
  3. Programming the device; Browse for the file disp_controller.jed in your project directory using the resulting window from previous step. Click Ok. Click on the Xilinx chip to highlight it and go to Operations → Program. Figure 8 shows the result of this operation and the options that must be selected. Click Ok.

Figure 8; iMPACT window and options for CPLD configuration.

  1. Test the system; Switches 1 to 4 are the input MSB while the switches 5 to 8 are the input LSB. Both inputs are a binary representation of the number we want to display in the dual-digit seven segment display (figure 9). Change the switches 1 to 8 and observe the changes in the displays.
  2. Test the clock; The XCR board provides a user-adjustable oscillator that can produce a clock signal in the 0.5 to 4 KHz range. The frequency is fixed by a 15-turn precision potentiometer (variable resistor) that can be adjusted from 0 to 500K ohms. Vary the

be declared. The declaration area for components instantiations is under the comment – Components Instantiations – in the top_counter.vhd file. Use the inverter instantiation as an example. Use the block diagram in figure 4 as a map to complete the connections.

  1. Synthesize the project; Highlight the file top_counter.vhd under Sources in Project , and double click Synthesize under Processes for current sources window. Make sure the process doesn’t generate any error. If it does, read the comment under the Console window. It will specify the line were the error is and the reason for it.

Programming the system into the CPLD Step 6

  1. Acquire files for the project; Download the file top_counter.ucf provided at the lab website and save it in the directory C:/summer04/student_name/counter. Make sure you are saving them without a “.txt” extension but an “.ucf” extension.
  2. Add VHDL code to the project; Go to Project → Add source , select the top_counter.ucf (User constraint file associated to top_counter.vhd).
  3. Completing User Constraint File; Highlight top_counter.ucf file under Sources in Project window. Double click on Edit Constraints (text) under Processes for current sources window. Using table 3 of the XCR datasheet complete the information missing on the top_counter.ucf file.
  4. Create programming file; Highlight top_counter.vhd file in the Sources in Project window and double click in Generate Programming File in the Processes for Current Source window.
  5. Launching iMPACT; Highlight top_counter.vhd in Sources in Project window; Expand Generate Programming File tasks on the Processes for Current Source window and double click on Configure Device (iMPACT). Choose Configure Devices → Next → Boundary-Scan Mode → Next → Automatically connect to cable and identify Boundary-Scan chain → Finish → Ok. An Assign New Configuration File window must be the result of this operation.
  6. Programming the device; Browse for the file top_counter.jed in your project directory using the resulting window from previous step. Click Ok. Click on the Xilinx chip to highlight it and go to Operations → Program. Figure 8 shows the result of this operation and the options that must be selected. Click Ok.

Project Testing Step 7

  1. Wait until the display shows a count different than 0 and apply the reset signal (set reset signal to 1). Make sure the system goes to reset state (Displays must show “00”). The system should reinitiate the count as soon as you set the reset signal to 0 again.
  2. Wait until the display shows a count different than 0 and apply the pause signal (set pause signal to 1). Make sure the system stays in the same count until you set pause signal to zero again.
  3. Demonstrating your system to your T.A.
  4. Testing CPLD memory capacity; Switch the power off and on to the power strip. The program should remain in the CPLD and the count will restart as soon as you power up the board.

Final Task Step 8

  1. Design a system: Design a system able to count from zero to 99. The display of the count will use both seven segment displays (note that previous system was only using one display while the second one was set up to zero).

Bonus Activity Step 9

  1. Modify your counter, such that it can be told to have an increasing and a decreasing count.