Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8738437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T10:43:55+00:00 2026-06-13T10:43:55+00:00

I am new to VHDL, working on a homework assignment. I have a very

  • 0

I am new to VHDL, working on a homework assignment.

I have a very simple clock divider using a generic. (It’s a counter/divider.)

-- the actual divider will be 2.1e6 or so (25Mhz down to 15hz)
run_divider : clk_divider
--pragma synthesis off
    generic map(clkmax => 4) -- simulation
--pragma synthesis on
    generic map(clkmax => 50000) -- synthesis
      port map( clk_in => mclk,
                reset => rst,
                clk_out => divider_out );

I partially used Equivalent of #ifdef in VHDL for simulation/synthesis separation? with the pragma above. However, this only works in synthesis but is a syntax error in simulation.

Other than using an external tool (M4, C preprocessor as another answer suggested), is there a better way to have separate code for synthesis vs simulation? I’d like to stopy worrying about these constants when I switch between synthesis to simulation.

Answers to How to convert 24MHz and 12MHz clock to 8MHz clock using VHDL? tell me the counter/divider is not an optimal solution but it’s simple enough for my homework 🙂

My full divider code is here:
https://github.com/linuxlizard/vhdl/blob/master/divider.vhdl

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T10:43:56+00:00Added an answer on June 13, 2026 at 10:43 am

    As simon says, you can use a flag with a generate – if you put this code into some utility package, you can use it throughout your design. Or just add it to the local architecture if it’s a one-off:

    constant in_simulation : boolean := false
    --synthesis translate_off
                                        or true
    --synthesis translate_on
    ;
    

    A potentially useful alternative is:

    constant in_simulation : integer  := 0
    --synthesis translate_off
                                        + 1
    --synthesis translate_on
    ;
    
    constant in_synthesis : integer  := 1
    --synthesis translate_off
                                        - 1
    --synthesis translate_on
    ;
    

    Which can be used, in your case, to do:

    constant clkmax_coefficient : integer := 4*in_simulation + 50000*in_synthesis;
    
    run_divider : clk_divider
        generic map(clkmax => clkmax_coefficient)
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to StackOverflow here. I'm working on the first Euler problem and have run
new on ruby and using windows xp and rails 3, i want to send
New to PHP and MySQL, have heard amazing things about this website from Leo
new to c#. I'm trying to make a simple system where I can search
New developer here,Im using the Custom Image Picker by ray wenderlich. But what I
New-style status messages (as in mobile apps and web interface) have new properties e.g.
New to SharePoint. I'm trying to upload a document to SharePoint using it's CopyIntoItems
New to ASP.NET MVC 3. This seems like it should be a really simple
(New to Objective-C, but well versed in C/C++). Presently I have an Objective-C class
New to Javascript and jQuery, so I assume this is a pretty simple question.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.