Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
10 years ago

how to generate a reset signal in Altera Cyclone Ⅳ series?

Verilog:

 
 input reset;
 reg counting;
 
 always@(posedge clk or negedge reset)
  begin
   if(!reset)
    counting <= 11'd0;
  end

reset signal is connect to “M1” pin.

is it counting = 0 when FPGA board power on?

15 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    All initial states of variables in Altera FPGA devices after power up are set to 'zero' logic.

    --- Quote End ---

     input reset;
     reg counting;
     
     always@(posedge clk or negedge reset)
      begin
       if(!reset)
        counting <= 11'd1;
      end

    I found that it counting is equal to 1 after power up! why?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    but my question is Could "M1" pin will generate a falling edge when FPGA board power on?

    --- Quote End ---

    All initial states of variables in Altera FPGA devices after power up are set to 'zero' logic.
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    --- Quote Start ---

    Yes, but it will not increase and remains zero permanently.

    Try this:

    
        input reset;
        reg counting;
        reg r_reset_n;
        always@(posedge clk or negedge reset)
        begin
            if(!reset)
                begin
                    counting <= 11'd0;
                    r_reset_n <= 1'b0;
                end
            else
                if (counting <= 11'd1234)// replace 11'd1234 with required reset delay, based on clock frequency, in order to remove glitches.
                    begin
                        counting <= counting + 1'b1;
                        r_reset_n <= 1'b0;
                    end
                else
                    begin
                        counting <= 11'd2047;
                        r_reset_n <= 1'b1;
                    end
        end
    

    --- Quote End ---

    hello

    when there is a falling edge of reset signal,counting will equal to 0.

    but my question is Could "M1" pin will generate a falling edge when FPGA board power on?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    hello

    when there is a falling edge of reset signal,counting will equal to 0.

    but my question is Could "M1" pin will generate a falling edge when FPGA board power on?
  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    Yes, but it will not increase and remains zero permanently.

    Try this:

    
        input reset;
        reg counting;
        reg r_reset_n;
        always@(posedge clk or negedge reset)
        begin
            if(!reset)
                begin
                    counting <= 11'd0;
                    r_reset_n <= 1'b0;
                end
            else
                if (counting <= 11'd1234)// replace 11'd1234 with required reset delay, based on clock frequency, in order to remove glitches.
                    begin
                        counting <= counting + 1'b1;
                        r_reset_n <= 1'b0;
                    end
                else
                    begin
                        counting <= 11'd2047;
                        r_reset_n <= 1'b1;
                    end
        end