Counters, Timers and Real-Time Clock

Similar documents
Finite State Machines

Numbering Systems. Number Representations Part 1

Finite State Machines

Behavioral Modeling and Timing Constraints

Multi-Output Circuits: Encoders, Decoders, and

Don t expect to be able to write and debug your code during the lab session.

Vivado Tutorial. Introduction. Objectives. Procedure. Lab Workbook. Vivado Tutorial

Hardware Description Languages (HDLs) Verilog

Creating a Processor System Lab

Behavioral Modeling and Timing Constraints

Verilog for High Performance

Verilog Simulation Mapping

Using Library Modules in Verilog Designs

Hardware Design Environments. Dr. Mahdi Abbasi Computer Engineering Department Bu-Ali Sina University

ECT 224: Digital Computer Fundamentals Using Xilinx StateCAD

PINE TRAINING ACADEMY

Lab 3 Sequential Logic for Synthesis. FPGA Design Flow.

Experiment 3. Digital Circuit Prototyping Using FPGAs

An easy to read reference is:

Advanced Synthesis Techniques

CSE140L: Components and Design Techniques for Digital Systems Lab. Verilog HDL. Instructor: Mohsen Imani UC San Diego. Source: Eric Crabill, Xilinx

Exp#8: Designing a Programmable Sequence Detector

Lecture 3: Modeling in VHDL. EE 3610 Digital Systems

Modeling Concepts. Introduction

CSE 591: Advanced Hardware Design and Verification (2012 Spring) LAB #0

CSE140L: Components and Design Techniques for Digital Systems Lab. Verilog HDL. Instructor: Mohsen Imani UC San Diego. Source: Eric Crabill, Xilinx

Lab 6 : Introduction to Verilog

Method We follow- How to Get Entry Pass in SEMICODUCTOR Industries for 3rd year engineering. Winter/Summer Training

Vivado Tutorial. Introduction. Objectives. Procedure

Multi-Output Circuits: Encoders, Decoders, and

Using Library Modules in Verilog Designs. 1 Introduction. For Quartus II 13.0

University of Hawaii EE 361L. Getting Started with Spartan 3E Digilent Basys2 Board. Lab 4.1

LAB 5 Implementing an ALU

Xilinx ChipScope ICON/VIO/ILA Tutorial

Verilog Module 1 Introduction and Combinational Logic

Tutorial: Working with the Xilinx tools 14.4

Adding Custom IP to the System

Lab 3 Verilog Simulation Mapping

Copyright 2014 Xilinx

EECS150 - Digital Design Lecture 5 - Verilog Logic Synthesis

Xilinx Vivado/SDK Tutorial

Basic Xilinx Design Capture. Objectives. After completing this module, you will be able to:

MASSACHUSETTS INSTITUTE OF TECHNOLOGY Department of Electrical Engineering and Computer Sciences

Verilog Sequential Logic. Verilog for Synthesis Rev C (module 3 and 4)

DSP Resources. Main features: 1 adder-subtractor, 1 multiplier, 1 add/sub/logic ALU, 1 comparator, several pipeline stages

Digital Circuit Design and Language. Datapath Design. Chang, Ik Joon Kyunghee University

Verilog Fundamentals. Shubham Singh. Junior Undergrad. Electrical Engineering

Lab Exercise 4 System on chip Implementation of a system on chip system on the Zynq

Chapter 6: Hierarchical Structural Modeling

NIOS CPU Based Embedded Computer System on Programmable Chip

Building Combinatorial Circuit Using Behavioral Modeling Lab

TUTORIALS FOR MAX3000A CPLD DEVICES

Verilog Essentials Simulation & Synthesis

This Lecture. Some components (useful for the homework) Verilog HDL (will continue next lecture)

Register Transfer Level in Verilog: Part I

Lab 6 Debugging. Objective. Introduction. Prelab

VLSI Programming 2016: Lecture 3

LogiCORE IP Floating-Point Operator v6.2

Memory Controller. System Integration Issues. Encoding numbers 1GB RAM FSM. Communicating FSMs Clocking, theory and practice. Combinational Logic

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

EE 1315 DIGITAL LOGIC LAB EE Dept, UMD

Tutorial - Using Xilinx System Generator 14.6 for Co-Simulation on Digilent NEXYS3 (Spartan-6) Board

Lab 3 Finite State Machines Movie Ticket Dispensing Machine

Asynchronous FIFO Design

EE260: Digital Design, Spring 2018

In this lecture, we will focus on two very important digital building blocks: counters which can either count events or keep time information, and

EN2911X: Reconfigurable Computing Topic 02: Hardware Definition Languages

RUN-TIME RECONFIGURABLE IMPLEMENTATION OF DSP ALGORITHMS USING DISTRIBUTED ARITHMETIC. Zoltan Baruch

ECE 2300 Digital Logic & Computer Organization. More Sequential Logic Verilog

structure syntax different levels of abstraction

Here is a list of lecture objectives. They are provided for you to reflect on what you are supposed to learn, rather than an introduction to this

Verilog introduction. Embedded and Ambient Systems Lab

ENGN1640: Design of Computing Systems Topic 02: Design/Lab Foundations

Lab 1 Modular Design and Testbench Simulation ENGIN 341 Advanced Digital Design University of Massachusetts Boston

ELEC 4200 Lab#10 Interrupting SPI Receiver for use with a Processor Core

Use Vivado to build an Embedded System

Field Programmable Gate Array (FPGA)

Overview. CSE372 Digital Systems Organization and Design Lab. Hardware CAD. Two Types of Chips

FPGA Design Tutorial

An Efficient Implementation of Floating Point Multiplier

ENEE245 Digital Circuits and Systems Lab Manual

DIGITAL LOGIC WITH VHDL (Fall 2013) Unit 1

Lab #1: Introduction to Design Methodology with FPGAs part 1 (80 pts)

Lab 1: FPGA Physical Layout

Register Transfer Methodology II

Outline. Register Transfer Methodology II. 1. One shot pulse generator. Refined block diagram of FSMD

Topics. Midterm Finish Chapter 7

Figure 1: Verilog used to generate divider

XST User Guide

How to use the IP generator from Xilinx to instantiate IP cores

INSTITUTE OF AERONAUTICAL ENGINEERING Dundigal, Hyderabad ELECTRONICS AND COMMUNICATIONS ENGINEERING

FPGA Design Challenge :Techkriti 14 Digital Design using Verilog Part 1

Date Performed: Marks Obtained: /10. Group Members (ID):. Experiment # 11. Introduction to Verilog II Sequential Circuits

NIOS CPU Based Embedded Computer System on Programmable Chip

Digital Design Using Digilent FPGA Boards -- Verilog / Active-HDL Edition


Nikhil Gupta. FPGA Challenge Takneek 2012

EE 101 Lab 5 Fast Adders

Lab 1: Introduction to Verilog HDL and the Xilinx ISE

Basic HLS Tutorial. using C++ language and Vivado Design Suite to design two frequencies PWM. modulator system

Transcription:

Introduction In the previous lab, you learned how the Architectural Wizard can be used to generate a desired clock frequency and how the IP Catalog can be used to generate various cores including counters. These two functional circuits are fundamental circuits used in creating timers and real-time clocks. In this lab, you will generate several kinds of counters, timers, and real-time clocks. Please refer to the Vivado tutorial on how to use the Vivado tool for creating projects and verifying digital circuits. Objectives After completing this lab, you will be able to: Define a parameterized model Model counters using behavioral modeling Design counters using the IP Catalog Compare and contrast the counters developed using the behavioral modeling and the IP Catalog Design timer circuits using the cores and using additional circuits modeled in HDL Create a real-time clock Parameter and defparam Statements Part 1 The Verilog HDL language supports model parameterization, i.e. write a model in HDL and reuse the same model number of times by passing different parameter values (typically widths and delays). Use the parameter construct to define a parameterize-able model. There are two ways to change the values: (i) during the instantiation of the module (shown in the example below), and (ii) using a defparam statement. Here is an example of defining a width as a parameter with a default value of 4. parameter WIDTH = 4; The parameter (WIDTH) must be defined before it can be used in the model. Here is an example, in Verilog-2001 standard, of a dataflow model of reduction-or functionality. module reduction_or #(parameter WIDTH = 4)(input ain[width-1:0], output result); assign result = ain; module test_reduction_or_tb; reg [3:0] ain1; reg [6:0] ain2; reg [9:0] ain3; wire result1, result2, result3; reduction_or U1 (ain1, result1); // use default value of 4 reduction_or #(7) U2 (ain2, result2); // use value of 7 reduction_or #(10) U3 (in3, result3); // use value of 10 Note that the parameter WIDTH is defined before it is used. In case of multiple parameter definitions, the values listed during instantiation maps to the order in which the parameters are defined. In Verilog-2001 standard, all parameters values must be defined, even when some of the values are default values, in case of multiple parameters. For example, www.xilinx.com/university Artix-7 9-1

module FA; parameter AND_DELAY=2, XOR_DELAY=3; //gate-level model which uses AND_DELAY and XOR_DEALY in the gate instantiations module FA2BIT( ports listing); FA #(4,5) f1(ports connections); // AND_DELAY will be 4 and XOR_DELAY will be 5 FA #(1,2) f2(ports conenctions); // AND_DELAY will be 1 and XOR_DELAY will be 2 The defparam statement can also be used to change the parameters value from a higher level module by referencing the module instantiation. For example, module TOP; defparam fa2.f1.and_delay=4, fa2.f1.xor_delay=5, fa2.f2.and_delay=1, fa2.f2.xor_delay=2; FA2BIT fa2(ports connections); The parameter definition can be in the same file where it is used or in a separate file (like a header file in C programming language) and the header file could be included in the model using the `include directive. For example, Let us define the following parameter in a file called header.v parameter WIDTH = 4; Then to use it in a file where reduction_or and test_reduction_or_tb modules are defined, use the following line at the beginning of the file. `include header.v // you can add a full path to the file if it is located in some other directory path 1-1. Design a carry-look-ahead adder similar to that you designed in Part 4-1 of Lab 2 but using gate-level modeling. Define 2 units delay for each kind of gate that you use in the full-adder circuit using the parameter statements. When creating hierarchical models, use 1 unit delay for inverters, 3 units delay for and and or gates, and 4 units delay for xor gates. Use the module instance parameter value assignment statement method. Develop a testbench to verify the functionality and to see the delays propagated through the hierarchy. Do not implement the design. 1-2. Modify the carry-look-ahead adder of 1-1 using the defparam statements, changing the values of the delays from the testbench. Perform the behavioral modeling simulation and observe the delays propagated through the hierarchy. Do not implement the design. Artix-7 9-2 www.xilinx.com/university

Counters and Used Resources Part 2 Counters are fundamental circuits used in measuring events. They may be classified as simple freerunning binary up counting, up/down counting, modulo-k counting, Johnson counting, gray-code counting, and special sequence counting. In a given design or set of designs, designer use counters of different widths a number of times. The parameter and defparam statements covered in Part 1 are used to obtain different widths. Counters normally use adder and subtractor circuits which can be implemented in the Xilinx FPGA either using LUTs and/or FFs, or DSP48 slices. You can control the type of resources to be used by using the synthesis attribute, called USE_DSP48 with a value of yes or no, in the Verilog code. USE_DSP48 instructs the synthesis tool how to deal with synthesis arithmetic structures. By default, mults, mult-add, mult-sub, mult-accumulate type structures go into DSP48 blocks. Adders, subtractors, and accumulators can also go into these blocks but by default, are implemented with the fabric instead of with DSP48 blocks. The USE_DSP48 attribute overrides the default behavior and force these structures into DSP48 blocks. The attribute can be placed in the RTL on signals and modules. For example, (* use_dsp48 = "yes" *) // will force the use of DSP48 even on adders module updown_ctr_behavior( input clk,... (* use_dsp48 = "no" *) // will force not to use the DSP48 even on mults module matrixmul_behavior( input clk,... 2-1. Design an 8-Bit up/down counter using behavioral modeling. Your model should define COUNT_SIZE as a parameter and use it in the model. The counter will use the on-board 100 MHz clock source. Use the clocking wizard to generate a 5 MHz clock, dividing it further by a clock divider to generate a periodic one second signal. Define the synthesis attribute to not to use the DSP48 slices. Use the BTNU button as reset to the circuit, SW0 as enable, SW1 as the Up/Dn (1=Up, 0=Dn), and LED7 to LED0 to output the counter output. Go through the design flow, generate the bitstream, and download it into the Basys3 or the Nexys4 DDR board. Verify the functionality. Fill out the following information after reviewing the Project Summary tab. 1. Number of BUFG/BUFGCTRL Number of DSP48E1 slices used: 2-2. Use the 8-Bit up/down counter design from 2-1. Set the synthesis attribute to force the use of the DSP48 slices. Use the BTNU button as reset to the circuit, SW0 as enable, SW1 as the Up/Dn (1=Up, 0=Dn), and LED7 to LED0 to output the counter output. Go through the design flow, generate the bitstream, and download it into the Basys3 or the Nexys4 DDR board. www.xilinx.com/university Artix-7 9-3

Verify the functionality. Fill out the following information after reviewing the Project Summary tab. 2. Number of BUFG/BUFGCTRL Number of DSP48E1 slices used: 2-3. Design an 8-Bit up/down counter using the 8-Bit core generated using the IP Catalog. When generating the core, set the setting to use the fabric resource. Use the clocking wizard to generate a 5 MHz clock from the onboard 100 MHz clock source, dividing it further by a clock divider to generate a periodic one second signal. Use the BTNU button as reset to the circuit, SW0 as enable, SW1 as the Up/Dn (1=Up, 0=Dn), and LED7 to LED0 to output the counter output. Go through the design flow, generate the bitstream, and download it into the Basys3 or the Nexys4 DDR board. Verify the functionality. Fill out the following information after reviewing the Project Summary tab. 3. Number of BUFG/BUFGCTRL Number of registers used: Number of DSP48E1 slices used: 2-4. Use the 8-Bit up/down counter design from 2-3 but with the counter regenerated to use the DSP48 slices. Use the BTNU button as reset to the circuit, SW0 as enable, SW1 as the Up/Dn (1=Up, 0=Dn), and LED7 to LED0 to output the counter output. Go through the design flow, generate the bitstream, and download it into the Basys3 or the Nexys4 DDR board. Verify the functionality. Fill out the following information after reviewing the Project Summary tab. 4. Number of BUFG/BUFGCTRL Number of registers used: Number of DSP48E1 slices used: Timers and Real-Time Clock Part 3 Timers and real-time clock are natural applications of counters. The timers include a stop-watch timer and a lapse timer. The real-time clocks are used in a day to day life for keeping track of the time of the day. 3-1. Design a stop-watch timer using the IP Catalog to generate an appropriate sized (precision) counter core with the desired input control signals to measure a time up to five minutes at a resolution of one-tenth of a second. Instantiate the core a number of required times and add the required additional circuitry to display the time in M.SS.f format on the four 7- segment displays. The design input will be a 100 MHz clock source, a reset signal using the BTNU button, and an enable signal using SW0. When the Artix-7 9-4 www.xilinx.com/university

enable signal is asserted (ON) the clock counts, when it is de-asserted (OFF) the clock pauses. At any time if BTNU is pressed the clock resets to the 0.00.0 value. Verify the design functionality in hardware using the Basys3 or the Nexys4 DDR board. 3-2. Design a countdown timer using the behavioral modeling to model a parameterized counter down counter with the desired input control signals to show the count down time from a desired initial value set by the two slide switches of the board at a second resolution. Display the time in MM.SS format on the three 7-segment displays. The design input will be a 100 MHz clock source, a re-load signal using the BTNU button, an enable signal using SW0, and SW7-SW6 as the starting value in number of whole minutes. When the enable signal is asserted (ON) the clock counts, when it is de-asserted (OFF) the clock pauses. When the BTNU is pressed the timer loads to MM.00, where the value of MM is determined by the SW7- SW6 settings (MM=00 will be ignored). Verify the design functionality in hardware using the Basys3 or the Nexys4 DDR board. 3-3. Design a real-time clock using the IP Catalog to generate an appropriate sized (precision) counter core with the desired input control signals. Instantiate it two times and add the required circuit to display the time in MM.SS format on the four 7-segment displays. The design input will be a 100 MHz clock source and a reset signal using the BTNU button. At any time if BTNU is pressed the clock resets to 00.00. Verify the design functionality in hardware using the Basys3 or the Nexys4 DDR board. Conclusion In this lab, you learned how to parameterize models so they can be used in subsequent designs. You also designed and compared the resources usage of counters modeled behaviorally and using the IP Catalog. You also designed clocking applications using the counters. Answers 1. Number of BUFG/BUFGCTRL 2 Number of Slice LUTs used: 25 32 Number of DSP48E1 slices used: 0 12 2. Number of BUFG/BUFGCTRL 2 Number of Slice LUTs used: 22 33 Number of DSP48E1 slices used: 2 12 3. Number of BUFG/BUFGCTRL 2 Number of Slice LUTs used: 27 Number of registers used: 32 Number of DSP48E1 slices used: 0 12 www.xilinx.com/university Artix-7 9-5

4. Number of BUFG/BUFGCTRL 2 Number of Slice LUTs used: 18 Number of registers used: 24 Number of DSP48E1 slices used: 1 12 Artix-7 9-6 www.xilinx.com/university