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
|
|
|
`ifdef RANDOMIZE
|
|
|
|
integer initvar;
|
|
|
|
reg [31:0] _RAND;
|
|
|
|
initial begin
|
2017-08-22 01:06:36 +02:00
|
|
|
`ifndef verilator
|
2017-08-21 23:33:19 +02:00
|
|
|
#0.002 begin end
|
2017-08-22 01:06:36 +02:00
|
|
|
`endif
|
|
|
|
`ifdef RANDOMIZE_REG_INIT
|
2017-08-21 23:33:19 +02:00
|
|
|
_RAND = {1{$random}};
|
|
|
|
q = _RAND[0];
|
2017-08-22 01:06:36 +02:00
|
|
|
`endif
|
2017-08-21 23:33:19 +02:00
|
|
|
end
|
|
|
|
`endif // `ifdef RANDOMIZE
|
|
|
|
|
2016-09-09 05:01:03 +02:00
|
|
|
always @(posedge clk or posedge rst) begin
|
2017-08-22 01:06:36 +02: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
|
|
|
|
|
|
|
|
endmodule // AsyncResetReg
|
|
|
|
|