1 |
10 |
khatib |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Title : HDLC core
|
3 |
|
|
-- Project : HDLC Standalone controller with buffers
|
4 |
|
|
-------------------------------------------------------------------------------
|
5 |
|
|
-- File : hdlc.vhd
|
6 |
|
|
-- Author : Jamil Khatib (khatib@ieee.org)
|
7 |
|
|
-- Organization: OpenCores Project
|
8 |
|
|
-- Created :2001/03/022
|
9 |
|
|
-- Last update: 2001/03/22
|
10 |
|
|
-- Platform :
|
11 |
|
|
-- Simulators : Modelsim 5.3XE/Windows98,NC-SIM/Linux
|
12 |
|
|
-- Synthesizers:
|
13 |
|
|
-- Target :
|
14 |
|
|
-- Dependency : ieee.std_logic_1164
|
15 |
|
|
-- hdlc.hdlc_components_pkg
|
16 |
|
|
-------------------------------------------------------------------------------
|
17 |
|
|
-- Description: HDLC controller
|
18 |
|
|
-------------------------------------------------------------------------------
|
19 |
|
|
-- Copyright (c) 2000 Jamil Khatib
|
20 |
|
|
--
|
21 |
|
|
-- This VHDL design file is an open design; you can redistribute it and/or
|
22 |
|
|
-- modify it and/or implement it after contacting the author
|
23 |
|
|
-- You can check the draft license at
|
24 |
|
|
-- http://www.opencores.org/OIPC/license.shtml
|
25 |
|
|
|
26 |
|
|
-------------------------------------------------------------------------------
|
27 |
|
|
-- Revisions :
|
28 |
|
|
-- Revision Number : 1
|
29 |
|
|
-- Version : 0.1
|
30 |
|
|
-- Date : 22 March 2001
|
31 |
|
|
-- Modifier : Jamil Khatib (khatib@ieee.org)
|
32 |
|
|
-- Desccription : Created
|
33 |
|
|
-- ToOptimize :
|
34 |
|
|
-- Bugs :
|
35 |
|
|
-------------------------------------------------------------------------------
|
36 |
|
|
-- $Log: not supported by cvs2svn $
|
37 |
|
|
-- Revision 1.3 2001/04/22 20:08:16 jamil
|
38 |
|
|
-- Top level simulation
|
39 |
|
|
--
|
40 |
|
|
-- Revision 1.1 2001/03/22 21:58:01 jamil
|
41 |
|
|
-- Initial release
|
42 |
|
|
--
|
43 |
|
|
-------------------------------------------------------------------------------
|
44 |
|
|
LIBRARY ieee;
|
45 |
|
|
USE ieee.std_logic_1164.ALL;
|
46 |
|
|
|
47 |
|
|
LIBRARY hdlc;
|
48 |
|
|
USE hdlc.hdlc_components_pkg.ALL;
|
49 |
|
|
|
50 |
|
|
ENTITY hdlc_ent IS
|
51 |
|
|
GENERIC (
|
52 |
|
|
FCS_TYPE : INTEGER := 2; -- FCS 16
|
53 |
|
|
ADD_WIDTH : INTEGER := 7); -- Internal buffer address width
|
54 |
|
|
PORT (
|
55 |
|
|
Txclk : IN STD_LOGIC; -- Tx Clock
|
56 |
|
|
RxClk : IN STD_LOGIC; -- Rx Clock
|
57 |
|
|
Tx : OUT STD_LOGIC; -- Tx setial line
|
58 |
|
|
Rx : IN STD_LOGIC; -- Rx serial line
|
59 |
|
|
TxEN : IN STD_LOGIC; -- Tx Enable
|
60 |
|
|
RxEn : IN STD_LOGIC; -- Rx Enable
|
61 |
|
|
RST_I : IN STD_LOGIC; -- WB reset
|
62 |
|
|
CLK_I : IN STD_LOGIC; -- WB clock
|
63 |
|
|
ADR_I : IN STD_LOGIC_VECTOR(2 DOWNTO 0); -- WB address
|
64 |
|
|
DAT_O : OUT STD_LOGIC_VECTOR(31 DOWNTO 0); -- WB output data
|
65 |
|
|
DAT_I : IN STD_LOGIC_VECTOR(31 DOWNTO 0); -- WB input data
|
66 |
|
|
WE_I : IN STD_LOGIC; -- WB write/read signal
|
67 |
|
|
STB_I : IN STD_LOGIC; -- WB strobe
|
68 |
|
|
ACK_O : OUT STD_LOGIC; -- WB acknowledge
|
69 |
|
|
CYC_I : IN STD_LOGIC; -- WB cycle
|
70 |
|
|
RTY_O : OUT STD_LOGIC; -- WB Retry
|
71 |
|
|
TAG0_O : OUT STD_LOGIC; -- WB TAG (TxDone interrupt)
|
72 |
|
|
TAG1_O : OUT STD_LOGIC); -- WB TAG (RxReady interrupt)
|
73 |
|
|
|
74 |
|
|
END hdlc_ent;
|
75 |
|
|
|
76 |
|
|
ARCHITECTURE hdlc_str OF hdlc_ent IS
|
77 |
|
|
SIGNAL rst_n : STD_LOGIC; -- Internal Reset
|
78 |
|
|
|
79 |
|
|
SIGNAL Tx_rdy_D1 : STD_LOGIC; -- Tx rdy signal (Domain 1)
|
80 |
|
|
SIGNAL Tx_rdy_D2 : STD_LOGIC; -- Tx rdy signal (Domain 2)
|
81 |
|
|
SIGNAL Tx_ack : STD_LOGIC; -- Tx Acknowledge signal
|
82 |
|
|
SIGNAL TXD_D1 : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Tx Data bus (Domain 1)
|
83 |
|
|
SIGNAL TXD_D2 : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Tx Data Bus (Domain 2)
|
84 |
|
|
SIGNAL Tx_ValidFrame_D1 : STD_LOGIC; -- Tx Valid Frame (Domain 1)
|
85 |
|
|
SIGNAL Tx_ValidFrame_D2 : STD_LOGIC; -- Tx Valid Frame (Domain 2)
|
86 |
|
|
SIGNAL Tx_AbortedTrans_D1 : STD_LOGIC; -- Tx Aborted Transmission (Domain 1)
|
87 |
|
|
SIGNAL Tx_AbortedTrans_D2 : STD_LOGIC; -- Tx Aborted Transmission (Domain 2)
|
88 |
|
|
SIGNAL Tx_AbortFrame_D1 : STD_LOGIC; -- Tx Abort Frame (Domain 1)
|
89 |
|
|
SIGNAL Tx_AbortFrame_D2 : STD_LOGIC; -- Tx Abort Frame (Domain 2)
|
90 |
|
|
SIGNAL Tx_WriteByte_D1 : STD_LOGIC; -- Tx Write bytes (Domain 1)
|
91 |
|
|
SIGNAL Tx_WriteByte_D2 : STD_LOGIC; -- Tx Write Byte (Domain 2)
|
92 |
|
|
|
93 |
|
|
SIGNAL Rx_ValidFrame_D1 : STD_LOGIC; -- Rx Valid Frame (Domain1)
|
94 |
|
|
SIGNAL Rx_ValidFrame_D2 : STD_LOGIC; -- Rx Valid Frame (Domain 2)
|
95 |
|
|
|
96 |
|
|
SIGNAL RxD_D1 : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Rx Data bus (Domain 1)
|
97 |
|
|
SIGNAL RXD_D2 : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Rx data bus (Domain 2)
|
98 |
|
|
|
99 |
|
|
SIGNAL Rx_FrameError_D1 : STD_LOGIC; -- Rx Frame Error (Domain 1)
|
100 |
|
|
SIGNAL Rx_FrameError_D2 : STD_LOGIC; -- Rx Frame Error (Domain 2)
|
101 |
|
|
|
102 |
|
|
SIGNAL Rx_AbortSignal_D1 : STD_LOGIC; -- Rx Abort signal (Domain 1)
|
103 |
|
|
SIGNAL Rx_AbortSignal_D2 : STD_LOGIC; -- Rx Abort signal (Domain 2)
|
104 |
|
|
|
105 |
|
|
SIGNAL Rx_Readbyte_D1 : STD_LOGIC; -- Rx Read Byte (Domain 1)
|
106 |
|
|
SIGNAL Rx_Readbyte_D2 : STD_LOGIC; -- Rx Read Byte (Domain 2)
|
107 |
|
|
|
108 |
|
|
SIGNAL Rx_rdy_D1 : STD_LOGIC; -- Rx rdy (Domain 1)
|
109 |
|
|
SIGNAL Rx_rdy_D2 : STD_LOGIC; -- Rx rdy (Domain 2)
|
110 |
|
|
|
111 |
|
|
|
112 |
|
|
SIGNAL TxDataAvail : STD_LOGIC; -- Tx Data Available from the Buffer
|
113 |
|
|
SIGNAL Tx_RdBuff : STD_LOGIC; -- Tx Read Byte from the buffer
|
114 |
|
|
SIGNAL TxDone : STD_LOGIC; -- TxDone bit (Interrupt)
|
115 |
|
|
SIGNAL TxEnable : STD_LOGIC; -- TxEnable Bit
|
116 |
|
|
SIGNAL Tx_Full : STD_LOGIC; -- Tx Full Buffer Bit
|
117 |
|
|
SIGNAL TxDataInBuff : STD_LOGIC_VECTOR(7 DOWNTO 0);
|
118 |
|
|
-- Tx input data to buffer
|
119 |
|
|
SIGNAL TxDataOutBuff : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Tx Data output from buffer
|
120 |
|
|
SIGNAL Tx_Wr_Buff : STD_LOGIC; -- Write to Tx Buffer
|
121 |
|
|
|
122 |
|
|
SIGNAL FCSen : STD_LOGIC; -- FCS Enable (both Tx & Rx)
|
123 |
|
|
|
124 |
|
|
SIGNAL Rx_WrBuff : STD_LOGIC; -- Write to Rx Buffer
|
125 |
|
|
SIGNAL Rx_EOF : STD_LOGIC; -- RX End Of Frame
|
126 |
|
|
SIGNAL Rx_FrameSize : STD_LOGIC_VECTOR(ADD_WIDTH-1 DOWNTO 0);
|
127 |
|
|
-- Rx Frame size
|
128 |
|
|
SIGNAL Rx_DataBuff : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Rx Input data buffer
|
129 |
|
|
SIGNAL Rx_Buff_Overflow : STD_LOGIC; -- Rx Buffer overflow
|
130 |
|
|
SIGNAL Rx_FCSerr : STD_LOGIC; -- Rx FCS error
|
131 |
|
|
SIGNAL RxDataBuffOut : STD_LOGIC_VECTOR(7 DOWNTO 0); -- Rx Data BUFFER output
|
132 |
|
|
|
133 |
|
|
SIGNAL Rx_Rd_Buff : STD_LOGIC; -- Rx Read Data Buffer
|
134 |
|
|
SIGNAL RxRdy_int : STD_LOGIC; -- Rx Ready interrupt
|
135 |
|
|
|
136 |
|
|
BEGIN -- hdlc_str
|
137 |
|
|
|
138 |
|
|
rst_n <= NOT RST_I;
|
139 |
|
|
|
140 |
|
|
WB_host : WB_IF_ent
|
141 |
|
|
GENERIC MAP (
|
142 |
|
|
ADD_WIDTH => ADD_WIDTH)
|
143 |
|
|
PORT MAP (
|
144 |
|
|
CLK_I => CLK_I,
|
145 |
|
|
RST_I => RST_I,
|
146 |
|
|
ACK_O => ACK_O,
|
147 |
|
|
ADR_I => ADR_I,
|
148 |
|
|
CYC_I => CYC_I,
|
149 |
|
|
DAT_I => DAT_I,
|
150 |
|
|
DAT_O => DAT_O,
|
151 |
|
|
RTY_O => RTY_O,
|
152 |
|
|
STB_I => STB_I,
|
153 |
|
|
WE_I => WE_I,
|
154 |
|
|
TAG0_O => TAG0_O,
|
155 |
|
|
TAG1_O => TAG1_O,
|
156 |
|
|
TxEnable => TxEnable,
|
157 |
|
|
TxDone => TxDone,
|
158 |
|
|
TxDataInBuff => TxDataInBuff,
|
159 |
|
|
Txwr => Tx_Wr_Buff,
|
160 |
|
|
TxAborted => Tx_AbortedTrans_D2,
|
161 |
|
|
TxAbort => Tx_AbortFrame_D2,
|
162 |
|
|
TxOverflow => Tx_Full,
|
163 |
|
|
TxFCSen => FCSen,
|
164 |
|
|
RxFrameSize => Rx_FrameSize,
|
165 |
|
|
RxRdy => RxRdy_int,
|
166 |
|
|
RxDataBuffOut => RxDataBuffOut,
|
167 |
|
|
RxOverflow => Rx_Buff_Overflow,
|
168 |
|
|
RxFrameError => Rx_FrameError_D2,
|
169 |
|
|
RxFCSErr => Rx_FCSErr,
|
170 |
|
|
RxRd => Rx_Rd_Buff,
|
171 |
|
|
RxAbort => Rx_AbortSignal_D2);
|
172 |
|
|
|
173 |
|
|
TxSynch : txSynch_ent
|
174 |
|
|
PORT MAP (
|
175 |
|
|
rst_n => rst_n,
|
176 |
|
|
clk_D1 => Txclk,
|
177 |
|
|
clk_D2 => CLK_I,
|
178 |
|
|
rdy_D1 => Tx_rdy_D1,
|
179 |
|
|
rdy_D2 => Tx_rdy_D2,
|
180 |
|
|
ack => Tx_ack,
|
181 |
|
|
TXD_D1 => TXD_D1,
|
182 |
|
|
TXD_D2 => TXD_D2,
|
183 |
|
|
ValidFrame_D1 => Tx_ValidFrame_D1,
|
184 |
|
|
ValidFrame_D2 => Tx_ValidFrame_D2,
|
185 |
|
|
AbortedTrans_D1 => Tx_AbortedTrans_D1,
|
186 |
|
|
AbortedTrans_D2 => Tx_AbortedTrans_D2,
|
187 |
|
|
AbortFrame_D1 => Tx_AbortFrame_D1,
|
188 |
|
|
AbortFrame_D2 => Tx_AbortFrame_D2,
|
189 |
|
|
WriteByte_D1 => Tx_WriteByte_D1,
|
190 |
|
|
WriteByte_D2 => Tx_WriteByte_D2);
|
191 |
|
|
|
192 |
|
|
TxBuff : TxBuff_ent
|
193 |
|
|
GENERIC MAP (
|
194 |
|
|
ADD_WIDTH => ADD_WIDTH)
|
195 |
|
|
PORT MAP (
|
196 |
|
|
TxClk => CLK_I,
|
197 |
|
|
rst_n => rst_n,
|
198 |
|
|
RdBuff => Tx_RdBuff,
|
199 |
|
|
Wr => Tx_Wr_Buff,
|
200 |
|
|
TxDataAvail => TxDataAvail,
|
201 |
|
|
TxEnable => TxEnable,
|
202 |
|
|
TxDone => TxDone,
|
203 |
|
|
TxDataOutBuff => TxDataOutBuff,
|
204 |
|
|
TxDataInBuff => TxDataInBuff,
|
205 |
|
|
Full => Tx_Full);
|
206 |
|
|
|
207 |
|
|
TxFCS : Txfcs_ent
|
208 |
|
|
GENERIC MAP (
|
209 |
|
|
FCS_TYPE => FCS_TYPE)
|
210 |
|
|
PORT MAP (
|
211 |
|
|
TxClk => CLK_I,
|
212 |
|
|
rst_n => rst_n,
|
213 |
|
|
FCSen => FCSen,
|
214 |
|
|
ValidFrame => Tx_ValidFrame_D2,
|
215 |
|
|
WriteByte => Tx_WriteByte_D2,
|
216 |
|
|
rdy => Tx_rdy_D2,
|
217 |
|
|
ack => Tx_ack,
|
218 |
|
|
TxData => TXD_D2,
|
219 |
|
|
TxDataAvail => TxDataAvail,
|
220 |
|
|
RdBuff => Tx_RdBuff,
|
221 |
|
|
TxDataBuff => TxDataOutBuff);
|
222 |
|
|
|
223 |
|
|
|
224 |
|
|
TxCore : TxChannel_ent
|
225 |
|
|
PORT MAP (
|
226 |
|
|
TxClk => TxClk,
|
227 |
|
|
rst_n => rst_n,
|
228 |
|
|
TXEN => TXEN,
|
229 |
|
|
Tx => Tx,
|
230 |
|
|
ValidFrame => Tx_ValidFrame_D1,
|
231 |
|
|
AbortFrame => Tx_AbortFrame_D1,
|
232 |
|
|
AbortedTrans => Tx_AbortedTrans_D1,
|
233 |
|
|
WriteByte => Tx_WriteByte_D1,
|
234 |
|
|
rdy => Tx_rdy_D1,
|
235 |
|
|
TxData => TxD_D1);
|
236 |
|
|
|
237 |
|
|
RxChannel : RxChannel_ent
|
238 |
|
|
PORT MAP (
|
239 |
|
|
Rxclk => Rxclk,
|
240 |
|
|
rst => rst_n,
|
241 |
|
|
Rx => Rx,
|
242 |
|
|
RxData => RxD_D1,
|
243 |
|
|
ValidFrame => Rx_ValidFrame_D1,
|
244 |
|
|
FrameError => Rx_FrameError_D1,
|
245 |
|
|
AbortSignal => Rx_AbortSignal_D1,
|
246 |
|
|
Readbyte => Rx_Readbyte_D1,
|
247 |
|
|
rdy => Rx_rdy_D1,
|
248 |
|
|
RxEn => RxEn);
|
249 |
|
|
|
250 |
|
|
|
251 |
|
|
RxSynch : RxSynch_ent
|
252 |
|
|
PORT MAP (
|
253 |
|
|
rst_n => rst_n,
|
254 |
|
|
clk_D1 => Rxclk,
|
255 |
|
|
clk_D2 => CLK_I,
|
256 |
|
|
rdy_D1 => Rx_rdy_D1,
|
257 |
|
|
rdy_D2 => Rx_rdy_D2,
|
258 |
|
|
RXD_D1 => RxD_D1,
|
259 |
|
|
RXD_D2 => RXD_D2,
|
260 |
|
|
ValidFrame_D1 => Rx_ValidFrame_D1,
|
261 |
|
|
ValidFrame_D2 => Rx_ValidFrame_D2,
|
262 |
|
|
AbortSignal_D1 => Rx_AbortSignal_D1,
|
263 |
|
|
AbortSignal_D2 => Rx_AbortSignal_D2,
|
264 |
|
|
FrameError_D1 => Rx_FrameError_D1,
|
265 |
|
|
FrameError_D2 => Rx_FrameError_D2,
|
266 |
|
|
ReadByte_D1 => Rx_ReadByte_D1,
|
267 |
|
|
ReadByte_D2 => Rx_ReadByte_D2);
|
268 |
|
|
|
269 |
|
|
RxBuff : RxBuff_ent
|
270 |
|
|
GENERIC MAP (
|
271 |
|
|
FCS_TYPE => FCS_TYPE,
|
272 |
|
|
ADD_WIDTH => ADD_WIDTH)
|
273 |
|
|
PORT MAP (
|
274 |
|
|
Clk => CLK_I,
|
275 |
|
|
rst_n => rst_n,
|
276 |
|
|
DataBuff => Rx_DataBuff,
|
277 |
|
|
EOF => Rx_EOF,
|
278 |
|
|
WrBuff => Rx_WrBuff,
|
279 |
|
|
FrameSize => Rx_FrameSize,
|
280 |
|
|
RxRdy => RxRdy_int,
|
281 |
|
|
RxDataBuffOut => RxDataBuffOut,
|
282 |
|
|
Overflow => Rx_Buff_Overflow,
|
283 |
|
|
Rd => Rx_Rd_Buff);
|
284 |
|
|
|
285 |
|
|
|
286 |
|
|
RxFCS : RxFCS_ent
|
287 |
|
|
GENERIC MAP (
|
288 |
|
|
FCS_TYPE => FCS_TYPE)
|
289 |
|
|
PORT MAP (
|
290 |
|
|
clk => CLK_I,
|
291 |
|
|
rst_n => rst_n,
|
292 |
|
|
RxD => RxD_D2,
|
293 |
|
|
ValidFrame => Rx_ValidFrame_D2,
|
294 |
|
|
rdy => Rx_rdy_D2,
|
295 |
|
|
Readbyte => Rx_Readbyte_D2,
|
296 |
|
|
DataBuff => Rx_DataBuff,
|
297 |
|
|
WrBuff => Rx_WrBuff,
|
298 |
|
|
EOF => Rx_EOF,
|
299 |
|
|
FCSen => FCSen,
|
300 |
|
|
FCSerr => Rx_FCSerr);
|
301 |
|
|
|
302 |
|
|
|
303 |
|
|
END hdlc_str;
|