-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rstgen that cannot be bypassed (and doesn't need clock muxes) Signed-off-by: Nils Wistoff <[email protected]>
- Loading branch information
Showing
2 changed files
with
39 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Copyright 2018 ETH Zurich and University of Bologna. | ||
// Copyright and related rights are licensed under the Solderpad Hardware | ||
// License, Version 0.51 (the "License"); you may not use this file except in | ||
// compliance with the License. You may obtain a copy of the License at | ||
// http://solderpad.org/licenses/SHL-0.51. Unless required by applicable law | ||
// or agreed to in writing, software, hardware and materials distributed under | ||
// this License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR | ||
// CONDITIONS OF ANY KIND, either express or implied. See the License for the | ||
// specific language governing permissions and limitations under the License. | ||
|
||
// Nils Wistoff <[email protected]> | ||
|
||
module rstsync #( | ||
parameter int unsigned NumRegs = 4 | ||
) ( | ||
input logic clk_i, | ||
input logic rst_ni, | ||
output logic rst_no | ||
); | ||
logic [NumRegs-1:0] synch_regs_q; | ||
|
||
assign rst_no = synch_regs_q[NumRegs-1]; | ||
|
||
always @(posedge clk_i or negedge rst_ni) begin | ||
if (~rst_ni) begin | ||
synch_regs_q <= 0; | ||
end else begin | ||
synch_regs_q <= {synch_regs_q[NumRegs-2:0], 1'b1}; | ||
end | ||
end | ||
// pragma translate_off | ||
`ifndef VERILATOR | ||
initial begin : p_assertions | ||
if (NumRegs < 1) $fatal(1, "At least one register is required."); | ||
end | ||
`endif | ||
// pragma translate_on | ||
endmodule |