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

Status
Not open for further replies.

YuanJin

Newbie
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:

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
 

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.
 

For most FPGA families, an asynchronous global reset is available without consuming additional logic resources, not a synchronous reset as shown above.
 

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.
 

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?
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top