OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [sim/] [iverilog/] [sound/] [dma_id_gen.cpp] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 alfik
#include <cstdio>
2
 
3
static int E2_incr_table[4][9] = {
4
  {  0x01, -0x02, -0x04,  0x08, -0x10,  0x20,  0x40, -0x80, -106 },
5
  { -0x01,  0x02, -0x04,  0x08,  0x10, -0x20,  0x40, -0x80,  165 },
6
  { -0x01,  0x02,  0x04, -0x08,  0x10, -0x20, -0x40,  0x80, -151 },
7
  {  0x01, -0x02,  0x04, -0x08, -0x10,  0x20, -0x40,  0x80,   90 }
8
};
9
 
10
int get_value(int count, int input) {
11
    int ret = 0;
12
    for (int i = 0; i < 8; i++) {
13
        if ((input >> i) & 0x01) ret += E2_incr_table[count % 4][i];
14
    }
15
    ret += E2_incr_table[count % 4][8];
16
 
17
    return ret;
18
}
19
 
20
int main() {
21
    FILE *fp = fopen("dsp_dma_identification_rom.hex", "wb");
22
 
23
    for(int count=0; count<4; count++) {
24
        for(int input=0; input<256; input++) {
25
            int ret = get_value(count, input);
26
            fprintf(fp, "%d%d%d%d%d%d%d%d\n", (ret & 0x80)?1:0, (ret & 0x40)?1:0, (ret & 0x20)?1:0, (ret & 0x10)?1:0, (ret & 0x08)?1:0, (ret & 0x04)?1:0, (ret & 0x02)?1:0, (ret & 0x01)?1:0 );
27
        }
28
    }
29
 
30
    fclose(fp);
31
    return 0;
32
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.