OpenCores
URL https://opencores.org/ocsvn/an-fpga-implementation-of-low-latency-noc-based-mpsoc/an-fpga-implementation-of-low-latency-noc-based-mpsoc/trunk

Subversion Repositories an-fpga-implementation-of-low-latency-noc-based-mpsoc

[/] [an-fpga-implementation-of-low-latency-noc-based-mpsoc/] [trunk/] [mpsoc/] [rtl/] [src_peripheral/] [jtag/] [jtag_intfc.v] - Blame information for rev 48

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 48 alirezamon
/**********************************************************************
2
**      File:  jtag_intfc.v
3
**
4
**
5
**      Copyright (C) 2014-2017  Alireza Monemi
6
**
7
**      This file is part of ProNoC
8
**
9
**      ProNoC ( stands for Prototype Network-on-chip)  is free software:
10
**      you can redistribute it and/or modify it under the terms of the GNU
11
**      Lesser General Public License as published by the Free Software Foundation,
12
**      either version 2 of the License, or (at your option) any later version.
13
**
14
**      ProNoC is distributed in the hope that it will be useful, but WITHOUT
15
**      ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
**      or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General
17
**      Public License for more details.
18
**
19
**      You should have received a copy of the GNU Lesser General Public
20
**      License along with ProNoC. If not, see <http:**www.gnu.org/licenses/>.
21
**
22
**
23
**      Description:
24
**      Jtag interface for Altera FPGAs
25
**              .
26
**
27
*******************************************************************/
28
 
29
// synthesis translate_off
30
`timescale 1ns / 1ps
31
// synthesis translate_on
32
 
33
 
34
 
35
module  jtag_intfc #(
36
    parameter NI_BASE_ADDR     = 32'hx, //must be set by top level
37
    parameter JTAG_BASE_ADDR   = 32'hxx,
38
    parameter WR_RAM_TAG       ="J0",
39
    parameter RD_RAM_TAG       ="J1",
40
    parameter WR_RAMw          =8,
41
      //wishbone port parameters
42
 
43
    parameter Dw            =   32,
44
    parameter S_Aw          =   WR_RAMw+1,
45
    parameter M_Aw          =   32,
46
    parameter TAGw          =   3,
47
    parameter SELw          =   4
48
 
49
)(
50
 
51
   //source_probe
52
   /*
53
    busy,
54
    start_source,
55
    wr_pck_size,
56
    x_dest,y_dest,
57
    memory_pointer,
58
    */
59
 
60
    //wishbone slave interface signals
61
    s_dat_i,
62
    s_sel_i,
63
    s_addr_i,
64
    s_tag_i,
65
    s_stb_i,
66
    s_cyc_i,
67
    s_we_i,
68
    s_dat_o,
69
    s_ack_o,
70
    s_err_o,
71
    s_rty_o,
72
 
73
 
74
 
75
    //wishbone master interface signals
76
    m_sel_o,
77
    m_dat_o,
78
    m_addr_o,
79
    m_tag_o,
80
    m_stb_o,
81
    m_cyc_o,
82
    m_we_o,
83
    m_dat_i,
84
    m_ack_i,
85
    m_err_i,
86
    m_rty_i,
87
 
88
    //intruupt interface
89
    irq,
90
 
91
    reset_all_o,
92
    reset_cpus_o,
93
 
94
    //
95
    reset,
96
    clk
97
 
98
 
99
 
100
 
101
);
102
 
103
 localparam  WR_RAM_ID = {"ENABLE_RUNTIME_MOD=YES,INSTANCE_NAME=",WR_RAM_TAG};
104
 
105
        localparam  CLASS_IN_HDR_WIDTH      =8,
106
            DEST_IN_HDR_WIDTH       =8,
107
            X_Y_IN_HDR_WIDTH        =4;
108
 
109
 
110
//source_probe
111
 
112
/*
113
output reg busy;
114
input  start_source;
115
input [WR_RAMw        :   0] wr_pck_size;
116
input [X_Y_IN_HDR_WIDTH-1       :0] x_dest,y_dest;
117
input [31                                               :0] memory_pointer;
118
 
119
assign {reset_all_o,reset_cpus_o}=2'b01;
120
*/
121
 
122
 
123
 
124
 
125
//wishbone slave interface signals
126
    input   [Dw-1       :   0]      s_dat_i;
127
    input   [SELw-1     :   0]      s_sel_i;
128
    input   [S_Aw-1     :   0]      s_addr_i;
129
    input   [TAGw-1     :   0]      s_tag_i;
130
    input                           s_stb_i;
131
    input                           s_cyc_i;
132
    input                           s_we_i;
133
 
134
    output      [Dw-1       :   0]  s_dat_o;
135
    output                          s_ack_o;
136
    output                          s_err_o;
137
    output                          s_rty_o;
138
 
139
 
140
    //wishbone master interface signals
141
    output reg [SELw-1          :   0] m_sel_o;
142
    output reg [Dw-1            :   0] m_dat_o;
143
    output reg [M_Aw-1          :   0] m_addr_o;
144
    output reg [TAGw-1          :   0] m_tag_o;
145
    output reg                         m_stb_o;
146
    output reg                         m_cyc_o;
147
    output reg                         m_we_o;
148
    input       [Dw-1           :  0]  m_dat_i;
149
    input                              m_ack_i;
150
    input                              m_err_i;
151
    input                              m_rty_i;
152
    //intrrupt interface
153
    output                          irq;
154
 
155
    input                           clk,reset;
156
 
157
    output  reset_all_o,  reset_cpus_o;
158
 
159
 
160
 
161
 
162
 
163
 
164
 
165
 
166
   wire [S_Aw-1     :   0]   ram_wr_addr_i;
167
   wire [Dw-1       :   0]   ram_wr_dat_o,hdr_flit_payload;
168
        reg  [S_Aw-1     :   0]   s_addr_i_reg;
169
 
170
    //jtag source prob
171
 
172
   reg busy;
173
   wire start_source;
174
   wire [WR_RAMw                        :0] wr_pck_size;
175
   wire [X_Y_IN_HDR_WIDTH-1     :0] x_dest,y_dest;
176
   wire [31                                             :0] memory_pointer;
177
 
178
        localparam SOURCEw=32+WR_RAMw+1+X_Y_IN_HDR_WIDTH+X_Y_IN_HDR_WIDTH;
179
 
180
    jtag_sp #(
181
        .INDEX(2),
182
        .Pw(1),
183
        .Sw(3)
184
 
185
    )
186
    source_probe
187
    (
188
        .probe(busy),
189
        .source({reset_all_o,reset_cpus_o,start_source})
190
 
191
    );
192
 
193
   jtag_sp #(
194
                  .INDEX(3),
195
        .Pw(1),
196
        .Sw(SOURCEw)
197
 
198
    )
199
    source_probe
200
    (
201
        .probe(busy),
202
        .source({wr_pck_size,y_dest,x_dest,memory_pointer})
203
 
204
    );
205
 
206
 
207
 
208
 
209
 
210
 
211
 assign hdr_flit_payload={{CLASS_IN_HDR_WIDTH{1'b1}},{DEST_IN_HDR_WIDTH{1'b0}},x_dest,y_dest,{(2*X_Y_IN_HDR_WIDTH){1'b0}}};
212
 
213
 
214
   assign ram_wr_addr_i= s_addr_i[ WR_RAMw :0] -2'd2;
215
   assign s_dat_o=(s_addr_i_reg==0)?  hdr_flit_payload:
216
                                                (s_addr_i_reg==1)?       memory_pointer:
217
                                                                                         ram_wr_dat_o;
218
 
219
    prog_ram_single_port #(
220
        .Aw(WR_RAMw),
221
        .Dw(Dw),
222
        .FPGA_FAMILY("ALTERA"),
223
        .RAM_TAG_STRING(WR_RAM_TAG),
224
        .SELw(4),
225
        .TAGw(3)
226
    ) pc_write_ram
227
    (
228
        .clk        (clk),
229
        .reset      (reset),
230
        .sa_ack_o   (s_ack_o),
231
        .sa_addr_i  (ram_wr_addr_i),
232
        .sa_cyc_i   (s_cyc_i),
233
        .sa_dat_i   (32'd0),
234
        .sa_dat_o   (ram_wr_dat_o),
235
        .sa_err_o   (s_err_o),
236
        .sa_rty_o   (s_rty_o),
237
        .sa_sel_i   (s_sel_i),
238
        .sa_stb_i   (s_stb_i),
239
        .sa_tag_i   (s_tag_i),
240
        .sa_we_i    (1'b0)
241
    );
242
 
243
 
244
 
245
 
246
 
247
 
248
   reg sent_start,start_source_delayed;
249
 
250
`ifdef SYNC_RESET_MODE
251
    always @ (posedge clk )begin
252
`else
253
    always @ (posedge clk or posedge reset)begin
254
`endif
255
    if(reset)begin
256
         sent_start<=1'b0;
257
         start_source_delayed<=1'b0;
258
 
259
    end
260
    else begin
261
        start_source_delayed    <=start_source;
262
        sent_start<= (start_source_delayed & ~start_source);  // sent_start is asserted at negedge of sent_start       
263
 
264
     end
265
   end
266
 
267
   localparam ST_NUM        =5,
268
                 IDEAL      =1,
269
                 WRITE_NI_PCK_SIZE=2,
270
                 WRITE_NI_MEM_PTR=4,
271
                 WAIT_1     =8,
272
                 WAIT_NI_DONE=16;
273
 
274
 
275
 
276
    reg [ST_NUM-1  : 0]ps,ns;
277
 
278
    localparam
279
     NI_STATUS_ADDR          =   NI_BASE_ADDR+0,
280
    // update memory pinter, packet size and send packet read command. If memory pointer and packet size width are smaller than COMB_MEM_PTR_W and COMB_PCK_SIZE_W respectively.
281
    NI_RD_MEM_PCKSIZ_ADDR   =   NI_BASE_ADDR+1,
282
    // update memory pinter, packet size and send packet write command. If memory pointer and packet size width are smaller than COMB_MEM_PTR_W and COMB_PCK_SIZE_W respectively.
283
    NI_WR_MEM_PCKSIZ_ADDR   =   NI_BASE_ADDR+2,
284
    //update packet size  
285
    NI_PCK_SIZE_ADDR        =   NI_BASE_ADDR+3,
286
    //update the memory pointer address and send read command. The packet size must be updated before setting this register. use it when memory pointer width is larger than COMB_MEM_PTR_W
287
    NI_RD_MEM_ADDR          =   NI_BASE_ADDR+4,
288
    //update the memory pointer address and send write command. The packet size must be updated before setting this register. use it when memory pointer width is larger than COMB_MEM_PTR_W
289
    NI_WR_MEM_ADDR          =   NI_BASE_ADDR+5;
290
 
291
 
292
 
293
    localparam   NI_BUSY_LOC=         0;
294
 
295
 
296
    reg [2:0] cnt;
297
    reg       cnt_inc;
298
 
299
    always @(*)begin
300
        ns=ps;
301
        m_sel_o     =4'b1111;
302
        m_dat_o       =0;
303
        m_addr_o      = NI_STATUS_ADDR ;
304
        m_tag_o       =3'd0;
305
        m_stb_o       =1'b0;
306
        m_cyc_o       =1'b0;
307
        m_we_o        =1'b0;
308
        busy            =1'b1;
309
        cnt_inc     =1'b0;
310
        case(ps)
311
        IDEAL: begin
312
            if(sent_start) ns= WRITE_NI_PCK_SIZE;
313
            busy            =1'b0;
314
        end
315
        WRITE_NI_PCK_SIZE: begin
316
            m_dat_o     = wr_pck_size+1;// hdr
317
            m_addr_o        = NI_PCK_SIZE_ADDR;
318
            if(m_ack_i) ns= WRITE_NI_MEM_PTR;
319
            m_stb_o=1'b1;
320
            m_cyc_o=1'b1;
321
            m_we_o=1'b1;
322
 
323
 
324
        end
325
        WRITE_NI_MEM_PTR: begin
326
            m_dat_o     = (JTAG_BASE_ADDR<<2);
327
            m_addr_o        = NI_WR_MEM_ADDR;
328
            if(m_ack_i) ns= WAIT_1;
329
            m_stb_o=1'b1;
330
            m_cyc_o=1'b1;
331
            m_we_o=1'b1;
332
        end
333
        WAIT_1: begin
334
            if(cnt==3'd7)ns= WAIT_NI_DONE;
335
            cnt_inc=1'b1;
336
 
337
        end
338
        WAIT_NI_DONE: begin
339
            if(m_ack_i)begin
340
                                        ns=(m_dat_i[NI_BUSY_LOC])? WAIT_1  :IDEAL;
341
            end
342
                                m_addr_o    =   NI_STATUS_ADDR;
343
            m_stb_o =1'b1;
344
            m_cyc_o =1'b1;
345
            m_we_o  =1'b0;
346
        end
347
        endcase
348
    end
349
 
350
 
351
 
352
 
353
 
354
`ifdef SYNC_RESET_MODE
355
    always @ (posedge clk )begin
356
`else
357
    always @ (posedge clk or posedge reset)begin
358
`endif
359
        if(reset) begin
360
            ps<= IDEAL;
361
            cnt<= 3'd0;
362
                                s_addr_i_reg<=0;
363
        end else begin
364
            ps<=ns;
365
                                s_addr_i_reg<=s_addr_i;
366
            if( cnt_inc) cnt<= cnt +1'b1;
367
            else             cnt<= 3'd0;
368
 
369
        end
370
    end
371
 
372
 
373
 
374
 
375
 
376
endmodule
377
 
378
/*****************
379
 
380
    jtag_sp
381
 
382
******************/
383
 
384
module jtag_sp #(
385
         parameter INDEX=2,
386
    parameter Pw=8,
387
    parameter Sw=8
388
 
389
)(
390
    probe,
391
    source);
392
 
393
    input   [Pw:0]  probe;
394
    output  [Sw:0]  source;
395
 
396
    wire [Sw:0] sub_wire0;
397
    wire [Sw:0] source = sub_wire0[Sw:0];
398
 
399
    altsource_probe altsource_probe_component (
400
                .probe (probe),
401
                .source (sub_wire0)
402
                // synopsys translate_off
403
                ,
404
                .clrn (),
405
                .ena (),
406
                .ir_in (),
407
                .ir_out (),
408
                .jtag_state_cdr (),
409
                .jtag_state_cir (),
410
                .jtag_state_e1dr (),
411
                .jtag_state_sdr (),
412
                .jtag_state_tlr (),
413
                .jtag_state_udr (),
414
                .jtag_state_uir (),
415
                .raw_tck (),
416
                .source_clk (),
417
                .source_ena (),
418
                .tdi (),
419
                .tdo (),
420
                .usr1 ()
421
                // synopsys translate_on
422
                );
423
    defparam
424
        altsource_probe_component.enable_metastability = "NO",
425
        altsource_probe_component.instance_id = "JTAG",
426
        altsource_probe_component.probe_width = Pw,
427
        altsource_probe_component.sld_auto_instance_index = "NO",
428
        altsource_probe_component.sld_instance_index = INDEX,
429
        altsource_probe_component.source_initial_value = " 0",
430
        altsource_probe_component.source_width = Sw;
431
 
432
 
433
endmodule
434
 
435
 

powered by: WebSVN 2.1.0

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