diff options
author | Clifford Wolf <clifford@clifford.at> | 2017-09-14 21:44:26 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-09-14 21:44:26 +0200 |
commit | 498526cc0beef5f3d5da88f91806eb043551a549 (patch) | |
tree | cc2058ad22272273765fec5b59fed41c1ba78fc0 /techlibs | |
parent | b0b2f3fe29e5937cd1948640e0bb5fc1338bcc6a (diff) | |
parent | 367d6b2194c6ba2b09b81b6cd2946702cb5ce895 (diff) | |
download | yosys-498526cc0beef5f3d5da88f91806eb043551a549.tar.gz yosys-498526cc0beef5f3d5da88f91806eb043551a549.tar.bz2 yosys-498526cc0beef5f3d5da88f91806eb043551a549.zip |
Merge pull request #411 from azonenberg/counter-extraction-fixes
Various improvements and bug fixes to extract_counter
Diffstat (limited to 'techlibs')
-rw-r--r-- | techlibs/greenpak4/cells_blackbox.v | 1 | ||||
-rw-r--r-- | techlibs/greenpak4/cells_map.v | 87 |
2 files changed, 67 insertions, 21 deletions
diff --git a/techlibs/greenpak4/cells_blackbox.v b/techlibs/greenpak4/cells_blackbox.v index 8dd38a027..1895b90de 100644 --- a/techlibs/greenpak4/cells_blackbox.v +++ b/techlibs/greenpak4/cells_blackbox.v @@ -9,6 +9,7 @@ module \$__COUNT_ (CE, CLK, OUT, POUT, RST, UP); parameter COUNT_TO = 1; parameter RESET_MODE = "RISING"; + parameter RESET_TO_MAX = "1"; parameter HAS_POUT = 0; parameter HAS_CE = 0; parameter WIDTH = 8; diff --git a/techlibs/greenpak4/cells_map.v b/techlibs/greenpak4/cells_map.v index b0ec9fd3e..b971a51fa 100644 --- a/techlibs/greenpak4/cells_map.v +++ b/techlibs/greenpak4/cells_map.v @@ -156,13 +156,14 @@ module \$__COUNT_ (CE, CLK, OUT, POUT, RST, UP); parameter COUNT_TO = 1; parameter RESET_MODE = "RISING"; + parameter RESET_TO_MAX = 0; parameter HAS_POUT = 0; parameter HAS_CE = 0; 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 +188,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(RESET_TO_MAX ? "COUNT_TO" : "ZERO"), + .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_TO_MAX ? "COUNT_TO" : "ZERO"), + .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 |