2016-11-28 01:16:37 +01:00
|
|
|
// See LICENSE.SiFive for license details.
|
2016-09-09 05:01:03 +02:00
|
|
|
|
|
|
|
/** This black-boxes an Async Reset
|
|
|
|
* Reg.
|
|
|
|
*
|
|
|
|
* Because Chisel doesn't support
|
|
|
|
* parameterized black boxes,
|
|
|
|
* we unfortunately have to
|
|
|
|
* instantiate a number of these.
|
|
|
|
*
|
2016-09-16 22:50:09 +02:00
|
|
|
* We also have to hard-code the set/reset.
|
|
|
|
*
|
2016-09-09 05:01:03 +02:00
|
|
|
* Do not confuse an asynchronous
|
|
|
|
* reset signal with an asynchronously
|
|
|
|
* reset reg. You should still
|
|
|
|
* properly synchronize your reset
|
|
|
|
* deassertion.
|
|
|
|
*
|
|
|
|
* @param d Data input
|
|
|
|
* @param q Data Output
|
|
|
|
* @param clk Clock Input
|
|
|
|
* @param rst Reset Input
|
2016-09-16 22:50:09 +02:00
|
|
|
* @param en Write Enable Input
|
2016-09-09 05:01:03 +02:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2017-08-21 23:33:19 +02:00
|
|
|
`ifdef RANDOMIZE_GARBAGE_ASSIGN
|
|
|
|
`define RANDOMIZE
|
|
|
|
`endif
|
|
|
|
`ifdef RANDOMIZE_INVALID_ASSIGN
|
|
|
|
`define RANDOMIZE
|
|
|
|
`endif
|
|
|
|
`ifdef RANDOMIZE_REG_INIT
|
|
|
|
`define RANDOMIZE
|
|
|
|
`endif
|
|
|
|
`ifdef RANDOMIZE_MEM_INIT
|
|
|
|
`define RANDOMIZE
|
|
|
|
`endif
|
|
|
|
|
2016-09-09 05:01:03 +02:00
|
|
|
module AsyncResetReg (
|
|
|
|
input d,
|
|
|
|
output reg q,
|
2016-09-16 22:50:09 +02:00
|
|
|
input en,
|
2016-09-09 05:01:03 +02:00
|
|
|
|
|
|
|
input clk,
|
2016-09-16 22:50:09 +02:00
|
|
|
input rst);
|
|
|
|
|
2017-08-21 23:33:19 +02:00
|
|
|
initial begin
|
2017-12-02 02:43:01 +01:00
|
|
|
`ifdef RANDOMIZE
|
|
|
|
integer initvar;
|
|
|
|
reg [31:0] _RAND;
|
2017-08-21 23:33:19 +02:00
|
|
|
_RAND = {1{$random}};
|
2017-12-02 02:43:01 +01:00
|
|
|
`endif
|
|
|
|
if (rst) begin
|
|
|
|
`ifdef verilator
|
|
|
|
q = 1'b0;
|
|
|
|
`endif
|
|
|
|
end
|
|
|
|
`ifdef RANDOMIZE
|
|
|
|
`ifndef verilator
|
|
|
|
`endif
|
|
|
|
`ifdef RANDOMIZE_REG_INIT
|
|
|
|
else begin
|
|
|
|
#0.002 begin end
|
2017-09-20 23:47:00 +02:00
|
|
|
q = _RAND[0];
|
|
|
|
end
|
2017-12-02 02:43:01 +01:00
|
|
|
`endif
|
|
|
|
`endif // `ifdef RANDOMIZE
|
2017-08-21 23:33:19 +02:00
|
|
|
end
|
|
|
|
|
2016-09-09 05:01:03 +02:00
|
|
|
always @(posedge clk or posedge rst) begin
|
2017-12-02 02:43:01 +01:00
|
|
|
|
2016-09-09 05:01:03 +02:00
|
|
|
if (rst) begin
|
2016-09-16 22:50:09 +02:00
|
|
|
q <= 1'b0;
|
|
|
|
end else if (en) begin
|
2016-09-09 05:01:03 +02:00
|
|
|
q <= d;
|
|
|
|
end
|
|
|
|
end
|
2017-12-02 02:43:01 +01:00
|
|
|
|
2016-09-09 05:01:03 +02:00
|
|
|
endmodule // AsyncResetReg
|
|
|
|
|