diff --git a/verilog/dv/edabk_firmware_demo/SNN_data.c b/verilog/dv/edabk_firmware_demo/SNN_data.c index 28e4823..be90380 100644 --- a/verilog/dv/edabk_firmware_demo/SNN_data.c +++ b/verilog/dv/edabk_firmware_demo/SNN_data.c @@ -2,213 +2,239 @@ #include "SNN_data.h" +#define NUM_CORES 5 +#define NEURONS_PER_CORE 32 +#define AXONS_PER_CORE 256 + +typedef struct { + int8_t membrane_potential; + int8_t reset_posi_potential; + int8_t reset_nega_potential; + int8_t weights[4]; + int8_t leakage_value; + int8_t positive_threshold; + int8_t negative_threshold; + uint8_t axon_dest; +} Neuron; + +typedef struct { + Neuron neurons[NEURONS_PER_CORE]; + uint32_t synapse_connection[AXONS_PER_CORE]; +} Core; + +typedef struct { + int8_t dx; + int8_t dy; + uint8_t axon_dest; +} Packet; + Core cores[NUM_CORES] = { { // Core 0 .neurons = { - { 0, 0, -23, {0, 0, -19, 0}, 0, -18, 0, 0 }, - { -17, 0, 0, {-16, 1, 0, 5}, 1, 0, 6, 1 }, - { 0, 7, 1, {0, 8, 1, 0}, 9, 1, 0, 10 }, - { 1, 0, 11, {1, 0, 12, 1}, 0, 13, 1, 0 }, - { 14, 1, 0, {15, 1, 0, 16}, 1, 0, 33, 1 }, - { 0, 34, 1, {0, 35, 1, 0}, 36, 1, 0, 37 }, - { 1, 0, 38, {1, 0, 39, 1}, 0, 40, 1, 0 }, - { 41, 1, 0, {42, 1, 0, 43}, 1, 0, 44, 1 }, - { 0, 57, 1, {0, 61, 1, 0}, 62, 1, 0, 63 }, - { 1, 0, 64, {1, 0, 84, 1}, 0, 85, 1, 0 }, - { 111, 1, 0, {112, 1, 0, 113}, 1, 0, -118, 1 }, - { 0, -117, 1, {0, -116, 1, 0}, -90, 1, 0, 167 }, - { 1, 0, -63, {1, 0, -62, 1}, 0, -61, 1, 0 }, - { -35, 1, 0, {-34, 1, 0, -33}, 1, 0, -7, 1 }, - { 0, -6, 1, {0, -5, 1, 0}, -4, 1, 0, 253 }, - { 1, 0, -2, {2, 0, 17, 2}, 0, 18, 2, 0 }, - { 19, 2, 0, {45, 2, 0, 46}, 2, 0, 47, 2 }, - { 0, 73, 2, {0, 74, 2, 0}, 75, 2, 0, 76 }, - { 2, 0, 77, {2, 0, 78, 2}, 0, 101, 2, 0 }, - { 102, 2, 0, {103, 2, 0, 104}, 2, 0, 105, 2 }, - { 0, 106, 2, {0, 107, 2, 0}, 108, 2, 0, 109 }, - { 2, 0, 110, {2, 0, 111, 2}, 0, 112, 2, 0 }, - { 113, 2, 0, {114, 2, 0, -125}, 2, 0, -124, 2 }, - { 0, -123, 2, {0, -122, 2, 0}, -121, 2, 0, 136 }, - { 2, 0, -119, {2, 0, -118, 2}, 0, -117, 2, 0 }, - { -116, 2, 0, {-115, 2, 0, -114}, 2, 0, -93, 2 }, - { 0, -92, 2, {0, -91, 2, 0}, -90, 2, 0, 167 }, - { 2, 0, -88, {2, 0, -87, 2}, 0, -86, 2, 0 }, - { -85, 2, 0, {-64, 2, 0, -63}, 2, 0, -62, 2 }, - { 0, -60, 2, {0, -59, 2, 0}, -58, 2, 0, 199 }, - { 2, 0, -36, {2, 0, -35, 2}, 0, -34, 2, 0 }, - { -33, 2, 0, {-32, 2, 0, -31}, 2, 0, -30, 2 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 0 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 1 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 2 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 3 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 4 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 5 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 6 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 7 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, + { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, }, .synapse_connection = { - 0x0002E300, - 0xF90002F8, - 0x02FA0002, - 0x0002FB00, - 0xFD0002FC, - 0x03FE0002, - 0x00031000, - 0x12000311, - 0x03140003, - 0x00031500, - 0x17000316, - 0x032C0003, - 0x00032D00, - 0x2F00032E, - 0x03300003, - 0x00033100, - 0x33000332, - 0x03480003, - 0x00034900, - 0x4B00034A, - 0x034C0003, - 0x00034D00, - 0x6500034E, - 0x03660003, - 0x00036700, - 0x69000368, - 0x00830003, - 0x0000D300, - 0xD50000D4, - 0x00EC0000, - 0x0000ED00, - 0xEF0000EE, - 0x00F00000, - 0x0000F100, - 0xF30000F2, - 0x00F40000, - 0x0001F500, - 0x24000123, - 0x01250001, - 0x00013C00, - 0x3E00013D, - 0x013F0001, - 0x00014000, - 0x42000141, - 0x01430001, - 0x00014400, - 0x56000145, - 0x01570001, - 0x00015800, - 0x5A000159, - 0x015B0001, - 0x00015C00, - 0x5E00015D, - 0x015F0001, - 0x00016000, - 0x70000161, - 0x01710001, - 0x00017200, - 0x74000173, - 0x01750001, - 0x00017900, - 0x7C00017B, - 0x017D0001, - 0x00017E00, - 0x8D00018C, - 0x018E0001, - 0x00018F00, - 0x98000195, - 0x01990001, - 0x00019A00, - 0xA80001A7, - 0x01A90001, - 0x0001B200, - 0xB40001B3, - 0x01B50001, - 0x0001B600, - 0xC40001C3, - 0x01C50001, - 0x0001C700, - 0xC90001C8, - 0x01CA0001, - 0x0001CB00, - 0xCD0001CC, - 0x01CE0001, - 0x0001CF00, - 0xD10001D0, - 0x01DF0001, - 0x0001E000, - 0xE20001E1, - 0x01E30001, - 0x0001E400, - 0xE60001E5, - 0x01E70001, - 0x0001E800, - 0xEA0001E9, - 0x01EB0001, - 0x0001EC00, - 0xFE0001FD, - 0x02FF0001, - 0x00020200, - 0x04000203, - 0x02050002, - 0x00020600, - 0x14000213, - 0x02150002, - 0x00021700, - 0x19000218, - 0x021A0002, - 0x00021B00, - 0x1D00021C, - 0x021E0002, - 0x00021F00, - 0x21000220, - 0x022F0002, - 0x00023000, - 0x32000231, - 0x02330002, - 0x00023400, - 0x36000235, - 0x02370002, - 0x00023800, - 0x3A000239, - 0x023B0002, - 0x00023C00, - 0x4E00024D, - 0x024F0002, - 0x00025000, - 0x52000251, - 0x02530002, - 0x00025400, - 0x56000255, - 0x02570002, - 0x00026E00, - 0x7000026F, - 0x02710002, - 0x00028A00, - 0x8C00028B, - 0x02A50002, - 0x0002A600, - 0xA80002A7, - 0x02C00002, - 0x0002C100, - 0xC30002C2, - 0x02DB0002, - 0x0002DC00, - 0xDE0002DD, - 0x02F70002, - 0x0002F800, - 0xFA0002F9, - 0x03100003, - 0x00031100, - 0x13000312, - 0x032B0003, - 0x00032C00, - 0x2E00032D, - 0x03470003, - 0x00034800, - 0x4A000349, - 0x03620003, - 0x00036300, - 0x65000364, - 0x037E0003, - 0x00037F00, - 0x99000380, - 0x039A0003, - 0x00039B00, - 0xB500039C, - 0x03B60003, - 0x0003B700, + 0x000000DF, + 0x0000000C, + 0x00000073, + 0x00000060, + 0x000000BE, + 0x00000061, + 0x00000096, + 0x00000028, + 0x00000096, + 0x000000E8, + 0x00000097, + 0x00000009, + 0x000000F2, + 0x00000048, + 0x00000070, + 0x0000000B, + 0x000000DC, + 0x00000000, + 0x000000DE, + 0x00000066, + 0x00000061, + 0x000000FA, + 0x00000005, + 0x000000F2, + 0x0000003F, + 0x000000A0, + 0x00000061, + 0x0000009C, + 0x00000073, + 0x0000008B, + 0x0000005B, + 0x0000002A, + 0x00000017, + 0x00000061, + 0x0000001B, + 0x00000032, + 0x00000096, + 0x000000B1, + 0x000000D1, + 0x00000005, + 0x000000BA, + 0x00000047, + 0x000000B4, + 0x00000003, + 0x000000FC, + 0x00000002, + 0x000000AE, + 0x000000D4, + 0x00000020, + 0x000000F7, + 0x00000015, + 0x0000008A, + 0x000000B5, + 0x000000C2, + 0x00000075, + 0x00000090, + 0x000000F4, + 0x0000003A, + 0x0000008F, + 0x00000059, + 0x00000001, + 0x00000020, + 0x000000FA, + 0x00000020, + 0x00000053, + 0x000000F4, + 0x00000016, + 0x0000006D, + 0x00000040, + 0x00000006, + 0x00000015, 0x000000D2, + 0x0000004C, + 0x00000072, + 0x00000029, + 0x00000065, + 0x00000023, + 0x000000D6, + 0x00000001, + 0x0000008A, + 0x00000065, + 0x00000098, + 0x00000065, + 0x000000BA, + 0x00000075, + 0x0000008B, + 0x0000002B, + 0x000000AF, + 0x00000003, + 0x000000F8, + 0x0000001B, + 0x00000069, + 0x00000090, + 0x00000063, + 0x00000000, + 0x000000F6, + 0x00000041, + 0x000000B6, + 0x00000005, + 0x00000092, + 0x0000006F, + 0x000000D0, + 0x0000001B, + 0x00000055, + 0x00000009, + 0x000000F5, + 0x00000045, + 0x00000082, + 0x00000065, + 0x0000009A, + 0x00000074, + 0x0000009A, + 0x0000002F, + 0x000000EC, + 0x0000007C, + 0x0000009D, + 0x000000F5, + 0x00000070, + 0x0000009F, + 0x00000068, + 0x00000011, + 0x000000E6, + 0x00000010, + 0x000000B6, + 0x00000041, + 0x000000EF, + 0x00000049, + 0x00000036, + 0x00000069, + 0x00000030, + 0x000000E3, + 0x000000DE, + 0x00000085, + 0x000000D6, + 0x00000025, + 0x0000009E, + 0x00000065, + 0x00000032, + 0x0000006D, + 0x0000008A, + 0x000000D8, + 0x00000071, + 0x00000002, + 0x0000005D, + 0x000000D1, + 0x00000098, + 0x0000008E, + 0x000000AB, + 0x0000009C, + 0x000000AC, + 0x00000043, + 0x000000AA, + 0x00000056, + 0x00000033, + 0x00000009, + 0x000000B6, + 0x0000004B, + 0x000000F4, + 0x00000063, + 0x000000FC, + 0x00000020, + 0x000000AE, + 0x00000049, + 0x0000009E, + 0x00000025, + 0x000000B2, + 0x00000065, + 0x00000050, + 0x00000076, + 0x00000007, 0x000000F1, 0x000000AC, 0x000000FB, @@ -299,14 +325,14 @@ Core cores[NUM_CORES] = { }, { // Core 1 .neurons = { - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 64 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 65 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 66 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 67 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 68 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 69 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 70 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 71 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 64 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 65 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 66 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 67 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 68 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 69 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 70 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 71 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, @@ -593,14 +619,14 @@ Core cores[NUM_CORES] = { }, { // Core 2 .neurons = { - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 72 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 73 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 74 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 75 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 76 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 77 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 78 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 79 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 72 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 73 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 74 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 75 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 76 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 77 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 78 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 79 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, @@ -887,14 +913,14 @@ Core cores[NUM_CORES] = { }, { // Core 3 .neurons = { - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 80 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 81 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 82 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 83 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 84 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 85 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 86 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 87 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 80 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 81 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 82 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 83 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 84 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 85 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 86 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 87 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, @@ -1181,36 +1207,36 @@ Core cores[NUM_CORES] = { }, { // Core 4 .neurons = { - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 88 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 89 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 90 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 91 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 92 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 93 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 94 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 95 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 96 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 0 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 1 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 2 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 3 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 4 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 5 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 6 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 7 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 8 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 9 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 138 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 139 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 140 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 141 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 142 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 143 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 144 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 145 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 146 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 147 }, - { 0, 0, 0, {1, -127, 1, -127}, 0, 0, 0, 148 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 88 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 89 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 90 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 91 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 92 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 93 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 94 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 95 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 96 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 0 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 1 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 2 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 3 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 4 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 5 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 6 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 7 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 8 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 9 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 138 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 139 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 140 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 141 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 142 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 143 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 144 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 145 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 146 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 147 }, + { 0, 0, 0, {1, -1, 1, -1}, 0, 0, 0, 148 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, { 0, 0, 0, {0, 0, 0, 0}, 0, 1, 0, 0 }, }, diff --git a/verilog/dv/edabk_firmware_demo/convert b/verilog/dv/edabk_firmware_demo/convert index d04e965..06c4c38 100755 Binary files a/verilog/dv/edabk_firmware_demo/convert and b/verilog/dv/edabk_firmware_demo/convert differ diff --git a/verilog/dv/edabk_firmware_demo/convert.c b/verilog/dv/edabk_firmware_demo/convert.c index 288d39f..4085ba8 100644 --- a/verilog/dv/edabk_firmware_demo/convert.c +++ b/verilog/dv/edabk_firmware_demo/convert.c @@ -36,25 +36,6 @@ typedef struct { uint8_t axon_dest; } Packet; -// Function to convert a string of bits to a signed integer -int bitStringToSignedInt(char *str, int start, int end) { - int value = 0; - int sign = str[start] == '1' ? -1 : 1; - for (int i = start; i < end; i++) { - value = value * 2 + (str[i] - '0'); - } - return sign == -1 ? -(value & ~(1 << (end - start - 1))) : value; -} - -// Function to convert a string of bits to an unsigned integer -unsigned int bitStringToUnsignedInt(char *str, int start, int end) { - unsigned int value = 0; - for (int i = start; i < end; i++) { - value = value * 2 + (str[i] - '0'); - } - return value; -} - // // Function to convert a string of bits to a signed integer // int bitStringToSignedInt(char *str, int start, int end) { // int value = 0; @@ -74,6 +55,15 @@ unsigned int bitStringToUnsignedInt(char *str, int start, int end) { // return value; // } +// Function to convert a string of bits to an integer +int bitStringToInt(char *str, int start, int end) { + int value = 0; + for (int i = start; i < end; i++) { + value = value * 2 + (str[i] - '0'); + } + return value; +} + int main() { FILE *inputFile1, *inputFile2, *outputFile; char bitString[BITS_PER_NEURON + 1]; @@ -114,15 +104,15 @@ int main() { baseIndex += 16; for (int i = 0; i < 4; i++) { - cores[core].neurons[neuron].weights[i] = bitStringToSignedInt(bitString, baseIndex + i * 8, baseIndex + 8 + i * 8); + cores[core].neurons[neuron].weights[i] = bitStringToInt(bitString, baseIndex + i * 8, baseIndex + 8 + i * 8); } baseIndex += 32; - cores[core].neurons[neuron].leakage_value = bitStringToSignedInt(bitString, baseIndex, baseIndex + 8); - cores[core].neurons[neuron].positive_threshold = bitStringToSignedInt(bitString, baseIndex + 8, baseIndex + 16); - cores[core].neurons[neuron].negative_threshold = bitStringToSignedInt(bitString, baseIndex + 16, baseIndex + 24); + cores[core].neurons[neuron].leakage_value = bitStringToInt(bitString, baseIndex, baseIndex + 8); + cores[core].neurons[neuron].positive_threshold = bitStringToInt(bitString, baseIndex + 8, baseIndex + 16); + cores[core].neurons[neuron].negative_threshold = bitStringToInt(bitString, baseIndex + 16, baseIndex + 24); baseIndex += 24; - cores[core].neurons[neuron].axon_dest = bitStringToUnsignedInt(bitString, baseIndex, baseIndex + 8); + cores[core].neurons[neuron].axon_dest = bitStringToInt(bitString, baseIndex, baseIndex + 8); //Debug if (neuron == 1 && core ==0) { @@ -160,7 +150,7 @@ int main() { packets[packetCount].dx = bitStringToInt(bitString, 0, 9); // printf("dx: %d; ", packets[packetCount].dx); packets[packetCount].dy = bitStringToInt(bitString, 9, 18); - packets[packetCount].axon_dest = bitStringToUnsignedInt(bitString, 18, 26); + packets[packetCount].axon_dest = bitStringToInt(bitString, 18, 26); packetCount++; }