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

Subversion Repositories z80control

[/] [z80control/] [trunk/] [CII_Starter_USB_API_v1/] [HW/] [USB_JTAG.v] - Blame information for rev 12

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 12 tylerapohl
//Legal Notice: (C)2006 Altera Corporation. All rights reserved. Your
2
//use of Altera Corporation's design tools, logic functions and other
3
//software and tools, and its AMPP partner logic functions, and any
4
//output files any of the foregoing (including device programming or
5
//simulation files), and any associated documentation or information are
6
//expressly subject to the terms and conditions of the Altera Program
7
//License Subscription Agreement or other applicable license agreement,
8
//including, without limitation, that your use is for the sole purpose
9
//of programming logic devices manufactured by Altera and sold by Altera
10
//or its authorized distributors.  Please refer to the applicable
11
//agreement for further details.
12
 
13
module USB_JTAG (       //      HOST
14
                                        iTxD_DATA,oTxD_Done,iTxD_Start,
15
                                        oRxD_DATA,oRxD_Ready,iRST_n,iCLK,
16
                                        //      JTAG
17
                                        TDO,TDI,TCS,TCK );
18
input [7:0] iTxD_DATA;
19
input iTxD_Start,iRST_n,iCLK;
20
output reg [7:0] oRxD_DATA;
21
output reg oTxD_Done,oRxD_Ready;
22
input TDI,TCS,TCK;
23
output TDO;
24
wire [7:0] mRxD_DATA;
25
wire mTxD_Done,mRxD_Ready;
26
reg Pre_TxD_Done,Pre_RxD_Ready;
27
reg mTCK;
28
////////////    JTAG CLK Sync.  ///////////////
29
always@(posedge iCLK)   mTCK<=TCK;
30
/////////////////       JTAG Receiver   ///////////////
31
JTAG_REC        u0      (mRxD_DATA,mRxD_Ready,TDI,TCS,mTCK);
32
//      JTAG Receiver Sync.
33
always@(posedge iCLK or negedge iRST_n)
34
begin
35
        if(!iRST_n)
36
        begin
37
                oRxD_Ready<=0;
38
                Pre_RxD_Ready<=0;
39
        end
40
        else
41
        begin
42
                Pre_RxD_Ready<=mRxD_Ready;
43
                if({Pre_RxD_Ready,mRxD_Ready}==2'b01 && ~iTxD_Start)
44
                begin
45
                        oRxD_Ready<=1;
46
                        oRxD_DATA<=mRxD_DATA;
47
                end
48
                else
49
                        oRxD_Ready<=0;
50
        end
51
end
52
///////////////////////////////////////////////////
53
/////////////   JTAG Transmitter        ///////////////
54
JTAG_TRANS      u1      (iTxD_DATA,iTxD_Start,mTxD_Done,TDO,TCK,TCS);
55
//      JTAG Transmitter Sync.
56
always@(posedge iCLK or negedge iRST_n)
57
begin
58
        if(!iRST_n)
59
        begin
60
                oTxD_Done<=0;
61
                Pre_TxD_Done<=0;
62
        end
63
        else
64
        begin
65
                Pre_TxD_Done<=mTxD_Done;
66
                if({Pre_TxD_Done,mTxD_Done}==2'b01)
67
                        oTxD_Done<=1;
68
                else
69
                        oTxD_Done<=0;
70
        end
71
end
72
///////////////////////////////////////////////////
73
endmodule
74
 
75
module JTAG_REC (       //      HOST    
76
                                        oRxD_DATA,oRxD_Ready,
77
                                        //      JTAG
78
                                        TDI,TCS,TCK     );
79
input TDI,TCS,TCK;
80
output reg [7:0] oRxD_DATA;
81
output reg oRxD_Ready;
82
reg [7:0] rDATA;
83
reg [2:0] rCont;
84
always@(posedge TCK or posedge TCS)
85
begin
86
        if(TCS)
87
        begin
88
                oRxD_Ready<=0;
89
                rCont<=0;
90
        end
91
        else
92
        begin
93
                rCont<=rCont+1;
94
                rDATA<={TDI,rDATA[7:1]};
95
                if(rCont==0)
96
                begin
97
                        oRxD_DATA<={TDI,rDATA[7:1]};
98
                        oRxD_Ready<=1;
99
                end
100
                else
101
                        oRxD_Ready<=0;
102
        end
103
end
104
endmodule
105
 
106
module JTAG_TRANS(      //      HOST
107
                                        iTxD_DATA,iTxD_Start,oTxD_Done,
108
                                        //      JTAG
109
                                        TDO,TCK,TCS     );
110
input [7:0] iTxD_DATA;
111
input iTxD_Start;
112
output reg oTxD_Done;
113
input TCK,TCS;
114
output reg TDO;
115
reg [2:0] rCont;
116
always@(posedge TCK or posedge TCS)
117
begin
118
        if(TCS)
119
        begin
120
                oTxD_Done<=0;
121
                rCont<=0;
122
                TDO<=0;
123
        end
124
        else
125
        begin
126
                if(iTxD_Start)
127
                begin
128
                        rCont<=rCont+1;
129
                        TDO<=iTxD_DATA[rCont];
130
                end
131
                else
132
                begin
133
                        rCont<=0;
134
                        TDO<=0;
135
                end
136
                if(rCont==7)
137
                oTxD_Done<=1;
138
                else
139
                oTxD_Done<=0;
140
        end
141
end
142
 
143
endmodule
144
 

powered by: WebSVN 2.1.0

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