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.

gating reset signal

YuanJin

Newbie
Newbie level 2
Joined
Jan 30, 2023
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
8
As the snippet of code shown above, I am wondering if it's a good practice to perform logic operation on rst signal. rst signal is a global reset signal. if not, how can i modify the code.


Code Verilog - [expand]
1
2
3
4
5
6
always @(posedge clk) begin
   counter <= counter + 1;
    if (rst or reload) begin
        counter <= load_value;
    end
end

 
Last edited by a moderator:

ThisIsNotSam

Advanced Member level 5
Advanced Member level 5
Joined
Apr 6, 2016
Messages
2,331
Helped
390
Reputation
780
Reaction score
418
Trophy points
83
Activity points
12,156
this is bad coding style. reset should not be treated as logic, it is a special signal after all. if you follow a traditional template for sequential logic you can avoid this:

Code:
always @(posedge clk) begin
  if (reset)
    counter <= load_value;
  else begin
    if (reload)
      counter <= load_value;
    else
      counter <= counter + 1;
  end
end
 

ads-ee

Super Moderator
Staff member
Advanced Member level 7
Joined
Sep 10, 2013
Messages
7,940
Helped
1,822
Reputation
3,654
Reaction score
1,807
Trophy points
1,393
Location
USA
Activity points
60,173
this is bad coding style. reset should not be treated as logic, it is a special signal after all. if you follow a traditional template for sequential logic you can avoid this:

Code:
always @(posedge clk) begin
  if (reset)
    counter <= load_value;
  else begin
    if (reload)
      counter <= load_value;
    else
      counter <= counter + 1;
  end
end
Unless load_value is a constant, this is only slightly better as reset is still being treated as a logic input (i.e. it is another load enable).

The reset should set the counter to a constant e.g.: (others => '0'), (others => '1'), or some constant value. Using a constant will ensure any dedicated reset resources will be used in the design and not merged into the general purpose logic cells.
 

FvM

Super Moderator
Staff member
Advanced Member level 7
Joined
Jan 22, 2008
Messages
51,003
Helped
14,633
Reputation
29,542
Reaction score
13,742
Trophy points
1,393
Location
Bochum, Germany
Activity points
291,794
For most FPGA families, an asynchronous global reset is available without consuming additional logic resources, not a synchronous reset as shown above.
 

ThisIsNotSam

Advanced Member level 5
Advanced Member level 5
Joined
Apr 6, 2016
Messages
2,331
Helped
390
Reputation
780
Reaction score
418
Trophy points
83
Activity points
12,156
Unless load_value is a constant, this is only slightly better as reset is still being treated as a logic input (i.e. it is another load enable).

The reset should set the counter to a constant e.g.: (others => '0'), (others => '1'), or some constant value. Using a constant will ensure any dedicated reset resources will be used in the design and not merged into the general purpose logic cells.
sure, load_value has to be a constant.
 

YuanJin

Newbie
Newbie level 2
Joined
Jan 30, 2023
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
8
this is bad coding style. reset should not be treated as logic, it is a special signal after all. if you follow a traditional template for sequential logic you can avoid this:

Code:
always @(posedge clk) begin
  if (reset)
    counter <= load_value;
  else begin
    if (reload)
      counter <= load_value;
    else
      counter <= counter + 1;
  end
end
Thanks for your answer. Now, I want to consider a similar circuit where I keep reload signal and remove reset signal. If the reload signal is a control signal generated by a FSM. Will it infer a FDRE with reset port connected to 0, while D is connected to a MUX with reload signal acting as a sel signal?

For most FPGA families, an asynchronous global reset is available without consuming additional logic resources, not a synchronous reset as shown above.
Does it mean I don't have to include piece of code dealing with reset signal in a sequential design if the default value of the register is 0?

Unless load_value is a constant, this is only slightly better as reset is still being treated as a logic input (i.e. it is another load enable).

The reset should set the counter to a constant e.g.: (others => '0'), (others => '1'), or some constant value. Using a constant will ensure any dedicated reset resources will be used in the design and not merged into the general purpose logic
Could you please explain why it would be beneficial if the load_value is a const value. How will the xilinx chip be configured in this case?
 

LaTeX Commands Quick-Menu:

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top