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
|
/*
* yosys -- Yosys Open SYnthesis Suite
*
* Copyright (C) 2021 Cologne Chip AG <support@colognechip.com>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*
*/
`timescale 1ps/1ps
module CC_IBUF #(
parameter PIN_NAME = "UNPLACED",
parameter V_IO = "UNDEFINED",
parameter [0:0] PULLUP = 1'bx,
parameter [0:0] PULLDOWN = 1'bx,
parameter [0:0] KEEPER = 1'bx,
parameter [0:0] SCHMITT_TRIGGER = 1'bx,
// IOSEL
parameter [3:0] DELAY_IBF = 1'bx,
parameter [0:0] FF_IBF = 1'bx
)(
(* iopad_external_pin *)
input I,
output Y
);
assign Y = I;
endmodule
module CC_OBUF #(
parameter PIN_NAME = "UNPLACED",
parameter V_IO = "UNDEFINED",
parameter DRIVE = "UNDEFINED",
parameter SLEW = "UNDEFINED",
// IOSEL
parameter [3:0] DELAY_OBF = 1'bx,
parameter [0:0] FF_OBF = 1'bx
)(
input A,
(* iopad_external_pin *)
output O
);
assign O = A;
endmodule
module CC_TOBUF #(
parameter PIN_NAME = "UNPLACED",
parameter V_IO = "UNDEFINED",
parameter DRIVE = "UNDEFINED",
parameter SLEW = "UNDEFINED",
parameter [0:0] PULLUP = 1'bx,
parameter [0:0] PULLDOWN = 1'bx,
parameter [0:0] KEEPER = 1'bx,
// IOSEL
parameter [3:0] DELAY_OBF = 1'bx,
parameter [0:0] FF_OBF = 1'bx
)(
input A, T,
(* iopad_external_pin *)
output O
);
assign O = T ? 1'bz : A;
endmodule
module CC_IOBUF #(
parameter PIN_NAME = "UNPLACED",
parameter V_IO = "UNDEFINED",
parameter DRIVE = "UNDEFINED",
parameter SLEW = "UNDEFINED",
parameter [0:0] PULLUP = 1'bx,
parameter [0:0] PULLDOWN = 1'bx,
parameter [0:0] KEEPER = 1'bx,
parameter [0:0] SCHMITT_TRIGGER = 1'bx,
// IOSEL
parameter [3:0] DELAY_IBF = 1'bx,
parameter [3:0] DELAY_OBF = 1'bx,
parameter [0:0] FF_IBF = 1'bx,
parameter [0:0] FF_OBF = 1'bx
)(
input A, T,
output Y,
(* iopad_external_pin *)
inout IO
);
assign IO = T ? 1'bz : A;
assign Y = IO;
endmodule
module CC_LVDS_IBUF #(
parameter PIN_NAME_P = "UNPLACED",
parameter PIN_NAME_N = "UNPLACED",
parameter V_IO = "UNDEFINED",
parameter [0:0] LVDS_RTERM = 1'bx,
// IOSEL
parameter [3:0] DELAY_IBF = 1'bx,
parameter [0:0] FF_IBF = 1'bx
)(
(* iopad_external_pin *)
input IP, IN,
output Y
);
assign Y = IP;
endmodule
module CC_LVDS_OBUF #(
parameter PIN_NAME_P = "UNPLACED",
parameter PIN_NAME_N = "UNPLACED",
parameter V_IO = "UNDEFINED",
parameter [0:0] LVDS_BOOST = 1'bx,
// IOSEL
parameter [3:0] DELAY_OBF = 1'bx,
parameter [0:0] FF_OBF = 1'bx
)(
input A,
(* iopad_external_pin *)
output OP, ON
);
assign OP = A;
assign ON = ~A;
endmodule
module CC_LVDS_TOBUF #(
parameter PIN_NAME_P = "UNPLACED",
parameter PIN_NAME_N = "UNPLACED",
parameter V_IO = "UNDEFINED",
parameter [0:0] LVDS_BOOST = 1'bx,
// IOSEL
parameter [3:0] DELAY_OBF = 1'bx,
parameter [0:0] FF_OBF = 1'bx
)(
input A, T,
(* iopad_external_pin *)
output OP, ON
);
assign OP = T ? 1'bz : A;
assign ON = T ? 1'bz : ~A;
endmodule
module CC_LVDS_IOBUF #(
parameter PIN_NAME_P = "UNPLACED",
parameter PIN_NAME_N = "UNPLACED",
parameter V_IO = "UNDEFINED",
parameter [0:0] LVDS_RTERM = 1'bx,
parameter [0:0] LVDS_BOOST = 1'bx,
// IOSEL
parameter [3:0] DELAY_IBF = 1'bx,
parameter [3:0] DELAY_OBF = 1'bx,
parameter [0:0] FF_IBF = 1'bx,
parameter [0:0] FF_OBF = 1'bx
)(
input A, T,
(* iopad_external_pin *)
inout IOP, ION,
output Y
);
assign IOP = T ? 1'bz : A;
assign ION = T ? 1'bz : ~A;
assign Y = IOP;
endmodule
module CC_IDDR #(
parameter [0:0] CLK_INV = 1'b0
)(
input D,
(* clkbuf_sink *)
input CLK,
output reg Q0, Q1
);
wire clk;
assign clk = (CLK_INV) ? ~CLK : CLK;
always @(posedge clk)
begin
Q0 <= D;
end
always @(negedge clk)
begin
Q1 <= D;
end
endmodule
module CC_ODDR #(
parameter [0:0] CLK_INV = 1'b0
)(
input D0,
input D1,
(* clkbuf_sink *)
input CLK,
(* clkbuf_sink *)
input DDR,
output Q
);
wire clk;
assign clk = (CLK_INV) ? ~CLK : CLK;
reg q0, q1;
assign Q = (DDR) ? q0 : q1;
always @(posedge clk)
begin
q0 <= D0;
end
always @(negedge clk)
begin
q1 <= D1;
end
endmodule
module CC_DFF #(
parameter [0:0] CLK_INV = 1'b0,
parameter [0:0] EN_INV = 1'b0,
parameter [0:0] SR_INV = 1'b0,
parameter [0:0] SR_VAL = 1'b0
)(
input D,
(* clkbuf_sink *)
input CLK,
input EN,
input SR,
output reg Q
);
wire clk, en, sr;
assign clk = (CLK_INV) ? ~CLK : CLK;
assign en = (EN_INV) ? ~EN : EN;
assign sr = (SR_INV) ? ~SR : SR;
initial Q = 1'bX;
always @(posedge clk or posedge sr)
begin
if (sr) begin
Q <= SR_VAL;
end
else if (en) begin
Q <= D;
end
end
endmodule
module CC_DLT #(
parameter [0:0] G_INV = 1'b0,
parameter [0:0] SR_INV = 1'b0,
parameter [0:0] SR_VAL = 1'b0
)(
input D,
input G,
input SR,
output reg Q
);
wire en, sr;
assign en = (G_INV) ? ~G : G;
assign sr = (SR_INV) ? ~SR : SR;
initial Q = 1'bX;
always @(*)
begin
if (sr) begin
Q <= SR_VAL;
end
else if (en) begin
Q <= D;
end
end
endmodule
module CC_LUT1 (
output O,
input I0
);
parameter [1:0] INIT = 0;
assign O = I0 ? INIT[1] : INIT[0];
endmodule
module CC_LUT2 (
output O,
input I0, I1
);
parameter [3:0] INIT = 0;
wire [1:0] s1 = I1 ? INIT[3:2] : INIT[1:0];
assign O = I0 ? s1[1] : s1[0];
endmodule
module CC_LUT3 (
output O,
input I0, I1, I2
);
parameter [7:0] INIT = 0;
wire [3:0] s2 = I2 ? INIT[7:4] : INIT[3:0];
wire [1:0] s1 = I1 ? s2[3:2] : s2[1:0];
assign O = I0 ? s1[1] : s1[0];
endmodule
module CC_LUT4 (
output O,
input I0, I1, I2, I3
);
parameter [15:0] INIT = 0;
wire [7:0] s3 = I3 ? INIT[15:8] : INIT[7:0];
wire [3:0] s2 = I2 ? s3[7:4] : s3[3:0];
wire [1:0] s1 = I1 ? s2[3:2] : s2[1:0];
assign O = I0 ? s1[1] : s1[0];
endmodule
module CC_MX2 (
input D0, D1,
input S0,
output Y
);
assign Y = S0 ? D1 : D0;
endmodule
module CC_MX4 (
input D0, D1, D2, D3,
input S0, S1,
output Y
);
assign Y = S1 ? (S0 ? D3 : D2) :
(S0 ? D1 : D0);
endmodule
module CC_MX8 (
input D0, D1, D2, D3,
input D4, D5, D6, D7,
input S0, S1, S2,
output Y
);
assign Y = S2 ? (S1 ? (S0 ? D7 : D6) :
(S0 ? D5 : D4)) :
(S1 ? (S0 ? D3 : D2) :
(S0 ? D1 : D0));
endmodule
module CC_ADDF (
input A, B, CI,
output CO, S
);
assign {CO, S} = A + B + CI;
endmodule
module CC_MULT #(
parameter A_WIDTH = 0,
parameter B_WIDTH = 0,
parameter P_WIDTH = 0
)(
input signed [A_WIDTH-1:0] A,
input signed [B_WIDTH-1:0] B,
output reg signed [P_WIDTH-1:0] P
);
always @(*)
begin
P <= A * B;
end
endmodule
module CC_BUFG (
input I,
(* clkbuf_driver *)
output O
);
assign O = I;
endmodule
module CC_BRAM_20K (
output [19:0] A_DO,
output [19:0] B_DO,
output ECC_1B_ERR,
output ECC_2B_ERR,
(* clkbuf_sink *)
input A_CLK,
(* clkbuf_sink *)
input B_CLK,
input A_EN,
input B_EN,
input A_WE,
input B_WE,
input [15:0] A_ADDR,
input [15:0] B_ADDR,
input [19:0] A_DI,
input [19:0] B_DI,
input [19:0] A_BM,
input [19:0] B_BM
);
// Location format: D(0..N-1)(0..N-1)X(0..3)Y(0..7)Z(0..1) or UNPLACED
parameter LOC = "UNPLACED";
// Port Widths
parameter A_RD_WIDTH = 0;
parameter B_RD_WIDTH = 0;
parameter A_WR_WIDTH = 0;
parameter B_WR_WIDTH = 0;
// RAM and Write Modes
parameter RAM_MODE = "SDP";
parameter A_WR_MODE = "NO_CHANGE";
parameter B_WR_MODE = "NO_CHANGE";
// Inverting Control Pins
parameter A_CLK_INV = 1'b0;
parameter B_CLK_INV = 1'b0;
parameter A_EN_INV = 1'b0;
parameter B_EN_INV = 1'b0;
parameter A_WE_INV = 1'b0;
parameter B_WE_INV = 1'b0;
// Output Register
parameter A_DO_REG = 1'b0;
parameter B_DO_REG = 1'b0;
// Error Checking and Correction
parameter ECC_EN = 1'b0;
// RAM Contents
parameter INIT_00 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_01 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_02 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_03 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_04 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_05 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_06 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_07 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_08 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_09 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_10 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_11 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_12 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_13 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_14 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_15 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_16 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_17 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_18 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_19 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_20 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_21 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_22 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_23 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_24 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_25 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_26 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_27 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_28 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_29 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_30 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_31 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_32 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_33 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_34 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_35 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_36 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_37 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_38 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_39 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
localparam WIDTH_MODE_A = (A_RD_WIDTH > A_WR_WIDTH) ? A_RD_WIDTH : A_WR_WIDTH;
localparam WIDTH_MODE_B = (B_RD_WIDTH > B_WR_WIDTH) ? B_RD_WIDTH : B_WR_WIDTH;
integer i, k;
// 512 x 40 bit
reg [20479:0] memory = 20480'b0;
initial begin
// Check parameters
if ((RAM_MODE != "SDP") && (RAM_MODE != "TDP")) begin
$display("ERROR: Illegal RAM MODE %d.", RAM_MODE);
$finish();
end
if ((A_WR_MODE != "WRITE_THROUGH") && (A_WR_MODE != "NO_CHANGE")) begin
$display("ERROR: Illegal RAM MODE %d.", RAM_MODE);
$finish();
end
if ((RAM_MODE == "SDP") && (A_WR_MODE == "WRITE_THROUGH")) begin
$display("ERROR: %s is not supported in %s mode.", A_WR_MODE, RAM_MODE);
$finish();
end
if (ECC_EN != 1'b0) begin
$display("WARNING: ECC feature not supported in simulation.");
end
if ((ECC_EN == 1'b1) && (RAM_MODE != "SDP") && (WIDTH_MODE_A != 40)) begin
$display("ERROR: Illegal ECC Port configuration. Must be SDP 40 bit, but is %s %d.", RAM_MODE, WIDTH_MODE_A);
$finish();
end
if ((WIDTH_MODE_A == 40) && (RAM_MODE == "TDP")) begin
$display("ERROR: Port A width of 40 bits is only supported in SDP mode.");
$finish();
end
if ((WIDTH_MODE_B == 40) && (RAM_MODE == "TDP")) begin
$display("ERROR: Port B width of 40 bits is only supported in SDP mode.");
$finish();
end
if ((WIDTH_MODE_A != 40) && (WIDTH_MODE_A != 20) && (WIDTH_MODE_A != 10) &&
(WIDTH_MODE_A != 5) && (WIDTH_MODE_A != 2) && (WIDTH_MODE_A != 1) && (WIDTH_MODE_A != 0)) begin
$display("ERROR: Illegal %s Port A width configuration %d.", RAM_MODE, WIDTH_MODE_A);
$finish();
end
if ((WIDTH_MODE_B != 40) && (WIDTH_MODE_B != 20) && (WIDTH_MODE_B != 10) &&
(WIDTH_MODE_B != 5) && (WIDTH_MODE_B != 2) && (WIDTH_MODE_B != 1) && (WIDTH_MODE_B != 0)) begin
$display("ERROR: Illegal %s Port B width configuration %d.", RAM_MODE, WIDTH_MODE_B);
$finish();
end
// RAM initialization
memory[320*0+319:320*0] = INIT_00;
memory[320*1+319:320*1] = INIT_01;
memory[320*2+319:320*2] = INIT_02;
memory[320*3+319:320*3] = INIT_03;
memory[320*4+319:320*4] = INIT_04;
memory[320*5+319:320*5] = INIT_05;
memory[320*6+319:320*6] = INIT_06;
memory[320*7+319:320*7] = INIT_07;
memory[320*8+319:320*8] = INIT_08;
memory[320*9+319:320*9] = INIT_09;
memory[320*10+319:320*10] = INIT_0A;
memory[320*11+319:320*11] = INIT_0B;
memory[320*12+319:320*12] = INIT_0C;
memory[320*13+319:320*13] = INIT_0D;
memory[320*14+319:320*14] = INIT_0E;
memory[320*15+319:320*15] = INIT_0F;
memory[320*16+319:320*16] = INIT_10;
memory[320*17+319:320*17] = INIT_11;
memory[320*18+319:320*18] = INIT_12;
memory[320*19+319:320*19] = INIT_13;
memory[320*20+319:320*20] = INIT_14;
memory[320*21+319:320*21] = INIT_15;
memory[320*22+319:320*22] = INIT_16;
memory[320*23+319:320*23] = INIT_17;
memory[320*24+319:320*24] = INIT_18;
memory[320*25+319:320*25] = INIT_19;
memory[320*26+319:320*26] = INIT_1A;
memory[320*27+319:320*27] = INIT_1B;
memory[320*28+319:320*28] = INIT_1C;
memory[320*29+319:320*29] = INIT_1D;
memory[320*30+319:320*30] = INIT_1E;
memory[320*31+319:320*31] = INIT_1F;
memory[320*32+319:320*32] = INIT_20;
memory[320*33+319:320*33] = INIT_21;
memory[320*34+319:320*34] = INIT_22;
memory[320*35+319:320*35] = INIT_23;
memory[320*36+319:320*36] = INIT_24;
memory[320*37+319:320*37] = INIT_25;
memory[320*38+319:320*38] = INIT_26;
memory[320*39+319:320*39] = INIT_27;
memory[320*40+319:320*40] = INIT_28;
memory[320*41+319:320*41] = INIT_29;
memory[320*42+319:320*42] = INIT_2A;
memory[320*43+319:320*43] = INIT_2B;
memory[320*44+319:320*44] = INIT_2C;
memory[320*45+319:320*45] = INIT_2D;
memory[320*46+319:320*46] = INIT_2E;
memory[320*47+319:320*47] = INIT_2F;
memory[320*48+319:320*48] = INIT_30;
memory[320*49+319:320*49] = INIT_31;
memory[320*50+319:320*50] = INIT_32;
memory[320*51+319:320*51] = INIT_33;
memory[320*52+319:320*52] = INIT_34;
memory[320*53+319:320*53] = INIT_35;
memory[320*54+319:320*54] = INIT_36;
memory[320*55+319:320*55] = INIT_37;
memory[320*56+319:320*56] = INIT_38;
memory[320*57+319:320*57] = INIT_39;
memory[320*58+319:320*58] = INIT_3A;
memory[320*59+319:320*59] = INIT_3B;
memory[320*60+319:320*60] = INIT_3C;
memory[320*61+319:320*61] = INIT_3D;
memory[320*62+319:320*62] = INIT_3E;
memory[320*63+319:320*63] = INIT_3F;
end
// Signal inversion
wire clka = A_CLK_INV ^ A_CLK;
wire clkb = B_CLK_INV ^ B_CLK;
wire ena = A_EN_INV ^ A_EN;
wire enb = B_EN_INV ^ B_EN;
wire wea = A_WE_INV ^ A_WE;
wire web = B_WE_INV ^ B_WE;
// Internal signals
wire [15:0] addra;
wire [15:0] addrb;
reg [19:0] A_DO_out = 0, A_DO_reg = 0;
reg [19:0] B_DO_out = 0, B_DO_reg = 0;
generate
if (RAM_MODE == "SDP") begin
// Port A (write)
if (A_WR_WIDTH == 40) begin
assign addra = A_ADDR[15:7]*40;
end
// Port B (read)
if (B_RD_WIDTH == 40) begin
assign addrb = B_ADDR[15:7]*40;
end
end
else if (RAM_MODE == "TDP") begin
// Port A
if (WIDTH_MODE_A <= 1) begin
wire [15:0] tmpa = {2'b0, A_ADDR[15:7], A_ADDR[5:1]};
assign addra = tmpa + (tmpa/4);
end
else if (WIDTH_MODE_A <= 2) begin
wire [15:0] tmpa = {3'b0, A_ADDR[15:7], A_ADDR[5:2]};
assign addra = tmpa*2 + (tmpa/2);
end
else if (WIDTH_MODE_A <= 5) begin
assign addra = {4'b0, A_ADDR[15:7], A_ADDR[5:3]}*5;
end
else if (WIDTH_MODE_A <= 10) begin
assign addra = {5'b0, A_ADDR[15:7], A_ADDR[5:4]}*10;
end
else if (WIDTH_MODE_A <= 20) begin
assign addra = {6'b0, A_ADDR[15:7], A_ADDR[5]}*20;
end
// Port B
if (WIDTH_MODE_B <= 1) begin
wire [15:0] tmpb = {2'b0, B_ADDR[15:7], B_ADDR[5:1]};
assign addrb = tmpb + (tmpb/4);
end
else if (WIDTH_MODE_B <= 2) begin
wire [15:0] tmpb = {3'b0, B_ADDR[15:7], B_ADDR[5:2]};
assign addrb = tmpb*2 + (tmpb/2);
end
else if (WIDTH_MODE_B <= 5) begin
assign addrb = {4'b0, B_ADDR[15:7], B_ADDR[5:3]}*5;
end
else if (WIDTH_MODE_B <= 10) begin
assign addrb = {5'b0, B_ADDR[15:7], B_ADDR[5:4]}*10;
end
else if (WIDTH_MODE_B <= 20) begin
assign addrb = {6'b0, B_ADDR[15:7], B_ADDR[5]}*20;
end
end
endgenerate
generate
if (RAM_MODE == "SDP") begin
// SDP write port
always @(posedge clka)
begin
for (k=0; k < A_WR_WIDTH; k=k+1) begin
if (k < 20) begin
if (ena && wea && A_BM[k]) memory[addra+k] <= A_DI[k];
end
else begin // use both ports
if (ena && wea && B_BM[k-20]) memory[addra+k] <= B_DI[k-20];
end
end
end
// SDP read port
always @(posedge clkb)
begin
// "NO_CHANGE" only
for (k=0; k < B_RD_WIDTH; k=k+1) begin
if (k < 20) begin
if (enb && !wea) A_DO_out[k] <= memory[addrb+k];
end
else begin // use both ports
if (enb && !wea) B_DO_out[k-20] <= memory[addrb+k];
end
end
end
end
else if (RAM_MODE == "TDP") begin
// TDP port A
always @(posedge clka)
begin
for (i=0; i < WIDTH_MODE_A; i=i+1) begin
if (ena && wea && A_BM[i]) memory[addra+i] <= A_DI[i];
if (A_WR_MODE == "NO_CHANGE") begin
if (ena && !wea) A_DO_out[i] <= memory[addra+i];
end
else if (A_WR_MODE == "WRITE_THROUGH") begin
if (ena) begin
if (wea && A_BM[i]) begin
A_DO_out[i] <= A_DI[i];
end
else begin
A_DO_out[i] <= memory[addra+i];
end
end
end
end
end
// TDP port B
always @(posedge clkb)
begin
for (i=0; i < WIDTH_MODE_B; i=i+1) begin
if (enb && web && B_BM[i]) memory[addrb+i] <= B_DI[i];
if (B_WR_MODE == "NO_CHANGE") begin
if (enb && !web) B_DO_out[i] <= memory[addrb+i];
end
else if (B_WR_MODE == "WRITE_THROUGH") begin
if (enb) begin
if (web && B_BM[i]) begin
B_DO_out[i] <= B_DI[i];
end
else begin
B_DO_out[i] <= memory[addrb+i];
end
end
end
end
end
end
endgenerate
// Optional output register
generate
if (A_DO_REG) begin
always @(posedge clka) begin
A_DO_reg <= A_DO_out;
end
assign A_DO = A_DO_reg;
end
else begin
assign A_DO = A_DO_out;
end
if (B_DO_REG) begin
always @(posedge clkb) begin
B_DO_reg <= B_DO_out;
end
assign B_DO = B_DO_reg;
end
else begin
assign B_DO = B_DO_out;
end
endgenerate
endmodule
module CC_BRAM_40K (
output [39:0] A_DO,
output [39:0] B_DO,
output A_ECC_1B_ERR,
output B_ECC_1B_ERR,
output A_ECC_2B_ERR,
output B_ECC_2B_ERR,
output reg A_CO = 0,
output reg B_CO = 0,
(* clkbuf_sink *)
input A_CLK,
(* clkbuf_sink *)
input B_CLK,
input A_EN,
input B_EN,
input A_WE,
input B_WE,
input [15:0] A_ADDR,
input [15:0] B_ADDR,
input [39:0] A_DI,
input [39:0] B_DI,
input [39:0] A_BM,
input [39:0] B_BM,
input A_CI,
input B_CI
);
// Location format: D(0..N-1)X(0..3)Y(0..7) or UNPLACED
parameter LOC = "UNPLACED";
parameter CAS = "NONE"; // NONE, UPPER, LOWER
// Port Widths
parameter A_RD_WIDTH = 0;
parameter B_RD_WIDTH = 0;
parameter A_WR_WIDTH = 0;
parameter B_WR_WIDTH = 0;
// RAM and Write Modes
parameter RAM_MODE = "SDP";
parameter A_WR_MODE = "NO_CHANGE";
parameter B_WR_MODE = "NO_CHANGE";
// Inverting Control Pins
parameter A_CLK_INV = 1'b0;
parameter B_CLK_INV = 1'b0;
parameter A_EN_INV = 1'b0;
parameter B_EN_INV = 1'b0;
parameter A_WE_INV = 1'b0;
parameter B_WE_INV = 1'b0;
// Output Register
parameter A_DO_REG = 1'b0;
parameter B_DO_REG = 1'b0;
// Error Checking and Correction
parameter A_ECC_EN = 1'b0;
parameter B_ECC_EN = 1'b0;
parameter INIT_00 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_01 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_02 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_03 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_04 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_05 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_06 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_07 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_08 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_09 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_0F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_10 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_11 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_12 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_13 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_14 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_15 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_16 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_17 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_18 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_19 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_1F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_20 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_21 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_22 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_23 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_24 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_25 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_26 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_27 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_28 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_29 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_2F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_30 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_31 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_32 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_33 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_34 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_35 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_36 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_37 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_38 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_39 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_3F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_40 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_41 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_42 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_43 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_44 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_45 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_46 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_47 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_48 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_49 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_4A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_4B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_4C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_4D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_4E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_4F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_50 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_51 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_52 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_53 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_54 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_55 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_56 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_57 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_58 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_59 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_5A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_5B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_5C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_5D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_5E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_5F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_60 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_61 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_62 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_63 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_64 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_65 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_66 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_67 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_68 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_69 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_6A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_6B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_6C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_6D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_6E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_6F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_70 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_71 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_72 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_73 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_74 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_75 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_76 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_77 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_78 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_79 = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_7A = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_7B = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_7C = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_7D = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_7E = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
parameter INIT_7F = 320'h00000000000000000000000000000000000000000000000000000000000000000000000000000000;
localparam WIDTH_MODE_A = (A_RD_WIDTH > A_WR_WIDTH) ? A_RD_WIDTH : A_WR_WIDTH;
localparam WIDTH_MODE_B = (B_RD_WIDTH > B_WR_WIDTH) ? B_RD_WIDTH : B_WR_WIDTH;
integer i, k;
// 512 x 80 bit
reg [40959:0] memory = 40960'b0;
initial begin
// Check parameters
if ((RAM_MODE != "SDP") && (RAM_MODE != "TDP")) begin
$display("ERROR: Illegal RAM MODE %d.", RAM_MODE);
$finish();
end
if ((A_WR_MODE != "WRITE_THROUGH") && (A_WR_MODE != "NO_CHANGE")) begin
$display("ERROR: Illegal RAM MODE %d.", RAM_MODE);
$finish();
end
if ((RAM_MODE == "SDP") && (A_WR_MODE == "WRITE_THROUGH")) begin
$display("ERROR: %s is not supported in %s mode.", A_WR_MODE, RAM_MODE);
$finish();
end
if ((A_ECC_EN != 1'b0) || (B_ECC_EN != 1'b0)) begin
$display("WARNING: ECC feature not supported in simulation.");
end
if ((A_ECC_EN == 1'b1) && (RAM_MODE != "SDP") && (WIDTH_MODE_A != 40)) begin
$display("ERROR: Illegal ECC Port A configuration. Must be SDP 40 bit, but is %s %d.", RAM_MODE, WIDTH_MODE_A);
$finish();
end
if ((WIDTH_MODE_A == 80) && (RAM_MODE == "TDP")) begin
$display("ERROR: Port A width of 80 bits is only supported in SDP mode.");
$finish();
end
if ((WIDTH_MODE_B == 80) && (RAM_MODE == "TDP")) begin
$display("ERROR: Port B width of 80 bits is only supported in SDP mode.");
$finish();
end
if ((WIDTH_MODE_A != 80) && (WIDTH_MODE_A != 40) && (WIDTH_MODE_A != 20) && (WIDTH_MODE_A != 10) &&
(WIDTH_MODE_A != 5) && (WIDTH_MODE_A != 2) && (WIDTH_MODE_A != 1) && (WIDTH_MODE_A != 0)) begin
$display("ERROR: Illegal %s Port A width configuration %d.", RAM_MODE, WIDTH_MODE_A);
$finish();
end
if ((WIDTH_MODE_B != 80) && (WIDTH_MODE_B != 40) && (WIDTH_MODE_B != 20) && (WIDTH_MODE_B != 10) &&
(WIDTH_MODE_B != 5) && (WIDTH_MODE_B != 2) && (WIDTH_MODE_B != 1) && (WIDTH_MODE_B != 0)) begin
$display("ERROR: Illegal %s Port B width configuration %d.", RAM_MODE, WIDTH_MODE_B);
$finish();
end
if ((CAS != "NONE") && ((WIDTH_MODE_A > 1) || (WIDTH_MODE_B > 1))) begin
$display("ERROR: Cascade feature only supported in 1 bit data width mode.");
$finish();
end
if ((CAS != "NONE") && (RAM_MODE != "TDP")) begin
$display("ERROR: Cascade feature only supported in TDP mode.");
$finish();
end
// RAM initialization
memory[320*0+319:320*0] = INIT_00;
memory[320*1+319:320*1] = INIT_01;
memory[320*2+319:320*2] = INIT_02;
memory[320*3+319:320*3] = INIT_03;
memory[320*4+319:320*4] = INIT_04;
memory[320*5+319:320*5] = INIT_05;
memory[320*6+319:320*6] = INIT_06;
memory[320*7+319:320*7] = INIT_07;
memory[320*8+319:320*8] = INIT_08;
memory[320*9+319:320*9] = INIT_09;
memory[320*10+319:320*10] = INIT_0A;
memory[320*11+319:320*11] = INIT_0B;
memory[320*12+319:320*12] = INIT_0C;
memory[320*13+319:320*13] = INIT_0D;
memory[320*14+319:320*14] = INIT_0E;
memory[320*15+319:320*15] = INIT_0F;
memory[320*16+319:320*16] = INIT_10;
memory[320*17+319:320*17] = INIT_11;
memory[320*18+319:320*18] = INIT_12;
memory[320*19+319:320*19] = INIT_13;
memory[320*20+319:320*20] = INIT_14;
memory[320*21+319:320*21] = INIT_15;
memory[320*22+319:320*22] = INIT_16;
memory[320*23+319:320*23] = INIT_17;
memory[320*24+319:320*24] = INIT_18;
memory[320*25+319:320*25] = INIT_19;
memory[320*26+319:320*26] = INIT_1A;
memory[320*27+319:320*27] = INIT_1B;
memory[320*28+319:320*28] = INIT_1C;
memory[320*29+319:320*29] = INIT_1D;
memory[320*30+319:320*30] = INIT_1E;
memory[320*31+319:320*31] = INIT_1F;
memory[320*32+319:320*32] = INIT_20;
memory[320*33+319:320*33] = INIT_21;
memory[320*34+319:320*34] = INIT_22;
memory[320*35+319:320*35] = INIT_23;
memory[320*36+319:320*36] = INIT_24;
memory[320*37+319:320*37] = INIT_25;
memory[320*38+319:320*38] = INIT_26;
memory[320*39+319:320*39] = INIT_27;
memory[320*40+319:320*40] = INIT_28;
memory[320*41+319:320*41] = INIT_29;
memory[320*42+319:320*42] = INIT_2A;
memory[320*43+319:320*43] = INIT_2B;
memory[320*44+319:320*44] = INIT_2C;
memory[320*45+319:320*45] = INIT_2D;
memory[320*46+319:320*46] = INIT_2E;
memory[320*47+319:320*47] = INIT_2F;
memory[320*48+319:320*48] = INIT_30;
memory[320*49+319:320*49] = INIT_31;
memory[320*50+319:320*50] = INIT_32;
memory[320*51+319:320*51] = INIT_33;
memory[320*52+319:320*52] = INIT_34;
memory[320*53+319:320*53] = INIT_35;
memory[320*54+319:320*54] = INIT_36;
memory[320*55+319:320*55] = INIT_37;
memory[320*56+319:320*56] = INIT_38;
memory[320*57+319:320*57] = INIT_39;
memory[320*58+319:320*58] = INIT_3A;
memory[320*59+319:320*59] = INIT_3B;
memory[320*60+319:320*60] = INIT_3C;
memory[320*61+319:320*61] = INIT_3D;
memory[320*62+319:320*62] = INIT_3E;
memory[320*63+319:320*63] = INIT_3F;
memory[320*64+319:320*64] = INIT_40;
memory[320*65+319:320*65] = INIT_41;
memory[320*66+319:320*66] = INIT_42;
memory[320*67+319:320*67] = INIT_43;
memory[320*68+319:320*68] = INIT_44;
memory[320*69+319:320*69] = INIT_45;
memory[320*70+319:320*70] = INIT_46;
memory[320*71+319:320*71] = INIT_47;
memory[320*72+319:320*72] = INIT_48;
memory[320*73+319:320*73] = INIT_49;
memory[320*74+319:320*74] = INIT_4A;
memory[320*75+319:320*75] = INIT_4B;
memory[320*76+319:320*76] = INIT_4C;
memory[320*77+319:320*77] = INIT_4D;
memory[320*78+319:320*78] = INIT_4E;
memory[320*79+319:320*79] = INIT_4F;
memory[320*80+319:320*80] = INIT_50;
memory[320*81+319:320*81] = INIT_51;
memory[320*82+319:320*82] = INIT_52;
memory[320*83+319:320*83] = INIT_53;
memory[320*84+319:320*84] = INIT_54;
memory[320*85+319:320*85] = INIT_55;
memory[320*86+319:320*86] = INIT_56;
memory[320*87+319:320*87] = INIT_57;
memory[320*88+319:320*88] = INIT_58;
memory[320*89+319:320*89] = INIT_59;
memory[320*90+319:320*90] = INIT_5A;
memory[320*91+319:320*91] = INIT_5B;
memory[320*92+319:320*92] = INIT_5C;
memory[320*93+319:320*93] = INIT_5D;
memory[320*94+319:320*94] = INIT_5E;
memory[320*95+319:320*95] = INIT_5F;
memory[320*96+319:320*96] = INIT_60;
memory[320*97+319:320*97] = INIT_61;
memory[320*98+319:320*98] = INIT_62;
memory[320*99+319:320*99] = INIT_63;
memory[320*100+319:320*100] = INIT_64;
memory[320*101+319:320*101] = INIT_65;
memory[320*102+319:320*102] = INIT_66;
memory[320*103+319:320*103] = INIT_67;
memory[320*104+319:320*104] = INIT_68;
memory[320*105+319:320*105] = INIT_69;
memory[320*106+319:320*106] = INIT_6A;
memory[320*107+319:320*107] = INIT_6B;
memory[320*108+319:320*108] = INIT_6C;
memory[320*109+319:320*109] = INIT_6D;
memory[320*110+319:320*110] = INIT_6E;
memory[320*111+319:320*111] = INIT_6F;
memory[320*112+319:320*112] = INIT_70;
memory[320*113+319:320*113] = INIT_71;
memory[320*114+319:320*114] = INIT_72;
memory[320*115+319:320*115] = INIT_73;
memory[320*116+319:320*116] = INIT_74;
memory[320*117+319:320*117] = INIT_75;
memory[320*118+319:320*118] = INIT_76;
memory[320*119+319:320*119] = INIT_77;
memory[320*120+319:320*120] = INIT_78;
memory[320*121+319:320*121] = INIT_79;
memory[320*122+319:320*122] = INIT_7A;
memory[320*123+319:320*123] = INIT_7B;
memory[320*124+319:320*124] = INIT_7C;
memory[320*125+319:320*125] = INIT_7D;
memory[320*126+319:320*126] = INIT_7E;
memory[320*127+319:320*127] = INIT_7F;
end
// Signal inversion
wire clka = A_CLK_INV ^ A_CLK;
wire clkb = B_CLK_INV ^ B_CLK;
wire ena = A_EN_INV ^ A_EN;
wire enb = B_EN_INV ^ B_EN;
wire wea = A_WE_INV ^ A_WE;
wire web = B_WE_INV ^ B_WE;
// Internal signals
wire [15:0] addra;
wire [15:0] addrb;
reg [39:0] A_DO_out = 0, A_DO_reg = 0;
reg [39:0] B_DO_out = 0, B_DO_reg = 0;
generate
if (RAM_MODE == "SDP") begin
// Port A (write)
if (A_WR_WIDTH == 80) begin
assign addra = A_ADDR[15:7]*80;
end
// Port B (read)
if (B_RD_WIDTH == 80) begin
assign addrb = B_ADDR[15:7]*80;
end
end
else if (RAM_MODE == "TDP") begin
// Port A
if (WIDTH_MODE_A <= 1) begin
wire [15:0] tmpa = {1'b0, A_ADDR[15:1]};
assign addra = tmpa + (tmpa/4);
end
else if (WIDTH_MODE_A <= 2) begin
wire [15:0] tmpa = {2'b0, A_ADDR[15:2]};
assign addra = tmpa*2 + (tmpa/2);
end
else if (WIDTH_MODE_A <= 5) begin
assign addra = {3'b0, A_ADDR[15:3]}*5;
end
else if (WIDTH_MODE_A <= 10) begin
assign addra = {4'b0, A_ADDR[15:4]}*10;
end
else if (WIDTH_MODE_A <= 20) begin
assign addra = {5'b0, A_ADDR[15:5]}*20;
end
else if (WIDTH_MODE_A <= 40) begin
assign addra = {6'b0, A_ADDR[15:6]}*40;
end
// Port B
if (WIDTH_MODE_B <= 1) begin
wire [15:0] tmpb = {1'b0, B_ADDR[15:1]};
assign addrb = tmpb + (tmpb/4);
end
else if (WIDTH_MODE_B <= 2) begin
wire [15:0] tmpb = {2'b0, B_ADDR[15:2]};
assign addrb = tmpb*2 + (tmpb/2);
end
else if (WIDTH_MODE_B <= 5) begin
assign addrb = {3'b0, B_ADDR[15:3]}*5;
end
else if (WIDTH_MODE_B <= 10) begin
assign addrb = {4'b0, B_ADDR[15:4]}*10;
end
else if (WIDTH_MODE_B <= 20) begin
assign addrb = {5'b0, B_ADDR[15:5]}*20;
end
else if (WIDTH_MODE_B <= 40) begin
assign addrb = {6'b0, B_ADDR[15:6]}*40;
end
end
endgenerate
generate
if (RAM_MODE == "SDP") begin
// SDP write port
always @(posedge clka)
begin
for (k=0; k < A_WR_WIDTH; k=k+1) begin
if (k < 40) begin
if (ena && wea && A_BM[k]) memory[addra+k] <= A_DI[k];
end
else begin // use both ports
if (ena && wea && B_BM[k-40]) memory[addra+k] <= B_DI[k-40];
end
end
end
// SDP read port
always @(posedge clkb)
begin
// "NO_CHANGE" only
for (k=0; k < B_RD_WIDTH; k=k+1) begin
if (k < 40) begin
if (enb && !wea) A_DO_out[k] <= memory[addrb+k];
end
else begin // use both ports
if (enb && !wea) B_DO_out[k-40] <= memory[addrb+k];
end
end
end
end
else if (RAM_MODE == "TDP") begin
// {A,B}_ADDR[0]=0 selects lower, {A,B}_ADDR[0]=1 selects upper cascade memory
wire upper_sel_a = ((CAS == "UPPER") && (A_ADDR[0] == 1));
wire lower_sel_a = ((CAS == "LOWER") && (A_ADDR[0] == 0));
wire upper_sel_b = ((CAS == "UPPER") && (B_ADDR[0] == 1));
wire lower_sel_b = ((CAS == "LOWER") && (B_ADDR[0] == 0));
reg dumm;
// Cascade output port A
always @(*)
begin
if ((A_WR_MODE == "NO_CHANGE") && lower_sel_a) begin
A_CO = memory[addra];
end
else if ((A_WR_MODE == "WRITE_THROUGH") && lower_sel_a) begin
A_CO = ((wea && A_BM[0]) ? (A_DI[0]) : (memory[addra]));
end
end
// Cascade output port B
always @(*)
begin
if ((B_WR_MODE == "NO_CHANGE") && lower_sel_b) begin
B_CO = memory[addrb];
end
else if ((B_WR_MODE == "WRITE_THROUGH") && lower_sel_b) begin
B_CO = ((web && B_BM[0]) ? (B_DI[0]) : (memory[addrb]));
end
end
// TDP port A
always @(posedge clka)
begin
for (i=0; i < WIDTH_MODE_A; i=i+1) begin
if (upper_sel_a || lower_sel_a || (CAS == "NONE")) begin
if (ena && wea && A_BM[i])
memory[addra+i] <= A_DI[i];
end
if (A_WR_MODE == "NO_CHANGE") begin
if (ena && !wea) begin
if (CAS == "UPPER") begin
A_DO_out[i] <= ((A_ADDR[0] == 1) ? (memory[addra+i]) : (A_CI));
end
else if (CAS == "NONE") begin
A_DO_out[i] <= memory[addra+i];
end
end
end
else if (A_WR_MODE == "WRITE_THROUGH") begin
if (ena) begin
if (CAS == "UPPER") begin
if (A_ADDR[0] == 1) begin
A_DO_out[i] <= ((wea && A_BM[i]) ? (A_DI[i]) : (memory[addra+i]));
end else begin
A_DO_out[i] <= A_CI;
end
end
else if (CAS == "NONE") begin
A_DO_out[i] <= ((wea && A_BM[i]) ? (A_DI[i]) : (memory[addra+i]));
end
end
end
end
end
// TDP port B
always @(posedge clkb)
begin
for (i=0; i < WIDTH_MODE_B; i=i+1) begin
if (upper_sel_b || lower_sel_b || (CAS == "NONE")) begin
if (enb && web && B_BM[i])
memory[addrb+i] <= B_DI[i];
end
if (B_WR_MODE == "NO_CHANGE") begin
if (enb && !web) begin
if (CAS == "UPPER") begin
B_DO_out[i] <= ((B_ADDR[0] == 1) ? (memory[addrb+i]) : (B_CI));
end
else if (CAS == "NONE") begin
B_DO_out[i] <= memory[addrb+i];
end
end
end
else if (B_WR_MODE == "WRITE_THROUGH") begin
if (enb) begin
if (CAS == "UPPER") begin
if (B_ADDR[0] == 1) begin
B_DO_out[i] <= ((web && B_BM[i]) ? (B_DI[i]) : (memory[addrb+i]));
end else begin
B_DO_out[i] <= B_CI;
end
end
else if (CAS == "NONE") begin
B_DO_out[i] <= ((web && B_BM[i]) ? (B_DI[i]) : (memory[addrb+i]));
end
end
end
end
end
end
endgenerate
// Optional output register
generate
if (A_DO_REG) begin
always @(posedge clka) begin
A_DO_reg <= A_DO_out;
end
assign A_DO = A_DO_reg;
end
else begin
assign A_DO = A_DO_out;
end
if (B_DO_REG) begin
always @(posedge clkb) begin
B_DO_reg <= B_DO_out;
end
assign B_DO = B_DO_reg;
end
else begin
assign B_DO = B_DO_out;
end
endgenerate
endmodule
// Models of the LUT2 tree primitives
module CC_L2T4(
output O,
input I0, I1, I2, I3
);
parameter [3:0] INIT_L00 = 4'b0000;
parameter [3:0] INIT_L01 = 4'b0000;
parameter [3:0] INIT_L10 = 4'b0000;
wire [1:0] l00_s1 = I1 ? INIT_L00[3:2] : INIT_L00[1:0];
wire l00 = I0 ? l00_s1[1] : l00_s1[0];
wire [1:0] l01_s1 = I3 ? INIT_L01[3:2] : INIT_L01[1:0];
wire l01 = I2 ? l01_s1[1] : l01_s1[0];
wire [1:0] l10_s1 = l01 ? INIT_L10[3:2] : INIT_L10[1:0];
assign O = l00 ? l10_s1[1] : l10_s1[0];
endmodule
module CC_L2T5(
output O,
input I0, I1, I2, I3, I4
);
parameter [3:0] INIT_L02 = 4'b0000;
parameter [3:0] INIT_L03 = 4'b0000;
parameter [3:0] INIT_L11 = 4'b0000;
parameter [3:0] INIT_L20 = 4'b0000;
wire [1:0] l02_s1 = I1 ? INIT_L02[3:2] : INIT_L02[1:0];
wire l02 = I0 ? l02_s1[1] : l02_s1[0];
wire [1:0] l03_s1 = I3 ? INIT_L03[3:2] : INIT_L03[1:0];
wire l03 = I2 ? l03_s1[1] : l03_s1[0];
wire [1:0] l11_s1 = l03 ? INIT_L11[3:2] : INIT_L11[1:0];
wire l11 = l02 ? l11_s1[1] : l11_s1[0];
wire [1:0] l20_s1 = l11 ? INIT_L20[3:2] : INIT_L20[1:0];
assign O = I4 ? l20_s1[1] : l20_s1[0];
endmodule
|