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

Subversion Repositories openmsp430

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

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

Line No. Rev Author Line
1 106 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 111 olivier.gi
   integer test_nr;
40 106 olivier.gi
   integer test_var;
41
 
42
 
43
initial
44
   begin
45
      $display(" ===============================================");
46
      $display("|                 START SIMULATION              |");
47
      $display(" ===============================================");
48 111 olivier.gi
`ifdef DBG_EN
49 154 olivier.gi
`ifdef DBG_UART
50 134 olivier.gi
  `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 111 olivier.gi
      test_nr = 0;
58 106 olivier.gi
      #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 111 olivier.gi
      dbg_en  = 0;
66
      test_nr = 1;
67 106 olivier.gi
 
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 111 olivier.gi
      dbg_en  = 1;
77
      test_nr = 2;
78
 
79 106 olivier.gi
      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 111 olivier.gi
      dbg_en  = 1;
87
      test_nr = 3;
88 106 olivier.gi
 
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
      // Send uart synchronization frame
102
      dbg_uart_tx(DBG_SYNC);
103
 
104
      // Check CPU_CTL reset value
105
      dbg_uart_rd(CPU_CTL);
106
`ifdef DBG_RST_BRK_EN
107 134 olivier.gi
      if (dbg_uart_buf !== 16'h0030) tb_error("====== CPU_CTL wrong reset value -  test 4 =====");
108 106 olivier.gi
`else
109 134 olivier.gi
      if (dbg_uart_buf !== 16'h0010) tb_error("====== CPU_CTL wrong reset value -  test 4 =====");
110 106 olivier.gi
`endif
111
 
112
 
113
      // Make sure that DBG_EN resets the debug interface
114
      //--------------------------------------------------------
115 111 olivier.gi
      test_nr = 4;
116 106 olivier.gi
 
117
      // Let the CPU run
118
      dbg_uart_wr(CPU_CTL,  16'h0002);
119
 
120
      repeat(300) @(posedge mclk);
121
      dbg_uart_wr(CPU_CTL,   16'h0000);
122
      dbg_uart_wr(MEM_DATA,  16'haa55);
123
      dbg_uart_rd(CPU_CTL);
124
      if (dbg_uart_buf !== 16'h0000)  tb_error("====== CPU_CTL write access failed  - test 5 =====");
125
      dbg_uart_rd(MEM_DATA);
126
      if (dbg_uart_buf !== 16'haa55)  tb_error("====== MEM_DATA write access failed - test 6 =====");
127
 
128
 
129
      test_var = r14;  // Backup the current register value
130
 
131
 
132
      @(posedge mclk); // Resets the debug interface
133
      dbg_en = 1'b0;
134
      repeat(2) @(posedge mclk);
135
      dbg_en = 1'b1;
136
 
137
      // Make sure that the register was not reseted
138
      if (r14 < test_var) tb_error("====== CPU was reseted with DBG_EN -  test 7 =====");
139
      repeat(2) @(posedge mclk);
140
 
141
      // Send uart synchronization frame
142
      dbg_uart_tx(DBG_SYNC);
143
 
144
      // Check CPU_CTL reset value
145
      dbg_uart_rd(CPU_CTL);
146
`ifdef DBG_RST_BRK_EN
147 134 olivier.gi
      if (dbg_uart_buf !== 16'h0030) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
148 106 olivier.gi
`else
149 134 olivier.gi
      if (dbg_uart_buf !== 16'h0010) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
150 106 olivier.gi
`endif
151
      dbg_uart_rd(MEM_DATA);
152
      if (dbg_uart_buf !== 16'h0000) tb_error("====== MEM_DATA read access failed - test 9 =====");
153
 
154
 
155
      // Make sure that RESET_N resets the debug interface
156
      //--------------------------------------------------------
157 111 olivier.gi
      test_nr = 5;
158 106 olivier.gi
 
159
      // Let the CPU run
160
      dbg_uart_wr(CPU_CTL,  16'h0002);
161
 
162
      repeat(300) @(posedge mclk);
163
      dbg_uart_wr(CPU_CTL,   16'h0000);
164
      dbg_uart_wr(MEM_DATA,  16'haa55);
165
      dbg_uart_rd(CPU_CTL);
166
      if (dbg_uart_buf !== 16'h0000)  tb_error("====== CPU_CTL write access failed  - test 10 =====");
167
      dbg_uart_rd(MEM_DATA);
168
      if (dbg_uart_buf !== 16'haa55)  tb_error("====== MEM_DATA write access failed - test 11 =====");
169
 
170 111 olivier.gi
      test_nr = 6;
171 106 olivier.gi
 
172
      @(posedge mclk); // Generates POR
173
      reset_n = 1'b0;
174
      repeat(2) @(posedge mclk);
175
      reset_n = 1'b1;
176
 
177
      // Make sure that the register was reseted
178
      if (r14 !== 16'h0000) tb_error("====== CPU was not reseted with RESET_N -  test 12 =====");
179
      repeat(2) @(posedge mclk);
180
 
181
      // Send uart synchronization frame
182
      dbg_uart_tx(DBG_SYNC);
183
 
184 111 olivier.gi
      test_nr = 7;
185
 
186 106 olivier.gi
      // Check CPU_CTL reset value
187
      dbg_uart_rd(CPU_CTL);
188
`ifdef DBG_RST_BRK_EN
189 134 olivier.gi
      if (dbg_uart_buf !== 16'h0030) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
190 106 olivier.gi
`else
191 134 olivier.gi
      if (dbg_uart_buf !== 16'h0010) tb_error("====== CPU_CTL wrong reset value -  test 8 =====");
192 106 olivier.gi
`endif
193
      dbg_uart_rd(MEM_DATA);
194
      if (dbg_uart_buf !== 16'h0000) tb_error("====== MEM_DATA read access failed - test 9 =====");
195
 
196
 
197
      // Let the CPU run
198
      dbg_uart_wr(CPU_CTL,  16'h0002);
199
 
200 111 olivier.gi
      test_nr = 8;
201
 
202 106 olivier.gi
      // Generate IRQ to terminate the test pattern
203
      irq[1] = 1'b1;
204
      @(r13);
205
      irq[1] = 1'b0;
206
 
207
      stimulus_done = 1;
208 134 olivier.gi
 
209
  `endif
210 111 olivier.gi
`else
211
 
212
       $display(" ===============================================");
213
       $display("|               SIMULATION SKIPPED              |");
214 154 olivier.gi
       $display("|   (serial debug interface UART not included)  |");
215
       $display(" ===============================================");
216
       $finish;
217
`endif
218
`else
219
 
220
       $display(" ===============================================");
221
       $display("|               SIMULATION SKIPPED              |");
222 111 olivier.gi
       $display("|      (serial debug interface not included)    |");
223
       $display(" ===============================================");
224
       $finish;
225
`endif
226 106 olivier.gi
   end
227
 

powered by: WebSVN 2.1.0

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