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

Subversion Repositories minsoc

[/] [minsoc/] [trunk/] [bench/] [verilog/] [vpi/] [dbg_comm_vpi.v] - Blame information for rev 48

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

Line No. Rev Author Line
1 2 rfajardo
//////////////////////////////////////////////////////////////////////
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
////       Raul Fajardo (rfajardo@gmail.com)                                      ////
15
////                                                              ////
16
////                                                              ////
17
//////////////////////////////////////////////////////////////////////
18
////                                                              ////
19
//// Copyright (C) 2000-2008 Authors                              ////
20
////                                                              ////
21
//// This source file may be used and distributed without         ////
22
//// restriction provided that this copyright statement is not    ////
23
//// removed from the file and that any derivative work contains  ////
24
//// the original copyright notice and the associated disclaimer. ////
25
////                                                              ////
26
//// This source file is free software; you can redistribute it   ////
27
//// and/or modify it under the terms of the GNU Lesser General   ////
28
//// Public License as published by the Free Software Foundation; ////
29
//// either version 2.1 of the License, or (at your option) any   ////
30
//// later version.                                               ////
31
////                                                              ////
32
//// This source is distributed in the hope that it will be       ////
33
//// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
34
//// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
35
//// PURPOSE.  See the GNU Lesser General Public License for more ////
36
//// details.                                                     ////
37
////                                                              ////
38
//// You should have received a copy of the GNU Lesser General    ////
39
//// Public License along with this source; if not, download it   ////
40
//// from http://www.opencores.org/lgpl.shtml                     ////
41
////                                                              ////
42
//////////////////////////////////////////////////////////////////////
43
//
44
// CVS Revision History
45
//
46
// $Log: dbg_comm_vpi.v,v $
47
// Revision 1.2.1  2009/09/08 14:57  rfajardo
48
// Changed clock and reset outputs to inputs for minsoc
49
//
50
// $Log: dbg_comm_vpi.v,v $
51
// Revision 1.2  2009/05/17 20:55:57  Nathan
52
// Changed email address to opencores.org
53
//
54
// Revision 1.1  2008/07/26 17:33:20  Nathan
55
// Added debug comm module for use with VPI / network communication.
56
//
57
// Revision 1.1  2002/03/28 19:59:54  lampret
58
// Added bench directory
59
//
60
// Revision 1.1.1.1  2001/11/04 18:51:07  lampret
61
// First import.
62
//
63
// Revision 1.3  2001/09/24 14:06:13  mohor
64
// Changes connected to the OpenRISC access (SPR read, SPR write).
65
//
66
// Revision 1.2  2001/09/20 10:10:30  mohor
67
// Working version. Few bugs fixed, comments added.
68
//
69
// Revision 1.1.1.1  2001/09/13 13:49:19  mohor
70
// Initial official release.
71
//
72
//
73
//
74
//
75
//
76
 
77
 
78
`define JP_PORT "4567"
79
`define TIMEOUT_COUNT 6'd20  // 1/2 of a TCK clock will be this many SYS_CLK ticks.  Must be less than 6 bits. 
80
 
81
  module dbg_comm_vpi (
82
                       SYS_CLK,
83
                       P_TMS,
84
                       P_TCK,
85
                       P_TRST,
86
                       P_TDI,
87
                       P_TDO
88
                       );
89
 
90
   //parameter Tp = 20;
91
 
92
   input     SYS_CLK;
93
   output    P_TMS;
94
   output    P_TCK;
95
   output    P_TRST;
96
   output    P_TDI;
97
   input     P_TDO;
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
   // Handle commands from the upper level
114
   initial
115
     begin
116
        in_word_r = 5'b0;
117
        memory = 5'b0;
118
        $jp_init(`JP_PORT);
119
        #5500;  // Wait until reset is complete
120
 
121
        while(1)
122
          begin
123
             #1;
124
             $jp_in(memory);  // This will not change memory[][] if no command has been sent from jp
125
             if(memory[4])  // was memory[0][4]
126
               begin
127
                  in_word_r = memory[3:0];
128
                  memory = memory & 4'b1111;
129
                  clk_count = 6'b000000;  // Reset the timeout clock in case jp wants to wait for a timeout / half TCK period
130
               end
131
          end
132
     end
133
 
134
 
135
 
136
   // Send the output bit to the upper layer
137
   always @ (P_TDO)
138
     begin
139
        $jp_out(P_TDO);
140
     end
141
 
142
 
143
   assign P_TCK  = in_word_r[0];
144
   assign P_TRST = in_word_r[1];
145
   assign P_TDI  = in_word_r[2];
146
   assign P_TMS  = in_word_r[3];
147
 
148
 
149
   // Send timeouts / wait periods to the upper layer
150
   always @ (posedge SYS_CLK)
151
     begin
152
        if(clk_count < `TIMEOUT_COUNT) clk_count[5:0] = clk_count[5:0] + 1;
153
        else if(clk_count == `TIMEOUT_COUNT) begin
154
           $jp_wait_time();
155
           clk_count[5:0] = clk_count[5:0] + 1;
156
        end
157
        // else it's already timed out, don't do anything
158
     end
159
 
160
endmodule
161
 

powered by: WebSVN 2.1.0

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