nvrm_nc15gfh_16x32.v 76.2 KB
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528 1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577 1578 1579 1580 1581 1582 1583 1584 1585 1586 1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600 1601 1602 1603 1604 1605 1606 1607 1608 1609 1610 1611 1612 1613 1614 1615 1616 1617 1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791 1792 1793 1794 1795 1796 1797 1798 1799 1800 1801 1802 1803 1804 1805 1806 1807 1808 1809 1810 1811 1812 1813 1814 1815 1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831 1832 1833 1834 1835 1836 1837 1838 1839 1840 1841 1842 1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 1853 1854 1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866 1867 1868 1869 1870 1871 1872 1873 1874 1875 1876 1877 1878 1879 1880 1881 1882 1883 1884 1885 1886 1887 1888 1889 1890 1891 1892 1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912 1913 1914 1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970 1971 1972 1973 1974 1975 1976 1977 1978 1979 1980 1981 1982 1983 1984 1985 1986 1987 1988 1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 2002 2003 2004 2005 2006 2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 2017 2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 2030 2031 2032 2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457
//---------------------------------------------------------------------
//               Copyright(c) Virage Logic Corporation.                
//     All Rights reserved - Unpublished -rights reserved under        
//     the Copyright laws of the United States of America.             
//                                                                     
//  This file includes the Confidential information of Virage Logic    
//  and NEC                                                            
//  The receiver of this Confidential Information shall not disclose   
//  it to any third party and shall protect its confidentiality by     
//  using the same degree of care, but not less then a reasonable      
//  degree of care, as the receiver uses to protect receiver's own     
//  Confidential Information.                                          
//                                                                     
//                    Virage Logic Corporation.                        
//                    47100 Bayside Pkwy                               
//                    Fremont , California 94538.                      
//                                                                     
//---------------------------------------------------------------------
//                                                                     
//  Software           : Rev: 3.2.2 (build REL-3-2-2-2002-12-13)       
//  Library Format     : Rev: 1.05.00                                  
//  Compiler Name      : nc15upfp1p11nonrm16sa                         
//  Date of Generation : Tue Jan 28 19:11:57 PST 2003                  
//                                                                     
//---------------------------------------------------------------------

//   --------------------------------------------------------------     
//                       Template Revision : 1.0.6                      
//   --------------------------------------------------------------     



//                * Synchronous, 1-Port Non Volatile RAM *            
//                      * Verilog Behavioral Model *                  
//                THIS IS A SYNCHRONOUS 1-PORT MEMORY MODEL           
//                                                                    
//   Memory Name:nvrm_nc15gfh_16x32                                   
//   Memory Size:16 words x 32 bits                                   
//                                                                    
//                               PORT NAME                            
//                               ---------                            
//               Output Ports                                         
//                                   Q[31:0]                          
//                                   SO                               
//                                   MATCH                            
//                                   RCREADY                          
//               Input Ports:                                         
//                                   ADR[3:0]                         
//                                   D[31:0]                          
//                                   WE                               
//                                   ME                               
//                                   OE                               
//                                   CLK                              
//                                   SI                               
//                                   SCLK                             
//                                   SME                              
//                                   COMP                             
//                                   STORE                            
//                                   RECALL                           
//                                   VPP                              
//                                   MRCL0                            
//                                   MRCL1                            
//                                   TECC0                            
//                                   TECC1                            
//                                   BIAS0                            
//                                   BIAS1                            
//                                   PU1                              
//                                   PU2                              
//                                   PU3                              



`resetall 

`timescale 1 ns / 10 ps 
`celldefine 

`define True    1'b1
`define False   1'b0

module nvrm_nc15gfh_16x32 ( Q31, Q30, Q29, Q28, Q27, Q26, Q25, Q24, Q23, Q22, Q21, Q20, Q19, Q18, Q17, Q16, Q15, Q14, Q13, Q12, Q11, Q10, Q9, Q8, Q7 , Q6, Q5, Q4, Q3, Q2, Q1, Q0, SO, MATCH, ADR3, ADR2, ADR1, ADR0, D31, D30, D29, D28, D27, D26, D25, D24, D23, D22, D21, D20, D19, D18, D17, D16, D15, D14, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0, WE, ME, OE, CLK, SI, SCLK, SME, COMP, STORE, RECALL, VPP, MRCL0, MRCL1, TECC0, TECC1, BIAS0, BIAS1, RCREADY, PU1, PU2, PU3);

output Q31;
output Q30;
output Q29;
output Q28;
output Q27;
output Q26;
output Q25;
output Q24;
output Q23;
output Q22;
output Q21;
output Q20;
output Q19;
output Q18;
output Q17;
output Q16;
output Q15;
output Q14;
output Q13;
output Q12;
output Q11;
output Q10;
output Q9;
output Q8;
output Q7;
output Q6;
output Q5;
output Q4;
output Q3;
output Q2;
output Q1;
output Q0;
output SO;
output MATCH;
input ADR3;
input ADR2;
input ADR1;
input ADR0;
input D31;
input D30;
input D29;
input D28;
input D27;
input D26;
input D25;
input D24;
input D23;
input D22;
input D21;
input D20;
input D19;
input D18;
input D17;
input D16;
input D15;
input D14;
input D13;
input D12;
input D11;
input D10;
input D9;
input D8;
input D7;
input D6;
input D5;
input D4;
input D3;
input D2;
input D1;
input D0;
input WE;
input ME;
input OE;
input CLK;
input SI;
input SCLK;
input SME;
input COMP;
input STORE;
input RECALL;
input VPP;
input MRCL0;
input MRCL1;
input TECC0;
input TECC1;
input BIAS0;
input BIAS1;
output RCREADY;
input PU1;
input PU2;
input PU3;

wire   [31:0] Q;
wire   [31:0] D;
wire    [3:0] ADR;
assign {Q31, Q30, Q29, Q28, Q27, Q26, Q25, Q24, Q23, Q22, Q21, Q20, Q19, Q18, Q17, Q16, Q15, Q14, Q13, Q12, Q11, Q10, Q9, Q8, Q7 , Q6, Q5, Q4 , Q3, Q2, Q1, Q0} = Q;
assign  D = {D31, D30, D29, D28, D27, D26, D25, D24, D23, D22, D21, D20, D19, D18, D17, D16, D15, D14, D13, D12, D11, D10, D9, D8, D7, D6, D5, D4, D3, D2, D1, D0};
assign ADR = {ADR3, ADR2, ADR1, ADR0} ;


`ifdef MEM_CHECK_OFF
parameter MES_ALL = "OFF";
`else
parameter MES_ALL = "ON";
`endif


// Local registers, wires, etc


reg notif_adr; 
reg notif_d; 
reg notif_we; 
reg notif_me; 
reg notif_clk; 
reg notif_clk_COMP_rise_rec;
reg notif_clk_SCLK_rise_rec;
reg notif_clk_RECALL_rise_rec;
reg notif_clk_STORE_rise_rec;
reg notif_si; 
reg notif_sclk; 
reg notif_sclk_COMP_rise_rec;
reg notif_sclk_CLK_rise_rec;
reg notif_sclk_RECALL_rise_rec;
reg notif_sclk_STORE_rise_rec;
reg notif_sme; 
reg notif_comp; 
reg notif_comp_RECALL_rise_rec;
reg notif_comp_STORE_rise_rec;
reg notif_comp_SCLK_rise_rec;
reg notif_comp_CLK_rise_rec;
reg notif_store; 
reg notif_store_RECALL_rise_rec;
reg notif_store_VPP_rise_rec;
reg notif_store_COMP_rise_rec;
reg notif_store_SCLK_rise_rec;
reg notif_store_CLK_rise_rec;
reg notif_recall; 
reg notif_recall_STORE_rise_rec;
reg notif_recall_COMP_rise_rec;
reg notif_recall_SCLK_rise_rec;
reg notif_recall_CLK_rise_rec;
reg notif_vpp; 
reg notif_vpp_STORE_fall_rec;
reg notif_mrcl0; 
reg notif_mrcl1; 
reg notif_tecc0; 
reg notif_tecc1; 
reg notif_bias0; 
reg notif_bias1; 
reg ADRFLAGA;
wire CHKENWE;
wire CHKENCLK;
wire CHKENSCLK;
wire CHKENSI;
wire CHKENCLKSCLK;
wire CHKENSCLKCLK;
wire CHKENME;
wire CHKENADR;
wire CHKEND;
wire CHKEN;
wire CHKEN6A;
wire CHKEN7A;
wire CHKEN10A;
wire CHKEN11A;
wire CHKEN12A;
wire CHKEN13A;
wire CHKEN14A;
reg SMElatched;
reg chk_tmp0;
reg chk_tp0;
wire OE_eff;
buf  #0.01 (OE_eff_delay , OE_eff);


reg [3:0] ADRlatched;
reg [31:0] Dlatched;
reg WElatched;
reg MElatched;

wire [31:0] Q_buf;
bufif1 (Q[0], Q_buf[0], OE_eff_delay );
bufif1 (Q[1], Q_buf[1], OE_eff_delay );
bufif1 (Q[2], Q_buf[2], OE_eff_delay );
bufif1 (Q[3], Q_buf[3], OE_eff_delay );
bufif1 (Q[4], Q_buf[4], OE_eff_delay );
bufif1 (Q[5], Q_buf[5], OE_eff_delay );
bufif1 (Q[6], Q_buf[6], OE_eff_delay );
bufif1 (Q[7], Q_buf[7], OE_eff_delay );
bufif1 (Q[8], Q_buf[8], OE_eff_delay );
bufif1 (Q[9], Q_buf[9], OE_eff_delay );
bufif1 (Q[10], Q_buf[10], OE_eff_delay );
bufif1 (Q[11], Q_buf[11], OE_eff_delay );
bufif1 (Q[12], Q_buf[12], OE_eff_delay );
bufif1 (Q[13], Q_buf[13], OE_eff_delay );
bufif1 (Q[14], Q_buf[14], OE_eff_delay );
bufif1 (Q[15], Q_buf[15], OE_eff_delay );
bufif1 (Q[16], Q_buf[16], OE_eff_delay );
bufif1 (Q[17], Q_buf[17], OE_eff_delay );
bufif1 (Q[18], Q_buf[18], OE_eff_delay );
bufif1 (Q[19], Q_buf[19], OE_eff_delay );
bufif1 (Q[20], Q_buf[20], OE_eff_delay );
bufif1 (Q[21], Q_buf[21], OE_eff_delay );
bufif1 (Q[22], Q_buf[22], OE_eff_delay );
bufif1 (Q[23], Q_buf[23], OE_eff_delay );
bufif1 (Q[24], Q_buf[24], OE_eff_delay );
bufif1 (Q[25], Q_buf[25], OE_eff_delay );
bufif1 (Q[26], Q_buf[26], OE_eff_delay );
bufif1 (Q[27], Q_buf[27], OE_eff_delay );
bufif1 (Q[28], Q_buf[28], OE_eff_delay );
bufif1 (Q[29], Q_buf[29], OE_eff_delay );
bufif1 (Q[30], Q_buf[30], OE_eff_delay );
bufif1 (Q[31], Q_buf[31], OE_eff_delay );
buf (SO, SO_buf);
buf (MATCH, MATCH_buf);
wire [3:0] ADR_buf;
buf (ADR_buf[0], ADR[0]);
buf (ADR_buf[1], ADR[1]);
buf (ADR_buf[2], ADR[2]);
buf (ADR_buf[3], ADR[3]);
wire [31:0] D_buf;
buf (D_buf[0], D[0]);
buf (D_buf[1], D[1]);
buf (D_buf[2], D[2]);
buf (D_buf[3], D[3]);
buf (D_buf[4], D[4]);
buf (D_buf[5], D[5]);
buf (D_buf[6], D[6]);
buf (D_buf[7], D[7]);
buf (D_buf[8], D[8]);
buf (D_buf[9], D[9]);
buf (D_buf[10], D[10]);
buf (D_buf[11], D[11]);
buf (D_buf[12], D[12]);
buf (D_buf[13], D[13]);
buf (D_buf[14], D[14]);
buf (D_buf[15], D[15]);
buf (D_buf[16], D[16]);
buf (D_buf[17], D[17]);
buf (D_buf[18], D[18]);
buf (D_buf[19], D[19]);
buf (D_buf[20], D[20]);
buf (D_buf[21], D[21]);
buf (D_buf[22], D[22]);
buf (D_buf[23], D[23]);
buf (D_buf[24], D[24]);
buf (D_buf[25], D[25]);
buf (D_buf[26], D[26]);
buf (D_buf[27], D[27]);
buf (D_buf[28], D[28]);
buf (D_buf[29], D[29]);
buf (D_buf[30], D[30]);
buf (D_buf[31], D[31]);
buf (WE_buf, WE);
buf (ME_buf, ME);
buf (OE_buf, OE);
buf (CLK_buf, CLK);
buf (SI_buf, SI);
buf (SCLK_buf, SCLK);
buf (SME_buf, SME);
buf (COMP_buf, COMP);
buf (STORE_buf, STORE);
buf (RECALL_buf, RECALL);
buf (VPP_buf, VPP);
buf (MRCL0_buf, MRCL0);
buf (MRCL1_buf, MRCL1);
buf (TECC0_buf, TECC0);
buf (TECC1_buf, TECC1);
buf (BIAS0_buf, BIAS0);
buf (BIAS1_buf, BIAS1);
buf (RCREADY, RCREADY_buf);
buf (PU1_buf, PU1);
buf (PU2_buf, PU2);
buf (PU3_buf, PU3);

// Disable recovery checks for initial 10 ns
reg init_time;
initial begin
 init_time = 0;
 // #10 init_time = 1;
 #64 init_time = 1;
end

wire enable_recovery_checks;
assign enable_recovery_checks = init_time;

wire enable_setuphold_checks;
assign enable_setuphold_checks = init_time;

real tstore;
real store_rise_time;
initial
begin
`ifdef VIRAGE_FAST
  tstore = 500000.00;
`else
  tstore = 10000000.00;
`endif
end
always @(posedge STORE_buf)
  store_rise_time = $realtime;
always @(negedge STORE_buf)
begin
 if ( enable_recovery_checks ) begin
  if( ($realtime - store_rise_time) < tstore )
  begin
    if (!$test$plusargs("notimingchecks") && !$test$plusargs("delay_mode_zero") && !$test$plusargs("delay_mode_unit"))
    begin
      $display("Warning! Timing violation on STORE(Tstore)");
      $display("      time=%t; instance=%m (NVM1H)",$realtime);
      if (notif_store === 1'bx && $time > 0 )
        notif_store = 1'b0;
      else
        notif_store = ~notif_store;
    end
  end
 end
end

real tvpp;
real vpp_rise_time;
initial
begin
`ifdef VIRAGE_FAST
  tvpp = 400000.00;
`else
  tvpp = 8000000.00;
`endif
end
always @(posedge VPP_buf)
  vpp_rise_time = $realtime;
always @(negedge VPP_buf)
begin
 if ( enable_recovery_checks ) begin
  if( ($realtime - vpp_rise_time) < tvpp )
  begin
    if (!$test$plusargs("notimingchecks") && !$test$plusargs("delay_mode_zero") && !$test$plusargs("delay_mode_unit"))
    begin
      $display("Warning! Timing violation on VPP(Tvpp)");
      $display("      time=%t; instance=%m (NVM1H)",$realtime);
      if (notif_vpp === 1'bx && $time > 0 )
        notif_vpp = 1'b0;
      else
        notif_vpp = ~notif_vpp;
    end
  end
 end
end




and u_chk_enable_sclk ( CHKENSCLK, SME_buf, enable_recovery_checks);
buf u_CHKENSI ( CHKENSI, SME_buf);
and u_chk_enableclksclk ( CHKENCLKSCLK, MElatched,SME_buf);
and u_chk_enablesclkclk ( CHKENSCLKCLK, SME_buf,ME_buf);
and u_CHKENWE_0 ( CHKENWE, ME_buf, ADRFLAGA);
and u_chk_enable_clk ( CHKENCLK, ME_buf, enable_recovery_checks);
and u_CHKEND_0 ( CHKEND, ME_buf, ADRFLAGA, WE_buf);
buf u_CHKENADR_0 ( CHKENADR, ME_buf );

buf u_CHKENME_0 ( CHKENME, ADRFLAGA );

and u_CHKEN10A_0 ( CHKEN10A, !ME_buf, !SME_buf, !STORE_buf,  !VPP_buf, !RECALL_buf );
and u_CHKEN11A_0 ( CHKEN11A, !ME_buf, !SME_buf, VPP_buf, !COMP_buf, !RECALL_buf );
and u_CHKEN12A_0 ( CHKEN12A, !WE_buf, !SME_buf, !STORE_buf, !VPP_buf, !COMP_buf );
and u_CHKEN13A_0 ( CHKEN13A, SME_buf, !STORE_buf, !VPP_buf, !COMP_buf );
and u_CHKEN14A_0 ( CHKEN14A, !STORE_buf, !VPP_buf, !COMP_buf );

specify
 
    specparam PATHPULSE$OE$Q = ( 0, 0.01 );
    specparam PATHPULSE$RECALL$RCREADY = ( 0, 0.01 );
    specparam PATHPULSE$COMP$RCREADY = ( 0, 0.01 );
    specparam

`ifdef VIRAGE_FAST
        Tac = 1.48,
        Tcax = 1.00,
        Tdc = 1.48,
        Tcdx = 1.00,
        Twc = 1.48,
        Tcwx = 1.00,
        Tmc = 1.48,
        Tcmx = 1.00,
        Tcc = 7.88,
        Tcl = 2.08,
        Tch = 2.08,
        Tdcs = 6.24,
        Tcdxs = 1.00,
        Tccs = 88.33,
        Tcls = 5.20,
        Tchs = 5.20,
        Tmcs = 6.24,
        Tcmxs = 2.77,
        Trcomp = 125.05,
        Tcomp = 1063.46,
        Trstore = 47548.39,
        Txvpp = 20498.81,
        Tstore = 500000.00,
        Trrecall = 125.05,
        Trecall = 1063.46,
        Trvpp = 9021.76,
        Tvpp = 400000.00,
        Tscomp = 442.52,
        Thcomp = 35.40,
        Tcq = 6.22,
        Tcqx = 0.35,
        Toq = 1.79,
        Toqz = 1.22,
        Tcqs = 88.33,
        Tcqxs = 0.26,
        Tcso = 4.98,
        Tcsox = 0.35,
        Tcmatch = 1063.20,
        Txmatch = 1.77,
        Trcrdy = 1063.46,
        Txrcrdy = 3.54;
`else
        Tac = 1.48,
        Tcax = 1.00,
        Tdc = 1.48,
        Tcdx = 1.00,
        Twc = 1.48,
        Tcwx = 1.00,
        Tmc = 1.48,
        Tcmx = 1.00,
        Tcc = 7.88,
        Tcl = 2.08,
        Tch = 2.08,
        Tdcs = 6.24,
        Tcdxs = 1.00,
        Tccs = 88.33,
        Tcls = 5.20,
        Tchs = 5.20,
        Tmcs = 6.24,
        Tcmxs = 2.77,
        Trcomp = 2500.97,
        Tcomp = 21269.25,
        Trstore = 950967.74,
        Txvpp = 409976.11,
        Tstore = 10000000.00,
        Trrecall = 2500.97,
        Trecall = 21269.25,
        Trvpp = 180435.17,
        Tvpp = 8000000.00,
        Tscomp = 8850.46,
        Thcomp = 35.40,
        Tcq = 6.22,
        Tcqx = 0.35,
        Toq = 1.79,
        Toqz = 1.22,
        Tcqs = 88.33,
        Tcqxs = 0.26,
        Tcso = 4.98,
        Tcsox = 0.35,
        Tcmatch = 21263.94,
        Txmatch = 1.77,
        Trcrdy = 21269.25,
        Txrcrdy = 3.54;
`endif

     if ( OE )
       ( posedge CLK => (  Q[0]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[1]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[2]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[3]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[4]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[5]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[6]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[7]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[8]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[9]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[10]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[11]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[12]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[13]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[14]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[15]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[16]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[17]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[18]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[19]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[20]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[21]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[22]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[23]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[24]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[25]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[26]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[27]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[28]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[29]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[30]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
     if ( OE )
       ( posedge CLK => (  Q[31]  : 1'bx )) = (  Tcq, Tcq, Tcqx, Tcq, Tcqx, Tcq );
       ( OE => ( Q[0]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[1]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[2]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[3]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[4]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[5]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[6]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[7]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[8]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[9]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[10]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[11]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[12]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[13]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[14]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[15]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[16]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[17]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[18]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[19]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[20]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[21]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[22]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[23]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[24]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[25]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[26]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[27]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[28]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[29]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[30]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
       ( OE => ( Q[31]  : 1'bx )) = (  Toq, Toq, Toqz, Toq, Toqz, Toq );
     if ( SME  )
       ( posedge SCLK => (  SO  : 1'bx )) = (  Tcqs, Tcqs, Tcqxs, Tcqs, Tcqxs, Tcqs );
       ( posedge CLK => (  SO  : 1'bx )) = (  Tcso, Tcso, Tcsox, Tcso, Tcsox, Tcso );
       ( COMP =>  MATCH ) = (  Tcmatch, Txmatch );
       ( COMP =>  RCREADY ) = (  Trcrdy, Txrcrdy );
       ( RECALL =>  RCREADY ) = (  Trcrdy, Txrcrdy );
// Timing Checks
    $width (negedge CLK, Tcl, 0, notif_clk);
    $width (posedge CLK, Tch, 0, notif_clk);
    $period (posedge CLK, Tcc, notif_clk);
    $period (negedge CLK, Tcc, notif_clk);
    $width (negedge SCLK, Tcls, 0, notif_sclk);
    $width (posedge SCLK, Tchs, 0, notif_sclk);
    $period (posedge SCLK, Tccs, notif_sclk);
    $period (negedge SCLK, Tccs, notif_sclk);
    $width (posedge COMP, Tcomp, 0, notif_comp);
    $width (posedge RECALL, Trecall, 0, notif_recall);
`ifdef SETUP_HOLD_CHECKS
    $hold (posedge CLK  &&& CHKENADR, posedge ADR[0], Tcax, notif_adr );
    $hold (posedge CLK  &&& CHKENADR, negedge ADR[0], Tcax, notif_adr );
    $hold (posedge CLK  &&& CHKENADR, posedge ADR[1], Tcax, notif_adr );
    $hold (posedge CLK  &&& CHKENADR, negedge ADR[1], Tcax, notif_adr );
    $hold (posedge CLK  &&& CHKENADR, posedge ADR[2], Tcax, notif_adr );
    $hold (posedge CLK  &&& CHKENADR, negedge ADR[2], Tcax, notif_adr );
    $hold (posedge CLK  &&& CHKENADR, posedge ADR[3], Tcax, notif_adr );
    $hold (posedge CLK  &&& CHKENADR, negedge ADR[3], Tcax, notif_adr );
    $setup ( posedge ADR[0],posedge CLK  &&& CHKENADR, Tac, notif_adr );
    $setup ( negedge ADR[0],posedge CLK  &&& CHKENADR, Tac, notif_adr );
    $setup ( posedge ADR[1],posedge CLK  &&& CHKENADR, Tac, notif_adr );
    $setup ( negedge ADR[1],posedge CLK  &&& CHKENADR, Tac, notif_adr );
    $setup ( posedge ADR[2],posedge CLK  &&& CHKENADR, Tac, notif_adr );
    $setup ( negedge ADR[2],posedge CLK  &&& CHKENADR, Tac, notif_adr );
    $setup ( posedge ADR[3],posedge CLK  &&& CHKENADR, Tac, notif_adr );
    $setup ( negedge ADR[3],posedge CLK  &&& CHKENADR, Tac, notif_adr );
    $hold (posedge CLK  &&& CHKEND, posedge D[0], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[0], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[1], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[1], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[2], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[2], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[3], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[3], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[4], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[4], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[5], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[5], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[6], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[6], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[7], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[7], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[8], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[8], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[9], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[9], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[10], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[10], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[11], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[11], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[12], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[12], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[13], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[13], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[14], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[14], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[15], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[15], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[16], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[16], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[17], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[17], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[18], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[18], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[19], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[19], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[20], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[20], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[21], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[21], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[22], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[22], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[23], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[23], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[24], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[24], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[25], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[25], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[26], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[26], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[27], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[27], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[28], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[28], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[29], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[29], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[30], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[30], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, posedge D[31], Tcdx, notif_d );
    $hold (posedge CLK  &&& CHKEND, negedge D[31], Tcdx, notif_d );
    $setup ( posedge D[0],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[0],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[1],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[1],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[2],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[2],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[3],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[3],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[4],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[4],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[5],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[5],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[6],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[6],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[7],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[7],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[8],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[8],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[9],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[9],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[10],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[10],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[11],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[11],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[12],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[12],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[13],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[13],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[14],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[14],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[15],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[15],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[16],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[16],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[17],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[17],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[18],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[18],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[19],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[19],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[20],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[20],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[21],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[21],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[22],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[22],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[23],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[23],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[24],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[24],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[25],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[25],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[26],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[26],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[27],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[27],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[28],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[28],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[29],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[29],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[30],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[30],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( posedge D[31],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $setup ( negedge D[31],posedge CLK  &&& CHKEND, Tdc, notif_d );
    $hold (posedge CLK  &&& CHKENWE, posedge WE, Tcwx, notif_we );
    $hold (posedge CLK  &&& CHKENWE, negedge WE, Tcwx, notif_we );
    $setup ( posedge WE,posedge CLK  &&& CHKENWE, Twc, notif_we );
    $setup ( negedge WE,posedge CLK  &&& CHKENWE, Twc, notif_we );
    $hold (posedge CLK  &&& CHKENME, posedge ME, Tcmx, notif_me );
    $hold (posedge CLK  &&& CHKENME, negedge ME, Tcmx, notif_me );
    $setup ( posedge ME,posedge CLK  &&& CHKENME, Tmc, notif_me );
    $setup ( negedge ME,posedge CLK  &&& CHKENME, Tmc, notif_me );
    $hold (posedge SCLK  &&& CHKENSI, posedge SI, Tcdxs, notif_si );
    $hold (posedge SCLK  &&& CHKENSI, negedge SI, Tcdxs, notif_si );
    $setup ( posedge SI,posedge SCLK  &&& CHKENSI, Tdcs, notif_si );
    $setup ( negedge SI,posedge SCLK  &&& CHKENSI, Tdcs, notif_si );
    $hold (posedge SCLK , posedge SME, Tcmxs, notif_sme );
    $hold (posedge SCLK , negedge SME, Tcmxs, notif_sme );
    $setup ( posedge SME,posedge SCLK , Tmcs, notif_sme );
    $setup ( negedge SME,posedge SCLK , Tmcs, notif_sme );
`endif
    $hold (negedge COMP  &&& enable_setuphold_checks, posedge MRCL0, Thcomp, notif_mrcl0 );
    $hold (negedge COMP  &&& enable_setuphold_checks, negedge MRCL0, Thcomp, notif_mrcl0 );
    $setup ( posedge MRCL0,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_mrcl0 );
    $setup ( negedge MRCL0,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_mrcl0 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, posedge MRCL0, Thcomp, notif_mrcl0 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, negedge MRCL0, Thcomp, notif_mrcl0 );
    $setup ( posedge MRCL0,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_mrcl0 );
    $setup ( negedge MRCL0,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_mrcl0 );
    $hold (negedge COMP  &&& enable_setuphold_checks, posedge MRCL1, Thcomp, notif_mrcl1 );
    $hold (negedge COMP  &&& enable_setuphold_checks, negedge MRCL1, Thcomp, notif_mrcl1 );
    $setup ( posedge MRCL1,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_mrcl1 );
    $setup ( negedge MRCL1,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_mrcl1 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, posedge MRCL1, Thcomp, notif_mrcl1 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, negedge MRCL1, Thcomp, notif_mrcl1 );
    $setup ( posedge MRCL1,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_mrcl1 );
    $setup ( negedge MRCL1,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_mrcl1 );
    $hold (negedge COMP  &&& enable_setuphold_checks, posedge TECC0, Thcomp, notif_tecc0 );
    $hold (negedge COMP  &&& enable_setuphold_checks, negedge TECC0, Thcomp, notif_tecc0 );
    $setup ( posedge TECC0,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_tecc0 );
    $setup ( negedge TECC0,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_tecc0 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, posedge TECC0, Thcomp, notif_tecc0 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, negedge TECC0, Thcomp, notif_tecc0 );
    $setup ( posedge TECC0,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_tecc0 );
    $setup ( negedge TECC0,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_tecc0 );
    $hold (negedge COMP  &&& enable_setuphold_checks, posedge TECC1, Thcomp, notif_tecc1 );
    $hold (negedge COMP  &&& enable_setuphold_checks, negedge TECC1, Thcomp, notif_tecc1 );
    $setup ( posedge TECC1,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_tecc1 );
    $setup ( negedge TECC1,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_tecc1 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, posedge TECC1, Thcomp, notif_tecc1 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, negedge TECC1, Thcomp, notif_tecc1 );
    $setup ( posedge TECC1,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_tecc1 );
    $setup ( negedge TECC1,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_tecc1 );
    $hold (negedge COMP  &&& enable_setuphold_checks, posedge BIAS0, Thcomp, notif_bias0 );
    $hold (negedge COMP  &&& enable_setuphold_checks, negedge BIAS0, Thcomp, notif_bias0 );
    $setup ( posedge BIAS0,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_bias0 );
    $setup ( negedge BIAS0,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_bias0 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, posedge BIAS0, Thcomp, notif_bias0 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, negedge BIAS0, Thcomp, notif_bias0 );
    $setup ( posedge BIAS0,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_bias0 );
    $setup ( negedge BIAS0,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_bias0 );
    $hold (negedge COMP  &&& enable_setuphold_checks, posedge BIAS1, Thcomp, notif_bias1 );
    $hold (negedge COMP  &&& enable_setuphold_checks, negedge BIAS1, Thcomp, notif_bias1 );
    $setup ( posedge BIAS1,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_bias1 );
    $setup ( negedge BIAS1,posedge COMP  &&& enable_setuphold_checks, Tscomp, notif_bias1 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, posedge BIAS1, Thcomp, notif_bias1 );
    $hold (negedge RECALL  &&& enable_setuphold_checks, negedge BIAS1, Thcomp, notif_bias1 );
    $setup ( posedge BIAS1,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_bias1 );
    $setup ( negedge BIAS1,posedge RECALL  &&& enable_setuphold_checks, Tscomp, notif_bias1 );


    $recovery ( posedge CLK ,posedge COMP  &&& CHKENCLK, Tcc, notif_clk_COMP_rise_rec);




    $recovery ( posedge CLK ,posedge SCLK  &&& CHKENSCLKCLK, Tcc, notif_clk_SCLK_rise_rec);




    $recovery ( posedge CLK ,posedge RECALL  &&& CHKENCLK, Tcc, notif_clk_RECALL_rise_rec);




    $recovery ( posedge CLK ,posedge STORE  &&& CHKENCLK, Tcc, notif_clk_STORE_rise_rec);




    $recovery ( posedge SCLK ,posedge COMP  &&& CHKENSCLK, Tccs, notif_sclk_COMP_rise_rec);




    $recovery ( posedge SCLK ,posedge CLK  &&& CHKENCLKSCLK, Tccs, notif_sclk_CLK_rise_rec);




    $recovery ( posedge SCLK ,posedge RECALL  &&& CHKENSCLK, Tccs, notif_sclk_RECALL_rise_rec);




    $recovery ( posedge SCLK ,posedge STORE  &&& CHKENSCLK, Tccs, notif_sclk_STORE_rise_rec);



    $recovery ( negedge COMP  &&& enable_recovery_checks,posedge RECALL , Trcomp, notif_comp_RECALL_rise_rec);

    $recovery ( posedge COMP  &&& enable_recovery_checks,posedge RECALL , Trcomp, notif_comp_RECALL_rise_rec);



    $recovery ( negedge COMP  &&& enable_recovery_checks,posedge STORE , Trcomp, notif_comp_STORE_rise_rec);

    $recovery ( posedge COMP  &&& enable_recovery_checks,posedge STORE , Trcomp, notif_comp_STORE_rise_rec);



    $recovery ( negedge COMP  &&& enable_recovery_checks,posedge SCLK  &&& CHKENSCLK, Trcomp, notif_comp_SCLK_rise_rec);




    $recovery ( negedge COMP  &&& enable_recovery_checks,posedge CLK  &&& CHKENCLK, Trcomp, notif_comp_CLK_rise_rec);




    $recovery ( negedge STORE  &&& enable_recovery_checks,posedge RECALL , Trstore, notif_store_RECALL_rise_rec);





    $recovery ( posedge STORE  &&& enable_recovery_checks,posedge VPP , Txvpp, notif_store_VPP_rise_rec);



    $recovery ( negedge STORE  &&& enable_recovery_checks,posedge COMP , Trstore, notif_store_COMP_rise_rec);




    $recovery ( negedge STORE  &&& enable_recovery_checks,posedge SCLK  &&& CHKENSCLK, Trstore, notif_store_SCLK_rise_rec);




    $recovery ( negedge STORE  &&& enable_recovery_checks,posedge CLK  &&& CHKENCLK, Trstore, notif_store_CLK_rise_rec);




    $recovery ( negedge RECALL  &&& enable_recovery_checks,posedge STORE , Trrecall, notif_recall_STORE_rise_rec);




    $recovery ( negedge RECALL  &&& enable_recovery_checks,posedge COMP , Trrecall, notif_recall_COMP_rise_rec);




    $recovery ( negedge RECALL  &&& enable_recovery_checks,posedge SCLK  &&& CHKENSCLK, Trrecall, notif_recall_SCLK_rise_rec);




    $recovery ( negedge RECALL  &&& enable_recovery_checks,posedge CLK  &&& CHKENCLK, Trrecall, notif_recall_CLK_rise_rec);






    $recovery ( negedge VPP  &&& enable_recovery_checks,negedge STORE , Trvpp, notif_vpp_STORE_fall_rec);


endspecify



generic_behav_nvrm_nc15gfh_16x32 #(MES_ALL) uut (  Q_buf, SO_buf, MATCH_buf, ADR_buf, D_buf, WE_buf, ME_buf, OE_buf, CLK_buf, SI_buf, SCLK_buf, SME_buf, COMP_buf, STORE_buf, RECALL_buf, VPP_buf, MRCL0_buf, MRCL1_buf, TECC0_buf, TECC1_buf, BIAS0_buf, BIAS1_buf, RCREADY_buf, PU1_buf, PU2_buf, PU3_buf,notif_adr, notif_d, notif_we, notif_me, notif_clk, notif_clk_COMP_rise_rec, notif_clk_SCLK_rise_rec, notif_clk_RECALL_rise_rec, notif_clk_STORE_rise_rec, notif_si, notif_sclk, notif_sclk_COMP_rise_rec, notif_sclk_CLK_rise_rec, notif_sclk_RECALL_rise_rec, notif_sclk_STORE_rise_rec, notif_sme, notif_comp, notif_comp_RECALL_rise_rec, notif_comp_STORE_rise_rec, notif_comp_SCLK_rise_rec, notif_comp_CLK_rise_rec, notif_store, notif_store_RECALL_rise_rec, notif_store_VPP_rise_rec, notif_store_COMP_rise_rec, notif_store_SCLK_rise_rec, notif_store_CLK_rise_rec, notif_recall, notif_recall_STORE_rise_rec, notif_recall_COMP_rise_rec, notif_recall_SCLK_rise_rec, notif_recall_CLK_rise_rec, notif_vpp, notif_vpp_STORE_fall_rec, 
notif_mrcl0, notif_mrcl1, notif_tecc0, notif_tecc1, notif_bias0, notif_bias1 );

and u_OE_0 (OE_eff, OE_buf, 1'b1);

always @( posedge CLK_buf )
 begin
   ADRlatched = ADR_buf;
   Dlatched = D_buf;
   WElatched = WE_buf;
   MElatched = ME_buf;
   ADRFLAGA = 1;
 end

always @( posedge SCLK_buf )
 begin
   SMElatched = SME;
 end


endmodule




module generic_behav_nvrm_nc15gfh_16x32 (  Q, SO, MATCH, ADR, D, WE, ME, OE, CLK, SI, SCLK, SME, COMP, STORE, RECALL, VPP, MRCL0, MRCL1, TECC0, TECC1, BIAS0, BIAS1, RCREADY, PU1, PU2, PU3,notif_adr, notif_d, notif_we, notif_me, notif_clk, notif_clk_COMP_rise_rec, notif_clk_SCLK_rise_rec, notif_clk_RECALL_rise_rec, notif_clk_STORE_rise_rec, notif_si, notif_sclk, notif_sclk_COMP_rise_rec, notif_sclk_CLK_rise_rec, notif_sclk_RECALL_rise_rec, notif_sclk_STORE_rise_rec, notif_sme, notif_comp, notif_comp_RECALL_rise_rec, notif_comp_STORE_rise_rec, notif_comp_SCLK_rise_rec, notif_comp_CLK_rise_rec, notif_store, notif_store_RECALL_rise_rec, notif_store_VPP_rise_rec, notif_store_COMP_rise_rec, notif_store_SCLK_rise_rec, notif_store_CLK_rise_rec, notif_recall, notif_recall_STORE_rise_rec, notif_recall_COMP_rise_rec, notif_recall_SCLK_rise_rec, notif_recall_CLK_rise_rec, notif_vpp, notif_vpp_STORE_fall_rec, notif_mrcl0, notif_mrcl1, notif_tecc0, notif_tecc1, notif_bias0, notif_bias1 );

parameter MES_ALL = "ON";
parameter words = 16, bits = 32, addrbits = 4, timingmode = 1;

output [bits-1:0] Q;
output SO;
output MATCH;
input [addrbits-1:0] ADR;
input [bits-1:0] D;
input WE;
input ME;
input OE;
input CLK;
input SI;
input SCLK;
input SME;
input COMP;
input STORE;
input RECALL;
input VPP;
input MRCL0;
input MRCL1;
input TECC0;
input TECC1;
input BIAS0;
input BIAS1;
output RCREADY;
input PU1;
input PU2;
input PU3;
input notif_adr, notif_d, notif_we, notif_me, notif_clk, notif_clk_COMP_rise_rec, notif_clk_SCLK_rise_rec, notif_clk_RECALL_rise_rec, notif_clk_STORE_rise_rec, notif_si, notif_sclk, notif_sclk_COMP_rise_rec, notif_sclk_CLK_rise_rec, notif_sclk_RECALL_rise_rec, notif_sclk_STORE_rise_rec, notif_sme, notif_comp, notif_comp_RECALL_rise_rec, notif_comp_STORE_rise_rec, notif_comp_SCLK_rise_rec, notif_comp_CLK_rise_rec, notif_store, notif_store_RECALL_rise_rec, notif_store_VPP_rise_rec, notif_store_COMP_rise_rec, notif_store_SCLK_rise_rec, notif_store_CLK_rise_rec, notif_recall, notif_recall_STORE_rise_rec, notif_recall_COMP_rise_rec, notif_recall_SCLK_rise_rec, notif_recall_CLK_rise_rec, notif_vpp, notif_vpp_STORE_fall_rec, notif_mrcl0, notif_mrcl1, notif_tecc0, notif_tecc1, notif_bias0, notif_bias1;


parameter DataX = { bits { 1'bx } };
parameter DataZ = { bits { 1'bz } };

reg [bits-1:0] memb [words-1:0];
reg [bits-1:0] earom [words-1:0];

reg [bits-1:0] temp1;
reg [bits-1:0] temp2;
reg [bits-1:0] temp3;
integer store_success_count;



real comp_start_time;
real comp_end_time;
real recall_start_time;
real recall_end_time;
real CLK_T;
reg
        flaga_read_ok,
        flaga_we_ok,
        flaga_d_ok,
        flaga_adr_ok,
        flaga_range_ok;
reg     flaga_adr_viol;
reg     flaga_clk_valid;
reg     flaga_output_ok;
reg     flaga_serial_read_ok;
reg     flaga_si_ok;
reg     flaga_sclk_valid;
reg     flag_keep_match_low ;
reg     rcready_viol_flag ;


reg [bits-1:0] Q;
reg [bits-1:0] QI;

integer i,j;
integer store_ctr;
integer store_ctr_buf;

task BlastCell;
    input [bits - 1 : 0] bits; 
    integer i;
begin
    if ($time > 0) begin
      $display("      time=%t; instance=%m (NVM1H)",$realtime);
      $display("      Corrupting the SRAM");
      if (store_ctr != 0) begin
        store_ctr = 0;
      end
      for (i = 0; i < words; i = i + 1)
        memb[i] = memb[i] ^ (bits & DataX);
    end
end
endtask


task corrupt_all_loc;
    input flag_range_ok; 
    integer i;
begin
   if( flag_range_ok == `True) 
    if ($time > 0) 
     if (store_ctr != 0) begin
      store_ctr = 0;
     end
        for (i = 0; i < words; i = i + 1)
            memb[i] <= DataX;
end
endtask

task corrupt_cur_loc;
    input flag_range_ok; 
    input [3:0] ADRlatched;
    integer i;
begin
   if( flag_range_ok == `False) 
    if ($time > 0) 
     if (store_ctr != 0) begin
      store_ctr = 0;
     end
       if ( ADRlatched < words ) 
         memb[ADRlatched] = DataX;
end

endtask


task BlastEarom;
    integer i;
begin
    if ($time > 0) begin
      $display("      time=%t; instance=%m (NVM1H)",$realtime);
      $display("      Corrupting the EAROM");
      if (store_ctr != 0) begin
        store_ctr = 0;
      end
      for (i = 0; i < words; i = i + 1)
        earom[i] = DataX;
    end
end
endtask

reg RECALL_start;
reg SOI;
reg MATCHI;
reg CLK_old;
reg SCLK_old;
reg STORE_old;
reg RECALL_old;
reg VPP_old;
reg RCREADYI;

reg WElatched;
reg WE_old;
reg MElatched;
reg ME_old;
reg [addrbits-1:0] ADRlatched;

reg [addrbits-1:0] ADR_old;

reg [bits-1:0] Dlatched;

reg [bits-1:0] D_old;

reg ME_chk;
reg WE_chk;
reg SME_chk;
reg SME_old;
reg SMElatched;





// Perform Sanity Check on Port A, Corrupt memory if required

task checkSanityOnAport;

 #0                // let CLOCK and NOTIFIER stuff execute first
 case ( {flaga_serial_read_ok,flaga_adr_ok, flaga_we_ok, flaga_d_ok} ) // only 1 and 0

  4'b1111   : ;                                                // everything ok!!!

  4'b1101,
  4'b1100   : corrupt_cur_loc( flaga_we_ok,ADRlatched);          // WE is unstable

  4'b1110   : if (WElatched !== 1'b0)
              corrupt_cur_loc( flaga_d_ok,ADRlatched);         // Data is unstable

  4'b1000,
  4'b1001   : corrupt_all_loc(flaga_range_ok);            // ADR and WE unstable

  4'b1010,
  4'b1011   : corrupt_all_loc(flaga_range_ok);

 endcase
endtask


// PORT FUNCTIONALITY FOR VIOLATION BEHAVIOR
initial
 begin
  RECALL_start = 1'b0;
  store_success_count = 1;
  store_ctr = 0;
  store_ctr_buf = 0;
  flaga_adr_ok  = `True;
  flaga_range_ok = `True;
  flaga_we_ok   = `True;
  flaga_d_ok    = `True;
  flaga_read_ok = `True;
  flaga_output_ok = `True;
  flaga_adr_viol = `True;
  flaga_clk_valid = `True;
  flaga_si_ok    = `True;
  flaga_serial_read_ok = `True;
  flaga_sclk_valid = `True;
  flag_keep_match_low = `False;
end

always @(notif_bias0)            // BIAS0 violation
begin
 if  ( $realtime == recall_start_time )    // For setup violation with RECALL
  BlastCell(DataX);
 else if ( $realtime == comp_start_time ) begin   // For setup violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
 end
 else if (($realtime - recall_end_time ) > ($realtime - comp_end_time)) begin // For hold violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
  end
 else if (($realtime - recall_end_time) < ($realtime - comp_end_time)) // For hold violation with RECALL
  BlastCell(DataX);
end

always @(notif_bias1)            // BIAS1 violation
begin
 if  ( $realtime == recall_start_time )    // For setup violation with RECALL
  BlastCell(DataX);
 else if ( $realtime == comp_start_time ) begin   // For setup violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
 end
 else if (($realtime - recall_end_time ) > ($realtime - comp_end_time)) begin // For hold violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
  end
 else if (($realtime - recall_end_time) < ($realtime - comp_end_time)) // For hold violation with RECALL
  BlastCell(DataX);
end

always @(notif_mrcl0)            // MRCL0 violation
begin
 if  ( $realtime == recall_start_time )    // For setup violation with RECALL
  BlastCell(DataX);
 else if ( $realtime == comp_start_time ) begin   // For setup violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
 end
 else if (($realtime - recall_end_time ) > ($realtime - comp_end_time)) begin // For hold violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
  end
 else if (($realtime - recall_end_time) < ($realtime - comp_end_time)) // For hold violation with RECALL
  BlastCell(DataX);
end

always @(notif_mrcl1)            // MRCL1 violation
begin
 if  ( $realtime == recall_start_time )    // For setup violation with RECALL
  BlastCell(DataX);
 else if ( $realtime == comp_start_time ) begin   // For setup violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
 end
 else if (($realtime - recall_end_time ) > ($realtime - comp_end_time)) begin // For hold violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
  end
 else if (($realtime - recall_end_time) < ($realtime - comp_end_time)) // For hold violation with RECALL
  BlastCell(DataX);
end

always @(notif_tecc0)            // TECC0 violation
begin
 if  ( $realtime == recall_start_time )    // For setup violation with RECALL
  BlastCell(DataX);
 else if ( $realtime == comp_start_time ) begin   // For setup violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
 end
 else if (($realtime - recall_end_time ) > ($realtime - comp_end_time)) begin // For hold violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
  end
 else if (($realtime - recall_end_time) < ($realtime - comp_end_time)) // For hold violation with RECALL
  BlastCell(DataX);
end

always @(notif_tecc1)            // TECC1 violation
begin
 if  ( $realtime == recall_start_time )    // For setup violation with RECALL
  BlastCell(DataX);
 else if ( $realtime == comp_start_time ) begin   // For setup violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
 end
 else if (($realtime - recall_end_time ) > ($realtime - comp_end_time)) begin // For hold violation with COMP
  flag_keep_match_low = `True;
  MATCHI = 1'b0;
  end
 else if (($realtime - recall_end_time) < ($realtime - comp_end_time)) // For hold violation with RECALL
  BlastCell(DataX);
end


always @(notif_recall)            // RECALL violation
begin
      BlastCell(DataX);
      QI <= DataX;
      SOI <= 1'bx;
    flaga_read_ok = `False;
     RCREADYI <= 1'b0;

 end

always @(notif_store)            // STORE violation 
begin
      BlastEarom;
    flaga_read_ok = `False;
 end



always @(notif_vpp)            // pulse width violation of VPP
begin
      BlastEarom;
      disable STORE_OP;
end

always @(notif_sme)            // pin_name(sme,0) violation 
begin
      BlastCell(DataX);
      QI <= DataX;
    flaga_read_ok = `False;
      disable serial_blk;
      SOI <= 1'bx;
    flaga_serial_read_ok = `False;
      checkSanityOnAport;
 end


always @(notif_sclk)            // SCLK violation 
begin
      BlastCell(DataX);
    flaga_serial_read_ok = `False;
      QI <= DataX;
      SOI <= 1'bx;
      checkSanityOnAport;
 end


always @(notif_si)            // SI violation 
begin
      temp3 = memb[0];
      memb[0] = {temp3[bits-1:1],1'bx};
 end






always @(notif_clk_SCLK_rise_rec)            // RECOVERY between posedge SCLK and posedge CLK
begin
      QI <= DataX;
      BlastCell(DataX);
      SOI <= 1'bx;
    flaga_read_ok = `False;
    flaga_serial_read_ok = `False;
 end

always @(notif_sclk_CLK_rise_rec)            // RECOVERY between posedge CLK and posedge SCLK
begin
      BlastCell(DataX);
      SOI <= 1'bx;
      QI <= DataX;
    flaga_read_ok = `False;
    flaga_serial_read_ok = `False;
 end



always @(notif_clk_COMP_rise_rec)            // RECOVERY between posedge CLK and posedge COMP
begin
      BlastCell(DataX);
      SOI <= 1'bx;
      QI <= DataX;

      MATCHI = 1'b0;
      RCREADYI <= 1'b0;
 end

always @(notif_clk_RECALL_rise_rec)            // RECOVERY between posedge CLK and posedge RECALL
begin
      BlastCell(DataX);
      QI <= DataX;
      SOI <= 1'bx;
    flaga_serial_read_ok = `False;
    flaga_read_ok = `False;
    RCREADYI <= 1'b0;
 end

always @(notif_clk_STORE_rise_rec)            // RECOVERY between posedge CLK and posedge STORE
begin
      BlastEarom;
      BlastCell(DataX);
      QI <= DataX;
      SOI <= 1'bx;
      checkSanityOnAport;
    flaga_read_ok = `False;
 end

always @(notif_comp_CLK_rise_rec)            // RECOVERY between negedge COMP and posedge CLK
begin
      MATCHI = 1'b0;
      BlastCell(DataX);
      QI <= DataX;
      SOI <= 1'bx;
    flaga_serial_read_ok = `False;
      RCREADYI <= 1'b0;
 end

always @(notif_store_CLK_rise_rec)            // RECOVERY between negedge STORE and posedge CLK
begin
      BlastCell(DataX);
      QI <= DataX;
      SOI <= 1'bx;
    flaga_serial_read_ok = `False;
 end

always @(notif_recall_CLK_rise_rec)            // RECOVERY between RECALL and posedge CLK
begin
      BlastCell(DataX);
      QI <= DataX;
      disable WriteArrayA.SERIAL_OUT;
      disable serial_blk;
      SOI <= 1'bx;
    flaga_serial_read_ok = `False;
    flaga_read_ok = `False;
    RCREADYI <= 1'b0;
 end



always @(notif_sclk_COMP_rise_rec)            // RECOVERY between posedge SCLK and posedge COMP
begin
      BlastCell(DataX);
      MATCHI = 1'b0;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
 end

always @(notif_sclk_RECALL_rise_rec)            // RECOVERY between posedge SCLK and posedge RECALL
begin
      BlastCell(DataX);
      QI <= DataX;
      flaga_read_ok = `False;
      SOI <= 1'bx;
      checkSanityOnAport;
      RCREADYI <= 1'b0;

 end

always @(notif_sclk_STORE_rise_rec)            // RECOVERY between posedge SCLK and negedge STORE
begin
    BlastCell(DataX);
      QI <= DataX;
      flaga_read_ok = `False;
      SOI <= 1'bx;
      flaga_serial_read_ok = `False;
 end

always @(notif_comp_SCLK_rise_rec)            // RECOVERY between negedge COMP and posedge SCLK
begin
    MATCHI = 1'b0;
    BlastCell(DataX);
      QI <= DataX;
      flaga_read_ok = `False;
      SOI <= 1'bx;
      flaga_serial_read_ok = `False;
      RCREADYI <= 1'b0;
 end

always @(notif_store_SCLK_rise_rec)            // RECOVERY between negedge STORE and posedge SCLK
begin
      BlastCell(DataX);
      QI <= DataX;
      flaga_read_ok = `False;
      SOI <= 1'bx;
 end

always @(notif_recall_SCLK_rise_rec)            // RECOVERY between negedge RECALL and posedge SCLK
begin
      BlastCell(DataX);
      QI <= DataX;
      flaga_read_ok = `False;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
 end


always @(notif_comp_RECALL_rise_rec)            // RECOVERY between COMP and RECALL
begin
    RCREADYI = 1'b0;
    rcready_viol_flag = 1'b1;
    disable RECALL_BLK;
    MATCHI = 1'b0;
      BlastCell(DataX);
      QI <= DataX;
      SOI <= 1'bx;

      flaga_read_ok = `False;
      RCREADYI <= 1'b0;
 end

always @(notif_comp_STORE_rise_rec)            // RECOVERY between posedge COMP and posedge STORE
begin
      BlastEarom;
      BlastCell(DataX);
      flaga_read_ok = `False;
    MATCHI = 1'b0;
      SOI <= 1'bx;
     RCREADYI <= 1'b0;
 end


always @(notif_store_RECALL_rise_rec)            // RECOVERY between negedge STORE and posedge RECALL
begin
      BlastCell(DataX);
      QI <= DataX;
      flaga_read_ok = `False;
      SOI <= 1'bx;
     RCREADYI <= 1'b0;
 end

always @(notif_store_COMP_rise_rec)            // RECOVERY between negedge STORE and posedge COMP
begin
      BlastCell(DataX);
      MATCHI = 1'b0;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
 end

always @(notif_recall_STORE_rise_rec)            // RECOVERY between negedge RECALL and posedge STORE
begin
      BlastCell(DataX);
      BlastEarom;
      QI <= DataX;
      flaga_read_ok = `False;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
 end

always @(notif_recall_COMP_rise_rec)            // RECOVERY between negedge RECALL and posedge COMP
begin
    RCREADYI = 1'b0;
    rcready_viol_flag = 1'b1;
    disable COMP_BLK;
    MATCHI = 1'b0;
      BlastCell(DataX);
      QI <= DataX;
      flaga_read_ok = `False;
      RCREADYI <= 1'b0;
 end

always @(notif_vpp_STORE_fall_rec)            // RECOVERY between negedge VPP and negedge STORE
begin
    $display("Trvpp violation.POSSIBLE CHIP DAMAGE!! ");
      BlastEarom;
      BlastCell(DataX);
      SOI <= 1'bx;
    flaga_read_ok = `False;
    end

always @(notif_store_VPP_rise_rec)            // RECOVERY between posedge VPP and posedge STORE
begin
    $display("Txvpp violation.POSSIBLE CHIP DAMAGE!! ");
      BlastEarom;
      BlastCell(DataX);
      SOI <= 1'bx;
    flaga_read_ok = `False;
    end




always @(notif_clk)            // CLK violation
 begin
  flaga_clk_valid = `False;
  flaga_output_ok = `False;
  flaga_adr_ok = `False;
  flaga_we_ok  = `False;
   QI <= DataX;
      SOI <= 1'bx;
  checkSanityOnAport;
  flaga_read_ok = `False;     
 end

always @(notif_d)             // D violation
 begin
  if ( $realtime == CLK_T )
   ME_chk = ME;
  else
   ME_chk = MElatched;
  if (ME_chk !== 1'b0)
   begin
    flaga_d_ok = `False;
    flaga_read_ok = `False;
    checkSanityOnAport;
      QI <= DataX;
     if ( ADRlatched == words - 1 && WElatched !== 1'b0) begin
      disable WriteArrayA.SERIAL_OUT;
      disable serial_blk;
      SOI <= 1'bx;
     end 
   end
 end

always @(notif_comp)             // COMP violation
 begin
     MATCHI = 1'b0;
     RCREADYI <= 1'b0;
 end

always @(notif_we)            // WE violation
 begin
  if ( $realtime == CLK_T )
   ME_chk = ME;
  else
   ME_chk = MElatched;
  if (ME_chk !== 1'b0)
   begin
    flaga_we_ok = `False;
    flaga_output_ok = `False;
    flaga_read_ok = `False;
      QI <= DataX;
     if ( ADRlatched == words - 1 ) begin
      disable WriteArrayA.SERIAL_OUT;
      disable serial_blk;
      SOI <= 1'bx;
     end 
    checkSanityOnAport;
   end
 end

always @(notif_me)            // ME violation
 begin
  if ( $realtime == CLK_T )
   WE_chk = WE;
  else
   WE_chk = WElatched;
  if (WE_chk != 1'b0) begin
  flaga_adr_ok = `False;
  end
  flaga_read_ok = `False;     // irrespective of WE
  flaga_output_ok = `False;
  disable OUTPUT;
  QI <= DataX;
     if ( WE_chk !== 1'b0) begin
  SOI <= 1'bx;
     end 
  checkSanityOnAport;
 end

always @(notif_adr )           // ADR violation
 begin
  if ( $realtime == CLK_T )
   ME_chk = ME;
  else
   ME_chk = MElatched;
  if (ME_chk !== 1'b0)
   begin
    flaga_adr_ok = `False;
    flaga_read_ok = `False; // irrespective of WE
    flaga_output_ok = `False;
   QI <= DataX;
      SOI <= 1'bx;
    checkSanityOnAport;
   end
 end


// PORT FUNCTIONALITY
//---- Clock Negative Edge
always @( negedge CLK) begin
   if ( CLK !== 1'bx ) begin     //RESETTING FLAGS FOR NEXT CYCLE
   #0.01;
   flaga_range_ok  = `True;
   flaga_read_ok = `True;
   flaga_adr_viol = `True;
   flaga_clk_valid = `True;
   flaga_output_ok = `True;
  end
  else
   begin
    flaga_clk_valid = `False;
    corrupt_all_loc(`True);
   end
end
//---- Scan Clock Negative Edge
always @( negedge SCLK) begin
   SCLK_old <= SCLK;
   if ( SCLK_old ===1'b1 && SCLK===1'bx) begin
      if( MES_ALL=="ON" ) begin 
        $display("<<SCLK unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end 
      BlastCell(DataX);
      QI = DataX;
      SOI <= 1'bx;
   end
   else 
    begin
   flaga_serial_read_ok = `True;
   flaga_sclk_valid = `True;
    end
end

//---- Scan Clock Positive Edge
always @( posedge SCLK) begin
  #0
   SCLK_old <= SCLK;
// Scan Clock 0-X
   if ( SCLK===1'bx) begin
      if( MES_ALL=="ON" && $realtime != 0) begin
        $display("<<SCLK unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end
      BlastCell(DataX);
      QI = DataX;
      SOI <= 1'bx;
   end
// Scan Clock X-1
   else if ( SCLK_old ===1'bx) begin
      QI = DataX;
      SOI <= 1'bx;
   end
   else begin
     SMElatched = SME_old;
      if ( SMElatched == 1'b1 ) begin
       if ( RECALL == 1'b0 && STORE == 1'b0 && COMP == 1'b0 ) begin : serial_blk
         if ( store_ctr != 0) begin
           if ( store_ctr < store_success_count-1) begin
             $display("Attempt to Write was made in the middle of a store operation from serial port , corrupting EAROM. time = %t",$realtime);
             BlastEarom;
           end
           else begin
             store_ctr = 0;
           end
         end

        for ( i = words-1; i>0; i = i-1 ) begin
         temp1 = memb[i] << 1;
         temp2 = memb[i-1];
         memb[i] = {temp1[bits-1:1],temp2[bits-1]};
        end
        temp1 = memb[0] << 1;
        memb[0] = {temp1[bits-1:1],SI};
        SOI <= 1'bx;
        #0.01
        temp1 = memb[words-1];
        SOI = temp1[bits-1];
       end
       else begin
          if ( RECALL !== 1'b0 && SMElatched == 1'b1) begin
            if( MES_ALL=="ON" && $realtime != 0) begin
              $display("<<RECALL non-zero at postive edge of SCLK>>");
              $display("      time=%t; instance=%m (NVM1H)",$realtime);
            end
            BlastCell(DataX);
            SOI <= 1'bx;


          end
          if ( STORE !== 1'b0 && SMElatched == 1'b1) begin
            if( MES_ALL=="ON" && $realtime != 0) begin
              $display("<<STORE non-zero at postive edge of SCLK>>");
              $display("      time=%t; instance=%m (NVM1H)",$realtime);
            end
            BlastEarom;
            BlastCell(DataX);
            SOI <= 1'bx;
          end
          if ( COMP !== 1'b0 && SMElatched == 1'b1) begin
            if( MES_ALL=="ON" && $realtime != 0) begin
              $display("<<COMP non-zero at postive edge of SCLK >>");
              $display("      time=%t; instance=%m (NVM1H)",$realtime);
            end
            BlastCell(DataX);
            SOI <= 1'bx;
            MATCHI = 1'b0;
          end
        end
      end
      else if ( SMElatched === 1'bx ) begin
        BlastCell(DataX);
        SOI <= 1'bx;
        if ( STORE !== 1'b0 ) begin
          if( MES_ALL=="ON" && $realtime != 0) begin
            $display("<<STORE non-zero at postive edge of SCLK>>");
            $display("      time=%t; instance=%m (NVM1H)",$realtime);
          end
          BlastEarom;
        end
      end
   end
end
assign SO = SOI;


always @( BIAS0 )
 begin
   if ( RECALL !== 1'b0  ) 
    BlastCell(DataX);
    else if ( COMP !== 1'b0 ) begin 
     flag_keep_match_low = `True;
     MATCHI = 1'b0;
    end
 end

always @( BIAS1 )
 begin
   if ( RECALL !== 1'b0  ) 
    BlastCell(DataX);
    else if ( COMP !== 1'b0 ) begin 
     flag_keep_match_low = `True;
     MATCHI = 1'b0;
    end
 end

always @( TECC0 )
 begin
   if ( RECALL !== 1'b0  ) 
    BlastCell(DataX);
    else if ( COMP !== 1'b0 ) begin 
     flag_keep_match_low = `True;
     MATCHI = 1'b0;
    end
 end
always @( TECC1 )
 begin
   if ( RECALL !== 1'b0  ) 
    BlastCell(DataX);
    else if ( COMP !== 1'b0 ) begin 
     flag_keep_match_low = `True;
     MATCHI = 1'b0;
    end
 end

always @( MRCL0 )
 begin
   if ( RECALL !== 1'b0  ) 
    BlastCell(DataX);
    else if ( COMP !== 1'b0 ) begin 
     flag_keep_match_low = `True;
     MATCHI = 1'b0;
    end
 end
always @( MRCL1 )
 begin
   if ( RECALL !== 1'b0  ) 
    BlastCell(DataX);
    else if ( COMP !== 1'b0 ) begin 
     flag_keep_match_low = `True;
     MATCHI = 1'b0;
    end
 end

always @( negedge CLK or WE )
 begin
   if ( CLK == 1'b0 )
     WE_old = WE;
 end

always @( negedge CLK or ME )
 begin
   if ( CLK == 1'b0 )
     ME_old = ME;
 end

always @( negedge CLK or ADR )
 begin
   if ( CLK == 1'b0 )
     ADR_old = ADR;
 end

always @( negedge CLK or D )
 begin
   if ( CLK == 1'b0 )
     D_old = D;
 end


always @( negedge SCLK or SME)
 begin
   if ( SCLK == 1'b0 )
     SME_old = SME;
 end


task WriteArrayA;
begin
  if ( (ADRlatched ^ ADRlatched) !== 0 ) begin
     BlastCell(DataX);
     if( MES_ALL=="ON" && $realtime != 0) begin
       $display("<<ADR unknown>>");
       $display("      time=%t; instance=%m (NVM1H)",$realtime);
     end
        QI = DataX;
        SOI = 1'bx;
  end
  else if ( ADRlatched < words ) begin
     memb[ADRlatched] = Dlatched;
      QI = Dlatched;
     if ( ADRlatched == words - 1 ) begin : SERIAL_OUT
        SOI <= 1'bx;
        #0.01
       SOI = Dlatched[bits-1];
     end
  end
  else if( MES_ALL=="ON" && $realtime != 0) begin
     $display("<<WARNING:address is out of range\n RANGE:0 to 15>>\n");
     $display("      time=%t; instance=%m (NVM1H)",$realtime);
        QI = Dlatched;
  end
end
endtask

task WriteFaultA;
begin
  if ( (ADRlatched ^ ADRlatched) !== 0 ) begin
     BlastCell(DataX);
  end
  else if ( ADRlatched < words ) begin
     memb[ADRlatched] = DataX;
  end

  else if( MES_ALL=="ON" && $realtime != 0) begin
     $display("<<%m WARNING:address is out of range\n RANGE:0 to 15>>\n");
  end
   QI = DataX;
end
endtask


//---- RECALL Negative Edge
always @( negedge RECALL) begin
   recall_end_time = $realtime ;
   if ( RECALL === 1'b0 && rcready_viol_flag !== 1'b1 ) RCREADYI <= RECALL;
    rcready_viol_flag = 1'b0;
   RECALL_old <= RECALL;
   if ( RECALL_old ===1'b1 && RECALL===1'bx) begin
      if( MES_ALL=="ON" ) begin 
        $display("<<RECALL unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end 
      BlastCell(DataX);
      QI <= DataX;
      SOI <= 1'bx;
   end
end

always @( posedge RCREADYI) begin
 RECALL_start = 1'b0;
end

//---- RECALL Positive Edge
always @( posedge RECALL) begin : RECALL_BLK
   recall_start_time = $realtime ;
   RECALL_start = 1'b1;
  if ( RECALL === 1'b1 && rcready_viol_flag !== 1'b1 ) RCREADYI <= RECALL;
    rcready_viol_flag = 1'b0;
   RECALL_old <= RECALL;
// RECALL 0-X
   if ( RECALL===1'bx) begin
      if( MES_ALL=="ON" && $realtime != 0) begin
        $display("<<RECALL unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end
      BlastCell(DataX);
      RCREADYI <= 1'b0;
      QI <= DataX;
      SOI <= 1'bx;
   end
// RECALL X-1
   else if ( RECALL_old ===1'bx) begin
      QI <= DataX;
      SOI <= 1'bx;
   end
   else if ( COMP != 1'b0) begin
      BlastCell(DataX);
      MATCHI = 1'b0;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
   end
   else if ( STORE != 1'b0) begin
      BlastCell(DataX);
      BlastEarom;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
   end
   else begin
      for ( i = words-1; i>=0; i = i-1 ) begin
        memb[i] = earom[i];
      end
      temp1 = memb[words-1];
      SOI <= temp1[bits-1];
   end
end

task store;
  begin
    for ( i = words-1; i>=0; i = i-1 ) begin
      earom[i] = memb[i];
    end
  end
endtask

task recall;
  begin
     if (store_ctr != 0) begin
      store_ctr = 0;
     end
    for ( i = words-1; i>=0; i = i-1 ) begin
      memb[i] = earom[i];
    end
  end
endtask

reg store_start;
reg vpp_start;
reg vpp_end;
//---- STORE Negative Edge
always @( negedge STORE) begin
   STORE_old <= STORE;
// STORE 1-X
   if ( STORE_old ===1'b1 && STORE===1'bx) begin
      if( MES_ALL=="ON" ) begin 
        $display("<<STORE unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end 
      BlastEarom;
   end
   else if ( STORE_old ===1'bx) begin
   end
   else begin
      if ( store_start == 1'b1 && vpp_start == 1'b1 && vpp_end == 1'b1 ) begin
         store_start = 1'b0;
         vpp_start = 1'b0;
         vpp_end = 1'b0;
      end
      else begin
          BlastEarom;
        if( MES_ALL=="ON" ) begin 
          $display("<<STORE AND VPP Sequence Wrong>>");
          $display("      time=%t; instance=%m (NVM1H)",$realtime);
        end 
      end
   end
end

//---- STORE Positive Edge
always @( posedge STORE) begin
  STORE_old <= STORE;
// STORE 0-X
    if ( STORE===1'bx) begin
      if( MES_ALL=="ON" && $realtime != 0) begin
        $display("<<STORE unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end
      BlastEarom;
    end
// STORE X-1
    else if ( STORE_old ===1'bx) begin
     store_ctr = 0;
    end
    else if (RECALL == 1'b1) begin
      BlastEarom;
      BlastCell(DataX);
      QI <= DataX;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
    end
    else if (COMP == 1'b1) begin
      BlastEarom;
      BlastCell(DataX);
      QI <= DataX;
      MATCHI = 1'b0;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
    end
    else begin
      store_start = 1'b1;
    end
end

//---- VPP Negative Edge
always @( negedge VPP) begin
  VPP_old <= VPP;
// VPP 1-X
    if ( VPP_old ===1'b1 && VPP===1'bx) begin
      if( MES_ALL=="ON" ) begin 
        $display("<<VPP unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end 
      BlastEarom;
    end
    else if ( VPP_old ===1'bx) begin
    end
    else begin
      if ( store_start == 1'b1 && vpp_start == 1'b1 ) begin : STORE_OP
        vpp_end = 1;
        if ( store_ctr >= store_success_count  - 1) begin
          store;
          store_ctr = store_ctr + 1;
        end
        else begin 
          store_ctr = store_ctr + 1;
          store_ctr_buf = store_ctr;
          BlastEarom;
          store_ctr = store_ctr_buf;
        end
      end
      else begin
        BlastEarom;
        if( MES_ALL=="ON" ) begin 
          $display("<<STORE AND VPP Sequence Wrong>>");
          $display("      time=%t; instance=%m (NVM1H)",$realtime);
        end 
      end
    end
end

//---- VPP Positive Edge
always @( posedge VPP) begin
   VPP_old <= VPP;
      if ( STORE == 1'b0) begin
    $display("VPP is not low when STORE is low.POSSIBLE CHIP DAMAGE!!.Exiting simulation. ");
     if ($time != 0) $finish;
      end
// VPP 0-X
   else if ( VPP===1'bx) begin
      if( MES_ALL=="ON" && $realtime != 0) begin
        $display("<<VPP unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end
      BlastEarom;
      vpp_start = 0;
      vpp_end = 0;
   end
// VPP X-1
   else if ( VPP_old ===1'bx) begin
      vpp_start = 0;
      vpp_end = 0;
   end
    else if (RECALL == 1'b1) begin
      BlastEarom;
      BlastCell(DataX);
      QI <= DataX;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
    end
    else if (COMP == 1'b1) begin
      BlastEarom;
      BlastCell(DataX);
      QI <= DataX;
      MATCHI = 1'b0;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
    end
   else if ( store_start == 1'b1 ) begin
      vpp_start = 1;
      vpp_end = 0;
   end
   else begin
      vpp_start = 0;
      vpp_end = 0;
      if( MES_ALL=="ON" && $realtime != 0) begin
        $display("<<VPP is ON, but STORE is OFF>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end
      if ( STORE == 1'b0) begin
       BlastCell(DataX);
      end
      BlastEarom;
   end
end

reg temp_comp;
reg COMP_old;

//---- Compare operation between EAROM & SRAM
always @( negedge COMP) begin
   if ( COMP === 1'b0 && rcready_viol_flag !== 1'b1 ) RCREADYI <= COMP;
    rcready_viol_flag = 1'b0;
   comp_end_time = $realtime ;
   COMP_old <= COMP;
   flag_keep_match_low = `False;
   if ( COMP_old ===1'b1 && COMP===1'bx) begin
      if( MES_ALL=="ON" ) begin 
        $display("<<COMP unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end 
      MATCHI = 1'b0;
   end
   else
      MATCHI = 1'b0;
end
//---- COMP Positive Edge
always @( posedge COMP) begin : COMP_BLK
   if ( COMP === 1'b1  && rcready_viol_flag !== 1'b1 ) RCREADYI <= COMP;
    rcready_viol_flag = 1'b0;
   comp_start_time = $realtime ;
   COMP_old <= COMP;
// COMP 0-X
   if ( COMP===1'bx) begin
      if( MES_ALL=="ON" && $realtime != 0) begin
        $display("<<COMP unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end
      MATCHI = 1'b0;
      RCREADYI <= 1'b0;
   end
// COMP X-1
   else if ( COMP_old ===1'bx) begin
   end
    else if (RECALL == 1'b1) begin
      BlastCell(DataX);
      QI <= DataX;
      MATCHI = 1'b0;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
    end

   else if ( STORE != 1'b0) begin
      BlastCell(DataX);
      BlastEarom;
      MATCHI = 1'b0;
      SOI <= 1'bx;
      RCREADYI <= 1'b0;
   end
   else if ( flag_keep_match_low ) begin 
    MATCHI = 1'b0;
   end
   else begin
      temp_comp = 1'b1;
      for ( i = 0; i<words; i = i+1 ) begin
        temp_comp = temp_comp&(&(~(earom[i] ^ memb[i])));
        if ( temp_comp == 1'b0 ) i = words;
      end
        if ( temp_comp === 1'bx ) begin
          MATCHI = 1'b0;
        end
        else begin
          MATCHI = temp_comp;
        end
   end
end

assign MATCH = (flag_keep_match_low?0:MATCHI);
assign RCREADY = RCREADYI;
//---- Clock Negative Edge
always @( negedge CLK) begin
   CLK_old <= CLK;
   if ( CLK_old ===1'b1 && CLK===1'bx) begin
      if( MES_ALL=="ON" ) begin 
        $display("<<CLK unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end 
      BlastCell(DataX);
      QI <= DataX;
     SOI <= 1'bx;
   end
end


always @( posedge CLK )
 begin
  #0
  CLK_T = $realtime ;
  flaga_adr_ok  = `True;
   flaga_we_ok   = `True;
   flaga_d_ok    = `True;

   if ( RECALL !== 1'b0 && ME !== 1'b0 && WE !== 1'b0) begin
     if( MES_ALL=="ON" && $realtime != 0) begin
       $display("<<RECALL non-zero at postive edge of CLK >>");
       $display("      time=%t; instance=%m (NVM1H)",$realtime);
     end
     BlastCell(DataX);
     QI <= DataX;
     SOI <= 1'bx;
   end
  else if ( ( RECALL == 1'b0 || (RECALL == 1'b1 && RCREADY == 1'b1))  &&  flaga_clk_valid ) begin
   CLK_old <= CLK;
// Clock 0-X
   if ( CLK===1'bx) begin
      if( MES_ALL=="ON" && $realtime != 0) begin
        $display("<<CLK unknown>>");
        $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end
      BlastCell(DataX);
      QI <= DataX;
     SOI <= 1'bx;
   end

// Clock X-1
   else if ( CLK_old ===1'bx) begin
      QI <= DataX;
     SOI <= 1'bx;
   end
   else if ( STORE !== 1'b0 && ME !== 1'b0) begin
     if( MES_ALL=="ON" && $realtime != 0) begin
       $display("<<STORE non-zero at postive edge of CLK>>");
       $display("      time=%t; instance=%m (NVM1H)",$realtime);
     end
     BlastCell(DataX);
     BlastEarom;
     QI <= DataX;
     SOI <= 1'bx;
   end
   else if ( COMP !== 1'b0 && ME !== 1'b0) begin
     if( MES_ALL=="ON" && $realtime != 0) begin
       $display("<<COMP non-zero at postive edge of CLK >>");
       $display("      time=%t; instance=%m (NVM1H)",$realtime);
     end
     BlastCell(DataX);
     QI <= DataX;
     SOI <= 1'bx;
      MATCHI = 1'b0;
   end

// ---- Normal Mode
   else begin : OUTPUT
   #0
     WElatched = WE_old;
     MElatched = ME_old;
     ADRlatched = ADR_old;
     Dlatched = D_old;
     if ( MElatched == 1'b1 ) begin
        if ( WElatched !== 1'b0 &&  flaga_read_ok && flaga_we_ok  &&  flaga_adr_ok &&  flaga_d_ok) begin // Write operation
         if ( store_ctr != 0) begin
           if ( store_ctr < store_success_count-1) begin
             $display("Attempt to Write was made in the middle of a store operation from parallel port, corrupting EAROM. time = %t",$realtime);
             BlastEarom;
           end
           else begin
             store_ctr = 0;
           end
         end
          if ( WElatched == 1'b1 && RECALL == 1'b0 ) begin
             WriteArrayA;
          end
          else begin
             if( MES_ALL=="ON" && $realtime != 0 ) begin
               $display("<<WE unknown>>");
               $display("      time=%t; instance=%m (NVM1H)",$realtime);
             end
             WriteFaultA;
            if ( ADRlatched == words - 1) begin
                SOI <= 1'bx;
            end
          end
        end // End of Write operation
        else begin // Valid read operation
          if ( WElatched == 1'b0 &&  flaga_read_ok &&  flaga_output_ok &&  flaga_adr_ok) begin 
            if ( (ADRlatched ^ ADRlatched) !== 0 ) begin
              if( MES_ALL=="ON" && $realtime != 0) begin
                $display("<<ADR unknown>>");
                $display("      time=%t; instance=%m (NVM1H)",$realtime);
              end
                 BlastCell(DataX);
              QI <= DataX;
              SOI <= 1'bx;
            end
            else if ( ADRlatched < words ) begin
              QI <= DataX;
              #0.01
              QI <= memb[ADRlatched];
            end
            else begin
              if( MES_ALL=="ON" && $realtime != 0) begin
                $display("<<WARNING:address is out of range\n RANGE:0 to 15>>\n");
                $display("      time=%t; instance=%m (NVM1H)",$realtime);
              end
              QI <= DataX;
              flaga_read_ok = `True;
              flaga_output_ok = `True;
            end
          end
          else begin
              QI <= DataX;
              flaga_read_ok = `True;
              flaga_output_ok = `True;
          end
        end // End of Read operation
      end // MElatched = 1'b1
      else if ( MElatched === 1'bx ) begin
        if( MES_ALL=="ON" && $realtime != 0 ) begin
          $display("<<ME unknown>>");
          $display("      time=%t; instance=%m (NVM1H)",$realtime);
        end
        if ( WElatched !== 1'b0 ) begin
              SOI <= 1'bx;
          QI <= DataX;
          BlastCell(DataX);
        end
        else
          QI <= DataX;
      end // MElatched = 1'bx
    end
   end

 end



always @( OE or QI )
begin
   if ( OE ) begin
     Q <= QI;
   end
   else if ( !OE ) begin
      Q <= DataX;
      #0.01
      Q <= DataZ;
   end
   else begin
      if( MES_ALL=="ON" && $realtime != 0 ) begin
         $display("<<OE unknown>>");
         $display("      time=%t; instance=%m (NVM1H)",$realtime);
      end
      Q <= DataX;
   end
end



endmodule
`endcelldefine