From 50ba9de376a6227b956af41c0bc9b62703a6b391 Mon Sep 17 00:00:00 2001 From: Yvan Tortorella <48508508+yvantor@users.noreply.github.com> Date: Thu, 7 Mar 2024 10:40:36 +0100 Subject: [PATCH] registers: Add FFARNC macro (#214) Co-authored-by: Yvan Tortorella --- include/common_cells/registers.svh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/include/common_cells/registers.svh b/include/common_cells/registers.svh index f32ce2ef..1e43dfcc 100644 --- a/include/common_cells/registers.svh +++ b/include/common_cells/registers.svh @@ -224,6 +224,29 @@ end \ end +// Flip-Flop with asynchronous active-low reset and synchronous clear +// __q: Q output of FF +// __d: D input of FF +// __clear: assign reset value into FF +// __reset_value: value assigned upon reset +// __clk: clock input +// __arst_n: asynchronous reset, active-low +`define FFARNC(__q, __d, __clear, __reset_value, __clk, __arst_n) \ + `ifndef NO_SYNOPSYS_FF \ + /``* synopsys sync_set_reset `"__clear`" *``/ \ + `endif \ + always_ff @(posedge (__clk) or negedge (__arst_n)) begin \ + if (!__arst_n) begin \ + __q <= (__reset_value); \ + end else begin \ + if (__clear) begin \ + __q <= (__reset_value); \ + end begin \ + __q <= (__d); \ + end \ + end \ + end + // Load-enable Flip-Flop without reset // __q: Q output of FF // __d: D input of FF