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

  • Home
  • SEARCH
  • 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 6015931
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:54:32+00:00 2026-05-23T02:54:32+00:00

MAJOR EDIT: Problem was solved after reading Will Dean’s comment. The original question is

  • 0

MAJOR EDIT:

Problem was solved after reading Will Dean’s comment. The original question is below the revised code:

-- REVISED CODE (NOW WORKS)
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

entity CLOCK_DIVIDER is
    port(
        reset   :   in std_logic;
        clk :   in std_logic;
        half_clk    :   out std_logic
        );
end CLOCK_DIVIDER;


architecture CLOCK_DIVIDER of CLOCK_DIVIDER is
signal tick : std_logic;

begin

    process(clk, reset)
    begin
        if reset = '1' then
            tick <= '0';
        elsif clk = '1' and clk'EVENT then
            if tick = '0' then
                tick <= '1';
            elsif tick = '1' then
                tick <= '0';
            end if;
        end if;
    end process;

    process(tick)
    begin
        half_clk <= tick;
    end process

end CLOCK_DIVIDER;

The synthesized logic block of the revised code is a single asynchronous-reset DFF that takes half_clk as output and inverted half_clk as input, which means the value of half_clk changes on every rising edge of clk.

Thanks, Will Dean 🙂

==== ==== ==== ==== ====

Original question below:

==== ==== ==== ==== ====

I need a simple clock divider (just divide-by-two) and instead of usinga template, I thought I’d try to write one myself to keep in training.

Unfortunately, the synthesized logic block does not appear to work – I present the logic block and the code (which I really think ought to work), in that order.

logic block http://img808.imageshack.us/img808/3333/unledly.png

What I’m really wondering is what the devil is up with the “tick” DFF – it apparently takes its input from the mux-selector which is… Yeah.

LIBRARY ieee;
USE ieee.std_logic_1164.ALL;

entity CLOCK_DIVIDER is
    port(
        reset   :   in std_logic;
        clk :   in std_logic;
        half_clk    :   out std_logic
        );
end CLOCK_DIVIDER;


architecture CLOCK_DIVIDER of CLOCK_DIVIDER is
signal tick : std_logic;

begin
    process(clk, reset)
    begin
        if reset = '1' then
            half_clk <= '0';
            tick <= '0';
        elsif clk = '1' and clk'EVENT then
            if tick = '0' then
                half_clk <= '0';
                tick <= '1';
            elsif tick = '1' then
                half_clk <= '1';
                tick <= '0';
            end if;
        end if;
    end process;
end CLOCK_DIVIDER;

I’m sure the error in the code is obvious but I’ve been staring myself blind trying to find it.

  • 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-05-23T02:54:33+00:00Added an answer on May 23, 2026 at 2:54 am

    Based on your revised code, I offer this modification to the architecture:

    -- REVISED CODE (NOW WORKS) and simplified and synthesisable
    architecture CLOCK_DIVIDER of CLOCK_DIVIDER is
        signal tick : std_logic;
    begin
        process(clk, reset)
        begin
            if reset = '1' then
                tick <= '0';
            elsif rising_edge(clk) then -- use of rising_edge() is the correct idiom these days
                tick <= not tick;
            end if;
        end process;
    
        half_clk <= tick;
    end CLOCK_DIVIDER;
    

    I’ve removed this process and replaced with a concurrent assignment:

        process(tick)
        begin
            half_clk <= tick;
        end process
    

    as what this is asking for is a flipflop clocked on both edges of tick.

    This will appear to achieve what you want in terms of the waveforms wiggling the way you want them to, but will not synthesise. It also adds an extra delta delay to the output which may or may not cause problems if you use it as a clock “down the road”. As others have commented, this is not a good plan anyway in most architectures (but for some it is “the right way”).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Issue solved, answered it below. Lame error. Blah So I upgraded to Django
If the major axis of the ellipse is vertical or horizontal, it's easy to
What are the major reasons for using WinDbg vs the Visual Studio debugger? And
Are there any major differences in performance between http and https? I seem to
One of the major advantages with Javascript is said to be that it is
For all major browsers (except IE), the JavaScript onload event doesn’t fire when the
With our next major release we are looking to globalize our ASP.Net application and
Is there a major difference between the Multiview control in ASP.NET 2.0 and the
I'm having major rendering issues in Safari with the web application I'm working on.
Do the major web application frameworks (Rails, Django, etc) have libraries that provide functionality

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.