OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [src_c/] [jtag/] [test_rtl/] [jtag_sim_pattern/] [main.c] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
#include <stdio.h>
2
#include <stdlib.h>
3
#include <stdint.h>
4
#include <string.h>
5
 
6
 
7
void jtag_reorder ( char * string_in, char *string_out ) {
8
 
9
  int size = strlen(string_in);
10
  int i;
11
  for (i=0;i<size;i+=2){
12
         string_out[i]=   string_in[size-i-2];
13
         string_out[i+1]= string_in[size-i-1];
14
  }
15
   string_out[i]=0;
16
}
17
 
18
void init_out_file (FILE * out){
19
fprintf(out," `ifdef INCLUDE_SIM_INPUT \n\
20
/*  \n\
21
parameter SIM_ACTION = \"((1,1,7,3),(0,2,010000007f,24),(0,2,0200000006,24),(0,2,04000000ff,24))\";  \n\
22
SIM_ACTION:\n\
23
((time,type,value,length),\n\
24
(time,type,value,length),\n\
25
...\n\
26
(time,type,value,length))\n\
27
where:\n\
28
time: A 32-bit value in milliseconds that represents the start time of the shift\n\
29
relative to the completion of the previous shift.\n\
30
type: A 4-bit value that determines whether the shift is a DR shift or an\n\
31
IR shift.\n\
32
value: The data associated with the shift. For IR shifts, it is a 32-bit value.\n\
33
For DR shifts, the length is determined by length.\n\
34
length: A 32-bit value that specifies the length of the data being shifted.\n\
35
This value should be equal to SLD_NODE_IR_WIDTH; otherwise, the value\n\
36
field may be padded or truncated. 0 is invalid.\n\
37
\n\
38
SLD_SIM_TOTAL_LENGTH: \n\
39
The total number of bits to be shifted in either an IR shift or a DR shift. This\n\
40
value should be equal to the sum of all the length values specified in the SLD_SIM_ACTION string\n\
41
\n\
42
SIM_N_SCAN:\n\
43
Specifies the number of shifts in the simulation model\n\
44
\n\
45
example:\n\
46
select index 7f\n\
47
$jseq drshift -state IDLE -hex 36 7f00000001    (0,2, 010000007f,24)\n\
48
I:6,D:32:FFFFFFF,D:32:FFFFFFFF to jtag\n\
49
\n\
50
$jseq drshift -state IDLE -hex 36 0600000002    (0,2, 0200000006,24)\n\
51
$jseq drshift -state IDLE -hex 36 ff00000004    (0,2, 04000000ff,24)\n\
52
\n\
53
        parameter SIM_ACTION = \"((1,1,7,3),(0,2,ff,20),(0,1,6,3),(0,2,ffffffff,20),(0,2,1,20),(0,2,2,20),(0,2,3,20),(0,2,4,20))\";  \n\
54
        parameter SIM_N_SCAN=8;\n\
55
        parameter SIM_LENGTH=198;\n\
56
*/\n\
57
    parameter SIM_ACTION = \"((1,1,7,3)");
58
 
59
 
60
 
61
}
62
 
63
 
64
int main (){
65
        char * line = NULL;
66
        char chunk[1024];
67
        char data[100];
68
        char data_o[100];
69
        int n=1;
70
        int len=3;
71
        FILE *in  = fopen ("to_xsct.txt", "r");
72
        FILE *out = fopen ("jtag_sim_input.v", "w");
73
        if (out == NULL) perror("cant creat out file");
74
        if (in == NULL)  perror("cant read input file");
75
        unsigned int num,size;
76
        init_out_file(out);
77
        while (fgets(chunk, sizeof(chunk), in) != NULL) {
78
                if(sscanf( chunk, "$jseq drshift -state IDLE -hex %u %s",&size, data )){
79
                        jtag_reorder(data,data_o);
80
                        fprintf(out,",(0,2,%s,%x)",data_o,size);
81
                        len+=size;
82
                        n++;
83
 
84
                }
85
                if(sscanf( chunk, "$jseq drshift -state IDLE -capture -hex %u %s",&size, data )){
86
                        jtag_reorder(data,data_o);
87
                        fprintf(out,",(0,2,%s,%x)",data_o,size);
88
                        len+=size;
89
                        n++;
90
                }
91
 
92
 
93
        }
94
        fprintf(out,")\";\n");
95
        fprintf(out,"parameter SIM_N_SCAN=%u;\n",n);
96
        fprintf(out,"parameter SIM_LENGTH=%u;\n`endif",len);
97
 
98
 
99
        fclose (in);
100
        fclose (out);
101
return 0;
102
}

powered by: WebSVN 2.1.0

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