OpenCores
URL https://opencores.org/ocsvn/bustap-jtag/bustap-jtag/trunk

Subversion Repositories bustap-jtag

[/] [bustap-jtag/] [trunk/] [rtl/] [up_monitor.v] - Blame information for rev 20

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 5 ash_riple
//**************************************************************
2
// Module             : up_monitor.v
3 18 ash_riple
// Platform           : Windows xp sp2, Ubuntu 10.04
4 5 ash_riple
// Simulator          : Modelsim 6.5b
5 18 ash_riple
// Synthesizer        : QuartusII 10.1 sp1, PlanAhead 14.2
6
// Place and Route    : QuartusII 10.1 sp1, PlanAhead 14.2
7
// Targets device     : Cyclone III, Zynq-7000
8 5 ash_riple
// Author             : Bibo Yang  (ash_riple@hotmail.com)
9
// Organization       : www.opencores.org
10 18 ash_riple
// Revision           : 2.3 
11
// Date               : 2012/11/19
12
// Description        : Top level: transaction record generation
13
//                      and glue logic to group together 
14 5 ash_riple
//                      the JTAG input and output modules.
15
//**************************************************************
16 2 ash_riple
 
17 5 ash_riple
`timescale 1ns/1ns
18 18 ash_riple
`include "vendor.h"
19 2 ash_riple
 
20 5 ash_riple
module up_monitor (
21 18 ash_riple
        `ifdef XILINX `ifdef AXI_IP
22
        icontrol0, icontrol1, icontrol2,
23
        `endif `endif
24
        clk,
25
        wr_en,rd_en,
26
        addr_in,
27
        data_in
28 5 ash_riple
);
29 2 ash_riple
 
30 18 ash_riple
input        clk;
31
input        wr_en,rd_en;
32 20 ash_riple
input [31:0] addr_in;
33 18 ash_riple
input [31:0] data_in;
34 6 ash_riple
/////////////////////////////////////////////////
35
// Registers and wires announcment
36
/////////////////////////////////////////////////
37 2 ash_riple
 
38 6 ash_riple
// for CPU bus signal buffer
39
reg         wr_en_d1,rd_en_d1;
40 20 ash_riple
reg  [31:0] addr_in_d1;
41 6 ash_riple
reg  [31:0] data_in_d1;
42
// for capture address mask
43
wire [35:0] addr_mask0,addr_mask1,addr_mask2 ,addr_mask3 ,addr_mask4 ,addr_mask5 ,addr_mask6 ,addr_mask7 ,  // inclusive
44
            addr_mask8,addr_mask9,addr_mask10,addr_mask11,addr_mask12,addr_mask13,addr_mask14,addr_mask15;  // exclusive
45
wire [15:0] addr_mask_en = {addr_mask15[32],addr_mask14[32],addr_mask13[32],addr_mask12[32],
46
                            addr_mask11[32],addr_mask10[32],addr_mask9 [32],addr_mask8 [32],
47
                            addr_mask7 [32],addr_mask6 [32],addr_mask5 [32],addr_mask4 [32],
48
                            addr_mask3 [32],addr_mask2 [32],addr_mask1 [32],addr_mask0 [32]};
49
wire        addr_wren = addr_mask15[35];
50
wire        addr_rden = addr_mask15[34];
51 5 ash_riple
reg         addr_mask_ok;
52 6 ash_riple
// for capture address+data trigger
53 20 ash_riple
wire [71:0] trig_cond;
54
wire        trig_aden = trig_cond[71];
55
wire        trig_daen = trig_cond[70];
56
wire        trig_wren = trig_cond[67];
57
wire        trig_rden = trig_cond[66];
58
wire        trig_en   = trig_cond[65];
59
wire        trig_set  = trig_cond[64];
60
wire [31:0] trig_addr = trig_cond[63:32];
61 5 ash_riple
wire [31:0] trig_data = trig_cond[31:0];
62 6 ash_riple
reg         trig_cond_ok,trig_cond_ok_d1;
63
// for capture storage
64 20 ash_riple
wire [97:0] capture_in;
65 5 ash_riple
wire        capture_wr;
66 11 ash_riple
// for pretrigger capture
67
wire [9:0] pretrig_num;
68
reg  [9:0] pretrig_cnt;
69
wire pretrig_full;
70
wire pretrig_wr;
71
reg  pretrig_wr_d1,pretrig_rd;
72 12 ash_riple
// for inter capture timer
73
reg [31:0] inter_cap_cnt;
74 5 ash_riple
 
75 6 ash_riple
/////////////////////////////////////////////////
76
// Capture logic main
77
/////////////////////////////////////////////////
78
 
79 5 ash_riple
// bus input pipeline, allowing back-to-back/continuous bus access
80
always @(posedge clk)
81 2 ash_riple
begin
82 5 ash_riple
        wr_en_d1   <= wr_en;
83
        rd_en_d1   <= rd_en;
84
        addr_in_d1 <= addr_in;
85
        data_in_d1 <= data_in;
86 2 ash_riple
end
87
 
88 5 ash_riple
// address range based capture enable
89
always @(posedge clk)
90 2 ash_riple
begin
91 20 ash_riple
        if (((addr_in[31:0]<=addr_mask0[31:0] && addr_in[31:0]>=addr_mask1[31:0] && addr_mask_en[ 0]) ||
92
             (addr_in[31:0]<=addr_mask2[31:0] && addr_in[31:0]>=addr_mask3[31:0] && addr_mask_en[ 2]) ||
93
             (addr_in[31:0]<=addr_mask4[31:0] && addr_in[31:0]>=addr_mask5[31:0] && addr_mask_en[ 4]) ||
94
             (addr_in[31:0]<=addr_mask6[31:0] && addr_in[31:0]>=addr_mask7[31:0] && addr_mask_en[ 6])
95 6 ash_riple
            ) //inclusive address range set with individual enable: addr_mask 0 - 7
96 5 ash_riple
            &&
97 20 ash_riple
            ((addr_in[31:0]>addr_mask8 [31:0] || addr_in[31:0]<addr_mask9 [31:0] || !addr_mask_en[ 8]) &&
98
             (addr_in[31:0]>addr_mask10[31:0] || addr_in[31:0]<addr_mask11[31:0] || !addr_mask_en[10]) &&
99
             (addr_in[31:0]>addr_mask12[31:0] || addr_in[31:0]<addr_mask13[31:0] || !addr_mask_en[12]) &&
100
             (addr_in[31:0]>addr_mask14[31:0] || addr_in[31:0]<addr_mask15[31:0] || !addr_mask_en[14])
101 6 ash_riple
            ) //exclusive address range set with individual enable: addr_mask 8 - 15
102 2 ash_riple
        )
103 6 ash_riple
                addr_mask_ok <= (addr_rden && rd_en) || (addr_wren && wr_en);
104 5 ash_riple
        else
105
                addr_mask_ok <= 0;
106 2 ash_riple
end
107
 
108 6 ash_riple
// address+data based capture trigger
109 5 ash_riple
always @(posedge clk)
110 2 ash_riple
begin
111 6 ash_riple
        if (trig_en==0) begin                      // trigger not enabled, trigger gate forced open
112
                trig_cond_ok    <= 1;
113
                trig_cond_ok_d1 <= 1;
114
        end
115
        else if (trig_set==0) begin                // trigger enabled and trigger stopped, trigger gate forced close
116
                trig_cond_ok    <= 0;
117
                trig_cond_ok_d1 <= 0;
118
        end
119
        else begin                                 // trigger enabled and trigger started, trigger gate conditional open
120 20 ash_riple
                if ((trig_aden? trig_addr[31:0]==addr_in[31:0]: 1) && (trig_daen? trig_data==data_in: 1) &&
121 6 ash_riple
                    (trig_wren? wr_en                         : 1) && (trig_rden? rd_en             : 1) &&
122
                    (rd_en || wr_en))
123
                        trig_cond_ok <= 1;
124
                trig_cond_ok_d1 <= trig_cond_ok;
125
        end
126
                                              // trigger gate kept open until trigger stoped
127 2 ash_riple
end
128 6 ash_riple
wire trig_cond_ok_pulse = trig_cond_ok & !trig_cond_ok_d1;
129 2 ash_riple
 
130 11 ash_riple
// generate capture wr_in
131 20 ash_riple
assign capture_in = {trig_cond_ok_pulse,wr_en_d1,inter_cap_cnt,addr_in_d1[31:0],data_in_d1[31:0]};
132 13 ash_riple
assign capture_wr =  trig_cond_ok_pulse || (addr_mask_ok && trig_cond_ok);
133 2 ash_riple
 
134 11 ash_riple
// generate pre-trigger wr_in
135
assign pretrig_full = (pretrig_cnt >= pretrig_num) || trig_cond_ok;
136
assign pretrig_wr = (!trig_en || (trig_en && !trig_set))? 1'b0 : (trig_cond_ok? 1'b0 : addr_mask_ok);
137
always @(posedge clk)
138
begin
139
        if      (!trig_en || (trig_en && !trig_set)) begin
140
                pretrig_cnt  <= 10'd0;
141
                pretrig_wr_d1<= 1'b0;
142
                pretrig_rd   <= 1'b0;
143
        end
144
        else if (!pretrig_full) begin
145
                pretrig_cnt  <=  pretrig_cnt + addr_mask_ok;
146
                pretrig_wr_d1<= 1'b0;
147
                pretrig_rd   <= 1'b0;
148
        end
149
        else if (pretrig_full) begin
150
                pretrig_cnt  <= pretrig_cnt;
151
                pretrig_wr_d1<= pretrig_wr;
152
                pretrig_rd   <= pretrig_wr_d1;
153
        end
154
end
155
 
156 12 ash_riple
// generate interval counter
157
always @(posedge clk)
158
begin
159
        if      (capture_wr || pretrig_wr)
160
                inter_cap_cnt <= 32'd0;
161
        else if (inter_cap_cnt[31])
162
                inter_cap_cnt <= 32'd3000000000;
163
        else
164
                inter_cap_cnt <= inter_cap_cnt + 32'd1;
165
end
166
 
167 6 ash_riple
/////////////////////////////////////////////////
168
// Instantiate vendor specific JTAG functions
169
/////////////////////////////////////////////////
170 18 ash_riple
`ifdef ALTERA
171 6 ash_riple
// index 0, instantiate capture fifo, as output
172
virtual_jtag_adda_fifo u_virtual_jtag_adda_fifo (
173
        .clk(clk),
174 11 ash_riple
        .wr_in(capture_wr || pretrig_wr),
175
        .data_in(capture_in),
176
        .rd_in(pretrig_rd)
177 6 ash_riple
        );
178
defparam
179 20 ash_riple
        u_virtual_jtag_adda_fifo.data_width     = 98,
180 6 ash_riple
        u_virtual_jtag_adda_fifo.fifo_depth     = 512,
181
        u_virtual_jtag_adda_fifo.addr_width     = 9,
182
        u_virtual_jtag_adda_fifo.al_full_val    = 511,
183
        u_virtual_jtag_adda_fifo.al_empt_val    = 0;
184
 
185
// index 1, instantiate capture mask, as input
186 2 ash_riple
virtual_jtag_addr_mask u_virtual_jtag_addr_mask (
187 6 ash_riple
        // inclusive
188 2 ash_riple
        .mask_out0(addr_mask0),
189
        .mask_out1(addr_mask1),
190
        .mask_out2(addr_mask2),
191
        .mask_out3(addr_mask3),
192
        .mask_out4(addr_mask4),
193
        .mask_out5(addr_mask5),
194
        .mask_out6(addr_mask6),
195
        .mask_out7(addr_mask7),
196 6 ash_riple
        // exclusive
197 2 ash_riple
        .mask_out8(addr_mask8),
198
        .mask_out9(addr_mask9),
199
        .mask_out10(addr_mask10),
200
        .mask_out11(addr_mask11),
201
        .mask_out12(addr_mask12),
202
        .mask_out13(addr_mask13),
203
        .mask_out14(addr_mask14),
204
        .mask_out15(addr_mask15)
205
        );
206
defparam
207
        u_virtual_jtag_addr_mask.mask_index     = 4,
208 6 ash_riple
        u_virtual_jtag_addr_mask.mask_enabl     = 4,
209
        u_virtual_jtag_addr_mask.addr_width     = 32;
210 2 ash_riple
 
211 6 ash_riple
// index 2, instantiate capture trigger, as input
212 2 ash_riple
virtual_jtag_adda_trig u_virtual_jtag_adda_trig (
213 11 ash_riple
        .trig_out(trig_cond),
214
        .pnum_out(pretrig_num)
215 2 ash_riple
        );
216
defparam
217 20 ash_riple
        u_virtual_jtag_adda_trig.trig_width     = 72,
218 11 ash_riple
        u_virtual_jtag_adda_trig.pnum_width     = 10;
219 18 ash_riple
`endif
220 2 ash_riple
 
221 18 ash_riple
`ifdef XILINX
222
 
223
`ifdef AXI_IP
224
// external ICON
225
inout [35:0] icontrol0, icontrol1, icontrol2;
226
`else
227
// internal ICON
228
wire [35:0] icontrol0, icontrol1, icontrol2;
229
`endif
230
 
231
// index 0, instantiate capture fifo, as output
232
chipscope_vio_adda_fifo u_chipscope_vio_adda_fifo (
233
        .wr_in(capture_wr || pretrig_wr),
234
        .data_in(capture_in),
235
        .rd_in(pretrig_rd),
236
        .clk(clk),
237
        .icon_ctrl(icontrol0)
238
        );
239
defparam
240 20 ash_riple
        u_chipscope_vio_adda_fifo.data_width    = 98,
241 18 ash_riple
        u_chipscope_vio_adda_fifo.addr_width    = 10,
242
        u_chipscope_vio_adda_fifo.al_full_val   = 511;
243
 
244
// index 1, instantiate capture mask, as input
245
chipscope_vio_addr_mask u_chipscope_vio_addr_mask (
246
        // inclusive
247
        .mask_out0(addr_mask0),
248
        .mask_out1(addr_mask1),
249
        .mask_out2(addr_mask2),
250
        .mask_out3(addr_mask3),
251
        .mask_out4(addr_mask4),
252
        .mask_out5(addr_mask5),
253
        .mask_out6(addr_mask6),
254
        .mask_out7(addr_mask7),
255
        // exclusive
256
        .mask_out8(addr_mask8),
257
        .mask_out9(addr_mask9),
258
        .mask_out10(addr_mask10),
259
        .mask_out11(addr_mask11),
260
        .mask_out12(addr_mask12),
261
        .mask_out13(addr_mask13),
262
        .mask_out14(addr_mask14),
263
        .mask_out15(addr_mask15),
264
        .clk(clk),
265
        .icon_ctrl(icontrol1)
266
        );
267
defparam
268
        u_chipscope_vio_addr_mask.mask_index    = 4,
269
        u_chipscope_vio_addr_mask.mask_enabl    = 4,
270
        u_chipscope_vio_addr_mask.addr_width    = 32;
271
 
272
// index 2, instantiate capture trigger, as input
273
chipscope_vio_adda_trig u_chipscope_vio_adda_trig (
274
        .trig_out(trig_cond),
275
        .pnum_out(pretrig_num),
276
        .clk(clk),
277
        .icon_ctrl(icontrol2)
278
        );
279
defparam
280 20 ash_riple
        u_chipscope_vio_adda_trig.trig_width    = 72,
281 18 ash_riple
        u_chipscope_vio_adda_trig.pnum_width    = 10;
282
 
283
`ifdef AXI_IP
284
// external ICON
285
`else
286
// internal ICON
287
chipscope_icon u_chipscope_icon (
288
        .CONTROL0(icontrol0),
289
        .CONTROL1(icontrol1),
290
        .CONTROL2(icontrol2)
291
        );
292
`endif
293
 
294
`endif
295
 
296 2 ash_riple
endmodule

powered by: WebSVN 2.1.0

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