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

Subversion Repositories uart2spi

[/] [uart2spi/] [trunk/] [verif/] [models/] [st_m25p16/] [acdc_check.v] - Blame information for rev 3

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 dinesha
// Author: Hugues CREUSY modified by Xue feng
2
// June 2004
3
// Verilog model
4
// project: M25P16 50 MHz,
5
// release: 1.2
6
 
7
 
8
 
9
// These Verilog HDL models are provided "as is" without warranty
10
// of any kind, included but not limited to, implied warranty
11
// of merchantability and fitness for a particular purpose.
12
 
13
 
14
 
15
 
16
 
17
`timescale 1ns/1ns
18
`include "parameter.v"
19
 
20
module acdc_check (c, d, s, hold, write_op, read_op,srwd_wrsr,write_protect, wrsr);
21
 
22
   input c;
23
   input d;
24
   input s;
25
   input hold;
26
   input write_op;
27
   input read_op;
28
   input write_protect;
29
   input srwd_wrsr;
30
   input wrsr;
31
 
32
   ////////////////
33
   // TIMING VALUES
34
   ////////////////
35
   time t_C_rise;
36
   time t_C_fall;
37
   time t_H_rise;
38
   time t_H_fall;
39
   time t_S_rise;
40
   time t_S_fall;
41
   time t_D_change;
42
   time high_time;
43
   time low_time;
44
   time t_write_protect_rise;
45
   time t_write_protect_fall;
46
   ////////////////
47
 
48
   reg toggle;
49
 
50
   initial
51
   begin
52
      high_time = 100000;
53
      low_time = 100000;
54
      toggle = 1'b0;
55
   end
56
 
57
   //--------------------------------------------
58
   // This process checks pulses length on pin /S
59
   //--------------------------------------------
60
   always
61
   begin : shsl_watch
62
      @(posedge s);
63
      begin
64
         if ($time != 0)
65
         begin
66
            t_S_rise = $time;
67
            @(negedge s);
68
            t_S_fall = $time;
69
            if ((t_S_fall - t_S_rise) < `TSHSL)
70
            begin
71
               $display("%t : ERROR : tSHSL condition violated",$realtime);
72
            end
73
         end
74
      end
75
   end
76
 
77
   //----------------------------------------------------
78
   // This process checks select setup and hold timings 
79
   //----------------------------------------------------
80
   always
81
   begin : s_watch1
82
      @(s);
83
      if ((s == 1'b0) && (hold != 1'b0))
84
      begin
85
         if ($time != 0)
86
         begin
87
            t_S_fall = $time;
88
            if ( ($time - t_C_rise) < `TCHSL)
89
                begin
90
                $display("%t : ERROR :tCHSL condition violated",$realtime);
91
            if (c ==1'b1)
92
                begin
93
                @(c);
94
                @(c);
95
                if (($time - t_S_fall) < `TSLCH)
96
                      begin
97
                      $display("%t : ERROR :tSLCH condition violated",$realtime);
98
                      end
99
                end
100
                end
101
            else if (c == 1'b0)
102
                begin
103
                @(c);
104
                if (($time - t_S_fall) < `TSLCH)
105
                    begin
106
                    $display("%t : ERROR :tSLCH condition violated",$realtime);
107
                    end
108
                end
109
                end
110
      end
111
   end
112
 
113
   //----------------------------------------------------
114
   // This process checks deselect setup and hold timings 
115
   //----------------------------------------------------
116
   always
117
   begin : s_watch2
118
   @(s);
119
      if ((s == 1'b1) && (hold != 1'b0))
120
      begin
121
         if ($time != 0)
122
         begin
123
            t_S_rise = $time;
124
            if ( ($time - t_C_rise) < `TCHSH)
125
                begin
126
                $display("%t : ERROR :tCHSH condition violated",$realtime);
127
                end
128
            if (c == 1'b1)
129
                begin
130
                @(c);
131
                @(c);
132
                if ( ($time - t_S_rise) < `TSHCH )
133
                    begin
134
                    $display("%t : ERROR :tSHCH condition violated",$realtime);
135
                    end
136
                end
137
            else if (c == 1'b0)
138
                begin
139
                @(c);
140
                if ( ($time - t_S_rise) < `TSHCH )
141
                    begin
142
                    $display("%t : ERROR :tSHCH condition violated",$realtime);
143
                    end
144
                end
145
          end
146
      end
147
   end
148
 
149
   //---------------------------------
150
   // This process checks hold timings
151
   //---------------------------------
152
   always
153
   begin : hold_watch
154
      @(hold);
155
      if ((hold == 1'b0) && (s == 1'b0))
156
      begin
157
         if ($time != 0)
158
         begin
159
            t_H_fall = $time ;
160
            if ( (t_H_fall - t_C_rise) < `TCHHL)
161
            begin
162
               $display("%t : ERROR : tCHHL condition violated",$realtime);
163
            end
164
 
165
            @(posedge c);
166
            if( ($time - t_H_fall) < `THLCH)
167
            begin
168
               $display("%t : ERROR : tHLCH condition violated",$realtime);
169
            end
170
         end
171
      end
172
 
173
 
174
      if ((hold == 1'b1) && (s == 1'b0))
175
      begin
176
         if ($time != 0)
177
         begin
178
            t_H_rise = $time ;
179
            if ( (t_H_rise - t_C_rise) < `TCHHH)
180
            begin
181
               $display("%t : ERROR : tCHHH condition violated",$realtime);
182
            end
183
            @(posedge c);
184
            if( ($time - t_H_fall) < `THHCH)
185
            begin
186
               $display("%t : ERROR : tHHCH condition violated",$realtime);
187
            end
188
         end
189
      end
190
   end
191
 
192
   //--------------------------------------------------
193
   // This process checks data hold and setup timings
194
   //--------------------------------------------------
195
   always
196
   begin : d_watch
197
      @(d);
198
      if ((s ==1'b0)  && (hold == 1'b1))
199
      begin
200
      if ($time != 0)
201
      begin
202
         t_D_change = $time;
203
         if (c == 1'b1)
204
         begin
205
            if ( ($time - t_C_rise) < `TCHDX)
206
            begin
207
               $display("%t : ERROR : tCHDX condition violated",$realtime);
208
            end
209
         end
210
         else if (c == 1'b0)
211
         begin
212
            @(c);
213
            if ( ($time - t_D_change) < `TDVCH)
214
            begin
215
               if ($time !=0) $display("%t : ERROR : tDVCH condition violated",$realtime);
216
            end
217
         end
218
      end
219
      end
220
   end
221
 
222
   //-------------------------------------
223
   // This process checks clock high time
224
   //-------------------------------------
225
   always
226
   begin : c_high_watch
227
      @(c);
228
      if ($time != 0)
229
         begin
230
         if (c == 1'b1)
231
             begin
232
             if (s==1'b1) high_time=100;
233
             if (s==1'b0)
234
                 begin
235
                 t_C_rise = $time;
236
                @(negedge c);
237
                t_C_fall = $time;
238
                high_time = t_C_fall - t_C_rise;
239
                toggle = ~toggle;
240
                if ((t_C_fall - t_C_rise) < `TCH)
241
                    begin
242
                     if ((s == 1'b0) && (hold == 1'b1))
243
                     begin
244
                     if ($time != 0)  $display("%t : ERROR : tCH condition violated",$realtime);
245
                     end
246
                end
247
           end
248
        end
249
     end
250
    end
251
 
252
 
253
   //-------------------------------------
254
   // This process checks clock low time
255
   //-------------------------------------
256
   always
257
   begin : c_low_watch
258
      @(c);
259
      if ($time != 0)
260
          begin
261
          if (s==1'b1) low_time=100;
262
          if (s==1'b0)
263
              begin
264
              if (c == 1'b0)
265
                  begin
266
                  t_C_fall = $time;
267
                  @(posedge c);
268
                  t_C_rise = $time;
269
                  low_time = t_C_rise - t_C_fall;
270
                  toggle = ~toggle;
271
                  if ((t_C_rise - t_C_fall) < `TCL)
272
                     begin
273
                     if ((s == 1'b0) && (hold == 1'b1))
274
                         begin
275
                         if ($time != 0) $display("%t : ERROR : tCL condition violated",$realtime);
276
                         end
277
                     end
278
                  end
279
              end
280
           end
281
         end
282
 
283
   //-----------------------------------------------
284
   // This process checks clock frequency
285
   //-----------------------------------------------
286
   always @(toggle or read_op)
287
   begin : freq_watch
288
      if ($time != 0)
289
      begin
290
         if ((s == 1'b0) && (hold == 1'b1))
291
         begin
292
            if (read_op)
293
            begin
294
               if ((high_time + low_time) < `TR)
295
               begin
296
                  if ($time != 0) $display("%t : ERROR : Clock frequency condition violated for READ instruction: fR>20MHz",$realtime);
297
               end
298
            end
299
            else if ((high_time + low_time) < `TC)
300
            begin
301
               if ($time != 0) $display("%t : ERROR : Clock frequency condition violated: fC>25MHz",$realtime);
302
            end
303
         end
304
      end
305
   end
306
 
307
   //--------------------------------------------------
308
   // This process detects the write_potect transitions  
309
   //--------------------------------------------------
310
   always @(write_protect)
311
   begin : write_protect_watch
312
         if ($time != 0)
313
         begin
314
              if (write_protect)
315
                  begin
316
                  t_write_protect_rise = $time;
317
                  end
318
              if (!write_protect)
319
                  begin
320
                  t_write_protect_fall = $time;
321
                  end
322
         end
323
   end
324
 
325
 
326
   //----------------------------------------
327
   // This process checks the TWHSL parameter  
328
   //----------------------------------------
329
      always @(posedge srwd_wrsr)
330
      begin : TWHSL_watch
331
            if ($time != 0)
332
                begin
333
                if ((t_S_fall - t_write_protect_fall) < `TWHSL)
334
                     begin
335
                     $display("%d",t_write_protect_fall, ": ERROR : TWHSL condition violated");
336
                     $finish;
337
                     end
338
                end
339
      end
340
 
341
 
342
    //----------------------------------------
343
    // This process checks the TSLWL parameter  
344
    //----------------------------------------
345
    always @(posedge write_protect)
346
    begin : TSHWL_watch
347
        if ($time != 0)
348
            begin
349
            t_write_protect_rise = $time;
350
            if (s)
351
                begin
352
                if (((t_write_protect_rise-t_S_rise) < `TSHWL) && wrsr)
353
                    begin
354
                    $display("%t : ERROR : TSHWL condition violated",$realtime);
355
                    $finish;
356
                    end
357
                end
358
             end
359
     end
360
 
361
 
362
 
363
 
364
 
365
 
366
 
367
endmodule

powered by: WebSVN 2.1.0

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