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

Subversion Repositories uart2spi

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

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 3 dinesha
// Author: Mehdi SEBBANE
2
// May 2002
3
// Verilog model
4
// project: M25P20 25 MHz,
5
// release: 1.4.1
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
`ifdef SFLASH_SPDUP
19
`include "parameter_fast.v"
20
`else
21
`include "parameter.v"
22
`endif
23
 
24
module acdc_check (c, d, s, hold, write_op, read_op);
25
 
26
   input c;
27
   input d;
28
   input s;
29
   input hold;
30
   input write_op;
31
   input read_op;
32
 
33
   ////////////////
34
   // TIMING VALUES
35
   ////////////////
36
   time t_C_rise;
37
   time t_C_fall;
38
   time t_H_rise;
39
   time t_H_fall;
40
   time t_S_rise;
41
   time t_S_fall;
42
   time t_D_change;
43
   time high_time;
44
   time low_time;
45
   ////////////////
46
 
47
   reg toggle;
48
 
49
   initial
50
   begin
51
      high_time = 100000;
52
      low_time = 100000;
53
      toggle = 1'b0;
54
   end
55
 
56
   //--------------------------------------------
57
   // This process checks pulses length on pin /S
58
   //--------------------------------------------
59
   always
60
   begin : shsl_watch
61
      @(posedge s);
62
      begin
63
         if ($time != 0)
64
         begin
65
            t_S_rise = $time;
66
            @(negedge s);
67
            t_S_fall = $time;
68
            if ((t_S_fall - t_S_rise) < `TSHSL)
69
            begin
70
               $display("ERROR : tSHSL condition violated");
71
            end
72
         end
73
      end
74
   end
75
 
76
   //----------------------------------------------------
77
   // This process checks select and deselect setup 
78
   // and hold timings 
79
   //----------------------------------------------------
80
   always
81
   begin : s_watch
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 (c == 1'b1)
89
            begin
90
               if ( ($time - t_C_rise) < `TCHSL)
91
               begin
92
                  $display("ERROR :tCHSL condition violated");
93
               end
94
            end
95
            else if (c == 1'b0)
96
            begin
97
               @(c);
98
               if ( ($time - t_S_fall) < `TSLCH)
99
               begin
100
                  $display("ERROR :tSLCH condition violated");
101
               end
102
            end
103
         end
104
      end
105
      if ((s == 1'b1) && (hold != 1'b0))
106
      begin
107
         if ($time != 0)
108
         begin
109
            t_S_rise = $time;
110
            if (c == 1'b1)
111
            begin
112
               if ( ($time - t_C_rise) < `TCHSH)
113
               begin
114
                  $display("ERROR :tCHSH condition violated");
115
               end
116
            end
117
            else if (c == 1'b0)
118
            begin
119
               @(c);
120
               if ( ($time - t_S_rise) < `TSHCH )
121
               begin
122
                  $display("ERROR :tSHCH condition violated");
123
               end
124
            end
125
         end
126
      end
127
   end
128
 
129
   //---------------------------------
130
   // This process checks hold timings
131
   //---------------------------------
132
   always
133
   begin : hold_watch
134
      @(hold);
135
      if ((hold == 1'b0) && (s == 1'b0))
136
      begin
137
         if ($time != 0)
138
         begin
139
            t_H_fall = $time ;
140
            if ( (t_H_fall - t_C_rise) < `TCHHL)
141
            begin
142
               $display("ERROR : tCHHL condition violated");
143
            end
144
 
145
            @(posedge c);
146
            if( ($time - t_H_fall) < `THLCH)
147
            begin
148
               $display("ERROR : tHLCH condition violated");
149
            end
150
         end
151
      end
152
 
153
 
154
      if ((hold == 1'b1) && (s == 1'b0))
155
      begin
156
         if ($time != 0)
157
         begin
158
            t_H_rise = $time ;
159
            if ( (t_H_rise - t_C_rise) < `TCHHH)
160
            begin
161
               $display("ERROR : tCHHH condition violated");
162
            end
163
            @(posedge c);
164
            if( ($time - t_H_fall) < `THHCH)
165
            begin
166
               $display("ERROR : tHHCH condition violated");
167
            end
168
         end
169
      end
170
   end
171
 
172
   //--------------------------------------------------
173
   // This process checks data hold and setup timings
174
   //--------------------------------------------------
175
   always
176
   begin : d_watch
177
      @(d);
178
      if ($time != 0)
179
      begin
180
         t_D_change = $time;
181
         if (c == 1'b1)
182
         begin
183
            if ( ($time - t_C_rise) < `TCHDX)
184
            begin
185
               $display("ERROR : tCHDX condition violated");
186
            end
187
         end
188
         else if (c == 1'b0)
189
         begin
190
            @(c);
191
            if ( ($time - t_D_change) < `TDVCH)
192
            begin
193
               $display("ERROR : tDVCH condition violated");
194
            end
195
         end
196
      end
197
   end
198
 
199
   //-------------------------------------
200
   // This process checks clock high time
201
   //-------------------------------------
202
   always
203
   begin : c_high_watch
204
      @(c);
205
      if ($time != 0)
206
      begin
207
         if (c == 1'b1)
208
         begin
209
            t_C_rise = $time;
210
            @(negedge c);
211
            t_C_fall = $time;
212
            high_time = t_C_fall - t_C_rise;
213
            toggle = ~toggle;
214
            if ((t_C_fall - t_C_rise) < `TCH)
215
            begin
216
               $display("ERROR : tCH condition violated");
217
            end
218
         end
219
      end
220
   end
221
 
222
   //-------------------------------------
223
   // This process checks clock low time
224
   //-------------------------------------
225
   always
226
   begin : c_low_watch
227
      @(c);
228
      if ($time != 0)
229
      begin
230
         if (c == 1'b0)
231
         begin
232
            t_C_fall = $time;
233
            @(posedge c);
234
            t_C_rise = $time;
235
            low_time = t_C_rise - t_C_fall;
236
            toggle = ~toggle;
237
            if ((t_C_rise - t_C_fall) < `TCL)
238
            begin
239
               $display("ERROR : tCL condition violated");
240
            end
241
         end
242
      end
243
   end
244
 
245
   //-----------------------------------------------
246
   // This process checks clock frequency
247
   //-----------------------------------------------
248
//   always @(high_time or low_time or read_op)
249
   always @(toggle or read_op)
250
   begin : freq_watch
251
      if ($time != 0)
252
      begin
253
         if (s == 1'b0)
254
         begin
255
            if (read_op)
256
            begin
257
               if ((high_time + low_time) < `TR)
258
               begin
259
                  $display("ERROR : Clock frequency condition violated for READ instruction: fR>20MHz");
260
               end
261
            end
262
            else if ((high_time + low_time) < `TC)
263
            begin
264
               $display("ERROR : Clock frequency condition violated: fC>25MHz");
265
            end
266
         end
267
      end
268
   end
269
endmodule

powered by: WebSVN 2.1.0

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