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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src/] [dbg_i2c_onoff_asic.v] - Blame information for rev 219

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

Line No. Rev Author Line
1 154 olivier.gi
/*===========================================================================*/
2
/* Copyright (C) 2001 Authors                                                */
3
/*                                                                           */
4
/* This source file may be used and distributed without restriction provided */
5
/* that this copyright statement is not removed from the file and that any   */
6
/* derivative work contains the original copyright notice and the associated */
7
/* disclaimer.                                                               */
8
/*                                                                           */
9
/* This source file is free software; you can redistribute it and/or modify  */
10
/* it under the terms of the GNU Lesser General Public License as published  */
11
/* by the Free Software Foundation; either version 2.1 of the License, or    */
12
/* (at your option) any later version.                                       */
13
/*                                                                           */
14
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
15
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or     */
16
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public       */
17
/* License for more details.                                                 */
18
/*                                                                           */
19
/* You should have received a copy of the GNU Lesser General Public License  */
20
/* along with this source; if not, write to the Free Software Foundation,    */
21
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA        */
22
/*                                                                           */
23
/*===========================================================================*/
24
/*                            DEBUG INTERFACE                                */
25
/*---------------------------------------------------------------------------*/
26
/* Test the debug interface:                                                 */
27
/*                           - CPU Control features.                         */
28
/*                                                                           */
29
/* Author(s):                                                                */
30
/*             - Olivier Girard,    olgirard@gmail.com                       */
31
/*                                                                           */
32
/*---------------------------------------------------------------------------*/
33
/* $Rev: 95 $                                                                */
34
/* $LastChangedBy: olivier.girard $                                          */
35
/* $LastChangedDate: 2011-02-24 21:37:57 +0100 (Thu, 24 Feb 2011) $          */
36
/*===========================================================================*/
37
 
38
 
39
   integer test_nr;
40
   integer test_var;
41
 
42
   integer dco_clk_counter;
43
   always @ (negedge dco_clk)
44
     dco_clk_counter <=  dco_clk_counter+1;
45
 
46
   integer dbg_clk_counter;
47
   always @ (negedge dbg_clk)
48
     dbg_clk_counter <=  dbg_clk_counter+1;
49
 
50 202 olivier.gi
 
51 154 olivier.gi
initial
52
   begin
53
      $display(" ===============================================");
54
      $display("|                 START SIMULATION              |");
55
      $display(" ===============================================");
56
`ifdef DBG_EN
57
`ifdef DBG_I2C
58 180 olivier.gi
  `ifdef ASIC_CLOCKING
59 154 olivier.gi
      test_nr = 0;
60
      #1 dbg_en = 0;
61
      repeat(30) @(posedge dco_clk);
62
      stimulus_done = 0;
63
 
64
      // Make sure the CPU always starts executing when the
65
      // debug interface is disabled during POR.
66
      // Also make sure that the debug interface clock is stopped
67
      // and that it is under reset
68
      //--------------------------------------------------------
69
      dbg_en  = 0;
70
      test_nr = 1;
71
 
72
      @(negedge dco_clk) dbg_clk_counter = 0;
73
 
74
      repeat(300) @(posedge dco_clk);
75
      if (r14 === 16'h0000)         tb_error("====== CPU is stopped event though the debug interface is disabled - test 1 =====");
76
      if (dbg_clk_counter !== 0)    tb_error("====== DBG_CLK is not stopped (test 1) =====");
77
      if (dbg_rst          == 1'b0) tb_error("====== DBG_RST signal is not active (test 3) =====");
78
      test_var = r14;
79 202 olivier.gi
 
80
 
81 154 olivier.gi
      // Make sure that enabling the debug interface after the POR
82
      // don't stop the cpu
83
      // Also make sure that the debug interface clock is running
84
      // and that its reset is released
85
      //--------------------------------------------------------
86
      dbg_en  = 1;
87
      test_nr = 2;
88 202 olivier.gi
 
89 154 olivier.gi
      @(negedge dco_clk) dbg_clk_counter = 0;
90
 
91
      repeat(300) @(posedge dco_clk);
92
      if (r14 === test_var[15:0])   tb_error("====== CPU is stopped when the debug interface is disabled after POR - test 4 =====");
93
      if (dbg_clk_counter  == 0)    tb_error("====== DBG_CLK is not running (test 5) =====");
94
      if (dbg_rst         !== 1'b0) tb_error("====== DBG_RST signal is active (test 6) =====");
95
 
96 202 olivier.gi
 
97 154 olivier.gi
      // Make sure that disabling the CPU with debug enabled
98
      // will stop the CPU
99
      // Also make sure that the debug interface clock is stopped
100
      // and that it is NOT under reset
101
      //--------------------------------------------------------
102
      cpu_en  = 0;
103
      dbg_en  = 1;
104
      test_nr = 3;
105 202 olivier.gi
 
106 154 olivier.gi
      #(6*50);
107
      test_var = r14;
108
      dbg_clk_counter = 0;
109
 
110
      #(300*50);
111
      if (r14 !== test_var[15:0])   tb_error("====== CPU is not stopped (test 7) =====");
112
      if (dbg_clk_counter !== 0)    tb_error("====== DBG_CLK is not running (test 8) =====");
113
      if (dbg_rst         !== 1'b0) tb_error("====== DBG_RST signal is active (test 9) =====");
114
 
115
      cpu_en  = 1;
116
      repeat(6) @(negedge dco_clk);
117
 
118 202 olivier.gi
 
119 154 olivier.gi
      // Create POR with debug enable and observe the
120
      // behavior depending on the DBG_RST_BRK_EN define
121
      //--------------------------------------------------------
122
      dbg_en  = 1;
123
      test_nr = 4;
124 202 olivier.gi
 
125 154 olivier.gi
      @(posedge dco_clk); // Generate POR
126
      reset_n = 1'b0;
127
      @(posedge dco_clk);
128
      reset_n = 1'b1;
129 202 olivier.gi
 
130 154 olivier.gi
      repeat(300) @(posedge dco_clk);
131
  `ifdef DBG_RST_BRK_EN
132
      if (r14 !== 16'h0000)       tb_error("====== CPU is not stopped with the debug interface enabled and DBG_RST_BRK_EN=1 - test 3 =====");
133
  `else
134
      if (r14 === 16'h0000)       tb_error("====== CPU is stopped with the debug interface enabled and DBG_RST_BRK_EN=0 - test 3 =====");
135
  `endif
136
 
137
      // Check CPU_CTL reset value
138
      dbg_i2c_rd(CPU_CTL);
139
  `ifdef DBG_RST_BRK_EN
140
      if (dbg_i2c_buf !== 16'h0030) tb_error("====== CPU_CTL wrong reset value -  test 4 =====");
141
  `else
142 202 olivier.gi
      if (dbg_i2c_buf !== 16'h0010) tb_error("====== CPU_CTL wrong reset value -  test 4 =====");
143 154 olivier.gi
  `endif
144
 
145
 
146
      // Make sure that DBG_EN resets the debug interface
147
      //--------------------------------------------------------
148
      test_nr = 5;
149
 
150
      // Let the CPU run
151
      dbg_i2c_wr(CPU_CTL,  16'h0002);
152
 
153
      repeat(300) @(posedge dco_clk);
154
      dbg_i2c_wr(CPU_CTL,   16'h0000);
155
      dbg_i2c_wr(MEM_DATA,  16'haa55);
156
      dbg_i2c_rd(CPU_CTL);
157
      if (dbg_i2c_buf !== 16'h0000)  tb_error("====== CPU_CTL write access failed  - test 5 =====");
158
      dbg_i2c_rd(MEM_DATA);
159
      if (dbg_i2c_buf !== 16'haa55)  tb_error("====== MEM_DATA write access failed - test 6 =====");
160
 
161 202 olivier.gi
 
162 154 olivier.gi
      test_var = r14;  // Backup the current register value
163
 
164 202 olivier.gi
 
165 154 olivier.gi
      @(posedge dco_clk); // Resets the debug interface
166
      dbg_en = 1'b0;
167
      repeat(2) @(posedge dco_clk);
168
      dbg_en = 1'b1;
169
 
170
      // Make sure that the register was not reseted
171
      if (r14 < test_var) tb_error("====== CPU was reseted with DBG_EN -  test 7 =====");
172 202 olivier.gi
      repeat(2) @(posedge dco_clk);
173
 
174 154 olivier.gi
      // Check CPU_CTL reset value
175
      dbg_i2c_rd(CPU_CTL);
176
  `ifdef DBG_RST_BRK_EN
177
      if (dbg_i2c_buf !== 16'h0030) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
178
  `else
179 202 olivier.gi
      if (dbg_i2c_buf !== 16'h0010) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
180 154 olivier.gi
  `endif
181
      dbg_i2c_rd(MEM_DATA);
182
      if (dbg_i2c_buf !== 16'h0000) tb_error("====== MEM_DATA read access failed - test 9 =====");
183
 
184
 
185
      // Make sure that RESET_N resets the debug interface
186
      //--------------------------------------------------------
187
      test_nr = 6;
188
 
189
      // Let the CPU run
190
      dbg_i2c_wr(CPU_CTL,  16'h0002);
191
 
192
      repeat(300) @(posedge dco_clk);
193
      dbg_i2c_wr(CPU_CTL,   16'h0000);
194
      dbg_i2c_wr(MEM_DATA,  16'haa55);
195
      dbg_i2c_rd(CPU_CTL);
196
      if (dbg_i2c_buf !== 16'h0000)  tb_error("====== CPU_CTL write access failed  - test 10 =====");
197
      dbg_i2c_rd(MEM_DATA);
198
      if (dbg_i2c_buf !== 16'haa55)  tb_error("====== MEM_DATA write access failed - test 11 =====");
199
 
200
      test_nr = 7;
201
 
202
      @(posedge dco_clk); // Generates POR
203
      reset_n = 1'b0;
204
      repeat(2) @(posedge dco_clk);
205
      reset_n = 1'b1;
206
 
207
      // Make sure that the register was reseted
208
      if (r14 !== 16'h0000) tb_error("====== CPU was not reseted with RESET_N -  test 12 =====");
209
      repeat(2) @(posedge dco_clk);
210 202 olivier.gi
 
211 154 olivier.gi
      test_nr = 8;
212
 
213
      // Check CPU_CTL reset value
214
      dbg_i2c_rd(CPU_CTL);
215
  `ifdef DBG_RST_BRK_EN
216
      if (dbg_i2c_buf !== 16'h0030) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
217
  `else
218 202 olivier.gi
      if (dbg_i2c_buf !== 16'h0010) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
219 154 olivier.gi
  `endif
220
      dbg_i2c_rd(MEM_DATA);
221
      if (dbg_i2c_buf !== 16'h0000) tb_error("====== MEM_DATA read access failed - test 9 =====");
222
 
223 202 olivier.gi
 
224 154 olivier.gi
      // Let the CPU run
225
      dbg_i2c_wr(CPU_CTL,  16'h0002);
226
 
227
      test_nr = 9;
228
 
229
      // Generate IRQ to terminate the test pattern
230 200 olivier.gi
      irq[`IRQ_NR-15] = 1'b1;
231 154 olivier.gi
      @(r13);
232 200 olivier.gi
      irq[`IRQ_NR-15] = 1'b0;
233 202 olivier.gi
 
234 154 olivier.gi
      stimulus_done = 1;
235
 
236
  `else
237 202 olivier.gi
      tb_skip_finish("|   (this test is not supported in FPGA mode)   |");
238 154 olivier.gi
  `endif
239
`else
240 202 olivier.gi
      tb_skip_finish("|   (serial debug interface I2C not included)   |");
241 154 olivier.gi
`endif
242
`else
243 202 olivier.gi
      tb_skip_finish("|      (serial debug interface not included)    |");
244 154 olivier.gi
`endif
245
   end

powered by: WebSVN 2.1.0

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