Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: How to generate Global RESET signal in Verilog?

  1. #1
    Join Date
    Nov 2014
    Location
    Melaysia
    Posts
    18
    Rep Power
    1

    Question How to generate Global RESET signal in Verilog?

    Hi,
    I want to generate a active LOW global reset signal once FPGA device power up.
    I write my code like this:

    reg [9:0] reset_sync_n = 1'b0; //initialize the reset signal

    always @ (posedge CLK_50M) //Sync the reset signal to clock
    begin
    reset_sync_n <= 1'b1;
    end

    //reset_sync_n will be using as synchronous reset signal in others flip-flops logic like below:
    always @ (posedge ref_clk)
    begin
    if (rst)
    x <= 0;
    else
    x<= y;

    end

    My questions are:
    1. Can the reset_sync_n initialized like the above? Will a active LOW reset signal be generated once FPGA device power up?
    2. What is the right way to generate the RESET signal?
    3. Asynchronous reset is better or synchronous reset is better? Which one is the better coding practice?

    This is the doubts that always bother me. Please help me! Thank you!^^

  2. #2
    Join Date
    Oct 2008
    Location
    London
    Posts
    3,402
    Rep Power
    1

    Default Re: How to generate Global RESET signal in Verilog?

    1. Can the reset_sync_n initialized like the above? Will a active LOW reset signal be generated once FPGA device power up?
    I doubt it as your signal will likely be optimised and set high permanently.

    2. What is the right way to generate the RESET signal?
    external reset is recommended. Internally generated reset is not guaranteed though may work well.

    3. Asynchronous reset is better or synchronous reset is better? Which one is the better coding practice?
    Old story I am afraid. either way is ok. Altera recommends async (less resource). Xilinx recommends sync (but runs into timing problem). The choice is yours.

  3. #3
    Join Date
    Jul 2008
    Posts
    100
    Rep Power
    1

    Default Re: How to generate Global RESET signal in Verilog?

    You can use an external reset source and then synchronize it inside FPGA. As kaz said internal reset may be OK, but your design can not be put in a safe state when you need it to be.
    an external reset signal should pass through a reset synchronizer. There are many documents addressing this issue. Study the followings which discuss this topic in details and present reset synchronizer design & code as well:
    http://www.gstitt.ece.ufl.edu/course...2SJ_Resets.pdf
    http://www.sunburst-design.com/paper...ton_Resets.pdf
    Asynchronous or Synchronous Reset? AS kaz said, an old issue. My conclusion is this:
    Use asynchronous design technique in your codes. In the top level, design a reset synchronizer which generates a synchronous reset signal. Connect that synchronized reset signal to your modules. A reset synchronizer should reset asynchronously, and set synchronously.
    Last edited by msj; August 13th, 2016 at 12:41 AM.

  4. #4
    Join Date
    Nov 2014
    Location
    Melaysia
    Posts
    18
    Rep Power
    1

    Default Re: How to generate Global RESET signal in Verilog?

    Thanks kaz!^^

  5. #5
    Join Date
    Oct 2008
    Location
    Silicon Valley, USA
    Posts
    84
    Rep Power
    1

    Default Re: How to generate Global RESET signal in Verilog?

    This works too, I've used it for a long time with Altera Cyclone FPGAs. This code assumes CLOCK_50 is running at 50MHz.

    Code:
        // PowerUP Reset Logic
    
        // generate a 500ms reset pulse on initial powerup
    
        reg [24:0]         pup_count = 25'd0;
        reg         pup_reset = 1'b1;
    
        always @(posedge CLOCK_50)
            begin
            pup_count <= #TPD pup_count + 1'd1;
            if (pup_count == 25'd25000000) pup_reset <= #TPD 1'b0;
            end
    
        wire         reset = pup_reset;
    Then it gets used like this (where clk is the global PLL generated clock signal, derived from CLOCK_50) as an async reset:

    Code:
        always @(posedge clk or posedge reset)
        begin
        if (reset)
            begin
            run <= 1'b0;
            end
        else
            begin
            run <= mode_normal | mode_emul&stepemul | mode_fast&stepfast | mode_slow&stepslow;
            end
        end
    Last edited by ak6dn; August 16th, 2016 at 10:24 AM.

  6. #6
    Join Date
    Nov 2014
    Location
    Melaysia
    Posts
    18
    Rep Power
    1

    Default Re: How to generate Global RESET signal in Verilog?

    Thanks msj!!!^^

  7. #7
    Join Date
    Jun 2014
    Posts
    26
    Rep Power
    1

    Default Re: How to generate Global RESET signal in Verilog?

    Quote Originally Posted by ak6dn View Post
    This works too, I've used it for a long time with Altera Cyclone FPGAs. This code assumes CLOCK_50 is running at 50MHz.

    Code:
        // PowerUP Reset Logic
    
        // generate a 500ms reset pulse on initial powerup
    
        reg [24:0]         pup_count = 25'd0;
        reg         pup_reset = 1'b1;
    
        always @(posedge CLOCK_50)
            begin
            pup_count <= #TPD pup_count + 1'd1;
            if (pup_count == 25'd25000000) pup_reset <= #TPD 1'b0;
            end
    
        wire         reset = pup_reset;
    how exactly does this work? after pup_count saturates won't it wrap around to 25'd0 and then start incrementing again?

  8. #8
    Join Date
    Oct 2008
    Location
    Silicon Valley, USA
    Posts
    84
    Rep Power
    1

    Default Re: How to generate Global RESET signal in Verilog?

    Quote Originally Posted by Numinus1 View Post
    how exactly does this work? after pup_count saturates won't it wrap around to 25'd0 and then start incrementing again?
    Yes, but that does not matter. Once PUP_RESET gets set to zero it will stay at that value. The only way to set PUP_RESET to one is to powercycle the FPGA and/or reload the configuration file.

    So the fact that the counter just keeps on counting and wrapping (forever) is irrelevant.

  9. #9
    Join Date
    Jun 2014
    Posts
    26
    Rep Power
    1

    Default Re: How to generate Global RESET signal in Verilog?

    Quote Originally Posted by ak6dn View Post
    Yes, but that does not matter. Once PUP_RESET gets set to zero it will stay at that value. The only way to set PUP_RESET to one is to powercycle the FPGA and/or reload the configuration file.

    So the fact that the counter just keeps on counting and wrapping (forever) is irrelevant.
    Oh, right, I should have seen that myself. I have a follow-up question: why would you want to generate a reset signal on start? Is it just to specify certain values on start? I ask because I thought that was what initial blocks were for. If that assumption is correct, is there a practical difference between using an initial block and a on-start reset signal? Thanks for clearing up my doubts

  10. #10
    Join Date
    Oct 2008
    Location
    Silicon Valley, USA
    Posts
    84
    Rep Power
    1

    Default Re: How to generate Global RESET signal in Verilog?

    For the design this was used in there was a requirement that the logic be held in reset for at least 500ms at powerup for external hardware to completely stabliize. This was an easy way to accomplish this.

Similar Threads

  1. Using PLL "lock" signal as the async reset in Verilog
    By buddha1987 in forum Verilog and System Verilog
    Replies: 13
    Last Post: January 6th, 2017, 02:35 PM
  2. how to generate a reset signal in Altera Cyclone Ⅳ series?
    By you_you in forum General Altera Discussion
    Replies: 15
    Last Post: June 8th, 2016, 06:19 AM
  3. converting an ordinary signal to a global signal?
    By ingdxdy in forum FPGA, Hardcopy, and CPLD Discussion
    Replies: 2
    Last Post: December 20th, 2010, 06:07 AM
  4. How can I generate a reset signal?
    By RayChen in forum General Altera Discussion
    Replies: 5
    Last Post: September 15th, 2009, 04:49 AM
  5. may i use the global oe pin as the global reset pin?
    By simplorer in forum FPGA, Hardcopy, and CPLD Discussion
    Replies: 5
    Last Post: November 18th, 2008, 04:37 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •