Created
June 13, 2021 17:31
-
-
Save CloudyPadmal/6f9403776aa7b716f678815ac7b3dda0 to your computer and use it in GitHub Desktop.
LUT maker
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
table = [256, 252, 249, 246, 243, 240, 237, 234, 230, 227, 224, 221, 218, 215, 212, \ | |
209, 206, 203, 200, 196, 193, 190, 187, 184, 181, 178, 175, 172, 169, 166, \ | |
164, 161, 158, 155, 152, 149, 146, 143, 141, 138, 135, 132, 130, 127, 124, \ | |
121, 119, 116, 114, 111, 108, 106, 103, 101, 98, 96, 93, 91, 89, 86, 84, 82, \ | |
79, 77, 75, 73, 70, 68, 66, 64, 62, 60, 58, 56, 54, 52, 50, 48, 47, 45, 43, \ | |
41, 40, 38, 36, 35, 33, 32, 30, 29, 27, 26, 25, 23, 22, 21, 19, 18, 17, 16, \ | |
15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 6, 6, 5, 4, 4, 3, 3, 2, 2, 2, 1, 1, 1, \ | |
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4, 5, 6, 6, 7, \ | |
8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 21, 22, 23, 25, 26, 27, 29, \ | |
30, 32, 33, 35, 36, 38, 40, 41, 43, 45, 47, 48, 50, 52, 54, 56, 58, 60, 62, \ | |
64, 66, 68, 70, 73, 75, 77, 79, 82, 84, 86, 89, 91, 93, 96, 98, 101, 103, \ | |
106, 108, 111, 114, 116, 119, 121, 124, 127, 130, 132, 135, 138, 141, 143, \ | |
146, 149, 152, 155, 158, 161, 164, 166, 169, 172, 175, 178, 181, 184, 187, \ | |
190, 193, 196, 200, 203, 206, 209, 212, 215, 218, 221, 224, 227, 230, 234, \ | |
237, 240, 243, 246, 249, 252, 256, 259, 262, 265, 268, 271, 274, 277, 281, \ | |
284, 287, 290, 293, 296, 299, 302, 305, 308, 311, 315, 318, 321, 324, 327, \ | |
330, 333, 336, 339, 342, 345, 347, 350, 353, 356, 359, 362, 365, 368, 370, \ | |
373, 376, 379, 381, 384, 387, 390, 392, 395, 397, 400, 403, 405, 408, 410, \ | |
413, 415, 418, 420, 422, 425, 427, 429, 432, 434, 436, 438, 441, 443, 445, \ | |
447, 449, 451, 453, 455, 457, 459, 461, 463, 464, 466, 468, 470, 471, 473, \ | |
475, 476, 478, 479, 481, 482, 484, 485, 486, 488, 489, 490, 492, 493, 494, \ | |
495, 496, 497, 498, 499, 500, 501, 502, 503, 503, 504, 505, 505, 506, 507, \ | |
507, 508, 508, 509, 509, 509, 510, 510, 510, 511, 511, 511, 511, 511, 511, \ | |
511, 511, 511, 511, 511, 510, 510, 510, 509, 509, 509, 508, 508, 507, 507, \ | |
506, 505, 505, 504, 503, 503, 502, 501, 500, 499, 498, 497, 496, 495, 494, \ | |
493, 492, 490, 489, 488, 486, 485, 484, 482, 481, 479, 478, 476, 475, 473, \ | |
471, 470, 468, 466, 464, 463, 461, 459, 457, 455, 453, 451, 449, 447, 445, \ | |
443, 441, 438, 436, 434, 432, 429, 427, 425, 422, 420, 418, 415, 413, 410, \ | |
408, 405, 403, 400, 397, 395, 392, 390, 387, 384, 381, 379, 376, 373, 370, \ | |
368, 365, 362, 359, 356, 353, 350, 347, 345, 342, 339, 336, 333, 330, 327, \ | |
324, 321, 318, 315, 311, 308, 305, 302, 299, 296, 293, 290, 287, 284, 281, \ | |
277, 274, 271, 268, 265, 262, 259] | |
output = [] | |
ff = open('output.txt', 'w') | |
def processBin(num): | |
l = ['0' for i in range(10)] | |
bn = list("{0:#b}".format(num)[2:]) | |
nl = l[:-len(bn)] + bn | |
nl.reverse() | |
sc = [] | |
for i, n in enumerate(nl): | |
if ((i + 1) % 4 == 0): | |
sc.append(n) | |
sc.append('_') | |
else: | |
sc.append(n) | |
sc.reverse() | |
sc = "10'b" + ''.join(sc) | |
return sc | |
for i, t in enumerate(table): | |
first_line = processBin(i) + ": begin\n" | |
second_line = "\tMAP <= " + str(t) + ";\n" | |
final_line = "\tDMAPNT <= DMAPNT + 1;\nend\n" | |
ff.write(first_line + second_line + final_line) | |
ff.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment