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

Subversion Repositories idea

[/] [idea/] [trunk/] [structural_c/] [idea_machine/] [idea_encryptor_pat_enc.c] - Blame information for rev 10

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 7 marta
/* File Name   : idea_encryptor_pat_enc.c                               */
2
/* Description : The encryption test patterns of IDEA encryption block  */
3
/* Purpose     : To be used by GENLIB                                   */
4
/* Date        : Aug 23, 2001                                           */
5
/* Version     : 1.1                                                    */
6
/* Author      : Martadinata A.                                         */
7
/* Address     : VLSI RG, Dept. of Electrical Engineering ITB,          */
8
/*               Bandung, Indonesia                                     */
9
/* E-mail      : marta@ic.vlsi.itb.ac.id                                */
10
 
11
#include <stdio.h>
12
#include "genpat.h"
13
#define interval 30
14
 
15
char *inttostr(entier)
16
int entier;
17
{
18
  char *str;
19
  str = (char *) mbkalloc (32 * sizeof (char));
20
  sprintf (str, "%d",entier);
21
  return(str);
22
}
23
 
24
main ()
25
{
26
  int round,i;
27
  int time, max;
28
 
29
  DEF_GENPAT("idea_encryptor_encrypt");
30
  SETTUNIT ("ns");
31
  /* Inputs */
32
  /* for power supply */
33
  DECLAR ("vdd", ":2", "B", IN, "", "");
34
  DECLAR ("vss", ":2", "B", IN, "", "");
35
  /* for 64-bit input data */
36
  DECLAR ("x1", ":2", "X", IN, "15 downto 0", "");
37
  DECLAR ("x2", ":2", "X", IN, "15 downto 0", "");
38
  DECLAR ("x3", ":2", "X", IN, "15 downto 0", "");
39
  DECLAR ("x4", ":2", "X", IN, "15 downto 0", "");
40
  /* for the 6 16-bit subkeys of each round */
41
  DECLAR ("z1", ":2", "X", IN, "15 downto 0", "");
42
  DECLAR ("z2", ":2", "X", IN, "15 downto 0", "");
43
  DECLAR ("z3", ":2", "X", IN, "15 downto 0", "");
44
  DECLAR ("z4", ":2", "X", IN, "15 downto 0", "");
45
  DECLAR ("z5", ":2", "X", IN, "15 downto 0", "");
46
  DECLAR ("z6", ":2", "X", IN, "15 downto 0", "");
47
  /* for the 4 16-bit subkeys of output transformation state */
48
  DECLAR ("z19", ":2", "X", IN, "15 downto 0", "");
49
  DECLAR ("z29", ":2", "X", IN, "15 downto 0", "");
50
  DECLAR ("z39", ":2", "X", IN, "15 downto 0", "");
51
  DECLAR ("z49", ":2", "X", IN, "15 downto 0", "");
52
 
53
 /* for control signals */
54
  DECLAR ("clk", ":2", "B", IN, "", "");
55
  DECLAR ("rst", ":2", "B", IN, "", "");
56
  DECLAR ("start", ":2", "B", IN, "", "");
57
  DECLAR ("key_ready", ":2", "B", IN, "", "");
58
 
59
  DECLAR ("round", ":2", "B", OUT, "2 downto 0","");
60
  DECLAR ("en_key_out", ":2", "B", OUT, "","");
61
  DECLAR ("finish", ":2", "B", OUT, "","");
62
 
63
  /* Outputs */
64
  /* for 4 16-bit outpus */
65
  DECLAR ("y1", ":2", "X", OUT, "15 downto 0", "");
66
  DECLAR ("y2", ":2", "X", OUT, "15 downto 0", "");
67
  DECLAR ("y3", ":2", "X", OUT, "15 downto 0", "");
68
  DECLAR ("y4", ":2", "X", OUT, "15 downto 0", "");
69
  max =21;
70
  for (round=0; round<8; round++)
71
  {
72
     for (i=0;i<max;i++)
73
     {
74
        if(round == 0)
75
            time = ((round*max) + i) * interval ;
76
        else if(round ==1 ) {
77
            max = 16;
78
            time = ((round*max) + i + 5) * interval; }
79
        else {
80
            max = 16;
81
            time = ((round*max) + i + 5) * interval; }
82
 
83
        AFFECT (inttostr(time), "vdd", "0b1");
84
        AFFECT (inttostr(time), "vss", "0b0");
85
 
86
 
87
        if(((time/interval)+2)% 2 == 0)
88
             AFFECT (inttostr(time), "clk", "0b0");
89
        else
90
             AFFECT (inttostr(time), "clk", "0b1");
91
 
92
        if((time/interval) < 2)
93
             AFFECT (inttostr(time), "rst", "0b1");
94
        else
95
             AFFECT (inttostr(time), "rst", "0b0");
96
 
97
        if((time/interval) < 5)
98
        {    AFFECT (inttostr(time), "start", "0b0");
99
             AFFECT (inttostr(time), "key_ready", "0b0");
100
        }
101
        else
102
        {    AFFECT (inttostr(time), "start", "0b1");
103
             AFFECT (inttostr(time), "key_ready", "0b1");
104
        }
105
 
106
        AFFECT (inttostr(time), "x1", "11");
107
        AFFECT (inttostr(time), "x2", "12");
108
        AFFECT (inttostr(time), "x3", "13");
109
        AFFECT (inttostr(time), "x4", "14");
110
 
111
        if(round == 0)
112
        {    LABEL ("round_1");
113
             AFFECT (inttostr(time), "z1", "3");
114
             AFFECT (inttostr(time), "z2", "5");
115
             AFFECT (inttostr(time), "z3", "7");
116
             AFFECT (inttostr(time), "z4", "9");
117
             AFFECT (inttostr(time), "z5", "11");
118
             AFFECT (inttostr(time), "z6", "13");
119
        }
120
        else if(round == 1)
121
        {    LABEL ("round_2");
122
             AFFECT (inttostr(time), "z1", "15");
123
             AFFECT (inttostr(time), "z2", "17");
124
             AFFECT (inttostr(time), "z3", "2560");
125
             AFFECT (inttostr(time), "z4", "3584");
126
             AFFECT (inttostr(time), "z5", "4608");
127
             AFFECT (inttostr(time), "z6", "5632");
128
        }
129
        else if(round == 2)
130
        {    LABEL ("round_3");
131
             AFFECT (inttostr(time), "z1", "6656");
132
             AFFECT (inttostr(time), "z2", "7680");
133
             AFFECT (inttostr(time), "z3", "8704");
134
             AFFECT (inttostr(time), "z4", "1536");
135
             AFFECT (inttostr(time), "z5", "36");
136
             AFFECT (inttostr(time), "z6", "44");
137
        }
138
        else if(round == 3)
139
        {    LABEL ("round_4");
140
             AFFECT (inttostr(time), "z1", "52");
141
             AFFECT (inttostr(time), "z2", "60");
142
             AFFECT (inttostr(time), "z3", "68");
143
             AFFECT (inttostr(time), "z4", "12");
144
             AFFECT (inttostr(time), "z5", "20");
145
             AFFECT (inttostr(time), "z6", "28");
146
        }
147
        else if(round == 4)
148
        {    LABEL ("round_5");
149
             AFFECT (inttostr(time), "z1", "22528");
150
             AFFECT (inttostr(time), "z2", "26624");
151
             AFFECT (inttostr(time), "z3", "30720");
152
             AFFECT (inttostr(time), "z4", "34816");
153
             AFFECT (inttostr(time), "z5", "6144");
154
             AFFECT (inttostr(time), "z6", "10240");
155
        }
156
        else if(round == 5)
157
        {    LABEL ("round_6");
158
             AFFECT (inttostr(time), "z1", "14336");
159
             AFFECT (inttostr(time), "z2", "18432");
160
             AFFECT (inttostr(time), "z3", "240");
161
             AFFECT (inttostr(time), "z4", "272");
162
             AFFECT (inttostr(time), "z5", "48");
163
             AFFECT (inttostr(time), "z6", "80");
164
        }
165
        else if(round == 6)
166
        {    LABEL ("round_7");
167
             AFFECT (inttostr(time), "z1", "112");
168
             AFFECT (inttostr(time), "z2", "144");
169
             AFFECT (inttostr(time), "z3", "176");
170
             AFFECT (inttostr(time), "z4", "208");
171
             AFFECT (inttostr(time), "z5", "8192");
172
             AFFECT (inttostr(time), "z6", "24576");
173
        }
174
        else
175
        {    max=22;
176
             LABEL ("round_8");
177
             AFFECT (inttostr(time), "z1", "40960");
178
             AFFECT (inttostr(time), "z2", "57345");
179
             AFFECT (inttostr(time), "z3", "8193");
180
             AFFECT (inttostr(time), "z4", "24577");
181
             AFFECT (inttostr(time), "z5", "40961");
182
             AFFECT (inttostr(time), "z6", "57346");
183
        }
184
 
185
        AFFECT (inttostr(time), "z19", "320");
186
        AFFECT (inttostr(time), "z29", "448");
187
        AFFECT (inttostr(time), "z39", "576");
188
        AFFECT (inttostr(time), "z49", "704");
189
 
190
      }
191
    }
192
  SAV_GENPAT ();
193
}
194
 

powered by: WebSVN 2.1.0

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