Karol Gugala | e814089 | 2022-03-30 13:43:15 +0200 | [diff] [blame] | 1 | // Copyright 2020-2022 F4PGA Authors |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 2 | // |
Karol Gugala | e814089 | 2022-03-30 13:43:15 +0200 | [diff] [blame] | 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 6 | // |
Karol Gugala | e814089 | 2022-03-30 13:43:15 +0200 | [diff] [blame] | 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | // |
| 15 | // SPDX-License-Identifier: Apache-2.0 |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 16 | |
rakeshm | 6eaaa3a | 2022-12-20 12:57:30 -0800 | [diff] [blame] | 17 | `timescale 1ps/1ps |
| 18 | |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 19 | `default_nettype none |
| 20 | |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 21 | (* abc9_flop, lib_whitebox *) |
| 22 | module sh_dff( |
| 23 | output reg Q, |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 24 | input wire D, |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 25 | (* clkbuf_sink *) |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 26 | input wire C |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 27 | ); |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 28 | |
Maciej Kurc | cbc6ed9 | 2022-06-13 14:59:14 +0200 | [diff] [blame] | 29 | initial Q <= 1'b0; |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 30 | always @(posedge C) |
Maciej Kurc | cbc6ed9 | 2022-06-13 14:59:14 +0200 | [diff] [blame] | 31 | Q <= D; |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 32 | |
| 33 | specify |
| 34 | (posedge C => (Q +: D)) = 0; |
| 35 | $setuphold(posedge C, D, 0, 0); |
| 36 | endspecify |
Maciej Kurc | cbc6ed9 | 2022-06-13 14:59:14 +0200 | [diff] [blame] | 37 | |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 38 | endmodule |
| 39 | |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 40 | (* abc9_box, lib_blackbox *) |
| 41 | module adder_carry( |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 42 | output wire sumout, |
| 43 | output wire cout, |
| 44 | input wire p, |
| 45 | input wire g, |
| 46 | input wire cin |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 47 | ); |
| 48 | assign sumout = p ^ cin; |
| 49 | assign cout = p ? cin : g; |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 50 | |
| 51 | specify |
| 52 | (p => sumout) = 0; |
| 53 | (g => sumout) = 0; |
| 54 | (cin => sumout) = 0; |
| 55 | (p => cout) = 0; |
| 56 | (g => cout) = 0; |
| 57 | (cin => cout) = 0; |
| 58 | endspecify |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 59 | |
| 60 | endmodule |
| 61 | |
Maciej Kurc | 0a3daaf | 2022-07-01 13:39:40 +0200 | [diff] [blame] | 62 | (* abc9_flop, lib_whitebox *) |
| 63 | module dff( |
| 64 | output reg Q, |
| 65 | input wire D, |
| 66 | (* clkbuf_sink *) |
| 67 | input wire C |
| 68 | ); |
| 69 | initial Q <= 1'b0; |
| 70 | |
| 71 | always @(posedge C) |
| 72 | Q <= D; |
| 73 | |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 74 | specify |
| 75 | (posedge C=>(Q+:D)) = 0; |
| 76 | $setuphold(posedge C, D, 0, 0); |
| 77 | endspecify |
| 78 | |
Maciej Kurc | 0a3daaf | 2022-07-01 13:39:40 +0200 | [diff] [blame] | 79 | endmodule |
| 80 | |
| 81 | (* abc9_flop, lib_whitebox *) |
| 82 | module dffn( |
| 83 | output reg Q, |
| 84 | input wire D, |
| 85 | (* clkbuf_sink *) |
| 86 | input wire C |
| 87 | ); |
| 88 | initial Q <= 1'b0; |
| 89 | |
| 90 | always @(negedge C) |
| 91 | Q <= D; |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 92 | |
| 93 | specify |
| 94 | (negedge C=>(Q+:D)) = 0; |
| 95 | $setuphold(negedge C, D, 0, 0); |
| 96 | endspecify |
Maciej Kurc | 0a3daaf | 2022-07-01 13:39:40 +0200 | [diff] [blame] | 97 | |
| 98 | endmodule |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 99 | |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 100 | (* abc9_flop, lib_whitebox *) |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 101 | module dffsre( |
| 102 | output reg Q, |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 103 | input wire D, |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 104 | (* clkbuf_sink *) |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 105 | input wire C, |
| 106 | input wire E, |
| 107 | input wire R, |
| 108 | input wire S |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 109 | ); |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 110 | initial Q <= 1'b0; |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 111 | |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 112 | always @(posedge C or negedge S or negedge R) |
| 113 | if (!R) |
| 114 | Q <= 1'b0; |
| 115 | else if (!S) |
| 116 | Q <= 1'b1; |
| 117 | else if (E) |
| 118 | Q <= D; |
| 119 | |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 120 | specify |
| 121 | (posedge C => (Q +: D)) = 0; |
| 122 | (R => Q) = 0; |
| 123 | (S => Q) = 0; |
| 124 | $setuphold(posedge C, D, 0, 0); |
| 125 | $setuphold(posedge C, E, 0, 0); |
| 126 | $setuphold(posedge C, R, 0, 0); |
| 127 | $setuphold(posedge C, S, 0, 0); |
| 128 | $recrem(posedge R, posedge C, 0, 0); |
| 129 | $recrem(posedge S, posedge C, 0, 0); |
| 130 | endspecify |
| 131 | |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 132 | endmodule |
| 133 | |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 134 | (* abc9_flop, lib_whitebox *) |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 135 | module dffnsre( |
| 136 | output reg Q, |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 137 | input wire D, |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 138 | (* clkbuf_sink *) |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 139 | input wire C, |
| 140 | input wire E, |
| 141 | input wire R, |
| 142 | input wire S |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 143 | ); |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 144 | initial Q <= 1'b0; |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 145 | |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 146 | always @(negedge C or negedge S or negedge R) |
| 147 | if (!R) |
| 148 | Q <= 1'b0; |
| 149 | else if (!S) |
| 150 | Q <= 1'b1; |
| 151 | else if (E) |
| 152 | Q <= D; |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 153 | |
| 154 | specify |
| 155 | (negedge C => (Q +: D)) = 0; |
| 156 | (R => Q) = 0; |
| 157 | (S => Q) = 0; |
| 158 | $setuphold(negedge C, D, 0, 0); |
| 159 | $setuphold(negedge C, E, 0, 0); |
| 160 | $setuphold(negedge C, R, 0, 0); |
| 161 | $setuphold(negedge C, S, 0, 0); |
| 162 | $recrem(posedge R, negedge C, 0, 0); |
| 163 | $recrem(posedge S, negedge C, 0, 0); |
| 164 | endspecify |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 165 | |
| 166 | endmodule |
| 167 | |
| 168 | (* abc9_flop, lib_whitebox *) |
| 169 | module sdffsre( |
| 170 | output reg Q, |
| 171 | input wire D, |
| 172 | (* clkbuf_sink *) |
| 173 | input wire C, |
| 174 | input wire E, |
| 175 | input wire R, |
| 176 | input wire S |
| 177 | ); |
| 178 | initial Q <= 1'b0; |
| 179 | |
| 180 | always @(posedge C) |
| 181 | if (!R) |
| 182 | Q <= 1'b0; |
| 183 | else if (!S) |
| 184 | Q <= 1'b1; |
| 185 | else if (E) |
| 186 | Q <= D; |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 187 | |
| 188 | specify |
| 189 | (posedge C => (Q +: D)) = 0; |
| 190 | $setuphold(posedge C, D, 0, 0); |
| 191 | $setuphold(posedge C, R, 0, 0); |
| 192 | $setuphold(posedge C, S, 0, 0); |
| 193 | $setuphold(posedge C, E, 0, 0); |
| 194 | endspecify |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 195 | |
| 196 | endmodule |
| 197 | |
| 198 | (* abc9_flop, lib_whitebox *) |
| 199 | module sdffnsre( |
| 200 | output reg Q, |
| 201 | input wire D, |
| 202 | (* clkbuf_sink *) |
| 203 | input wire C, |
| 204 | input wire E, |
| 205 | input wire R, |
| 206 | input wire S |
| 207 | ); |
| 208 | initial Q <= 1'b0; |
| 209 | |
| 210 | always @(negedge C) |
| 211 | if (!R) |
| 212 | Q <= 1'b0; |
| 213 | else if (!S) |
| 214 | Q <= 1'b1; |
| 215 | else if (E) |
| 216 | Q <= D; |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 217 | |
| 218 | specify |
| 219 | (negedge C => (Q +: D)) = 0; |
| 220 | $setuphold(negedge C, D, 0, 0); |
| 221 | $setuphold(negedge C, R, 0, 0); |
| 222 | $setuphold(negedge C, S, 0, 0); |
| 223 | $setuphold(negedge C, E, 0, 0); |
| 224 | endspecify |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 225 | |
| 226 | endmodule |
| 227 | |
| 228 | (* abc9_flop, lib_whitebox *) |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 229 | module latchsre ( |
| 230 | output reg Q, |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 231 | input wire S, |
| 232 | input wire R, |
| 233 | input wire D, |
| 234 | input wire G, |
| 235 | input wire E |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 236 | ); |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 237 | initial Q <= 1'b0; |
| 238 | |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 239 | always @* |
| 240 | begin |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 241 | if (!R) |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 242 | Q <= 1'b0; |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 243 | else if (!S) |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 244 | Q <= 1'b1; |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 245 | else if (E && G) |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 246 | Q <= D; |
| 247 | end |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 248 | |
| 249 | specify |
| 250 | (posedge G => (Q +: D)) = 0; |
| 251 | $setuphold(posedge G, D, 0, 0); |
| 252 | $setuphold(posedge G, E, 0, 0); |
| 253 | $setuphold(posedge G, R, 0, 0); |
| 254 | $setuphold(posedge G, S, 0, 0); |
| 255 | endspecify |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 256 | |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 257 | endmodule |
| 258 | |
| 259 | (* abc9_flop, lib_whitebox *) |
| 260 | module latchnsre ( |
| 261 | output reg Q, |
Paweł Czarnecki | 931a2f5 | 2022-04-14 14:01:33 +0200 | [diff] [blame] | 262 | input wire S, |
| 263 | input wire R, |
| 264 | input wire D, |
| 265 | input wire G, |
| 266 | input wire E |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 267 | ); |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 268 | initial Q <= 1'b0; |
| 269 | |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 270 | always @* |
| 271 | begin |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 272 | if (!R) |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 273 | Q <= 1'b0; |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 274 | else if (!S) |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 275 | Q <= 1'b1; |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 276 | else if (E && !G) |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 277 | Q <= D; |
| 278 | end |
rakeshm | 3611e4b | 2022-11-15 07:06:08 -0800 | [diff] [blame] | 279 | |
| 280 | specify |
| 281 | (negedge G => (Q +: D)) = 0; |
| 282 | $setuphold(negedge G, D, 0, 0); |
| 283 | $setuphold(negedge G, E, 0, 0); |
| 284 | $setuphold(negedge G, R, 0, 0); |
| 285 | $setuphold(negedge G, S, 0, 0); |
| 286 | endspecify |
Maciej Kurc | f4bb47e | 2022-06-07 11:44:48 +0200 | [diff] [blame] | 287 | |
Tarachand Pagarani | 3e6e399 | 2021-11-21 23:53:26 -0800 | [diff] [blame] | 288 | endmodule |
| 289 | |