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

Subversion Repositories or1k_soc_on_altera_embedded_dev_kit

[/] [or1k_soc_on_altera_embedded_dev_kit/] [trunk/] [soc/] [sw/] [adv_jtag_bridge/] [sim_rtl/] [dbg_comm_vpi.v] - Blame information for rev 21

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 xianfeng
//////////////////////////////////////////////////////////////////////
2
////                                                              ////
3
////  dbg_comm_vpi.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
////       Gyorgy Jeney (nog@sdf.lonestar.net)                    ////
13
////       Nathan Yawn (nathan.yawn@opencores.org)                ////
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
// $Log: dbg_comm_vpi.v,v $
46 21 xianfeng
// Revision 1.2  2009-05-17 20:55:57  Nathan
47 12 xianfeng
// Changed email address to opencores.org
48
//
49
// Revision 1.1  2008/07/26 17:33:20  Nathan
50
// Added debug comm module for use with VPI / network communication.
51
//
52
// Revision 1.1  2002/03/28 19:59:54  lampret
53
// Added bench directory
54
//
55
// Revision 1.1.1.1  2001/11/04 18:51:07  lampret
56
// First import.
57
//
58
// Revision 1.3  2001/09/24 14:06:13  mohor
59
// Changes connected to the OpenRISC access (SPR read, SPR write).
60
//
61
// Revision 1.2  2001/09/20 10:10:30  mohor
62
// Working version. Few bugs fixed, comments added.
63
//
64
// Revision 1.1.1.1  2001/09/13 13:49:19  mohor
65
// Initial official release.
66
//
67
//
68
//
69
//
70
//
71
 
72
 
73
`define JP_PORT "4567"
74
`define TIMEOUT_COUNT 6'd20  // 1/2 of a TCK clock will be this many SYS_CLK ticks.  Must be less than 6 bits. 
75
 
76
  module dbg_comm_vpi (
77
                       SYS_CLK,
78
                       SYS_RSTN,
79
                       P_TMS,
80
                       P_TCK,
81
                       P_TRST,
82
                       P_TDI,
83
                       P_TDO
84
                       );
85
 
86
   //parameter Tp = 20;
87
 
88
   output    SYS_CLK;
89
   output    SYS_RSTN;
90
   output    P_TMS;
91
   output    P_TCK;
92
   output    P_TRST;
93
   output    P_TDI;
94
   input     P_TDO;
95
 
96
   reg       SYS_CLK;
97
   reg       SYS_RSTN;
98
 
99
 
100
   reg [4:0] memory;  // [0:0];
101
 
102
 
103
   wire      P_TCK;
104
   wire      P_TRST;
105
   wire      P_TDI;
106
   wire      P_TMS;
107
   wire      P_TDO;
108
 
109
   reg [3:0] in_word_r;
110
   reg [5:0] clk_count;
111
 
112
 
113
   // Provide the wishbone / CPU / system clock
114
   initial
115
     begin
116
        SYS_CLK = 1'b0;
117
        clk_count[5:0] <= `TIMEOUT_COUNT + 1;  // Start with the timeout clock stopped
118
        forever #5 SYS_CLK = ~SYS_CLK;
119
     end
120
 
121
   // Provide the system reset
122
   initial
123
     begin
124
        SYS_RSTN = 1'b1;
125
        #200 SYS_RSTN = 1'b0;
126
        #5000 SYS_RSTN = 1'b1;
127
     end
128
 
129
 
130
   // Handle commands from the upper level
131
   initial
132
     begin
133
        in_word_r = 5'b0;
134
        memory = 5'b0;
135
        $jp_init(`JP_PORT);
136
        #5500;  // Wait until reset is complete
137
 
138
        while(1)
139
          begin
140
             #1;
141
             $jp_in(memory);  // This will not change memory[][] if no command has been sent from jp
142
             if(memory[4])  // was memory[0][4]
143
               begin
144
                  in_word_r = memory[3:0];
145
                  memory = memory & 4'b1111;
146
                  clk_count = 6'b000000;  // Reset the timeout clock in case jp wants to wait for a timeout / half TCK period
147
               end
148
          end
149
     end
150
 
151
 
152
 
153
   // Send the output bit to the upper layer
154
   always @ (P_TDO)
155
     begin
156
        $jp_out(P_TDO);
157
     end
158
 
159
 
160
   assign P_TCK  = in_word_r[0];
161
   assign P_TRST = in_word_r[1];
162
   assign P_TDI  = in_word_r[2];
163
   assign P_TMS  = in_word_r[3];
164
 
165
 
166
   // Send timeouts / wait periods to the upper layer
167
   always @ (posedge SYS_CLK)
168
     begin
169
        if(clk_count < `TIMEOUT_COUNT) clk_count[5:0] = clk_count[5:0] + 1;
170
        else if(clk_count == `TIMEOUT_COUNT) begin
171
           $jp_wait_time();
172
           clk_count[5:0] = clk_count[5:0] + 1;
173
        end
174
        // else it's already timed out, don't do anything
175
     end
176
 
177
endmodule
178
 

powered by: WebSVN 2.1.0

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