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

Subversion Repositories xulalx25soc

[/] [xulalx25soc/] [trunk/] [rtl/] [jtagser.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dgisselq
///////////////////////////////////////////////////////////////////////////
2
//
3
// Filename:    jtagser.v
4
//
5
// Project:     XuLA2 board
6
//
7
// Purpose:     All interaction between the FPGA and the host computer on a
8
//              XuLA board takes place via the JTAG port and the USER 
9
//      instruction.  There is no serial port, such as I have had on the other
10
//      boards I have worked with.  (Actually, this SoC project will have a 
11
//      UART port, but that port will not command the bus ...)  Nevertheless, I
12
//      still need to convert this JTAG interface into one that looks like a
13
//      32-bit wishbone bus in order to be compatible with all of my other
14
//      work.  This module is part of that conversion.  This module turns bits
15
//      shifted into the JTAG, when it is in the shift-dr state, into bytes
16
//      plus a strobe output to the rest of the FPGA (you can handle a strobe
17
//      at all times, right?).  Likewise, it takes bytes in for transmitting
18
//      back to the host and turns them into bits sent across this port.
19
//
20
//
21
// Creator:     Dan Gisselquist
22
//              Gisselquist Technology, LLC
23
//
24
///////////////////////////////////////////////////////////////////////////
25
//
26
// Copyright (C) 2015, Gisselquist Technology, LLC
27
//
28
// This program is free software (firmware): you can redistribute it and/or
29
// modify it under the terms of  the GNU General Public License as published
30
// by the Free Software Foundation, either version 3 of the License, or (at
31
// your option) any later version.
32
//
33
// This program is distributed in the hope that it will be useful, but WITHOUT
34
// ANY WARRANTY; without even the implied warranty of MERCHANTIBILITY or
35
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
36
// for more details.
37
//
38
// License:     GPL, v3, as defined and found on www.gnu.org,
39
//              http://www.gnu.org/licenses/gpl.html
40
//
41
//
42
///////////////////////////////////////////////////////////////////////////
43
//
44
//
45
module  jtagser(i_clk,
46
                o_rx_stb, o_rx_data, i_tx_stb, i_tx_data, o_tx_busy);
47
        input           i_clk;
48
        //
49
        output  reg             o_rx_stb;
50
        output  reg     [7:0]    o_rx_data;
51
        //
52
        input                   i_tx_stb;
53
        input           [7:0]    i_tx_data;
54
        output  reg             o_tx_busy;
55
 
56
        wire    w_capture, w_drck, w_reset, w_runtest, w_sel, w_shift, w_update,
57
                i_tck, i_tdi, i_tms;
58
        reg     o_tdo;
59
        BSCAN_SPARTAN6 #(.JTAG_CHAIN(1)) BSCANE2_inst(
60
                .CAPTURE(w_capture), // CAPTURE output from TAP controller
61
                .DRCK(w_drck),  // Gated TCK output. When SEL is asserted,
62
                        // DRCK toggles when CAPTURE or SHIFT are asserted
63
                .RESET(w_reset), // RESET output from tap controller
64
                .RUNTEST(w_runtest),
65
                .SEL(w_sel),
66
                .SHIFT(w_shift), // SHIFT output from TAP controller
67
                .TCK(i_tck), // Fabric connection to TCK pin
68
                .TDI(i_tdi), // Fabric connection to TDI pin
69
                .TMS(i_tms), // Fabric connection to TMS pin
70
                .UPDATE(w_update), // Update output from TAP controller
71
                .TDO(o_tdo)); // Test Data output (TDO) input pin for user func
72
 
73
        reg     r_tck, ck_tck, last_tck, edge_tck, r_tdi, ck_tdi,
74
                r_shift, ck_shift, r_sel, ck_sel;
75
        initial r_tck = 1'b0;
76
        initial ck_tck = 1'b0;
77
        initial last_tck = 1'b0;
78
        initial edge_tck = 1'b0;
79
        always @(posedge i_clk)
80
        begin // 10 FF's, 1/2 - 1 LUT
81
                r_tck <= i_tck;     ck_tck <= r_tck;
82
                r_shift <= w_shift; ck_shift <= r_shift;
83
                r_sel   <= w_sel;   ck_sel <= r_sel;
84
                r_tdi   <= i_tdi;   ck_tdi <= r_tdi;
85
                //
86
                last_tck <= ck_tck;
87
                edge_tck <= (ck_tck)&&(~last_tck);
88
                //
89
        end
90
 
91
        reg     [2:0]    state;
92
        initial state <= 0;
93
        always @(posedge i_clk) // Exactly 1 6-LUT and 3 FF's
94
                if (edge_tck)
95
                begin
96
                        if ((~ck_sel)||(~ck_shift))
97
                                state <= 0;
98
                        else if ((ck_sel)&&(ck_shift))
99
                                state <= state + 3'h1;
100
                end
101
 
102
        // Our receive data ... we'll ignore anything less than 8-bits, or
103
        // any fractions of a byte.
104
        always @(posedge i_clk)
105
                if (edge_tck)
106
                        o_rx_data <= { ck_tdi, o_rx_data[7:1] };
107
 
108
        reg     nxt_clk_stb;
109
        initial nxt_clk_stb = 1'b0;
110
        always @(posedge i_clk)
111
                if (edge_tck)
112
                        nxt_clk_stb <= (edge_tck)&&(state == 3'h7)&&(ck_sel)&&(ck_shift);
113
        initial o_rx_stb = 1'b0;
114
        always @(posedge i_clk)
115
                if (edge_tck)
116
                        o_rx_stb <= nxt_clk_stb;
117
                else    o_rx_stb <=1'b0;
118
 
119
        reg     [7:0]    tx_buf;
120
        initial o_tdo = 1'b1;
121
        always @(posedge i_clk) // 12 inputs, ... ? LUTs
122
                if (edge_tck)
123
                        o_tdo <= tx_buf[state];
124
 
125
        reg     filled;
126
        initial filled = 1'b0;
127
        always @(posedge i_clk)
128
        begin // 2-LUTs
129
                if ((i_tx_stb)&&(~o_tx_busy))
130
                        filled <= 1'b1;
131
                else if ((edge_tck)&&(state == 7))
132
                        filled <= 1'b0;
133
        end
134
        always @(posedge i_clk)
135
        begin // tx_busy <- 8 6-bit LUTs
136
                if ((i_tx_stb)&&(~o_tx_busy))
137
                        o_tx_busy <= 1'b1;
138
                else if ((edge_tck)&&(state == 7))
139
                        o_tx_busy <= 1'b0;
140
                else if (state == 0)
141
                        o_tx_busy <= (filled)||((ck_sel)&&(ck_shift));
142
                else if (state == 7)
143
                        o_tx_busy <= 1'b1; // filled;
144
                else
145
                        o_tx_busy <= 1'b1;
146
        end
147
        initial tx_buf = 8'hff;
148
        always @(posedge i_clk) // 8 FF's, 16-LUTs
149
                if ((i_tx_stb)&&(~o_tx_busy))
150
                        tx_buf <= i_tx_data;
151
                else if ((edge_tck)&&(state == 7))
152
                        tx_buf <= 8'hff;
153
 
154
endmodule
155
 

powered by: WebSVN 2.1.0

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