element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Members
    Members
    • Achievement Levels
    • Benefits of Membership
    • Feedback and Support
    • Members Area
    • Personal Blogs
    • What's New on element14
  • Learn
    Learn
    • eBooks
    • Learning Center
    • Learning Groups
    • STEM Academy
    • Webinars, Training and Events
  • Technologies
    Technologies
    • 3D Printing
    • Experts & Guidance
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Arduino Projects
    • Design Challenges
    • element14 presents
    • Project14
    • Project Groups
    • Raspberry Pi Projects
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • 'Choose another store...'
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
FPGA
  • Technologies
  • More
FPGA
Blog online lesson: clock domain crossing with a VHDL frequency counter - part 1: simulation in Vivado
  • Blog
  • Forum
  • Documents
  • Events
  • Polls
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
FPGA requires membership for participation - click to join
Blog Post Actions
  • Subscribe by email
  • More
  • Cancel
  • Share
  • Subscribe by email
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Jan Cumps
  • Date Created: 5 Jul 2022 3:44 PM Date Created
  • Views 1273 views
  • Likes 11 likes
  • Comments 4 comments
  • vhdl
  • arty
  • spartan-7
  • Spartan_Migration
Related
Recommended

online lesson: clock domain crossing with a VHDL frequency counter - part 1: simulation in Vivado

Jan Cumps
Jan Cumps
5 Jul 2022
online lesson: clock domain crossing with a VHDL frequency counter - part 1: simulation in Vivado

When your design has more than a single clock, you'll have to deal with cross-clock-domain situations. In my search for good online trainings, I bumped on this example from SURF-VHDL: How to compute the frequency of a clock. In this example, you have the usual clock for your design (called Reference Clock in the example). And a clock signal that you want to know the frequency of (called Test Clock here). A small VHDL design counts the frequency of the test clock. In order to have the HDL synthesiser do a proper synthesis, that second clock domain has to be synchronised with the primary clock that drives the counting. The example shows a technique to do that. 

This exercise is also an excuse to check if the SURF-VHDL tutorials are good (Yes, they are), and check how simulation in Vivado compares to the Xilinx ISE editor for Spartan 6. I will not provide the full sources and testbed for this example. The source is available from the link I posted above. The test bed and 4 videos digging into the detail of the design, are available when you subscribe to the SURF-VHDL tutorials (no charge). The tutorial uses Quartus, a DE0 kit and an Altera Celeron device. For this first part of my review, this doesn't matter. Everything is vendor-independent.

In part 2, where this frequency counter is used in a design, there will be differences. Because I'll use different clock sources and a different display. What you see below, is the result of simulating a test frequency that's 10 times faster than the reference frequency. Each 4096 clock ticks, the test counter counts to 40960. You see that in the picture below.

image

To do the simulation in Vivado, I added the SURF-VHDL test bed to the simulation sources, then ran a simulation for 1 ms. As expected, the results are the same as in Altera ModelSim.

What will I do in part 2?

  • the test clock will be generated by a Spartan-7 mixed-mode clock manager.
  • the Arty board doesn't have a display, or something that can show a 16 bit value. I could externalise the counter and use a logic analyser, or try working with the UART block and send the count to a PC ...
  • Sign in to reply
Parents
  • michaelkellett
    michaelkellett over 1 year ago

    Hello Jan,

    Since you are using Xilinx parts you might like to consider Xilinx's suggestions to:

    1) use synchronous resets by default

    2) not reset stuff unless you actually need to

    https://docs.xilinx.com/r/en-US/ug1387-acap-hardware-ip-platform-dev-methodology/Synchronous-Reset-vs.-Asynchronous-Reset

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • Jan Cumps
    Jan Cumps over 1 year ago in reply to michaelkellett

    I modified the reset, so that (I think) it's synchronous:

    --  CLOCK REFERENCE domain
    p_counter_ref : process (i_rstb,i_clk_ref)
    begin
      if(rising_edge(i_clk_ref)) then
        if(i_rstb='0') then
          r1_counter_ref                 <= (others=>'0');
          r1_counter_test_ena            <= '0';
          r1_counter_test_strobe         <= '0';
          r1_counter_test_rstb           <= '0';
        else
    

    I'll check whet to do to separate the signals to-be-reset process from the ones that don't play in the reset logic ...

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • michaelkellett
    michaelkellett over 1 year ago in reply to Jan Cumps

    Happy to be useful when I can. Time a bit short at the moment for posting much stuff of my own - lot's of work, dog not well, daughter not well, garden totally out of control .........

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Comment
  • michaelkellett
    michaelkellett over 1 year ago in reply to Jan Cumps

    Happy to be useful when I can. Time a bit short at the moment for posting much stuff of my own - lot's of work, dog not well, daughter not well, garden totally out of control .........

    MK

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
Children
No Data
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2023 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube