summaryrefslogtreecommitdiffstats
path: root/baseline/source/ndes
diff options
context:
space:
mode:
authorJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
committerJoshua Bakita <bakitajoshua@gmail.com>2019-10-07 19:13:39 -0400
commit386b7d3366f1359a265da207a9cafa3edf553b64 (patch)
treec76120c2c138faed822e4ae386be6ef22a738a78 /baseline/source/ndes
parent54a3f7091a2146b29c73a6fdc4b62a5c4ad7a3d8 (diff)
Reorganize and commit all the modified TACLeBench code and run scripts
Diffstat (limited to 'baseline/source/ndes')
-rw-r--r--baseline/source/ndes/ChangeLog.txt20
-rw-r--r--baseline/source/ndes/ndes.c378
2 files changed, 398 insertions, 0 deletions
diff --git a/baseline/source/ndes/ChangeLog.txt b/baseline/source/ndes/ChangeLog.txt
new file mode 100644
index 0000000..ae9c168
--- /dev/null
+++ b/baseline/source/ndes/ChangeLog.txt
@@ -0,0 +1,20 @@
1File: ndes.c
2Original provenience:
3
42017-04-18:
5- Annotated ndes_main as entry-point for timing analysis
6
72015-10-21:
8- Remove comment on line 1
9- Added generic TACLeBench header to line 1
10- Renamed functions to {name} to ndes_{name}
11- Renamed globale variables to {name} to ndes_{name}
12- Renamed structs to {name} to ndes_{name}
13- Removed the profiling code
14- Added forward decleration of functions
15- Added ndes_main function
16- Added ndes_init function
17- Initialize ndes_ipc1 and ndes_ipc2 in ndes_init function
18- int main variables to global variables for the ndes_init function
19- Applied Code Style
20
diff --git a/baseline/source/ndes/ndes.c b/baseline/source/ndes/ndes.c
new file mode 100644
index 0000000..e56906f
--- /dev/null
+++ b/baseline/source/ndes/ndes.c
@@ -0,0 +1,378 @@
1/*
2 This program is part of the TACLeBench benchmark suite.
3 Version V 1.x
4
5 Name: ndes
6
7 Author: unknown
8
9 Function: A lot of bit manipulation, shifts, array and matrix calculations.
10
11 Source:
12
13 Changes: no major functional changes
14
15 License: May be used, modified, and re-distributed freely.
16
17*/
18
19/* A read from this address will result in an known value of 1 */
20#include "../extra.h"
21#define KNOWN_VALUE 1
22#define NDES_WORSTCASE 1
23/*
24 Declaration of global variables
25*/
26
27typedef struct NDES_IMMENSE {
28 unsigned long l, r;
29} ndes_immense;
30typedef struct NDES_GREAT {
31 unsigned long l, c, r;
32} ndes_great;
33
34unsigned long ndes_bit[33];
35ndes_immense ndes_inp, ndes_key, ndes_out;
36int ndes_newkey, ndes_isw;
37
38static ndes_immense ndes_icd;
39static char ndes_ipc1[57];
40static char ndes_ipc2[49];
41
42
43#ifdef NDES_WORSTCASE
44int ndes_value = 1;
45#else
46int ndes_value = 0;
47#endif
48
49/* Forward funtion prototypes */
50
51void ndes_des( ndes_immense inp, ndes_immense key, int *newkey, int isw,
52 ndes_immense *out );
53void ndes_cyfun( unsigned long ir, ndes_great k, unsigned long *iout );
54unsigned long ndes_getbit( ndes_immense source, int bitno, int nbits );
55void ndes_ks( /*immense key, */int n, ndes_great *kn );
56void ndes_init( void );
57int ndes_return( void );
58void ndes_main( void );
59//int main( void );
60
61/*
62 Initialization
63*/
64void ndes_init()
65{
66 unsigned int i;
67 volatile char ndes_ipc1_tmp[57] = {
68 0, 57, 49, 41, 33, 25, 17, 9, 1, 58, 50,
69 42, 34, 26, 18, 10, 2, 59, 51, 43, 35, 27, 19, 11, 3, 60,
70 52, 44, 36, 63, 55, 47, 39, 31, 23, 15, 7, 62, 54, 46, 38,
71 30, 22, 14, 6, 61, 53, 45, 37, 29, 21, 13, 5, 28, 20, 12, 4
72 };
73 volatile char ndes_ipc2_tmp[49] = {
74 0, 14, 17, 11, 24, 1, 5, 3, 28, 15, 6, 21,
75 10, 23, 19, 12, 4, 26, 8, 16, 7, 27, 20, 13, 2, 41, 52, 31,
76 37, 47, 55, 30, 40, 51, 45, 33, 48, 44, 49, 39, 56, 34,
77 53, 46, 42, 50, 36, 29, 32
78 };
79 for ( i = 0; i < 57; i++ )
80 ndes_ipc1[i] = ndes_ipc1_tmp[i];
81 for ( i = 0; i < 49; i++ )
82 ndes_ipc2[i] = ndes_ipc2_tmp[i];
83
84 ndes_inp.l = KNOWN_VALUE * 35;
85 ndes_inp.r = KNOWN_VALUE * 26;
86 ndes_key.l = KNOWN_VALUE * 2;
87 ndes_key.r = KNOWN_VALUE * 16;
88
89 ndes_newkey = ndes_value;
90 ndes_isw = ndes_value;
91}
92/*
93 Arithmetic functions
94*/
95void ndes_des( ndes_immense inp, ndes_immense key, int *newkey, int isw,
96 ndes_immense *out )
97{
98 volatile char ip[65] = {
99 0, 58, 50, 42, 34, 26, 18, 10, 2, 60, 52, 44, 36,
100 28, 20, 12, 4, 62, 54, 46, 38, 30, 22, 14, 6, 64, 56, 48, 40,
101 32, 24, 16, 8, 57, 49, 41, 33, 25, 17, 9, 1, 59, 51, 43, 35,
102 27, 19, 11, 3, 61, 53, 45, 37, 29, 21, 13, 5, 63, 55, 47, 39,
103 31, 23, 15, 7
104 };
105
106 volatile char ipm[65] = {
107 0, 40, 8, 48, 16, 56, 24, 64, 32, 39, 7, 47, 15,
108 55, 23, 63, 31, 38, 6, 46, 14, 54, 22, 62, 30, 37, 5, 45, 13,
109 53, 21, 61, 29, 36, 4, 44, 12, 52, 20, 60, 28, 35, 3, 43, 11,
110 51, 19, 59, 27, 34, 2, 42, 10, 50, 18, 58, 26, 33, 1, 41, 9,
111 49, 17, 57, 25
112 };
113 static ndes_great kns[17];
114
115 #ifdef NDES_WORSTCASE
116 static int initflag = 1;
117 #else
118 static int initflag = 0;
119 #endif
120
121 int ii, i, j, k;
122 unsigned long ic, shifter;
123 ndes_immense itmp;
124 ndes_great pg;
125
126 if ( initflag ) {
127 initflag = 0;
128 ndes_bit[1] = shifter = 1L;
129
130 _Pragma( "loopbound min 31 max 31" )
131 for ( j = 2; j <= 32; j++ )
132 ndes_bit[j] = ( shifter <<= 1 );
133 }
134
135 if ( *newkey ) {
136 *newkey = 0;
137 ndes_icd.r = ndes_icd.l = 0L;
138
139 _Pragma( "loopbound min 28 max 28" )
140 for ( j = 28, k = 56; j >= 1; j--, k-- ) {
141 ndes_icd.r = ( ndes_icd.r << 1 ) | ndes_getbit( key, ndes_ipc1[j], 32 );
142 ndes_icd.l = ndes_icd.l << 1;
143 ndes_icd.l = ( ndes_icd.l ) | ndes_getbit( key, ndes_ipc1[k], 32 );
144 }
145
146 _Pragma( "loopbound min 16 max 16" )
147 for ( i = 1; i <= 16; i++ ) {
148 pg = kns[i];
149 ndes_ks( /* key,*/ i, &pg );
150 kns[i] = pg;
151 }
152 }
153
154 itmp.r = itmp.l = 0L;
155
156 _Pragma( "loopbound min 32 max 32" )
157 for ( j = 32, k = 64; j >= 1; j--, k-- ) {
158 itmp.r = itmp.r << 1;
159 itmp.r = ( itmp.r ) | ndes_getbit( inp, ip[j], 32 );
160 itmp.l = itmp.l << 1;
161 itmp.l = ( itmp.l ) | ndes_getbit( inp, ip[k], 32 );
162 }
163 _Pragma( "loopbound min 16 max 16" )
164 for ( i = 1; i <= 16; i++ ) {
165 ii = ( isw == 1 ? 17 - i : i );
166 ndes_cyfun( itmp.l, kns[ii], &ic );
167 ic ^= itmp.r;
168 itmp.r = itmp.l;
169 itmp.l = ic;
170 }
171
172 ic = itmp.r;
173 itmp.r = itmp.l;
174 itmp.l = ic;
175 ( *out ).r = ( *out ).l = 0L;
176
177 _Pragma( "loopbound min 32 max 32" )
178 for ( j = 32, k = 64; j >= 1; j--, k-- ) {
179 ( *out ).r = ( *out ).r << 1;
180 ( *out ).r = ( ( *out ).r ) | ndes_getbit( itmp, ipm[j], 32 );
181 ( *out ).l = ( *out ).l << 1;
182 ( *out ).l = ( ( *out ).l ) | ndes_getbit( itmp, ipm[k], 32 );
183 }