Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Async Reset Implementation -> Coding Styles

Status
Not open for further replies.

ivlsi

Advanced Member level 3
Joined
Feb 17, 2012
Messages
883
Helped
17
Reputation
32
Reaction score
16
Trophy points
1,298
Activity points
6,868
Hi All,

What's the difference in the following codes implementation (two pieces of code)?
Let's assume that the reset (rstn) happens only once... So, is there a difference in the code implementation/behavior?
Code:
----------------------------------------------------------------------
signal Q : std_logic := '0';
process (clk) is
  begin
      if rising_edge(clk) then  
         Q <= IN;
      end if;
   end process;
Code:
----------------------------------------------------------------------
 signal Q : std_logic;
process (clk,rstn) is
  begin
      if falling_edge(rstn) then  
         Q <= '0';
      elsif rising_edge(clk) then  
         Q <= IN;
      end if;
      end if;
   end process;

Thank you!
 
Last edited by a moderator:

The former case does not use a reset while the latter case uses an asynchronous reset.
 

Be aware that the first code snippet may cause differences between simulation and reality, since the initialization statement
Code:
signal Q : std_logic := '0';
will not be synthesized. This is a dangerous coding style which may easily cause bugs.
 

I don't understand the question. The first snippet has no reset action at all. Also the second code does not implement an asynchronous reset. Instead it has two edge sensitive conditions which aren't synthesizable in usual programmable logic hardware.

Contradicting maxbjurling, it should be noticed that most logic synthesis tool do synthesize initialization statements as power-on reset. But it's no exactly the same as an external reset input because you can't control its timing, it's e.g. not possible to release it synchronous to a clock.
 
  • Like
Reactions: ivlsi

    ivlsi

    Points: 2
    Helpful Answer Positive Rating
What you probably want for the first case is


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
process (clk) is
  begin
      if rising_edge(clk) then
        if rstn = '0' then
           Q <= '0';
        else   
          Q <= IN;
        end if;
     end if;
end process;



Also second case has two end ifs
 

What you probably want for the first case is


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
process (clk) is
  begin
      if rising_edge(clk) then
        if rstn = '0' then
           Q <= '0';
        else   
          Q <= IN;
        end if;
     end if;
end process;



Also second case has two end ifs

ivlsi, this code represents a synchronous reset, not an asynchronous reset, so that is a major difference.

The asynchronous version is written typically like this:

Code VHDL - [expand]
1
2
3
4
5
6
7
8
process (clk, rstn) is
  begin
      if rstn = '0' then
          Q <= '0';
      elsif rising_edge(clk) then
          Q <= IN;
      end if;
end process;



and behaves differently than the previous code posted by wesleytaylor.
 
  • Like
Reactions: ivlsi

    ivlsi

    Points: 2
    Helpful Answer Positive Rating
FvM, this may be true for FPGA tools but ASIC synthesis tools ignore initial assignments. And this thread is in the "ASIC Design Methodologies and Tools" section.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top