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

Subversion Repositories openmsp430

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

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
 
43
initial
44
   begin
45
      $display(" ===============================================");
46
      $display("|                 START SIMULATION              |");
47
      $display(" ===============================================");
48
`ifdef DBG_EN
49
`ifdef DBG_I2C
50
  `ifdef ASIC
51
      $display(" ===============================================");
52
      $display("|               SIMULATION SKIPPED              |");
53
      $display("|   (this test is not supported in ASIC mode)   |");
54
      $display(" ===============================================");
55
      $finish;
56
  `else
57
      test_nr = 0;
58
      #1 dbg_en = 0;
59
      repeat(30) @(posedge mclk);
60
      stimulus_done = 0;
61
 
62
      // Make sure the CPU always starts executing when the
63
      // debug interface is disabled during POR.
64
      //--------------------------------------------------------
65
      dbg_en  = 0;
66
      test_nr = 1;
67
 
68
      repeat(300) @(posedge mclk);
69
      if (r14 === 16'h0000)       tb_error("====== CPU is stopped event though the debug interface is disabled - test 1 =====");
70
      test_var = r14;
71
 
72
 
73
      // Make sure that enabling the debug interface after the POR
74
      // don't stop the cpu
75
      //--------------------------------------------------------
76
      dbg_en  = 1;
77
      test_nr = 2;
78
 
79
      repeat(300) @(posedge mclk);
80
      if (r14 === test_var[15:0]) tb_error("====== CPU is stopped when the debug interface is disabled after POR - test 2 =====");
81
 
82
 
83
      // Create POR with debug enable and observe the
84
      // behavior depending on the DBG_RST_BRK_EN define
85
      //--------------------------------------------------------
86
      dbg_en  = 1;
87
      test_nr = 3;
88
 
89
      @(posedge mclk); // Generate POR
90
      reset_n = 1'b0;
91
      @(posedge mclk);
92
      reset_n = 1'b1;
93
 
94
      repeat(300) @(posedge mclk);
95
`ifdef DBG_RST_BRK_EN
96
      if (r14 !== 16'h0000)       tb_error("====== CPU is not stopped with the debug interface enabled and DBG_RST_BRK_EN=1 - test 3 =====");
97
`else
98
      if (r14 === 16'h0000)       tb_error("====== CPU is stopped with the debug interface enabled and DBG_RST_BRK_EN=0 - test 3 =====");
99
`endif
100
 
101
      // Check CPU_CTL reset value
102
      dbg_i2c_rd(CPU_CTL);
103
`ifdef DBG_RST_BRK_EN
104
      if (dbg_i2c_buf !== 16'h0030) tb_error("====== CPU_CTL wrong reset value -  test 4 =====");
105
`else
106
      if (dbg_i2c_buf !== 16'h0010) tb_error("====== CPU_CTL wrong reset value -  test 4 =====");
107
`endif
108
 
109
 
110
      // Make sure that DBG_EN resets the debug interface
111
      //--------------------------------------------------------
112
      test_nr = 4;
113
 
114
      // Let the CPU run
115
      dbg_i2c_wr(CPU_CTL,  16'h0002);
116
 
117
      repeat(300) @(posedge mclk);
118
      dbg_i2c_wr(CPU_CTL,   16'h0000);
119
      dbg_i2c_wr(MEM_DATA,  16'haa55);
120
      dbg_i2c_rd(CPU_CTL);
121
      if (dbg_i2c_buf !== 16'h0000)  tb_error("====== CPU_CTL write access failed  - test 5 =====");
122
      dbg_i2c_rd(MEM_DATA);
123
      if (dbg_i2c_buf !== 16'haa55)  tb_error("====== MEM_DATA write access failed - test 6 =====");
124
 
125
 
126
      test_var = r14;  // Backup the current register value
127
 
128
 
129
      @(posedge mclk); // Resets the debug interface
130
      dbg_en = 1'b0;
131
      repeat(2) @(posedge mclk);
132
      dbg_en = 1'b1;
133
 
134
      // Make sure that the register was not reseted
135
      if (r14 < test_var) tb_error("====== CPU was reseted with DBG_EN -  test 7 =====");
136
      repeat(2) @(posedge mclk);
137
 
138
      // Check CPU_CTL reset value
139
      dbg_i2c_rd(CPU_CTL);
140
`ifdef DBG_RST_BRK_EN
141
      if (dbg_i2c_buf !== 16'h0030) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
142
`else
143
      if (dbg_i2c_buf !== 16'h0010) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
144
`endif
145
      dbg_i2c_rd(MEM_DATA);
146
      if (dbg_i2c_buf !== 16'h0000) tb_error("====== MEM_DATA read access failed - test 9 =====");
147
 
148
 
149
      // Make sure that RESET_N resets the debug interface
150
      //--------------------------------------------------------
151
      test_nr = 5;
152
 
153
      // Let the CPU run
154
      dbg_i2c_wr(CPU_CTL,  16'h0002);
155
 
156
      repeat(300) @(posedge mclk);
157
      dbg_i2c_wr(CPU_CTL,   16'h0000);
158
      dbg_i2c_wr(MEM_DATA,  16'haa55);
159
      dbg_i2c_rd(CPU_CTL);
160
      if (dbg_i2c_buf !== 16'h0000)  tb_error("====== CPU_CTL write access failed  - test 10 =====");
161
      dbg_i2c_rd(MEM_DATA);
162
      if (dbg_i2c_buf !== 16'haa55)  tb_error("====== MEM_DATA write access failed - test 11 =====");
163
 
164
      test_nr = 6;
165
 
166
      @(posedge mclk); // Generates POR
167
      reset_n = 1'b0;
168
      repeat(2) @(posedge mclk);
169
      reset_n = 1'b1;
170
 
171
      // Make sure that the register was reseted
172
      if (r14 !== 16'h0000) tb_error("====== CPU was not reseted with RESET_N -  test 12 =====");
173
      repeat(2) @(posedge mclk);
174
 
175
      test_nr = 7;
176
 
177
      // Check CPU_CTL reset value
178
      dbg_i2c_rd(CPU_CTL);
179
`ifdef DBG_RST_BRK_EN
180
      if (dbg_i2c_buf !== 16'h0030) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
181
`else
182
      if (dbg_i2c_buf !== 16'h0010) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
183
`endif
184
      dbg_i2c_rd(MEM_DATA);
185
      if (dbg_i2c_buf !== 16'h0000) tb_error("====== MEM_DATA read access failed - test 9 =====");
186
 
187
 
188
      // Let the CPU run
189
      dbg_i2c_wr(CPU_CTL,  16'h0002);
190
 
191
      test_nr = 8;
192
 
193
      // Generate IRQ to terminate the test pattern
194
      irq[1] = 1'b1;
195
      @(r13);
196
      irq[1] = 1'b0;
197
 
198
      stimulus_done = 1;
199
 
200
  `endif
201
`else
202
 
203
       $display(" ===============================================");
204
       $display("|               SIMULATION SKIPPED              |");
205
       $display("|   (serial debug interface I2C not included)   |");
206
       $display(" ===============================================");
207
       $finish;
208
`endif
209
`else
210
 
211
       $display(" ===============================================");
212
       $display("|               SIMULATION SKIPPED              |");
213
       $display("|      (serial debug interface not included)    |");
214
       $display(" ===============================================");
215
       $finish;
216
`endif
217
   end
218
 

powered by: WebSVN 2.1.0

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