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

Subversion Repositories adv_debug_sys

[/] [adv_debug_sys/] [trunk/] [Software/] [adv_jtag_bridge/] [sim_rtl/] [dbg_comm.v] - Blame information for rev 59

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 59 nyawn
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  dbg_comm.v                                                  ////
4
////                                                              ////
5
////                                                              ////
6
////  This file is part of the SoC/OpenRISC Development Interface ////
7
////  http://www.opencores.org/cores/DebugInterface/              ////
8
////                                                              ////
9
////                                                              ////
10
////  Author(s):                                                  ////
11
////       Igor Mohor  (igorm@opencores.org)                      ////
12
////       Nathan Yawn (nathan.yawn@opencores.org)                ////
13
////                                                              ////
14
////                                                              ////
15
////                                                              ////
16
//////////////////////////////////////////////////////////////////////
17
////                                                              ////
18
//// Copyright (C) 2000-2008 Authors                              ////
19
////                                                              ////
20
//// This source file may be used and distributed without         ////
21
//// restriction provided that this copyright statement is not    ////
22
//// removed from the file and that any derivative work contains  ////
23
//// the original copyright notice and the associated disclaimer. ////
24
////                                                              ////
25
//// This source file is free software; you can redistribute it   ////
26
//// and/or modify it under the terms of the GNU Lesser General   ////
27
//// Public License as published by the Free Software Foundation; ////
28
//// either version 2.1 of the License, or (at your option) any   ////
29
//// later version.                                               ////
30
////                                                              ////
31
//// This source is distributed in the hope that it will be       ////
32
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
33
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
34
//// PURPOSE.  See the GNU Lesser General Public License for more ////
35
//// details.                                                     ////
36
////                                                              ////
37
//// You should have received a copy of the GNU Lesser General    ////
38
//// Public License along with this source; if not, download it   ////
39
//// from http://www.opencores.org/lgpl.shtml                     ////
40
////                                                              ////
41
//////////////////////////////////////////////////////////////////////
42
//
43
// CVS Revision History
44
//
45 4 nyawn
// $Log: dbg_comm.v,v $
46 59 nyawn
// Revision 1.4  2011-10-28 01:13:26  natey
47
// Ran through dos2unix.
48
//
49 32 nyawn
// Revision 1.3  2009-05-17 20:55:57  Nathan
50 4 nyawn
// Changed email address to opencores.org
51 59 nyawn
//
52
// Revision 1.2  2008/07/22 18:23:25  Nathan
53
// Added clock and reset outputs to make simulation system simpler.  Fixed P_TRST signal name.  Added fflush calls to make file IO work as quickly as possible.  Write the data out bit on falling clock edge. Cleanup.
54
//
55
// Revision 1.1  2002/03/28 19:59:54  lampret
56
// Added bench directory
57
//
58
// Revision 1.1.1.1  2001/11/04 18:51:07  lampret
59
// First import.
60
//
61
// Revision 1.3  2001/09/24 14:06:13  mohor
62
// Changes connected to the OpenRISC access (SPR read, SPR write).
63
//
64
// Revision 1.2  2001/09/20 10:10:30  mohor
65
// Working version. Few bugs fixed, comments added.
66
//
67
// Revision 1.1.1.1  2001/09/13 13:49:19  mohor
68
// Initial official release.
69
//
70
//
71
//
72
//
73
//
74
 
75
 
76
 
77
`define GDB_IN  "e:/tmp/gdb_in.dat"
78
`define GDB_OUT "e:/tmp/gdb_out.dat"
79
 
80
 
81
module dbg_comm(
82
   SYS_CLK,
83
   SYS_RSTN,
84
   P_TMS,
85
   P_TCK,
86
   P_TRST,
87
   P_TDI,
88
   P_TDO
89
   );
90
 
91
parameter Tp = 20;
92
 
93
output  SYS_CLK;
94
output  SYS_RSTN;
95
output          P_TMS;
96
output          P_TCK;
97
output          P_TRST;
98
output          P_TDI;
99
input            P_TDO;
100
 
101
// Signal for the whole system
102
reg SYS_CLK;
103
reg SYS_RSTN;
104
 
105
// For handling data from the input file
106
integer handle1, handle2;
107
reg [4:0] memory[0:0];
108
 
109
wire P_TCK;
110
wire P_TRST;
111
wire P_TDI;
112
wire P_TMS;
113
wire P_TDO;
114
 
115
// Temp. signal
116
reg [3:0] in_word_r;
117
 
118
 
119
 
120
// Provide the wishbone / CPU / system clock
121
initial
122
begin
123
  SYS_CLK = 1'b0;
124
  forever #5 SYS_CLK = ~SYS_CLK;
125
end
126
 
127
// Provide the system reset
128
initial
129
begin
130
   SYS_RSTN = 1'b1;
131
   #200 SYS_RSTN = 1'b0;
132
   #5000 SYS_RSTN = 1'b1;
133
end
134
 
135
// Set the initial state of the JTAG pins
136
initial
137
begin
138
  in_word_r = 4'h0;  // This sets the TRSTN output active...
139
end
140
 
141
// Handle input from a file for the JTAG pins
142
initial
143
begin
144
  #5500;  // Wait until reset is complete
145
  while(1)
146
  begin
147
    #Tp;
148
    $readmemh(`GDB_OUT, memory);
149
    if(!(memory[0] & 5'b10000))
150
    begin
151
           in_word_r = memory[0][3:0];
152
      handle1 = $fopen(`GDB_OUT);
153
      $fwrite(handle1, "%h", 5'b10000 | memory[0]);  // To ack that we read dgb_out.dat
154
      $fflush(handle1);
155
      $fclose(handle1);
156
    end
157
  end
158
end
159
 
160
// Send the current state of the JTAG output to a file 
161
always @ (P_TDO or negedge P_TCK)
162
begin
163
  handle2 = $fopen(`GDB_IN);
164
  $fdisplay(handle2, "%b", P_TDO);
165
  $fflush(handle2);
166
  $fclose(handle2);
167
end
168
 
169
// Note these must match the bit definitions in the JTAG bridge program (adv_jtag_bridge)
170
assign P_TCK = in_word_r[0];
171
assign P_TRST = in_word_r[1];
172
assign P_TDI = in_word_r[2];
173
assign P_TMS = in_word_r[3];
174
 
175
 
176
endmodule // TAP
177
 

powered by: WebSVN 2.1.0

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