From a84172b23bce1429dedef1eb08fdb25393ba72b6 Mon Sep 17 00:00:00 2001 From: Andrew Zonenberg Date: Wed, 13 Sep 2017 10:58:41 -0700 Subject: Initial support for extraction of counters with clock enable --- techlibs/greenpak4/cells_map.v | 86 +++++++++++++++++++++++++++++++----------- 1 file changed, 65 insertions(+), 21 deletions(-) (limited to 'techlibs/greenpak4') diff --git a/techlibs/greenpak4/cells_map.v b/techlibs/greenpak4/cells_map.v index b0ec9fd3e..9897d4e35 100644 --- a/techlibs/greenpak4/cells_map.v +++ b/techlibs/greenpak4/cells_map.v @@ -161,8 +161,8 @@ module \$__COUNT_ (CE, CLK, OUT, POUT, RST, UP); parameter WIDTH = 8; parameter DIRECTION = "DOWN"; - //If we have a CE, or DIRECTION other than DOWN fail... GP_COUNTx_ADV is not supported yet - if(HAS_CE || (DIRECTION != "DOWN") ) begin + //If we have a DIRECTION other than DOWN fail... GP_COUNTx_ADV is not supported yet + if(DIRECTION != "DOWN") begin initial begin $display("ERROR: \$__COUNT_ support for GP_COUNTx_ADV is not yet implemented. This counter should never have been extracted (bug in extract_counter pass?)."); $finish; @@ -187,28 +187,72 @@ module \$__COUNT_ (CE, CLK, OUT, POUT, RST, UP); //Looks like a legal counter! Do something with it else if(WIDTH <= 8) begin - GP_COUNT8 #( - .COUNT_TO(COUNT_TO), - .RESET_MODE(RESET_MODE), - .CLKIN_DIVIDE(1) - ) _TECHMAP_REPLACE_ ( - .CLK(CLK), - .RST(RST), - .OUT(OUT), - .POUT(POUT) - ); + if(HAS_CE) begin + wire ce_not; + GP_INV ceinv( + .IN(CE), + .OUT(ce_not) + ); + GP_COUNT8_ADV #( + .COUNT_TO(COUNT_TO), + .RESET_MODE(RESET_MODE), + .RESET_VALUE("COUNT_TO"), + .CLKIN_DIVIDE(1) + ) _TECHMAP_REPLACE_ ( + .CLK(CLK), + .RST(RST), + .OUT(OUT), + .UP(1'b0), //always count down for now + .KEEP(ce_not), + .POUT(POUT) + ); + end + else begin + GP_COUNT8 #( + .COUNT_TO(COUNT_TO), + .RESET_MODE(RESET_MODE), + .CLKIN_DIVIDE(1) + ) _TECHMAP_REPLACE_ ( + .CLK(CLK), + .RST(RST), + .OUT(OUT), + .POUT(POUT) + ); + end end else begin - GP_COUNT14 #( - .COUNT_TO(COUNT_TO), - .RESET_MODE(RESET_MODE), - .CLKIN_DIVIDE(1) - ) _TECHMAP_REPLACE_ ( - .CLK(CLK), - .RST(RST), - .OUT(OUT) - ); + if(HAS_CE) begin + wire ce_not; + GP_INV ceinv( + .IN(CE), + .OUT(ce_not) + ); + GP_COUNT14_ADV #( + .COUNT_TO(COUNT_TO), + .RESET_MODE(RESET_MODE), + .RESET_VALUE("COUNT_TO"), + .CLKIN_DIVIDE(1) + ) _TECHMAP_REPLACE_ ( + .CLK(CLK), + .RST(RST), + .OUT(OUT), + .UP(1'b0), //always count down for now + .KEEP(ce_not), + .POUT(POUT) + ); + end + else begin + GP_COUNT14 #( + .COUNT_TO(COUNT_TO), + .RESET_MODE(RESET_MODE), + .CLKIN_DIVIDE(1) + ) _TECHMAP_REPLACE_ ( + .CLK(CLK), + .RST(RST), + .OUT(OUT) + ); + end end endmodule -- cgit v1.2.3