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

Subversion Repositories mips_enhanced

[/] [mips_enhanced/] [trunk/] [grlib-gpl-1.0.19-b3188/] [lib/] [opencores/] [can/] [can_top.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dimamali
----------------------------------------------------------------------------------------------
2
--
3
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
4
-- Tue Aug  9 07:33:50 2005
5
--
6
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
7
--      Design name        : can_acf
8
--      Author             : 
9
--      Company            : Actel
10
--
11
--      Description        : 
12
--
13
--
14
----------------------------------------------------------------------------------------------
15
--
16
--////////////////////////////////////////////////////////////////////
17
--//                                                              ////
18
--//  can_acf.v                                                   ////
19
--//                                                              ////
20
--//                                                              ////
21
--//  This file is part of the CAN Protocol Controller            ////
22
--//  http://www.opencores.org/projects/can/                      ////
23
--//                                                              ////
24
--//                                                              ////
25
--//  Author(s):                                                  ////
26
--//       Igor Mohor                                             ////
27
--//       igorm@opencores.org                                    ////
28
--//                                                              ////
29
--//                                                              ////
30
--//  All additional information is available in the README.txt   ////
31
--//  file.                                                       ////
32
--//                                                              ////
33
--////////////////////////////////////////////////////////////////////
34
--//                                                              ////
35
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
36
--//                                                              ////
37
--// This source file may be used and distributed without         ////
38
--// restriction provided that this copyright statement is not    ////
39
--// removed from the file and that any derivative work contains  ////
40
--// the original copyright notice and the associated disclaimer. ////
41
--//                                                              ////
42
--// This source file is free software; you can redistribute it   ////
43
--// and/or modify it under the terms of the GNU Lesser General   ////
44
--// Public License as published by the Free Software Foundation; ////
45
--// either version 2.1 of the License, or (at your option) any   ////
46
--// later version.                                               ////
47
--//                                                              ////
48
--// This source is distributed in the hope that it will be       ////
49
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
50
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
51
--// PURPOSE.  See the GNU Lesser General Public License for more ////
52
--// details.                                                     ////
53
--//                                                              ////
54
--// You should have received a copy of the GNU Lesser General    ////
55
--// Public License along with this source; if not, download it   ////
56
--// from http://www.opencores.org/lgpl.shtml                     ////
57
--//                                                              ////
58
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
59
--// protected by patents. Anybody who wants to implement this    ////
60
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
61
--// from Bosch.                                                  ////
62
--//                                                              ////
63
--////////////////////////////////////////////////////////////////////
64
--
65
-- CVS Revision History
66
--
67
-- $Log: can_acf.v,v $
68
-- Revision 1.10  2005/04/08 13:03:07  igorm
69
-- In "Extended mode" when dual filter was used and standard frame received,
70
-- upper nibble of the data was not filtered ok.
71
--
72
-- Revision 1.9  2004/05/31 14:46:11  igorm
73
-- Bit acceptance_filter_mode was inverted.
74
--
75
-- Revision 1.8  2004/02/08 14:16:44  mohor
76
-- Header changed.
77
--
78
-- Revision 1.7  2003/07/16 13:41:34  mohor
79
-- Fixed according to the linter.
80
--
81
-- Revision 1.6  2003/02/10 16:02:11  mohor
82
-- CAN is working according to the specification. WB interface and more
83
-- registers (status, IRQ, ...) needs to be added.
84
--
85
-- Revision 1.5  2003/02/09 18:40:29  mohor
86
-- Overload fixed. Hard synchronization also enabled at the last bit of
87
-- interframe.
88
--
89
-- Revision 1.4  2003/02/09 02:24:33  mohor
90
-- Bosch license warning added. Error counters finished. Overload frames
91
-- still need to be fixed.
92
--
93
-- Revision 1.3  2003/01/31 01:13:37  mohor
94
-- backup.
95
--
96
-- Revision 1.2  2003/01/14 12:19:35  mohor
97
-- rx_fifo is now working.
98
--
99
-- Revision 1.1  2003/01/08 02:13:15  mohor
100
-- Acceptance filter added.
101
--
102
--
103
--
104
--
105
-- synopsys translate_off
106
--`include "can_defines.v"
107
-- synopsys translate_on
108
 
109
LIBRARY ieee;
110
USE ieee.std_logic_1164.all;
111
USE ieee.numeric_std.all;
112
library grlib;
113
use grlib.stdlib.all;
114
 
115
ENTITY can_acf IS
116
   PORT (
117
      clk                     : IN std_logic;
118
      rst                     : IN std_logic;
119
      id                      : IN std_logic_vector(28 DOWNTO 0);
120
      reset_mode              : IN std_logic;
121
      acceptance_filter_mode  : IN std_logic;
122
      extended_mode           : IN std_logic;
123
      acceptance_code_0       : IN std_logic_vector(7 DOWNTO 0);
124
      acceptance_code_1       : IN std_logic_vector(7 DOWNTO 0);
125
      acceptance_code_2       : IN std_logic_vector(7 DOWNTO 0);
126
      acceptance_code_3       : IN std_logic_vector(7 DOWNTO 0);
127
      acceptance_mask_0       : IN std_logic_vector(7 DOWNTO 0);
128
      acceptance_mask_1       : IN std_logic_vector(7 DOWNTO 0);
129
      acceptance_mask_2       : IN std_logic_vector(7 DOWNTO 0);
130
      acceptance_mask_3       : IN std_logic_vector(7 DOWNTO 0);
131
      go_rx_crc_lim           : IN std_logic;
132
      go_rx_inter             : IN std_logic;
133
      go_error_frame          : IN std_logic;
134
      data0                   : IN std_logic_vector(7 DOWNTO 0);
135
      data1                   : IN std_logic_vector(7 DOWNTO 0);
136
      rtr1                    : IN std_logic;
137
      rtr2                    : IN std_logic;
138
      ide                     : IN std_logic;
139
      no_byte0                : IN std_logic;
140
      no_byte1                : IN std_logic;
141
      id_ok                   : OUT std_logic);
142
END ENTITY can_acf;
143
 
144
ARCHITECTURE RTL OF can_acf IS
145
 
146
 
147
   SIGNAL match                    :  std_logic;
148
   SIGNAL match_sf_std             :  std_logic;
149
   SIGNAL match_sf_ext             :  std_logic;
150
   SIGNAL match_df_std             :  std_logic;
151
   SIGNAL match_df_ext             :  std_logic;
152
   SIGNAL id_ok_xhdl1              :  std_logic;
153
 
154
BEGIN
155
   id_ok <= id_ok_xhdl1;
156
   -- Working in basic mode. ID match for standard format (11-bit ID).
157
   match <= (((((((CONV_STD_LOGIC(id(3) = acceptance_code_0(0)) OR acceptance_mask_0(0)) AND (CONV_STD_LOGIC(id(4) = acceptance_code_0(1)) OR acceptance_mask_0(1))) AND (CONV_STD_LOGIC(id(5) = acceptance_code_0(2)) OR acceptance_mask_0(2))) AND (CONV_STD_LOGIC(id(6) = acceptance_code_0(3)) OR acceptance_mask_0(3))) AND (CONV_STD_LOGIC(id(7) = acceptance_code_0(4)) OR acceptance_mask_0(4))) AND (CONV_STD_LOGIC(id(8) = acceptance_code_0(5)) OR acceptance_mask_0(5))) AND (CONV_STD_LOGIC(id(9) = acceptance_code_0(6)) OR acceptance_mask_0(6))) AND (CONV_STD_LOGIC(id(10) = acceptance_code_0(7)) OR acceptance_mask_0(7)) ;
158
   -- Working in extended mode. ID match for standard format (11-bit ID). Using single filter.
159
   match_sf_std <= (((((((((((((((((((((((((((CONV_STD_LOGIC(id(3) = acceptance_code_0(0)) OR acceptance_mask_0(0)) AND (CONV_STD_LOGIC(id(4) = acceptance_code_0(1))
160
        OR acceptance_mask_0(1))) AND (CONV_STD_LOGIC(id(5) = acceptance_code_0(2)) OR acceptance_mask_0(2))) AND (CONV_STD_LOGIC(id(6) = acceptance_code_0(3))
161
        OR acceptance_mask_0(3))) AND (CONV_STD_LOGIC(id(7) = acceptance_code_0(4)) OR acceptance_mask_0(4))) AND (CONV_STD_LOGIC(id(8) = acceptance_code_0(5))
162
        OR acceptance_mask_0(5))) AND (CONV_STD_LOGIC(id(9) = acceptance_code_0(6)) OR acceptance_mask_0(6))) AND (CONV_STD_LOGIC(id(10) = acceptance_code_0(7))
163
        OR acceptance_mask_0(7))) AND (CONV_STD_LOGIC(rtr1 = acceptance_code_1(4)) OR acceptance_mask_1(4))) AND (CONV_STD_LOGIC(id(0) = acceptance_code_1(5))
164
        OR acceptance_mask_1(5))) AND (CONV_STD_LOGIC(id(1) = acceptance_code_1(6)) OR acceptance_mask_1(6))) AND (CONV_STD_LOGIC(id(2) = acceptance_code_1(7))
165
        OR acceptance_mask_1(7))) AND (CONV_STD_LOGIC(data0(0) = acceptance_code_2(0)) OR acceptance_mask_2(0) OR no_byte0)) AND (CONV_STD_LOGIC(data0(1) = acceptance_code_2(1))
166
        OR acceptance_mask_2(1) OR no_byte0)) AND (CONV_STD_LOGIC(data0(2) = acceptance_code_2(2)) OR acceptance_mask_2(2)
167
        OR no_byte0)) AND (CONV_STD_LOGIC(data0(3) = acceptance_code_2(3)) OR acceptance_mask_2(3) OR no_byte0)) AND (CONV_STD_LOGIC(data0(4) = acceptance_code_2(4))
168
        OR acceptance_mask_2(4) OR no_byte0)) AND (CONV_STD_LOGIC(data0(5) = acceptance_code_2(5)) OR acceptance_mask_2(5) OR no_byte0)) AND (CONV_STD_LOGIC(data0(6) = acceptance_code_2(6))
169
        OR acceptance_mask_2(6) OR no_byte0)) AND (CONV_STD_LOGIC(data0(7) = acceptance_code_2(7)) OR acceptance_mask_2(7) OR no_byte0)) AND (CONV_STD_LOGIC(data1(0) = acceptance_code_3(0))
170
        OR acceptance_mask_3(0) OR no_byte1)) AND (CONV_STD_LOGIC(data1(1) = acceptance_code_3(1)) OR acceptance_mask_3(1) OR no_byte1)) AND (CONV_STD_LOGIC(data1(2) = acceptance_code_3(2))
171
        OR acceptance_mask_3(2) OR no_byte1)) AND (CONV_STD_LOGIC(data1(3) = acceptance_code_3(3)) OR acceptance_mask_3(3) OR no_byte1)) AND (CONV_STD_LOGIC(data1(4) = acceptance_code_3(4))
172
        OR acceptance_mask_3(4) OR no_byte1)) AND (CONV_STD_LOGIC(data1(5) = acceptance_code_3(5)) OR acceptance_mask_3(5) OR no_byte1)) AND (CONV_STD_LOGIC(data1(6) = acceptance_code_3(6))
173
        OR acceptance_mask_3(6) OR no_byte1)) AND (CONV_STD_LOGIC(data1(7) = acceptance_code_3(7)) OR acceptance_mask_3(7) OR no_byte1) ;
174
   -- Working in extended mode. ID match for extended format (29-bit ID). Using single filter.
175
   match_sf_ext <= (((((((((((((((((((((((((((((CONV_STD_LOGIC(id(21) = acceptance_code_0(0)) OR acceptance_mask_0(0)) AND (CONV_STD_LOGIC(id(22) = acceptance_code_0(1))
176
        OR acceptance_mask_0(1))) AND (CONV_STD_LOGIC(id(23) = acceptance_code_0(2)) OR acceptance_mask_0(2))) AND (CONV_STD_LOGIC(id(24) = acceptance_code_0(3))
177
        OR acceptance_mask_0(3))) AND (CONV_STD_LOGIC(id(25) = acceptance_code_0(4)) OR acceptance_mask_0(4))) AND (CONV_STD_LOGIC(id(26) = acceptance_code_0(5))
178
        OR acceptance_mask_0(5))) AND (CONV_STD_LOGIC(id(27) = acceptance_code_0(6)) OR acceptance_mask_0(6))) AND (CONV_STD_LOGIC(id(28) = acceptance_code_0(7))
179
        OR acceptance_mask_0(7))) AND (CONV_STD_LOGIC(id(13) = acceptance_code_1(0)) OR acceptance_mask_1(0))) AND (CONV_STD_LOGIC(id(14) = acceptance_code_1(1))
180
        OR acceptance_mask_1(1))) AND (CONV_STD_LOGIC(id(15) = acceptance_code_1(2)) OR acceptance_mask_1(2))) AND (CONV_STD_LOGIC(id(16) = acceptance_code_1(3))
181
        OR acceptance_mask_1(3))) AND (CONV_STD_LOGIC(id(17) = acceptance_code_1(4)) OR acceptance_mask_1(4))) AND (CONV_STD_LOGIC(id(18) = acceptance_code_1(5))
182
        OR acceptance_mask_1(5))) AND (CONV_STD_LOGIC(id(19) = acceptance_code_1(6)) OR acceptance_mask_1(6))) AND (CONV_STD_LOGIC(id(20) = acceptance_code_1(7))
183
        OR acceptance_mask_1(7))) AND (CONV_STD_LOGIC(id(5) = acceptance_code_2(0)) OR acceptance_mask_2(0))) AND (CONV_STD_LOGIC(id(6) = acceptance_code_2(1))
184
        OR acceptance_mask_2(1))) AND (CONV_STD_LOGIC(id(7) = acceptance_code_2(2)) OR acceptance_mask_2(2))) AND (CONV_STD_LOGIC(id(8) = acceptance_code_2(3))
185
        OR acceptance_mask_2(3))) AND (CONV_STD_LOGIC(id(9) = acceptance_code_2(4)) OR acceptance_mask_2(4))) AND (CONV_STD_LOGIC(id(10) = acceptance_code_2(5))
186
        OR acceptance_mask_2(5))) AND (CONV_STD_LOGIC(id(11) = acceptance_code_2(6)) OR acceptance_mask_2(6))) AND (CONV_STD_LOGIC(id(12) = acceptance_code_2(7))
187
        OR acceptance_mask_2(7))) AND (CONV_STD_LOGIC(rtr2 = acceptance_code_3(2)) OR acceptance_mask_3(2))) AND (CONV_STD_LOGIC(id(0) = acceptance_code_3(3))
188
         OR acceptance_mask_3(3))) AND (CONV_STD_LOGIC(id(1) = acceptance_code_3(4)) OR acceptance_mask_3(4))) AND (CONV_STD_LOGIC(id(2) = acceptance_code_3(5))
189
        OR acceptance_mask_3(5))) AND (CONV_STD_LOGIC(id(3) = acceptance_code_3(6)) OR acceptance_mask_3(6))) AND (CONV_STD_LOGIC(id(4) = acceptance_code_3(7))
190
        OR acceptance_mask_3(7)) ;
191
   -- Working in extended mode. ID match for standard format (11-bit ID). Using double filter.
192
   match_df_std <= ((((((((((((((((((((CONV_STD_LOGIC(id(3) = acceptance_code_0(0)) OR acceptance_mask_0(0)) AND (CONV_STD_LOGIC(id(4) = acceptance_code_0(1))
193
        OR acceptance_mask_0(1))) AND (CONV_STD_LOGIC(id(5) = acceptance_code_0(2)) OR acceptance_mask_0(2))) AND (CONV_STD_LOGIC(id(6) = acceptance_code_0(3))
194
        OR acceptance_mask_0(3))) AND (CONV_STD_LOGIC(id(7) = acceptance_code_0(4)) OR acceptance_mask_0(4))) AND (CONV_STD_LOGIC(id(8) = acceptance_code_0(5))
195
        OR acceptance_mask_0(5))) AND (CONV_STD_LOGIC(id(9) = acceptance_code_0(6)) OR acceptance_mask_0(6))) AND (CONV_STD_LOGIC(id(10) = acceptance_code_0(7))
196
        OR acceptance_mask_0(7))) AND (CONV_STD_LOGIC(rtr1 = acceptance_code_1(4)) OR acceptance_mask_1(4))) AND (CONV_STD_LOGIC(id(0) = acceptance_code_1(5))
197
        OR acceptance_mask_1(5))) AND (CONV_STD_LOGIC(id(1) = acceptance_code_1(6)) OR acceptance_mask_1(6))) AND (CONV_STD_LOGIC(id(2) = acceptance_code_1(7))
198
 
199
        OR acceptance_mask_1(7))) AND (CONV_STD_LOGIC(data0(0) = acceptance_code_3(0)) OR acceptance_mask_3(0)
200
        OR no_byte0)) AND (CONV_STD_LOGIC(data0(1) = acceptance_code_3(1)) OR acceptance_mask_3(1) OR no_byte0)) AND (CONV_STD_LOGIC(data0(2) = acceptance_code_3(2))
201
        OR acceptance_mask_3(2) OR no_byte0)) AND (CONV_STD_LOGIC(data0(3) = acceptance_code_3(3)) OR acceptance_mask_3(3)
202
        OR no_byte0)) AND (CONV_STD_LOGIC(data0(4) = acceptance_code_1(0)) OR acceptance_mask_1(0) OR no_byte0)) AND (CONV_STD_LOGIC(data0(5) = acceptance_code_1(1))
203
        OR acceptance_mask_1(1) OR no_byte0)) AND (CONV_STD_LOGIC(data0(6) = acceptance_code_1(2))
204
        OR acceptance_mask_1(2) OR no_byte0)) AND (CONV_STD_LOGIC(data0(7) = acceptance_code_1(3)) OR acceptance_mask_1(3) OR no_byte0))
205
 
206
        OR ((((((((((((CONV_STD_LOGIC(id(3) = acceptance_code_2(0)) OR acceptance_mask_2(0)) AND (CONV_STD_LOGIC(id(4) = acceptance_code_2(1))
207
        OR acceptance_mask_2(1))) AND (CONV_STD_LOGIC(id(5) = acceptance_code_2(2)) OR acceptance_mask_2(2))) AND (CONV_STD_LOGIC(id(6) = acceptance_code_2(3))
208
        OR acceptance_mask_2(3))) AND (CONV_STD_LOGIC(id(7) = acceptance_code_2(4)) OR acceptance_mask_2(4))) AND (CONV_STD_LOGIC(id(8) = acceptance_code_2(5))
209
        OR acceptance_mask_2(5))) AND (CONV_STD_LOGIC(id(9) = acceptance_code_2(6)) OR acceptance_mask_2(6))) AND (CONV_STD_LOGIC(id(10) = acceptance_code_2(7))
210
        OR acceptance_mask_2(7))) AND (CONV_STD_LOGIC(rtr1 = acceptance_code_3(4)) OR acceptance_mask_3(4))) AND (CONV_STD_LOGIC(id(0) = acceptance_code_3(5))
211
        OR acceptance_mask_3(5))) AND (CONV_STD_LOGIC(id(1) = acceptance_code_3(6)) OR acceptance_mask_3(6))) AND (CONV_STD_LOGIC(id(2) = acceptance_code_3(7))
212
        OR acceptance_mask_3(7))) ;
213
   -- Working in extended mode. ID match for extended format (29-bit ID). Using double filter.
214
   match_df_ext <= ((((((((((((((((CONV_STD_LOGIC(id(21) = acceptance_code_0(0)) OR acceptance_mask_0(0)) AND (CONV_STD_LOGIC(id(22) = acceptance_code_0(1))
215
        OR acceptance_mask_0(1))) AND (CONV_STD_LOGIC(id(23) = acceptance_code_0(2)) OR acceptance_mask_0(2))) AND (CONV_STD_LOGIC(id(24) = acceptance_code_0(3))
216
        OR acceptance_mask_0(3))) AND (CONV_STD_LOGIC(id(25) = acceptance_code_0(4)) OR acceptance_mask_0(4))) AND (CONV_STD_LOGIC(id(26) = acceptance_code_0(5))
217
        OR acceptance_mask_0(5))) AND (CONV_STD_LOGIC(id(27) = acceptance_code_0(6)) OR acceptance_mask_0(6))) AND (CONV_STD_LOGIC(id(28) = acceptance_code_0(7))
218
        OR acceptance_mask_0(7))) AND (CONV_STD_LOGIC(id(13) = acceptance_code_1(0)) OR acceptance_mask_1(0))) AND (CONV_STD_LOGIC(id(14) = acceptance_code_1(1))
219
        OR acceptance_mask_1(1))) AND (CONV_STD_LOGIC(id(15) = acceptance_code_1(2)) OR acceptance_mask_1(2))) AND (CONV_STD_LOGIC(id(16) = acceptance_code_1(3))
220
        OR acceptance_mask_1(3))) AND (CONV_STD_LOGIC(id(17) = acceptance_code_1(4)) OR acceptance_mask_1(4))) AND (CONV_STD_LOGIC(id(18) = acceptance_code_1(5))
221
        OR acceptance_mask_1(5))) AND (CONV_STD_LOGIC(id(19) = acceptance_code_1(6)) OR acceptance_mask_1(6))) AND (CONV_STD_LOGIC(id(20) = acceptance_code_1(7))
222
        OR acceptance_mask_1(7))) OR ((((((((((((((((CONV_STD_LOGIC(id(21) = acceptance_code_2(0)) OR acceptance_mask_2(0)) AND (CONV_STD_LOGIC(id(22) = acceptance_code_2(1))
223
        OR acceptance_mask_2(1))) AND (CONV_STD_LOGIC(id(23) = acceptance_code_2(2)) OR acceptance_mask_2(2))) AND (CONV_STD_LOGIC(id(24) = acceptance_code_2(3))
224
        OR acceptance_mask_2(3))) AND (CONV_STD_LOGIC(id(25) = acceptance_code_2(4)) OR acceptance_mask_2(4))) AND (CONV_STD_LOGIC(id(26) = acceptance_code_2(5))
225
        OR acceptance_mask_2(5))) AND (CONV_STD_LOGIC(id(27) = acceptance_code_2(6)) OR acceptance_mask_2(6))) AND (CONV_STD_LOGIC(id(28) = acceptance_code_2(7))
226
        OR acceptance_mask_2(7))) AND (CONV_STD_LOGIC(id(13) = acceptance_code_3(0)) OR acceptance_mask_3(0))) AND (CONV_STD_LOGIC(id(14) = acceptance_code_3(1))
227
        OR acceptance_mask_3(1))) AND (CONV_STD_LOGIC(id(15) = acceptance_code_3(2)) OR acceptance_mask_3(2))) AND (CONV_STD_LOGIC(id(16) = acceptance_code_3(3))
228
        OR acceptance_mask_3(3))) AND (CONV_STD_LOGIC(id(17) = acceptance_code_3(4)) OR acceptance_mask_3(4))) AND (CONV_STD_LOGIC(id(18) = acceptance_code_3(5))
229
        OR acceptance_mask_3(5))) AND (CONV_STD_LOGIC(id(19) = acceptance_code_3(6)) OR acceptance_mask_3(6))) AND (CONV_STD_LOGIC(id(20) = acceptance_code_3(7))
230
        OR acceptance_mask_3(7))) ;
231
 
232
   -- ID ok signal generation
233
 
234
   PROCESS (clk, rst)
235
   BEGIN
236
      IF (rst = '1') THEN
237
         id_ok_xhdl1 <= '0';
238
      ELSIF (clk'EVENT AND clk = '1') THEN
239
         IF (go_rx_crc_lim = '1') THEN
240
            -- sample_point is already included in go_rx_crc_lim
241
 
242
            IF (extended_mode = '1') THEN
243
               IF (NOT acceptance_filter_mode = '1') THEN
244
                  -- dual filter
245
 
246
                  IF (ide = '1') THEN
247
                     -- extended frame message
248
 
249
                     id_ok_xhdl1 <= match_df_ext ;
250
                  ELSE
251
                     -- standard frame message
252
 
253
                     id_ok_xhdl1 <= match_df_std ;
254
                  END IF;
255
               ELSE
256
                  -- single filter
257
 
258
                  IF (ide = '1') THEN
259
                     -- extended frame message
260
 
261
                     id_ok_xhdl1 <= match_sf_ext ;
262
                  ELSE
263
                     -- standard frame message
264
 
265
                     id_ok_xhdl1 <= match_sf_std ;
266
                  END IF;
267
               END IF;
268
            ELSE
269
               id_ok_xhdl1 <= match ;
270
            END IF;
271
         ELSE
272
            IF ((reset_mode OR go_rx_inter OR go_error_frame) = '1') THEN
273
               -- sample_point is already included in go_rx_inter
274
 
275
               id_ok_xhdl1 <= '0' ;
276
            END IF;
277
         END IF;
278
      END IF;
279
   END PROCESS;
280
 
281
END ARCHITECTURE RTL;
282
----------------------------------------------------------------------------------------------
283
--
284
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
285
-- Tue Aug  9 07:33:51 2005
286
--
287
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
288
--      Design name        : can_btl
289
--      Author             : 
290
--      Company            : Actel
291
--
292
--      Description        : 
293
--
294
--
295
----------------------------------------------------------------------------------------------
296
--
297
--////////////////////////////////////////////////////////////////////
298
--//                                                              ////
299
--//  can_btl.v                                                   ////
300
--//                                                              ////
301
--//                                                              ////
302
--//  This file is part of the CAN Protocol Controller            ////
303
--//  http://www.opencores.org/projects/can/                      ////
304
--//                                                              ////
305
--//                                                              ////
306
--//  Author(s):                                                  ////
307
--//       Igor Mohor                                             ////
308
--//       igorm@opencores.org                                    ////
309
--//                                                              ////
310
--//                                                              ////
311
--//  All additional information is available in the README.txt   ////
312
--//  file.                                                       ////
313
--//                                                              ////
314
--////////////////////////////////////////////////////////////////////
315
--//                                                              ////
316
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
317
--//                                                              ////
318
--// This source file may be used and distributed without         ////
319
--// restriction provided that this copyright statement is not    ////
320
--// removed from the file and that any derivative work contains  ////
321
--// the original copyright notice and the associated disclaimer. ////
322
--//                                                              ////
323
--// This source file is free software; you can redistribute it   ////
324
--// and/or modify it under the terms of the GNU Lesser General   ////
325
--// Public License as published by the Free Software Foundation; ////
326
--// either version 2.1 of the License, or (at your option) any   ////
327
--// later version.                                               ////
328
--//                                                              ////
329
--// This source is distributed in the hope that it will be       ////
330
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
331
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
332
--// PURPOSE.  See the GNU Lesser General Public License for more ////
333
--// details.                                                     ////
334
--//                                                              ////
335
--// You should have received a copy of the GNU Lesser General    ////
336
--// Public License along with this source; if not, download it   ////
337
--// from http://www.opencores.org/lgpl.shtml                     ////
338
--//                                                              ////
339
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
340
--// protected by patents. Anybody who wants to implement this    ////
341
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
342
--// from Bosch.                                                  ////
343
--//                                                              ////
344
--////////////////////////////////////////////////////////////////////
345
--
346
-- CVS Revision History
347
--
348
-- $Log: can_btl.v,v $
349
-- Revision 1.30  2004/10/27 18:51:37  igorm
350
-- Fixed synchronization problem in real hardware when 0xf is used for TSEG1.
351
--
352
-- Revision 1.29  2004/05/12 15:58:41  igorm
353
-- Core improved to pass all tests with the Bosch VHDL Reference system.
354
--
355
-- Revision 1.28  2004/02/08 14:25:26  mohor
356
-- Header changed.
357
--
358
-- Revision 1.27  2003/09/30 00:55:13  mohor
359
-- Error counters fixed to be compatible with Bosch VHDL reference model.
360
-- Small synchronization changes.
361
--
362
-- Revision 1.26  2003/09/25 18:55:49  mohor
363
-- Synchronization changed, error counters fixed.
364
--
365
-- Revision 1.25  2003/07/16 13:40:35  mohor
366
-- Fixed according to the linter.
367
--
368
-- Revision 1.24  2003/07/10 15:32:28  mohor
369
-- Unused signal removed.
370
--
371
-- Revision 1.23  2003/07/10 01:59:04  tadejm
372
-- Synchronization fixed. In some strange cases it didn't work according to
373
-- the VHDL reference model.
374
--
375
-- Revision 1.22  2003/07/07 11:21:37  mohor
376
-- Little fixes (to fix warnings).
377
--
378
-- Revision 1.21  2003/07/03 09:32:20  mohor
379
-- Synchronization changed.
380
--
381
-- Revision 1.20  2003/06/20 14:51:11  mohor
382
-- Previous change removed. When resynchronization occurs we go to seg1
383
-- stage. sync stage does not cause another start of seg1 stage.
384
--
385
-- Revision 1.19  2003/06/20 14:28:20  mohor
386
-- When hard_sync or resync occure we need to go to seg1 segment. Going to
387
-- sync segment is in that case blocked.
388
--
389
-- Revision 1.18  2003/06/17 15:53:33  mohor
390
-- clk_cnt reduced from [8:0] to [6:0].
391
--
392
-- Revision 1.17  2003/06/17 14:32:17  mohor
393
-- Removed few signals.
394
--
395
-- Revision 1.16  2003/06/16 13:57:58  mohor
396
-- tx_point generated one clk earlier. rx_i registered. Data corrected when
397
-- using extended mode.
398
--
399
-- Revision 1.15  2003/06/13 15:02:24  mohor
400
-- Synchronization is also needed when transmitting a message.
401
--
402
-- Revision 1.14  2003/06/13 14:55:11  mohor
403
-- Counters width changed.
404
--
405
-- Revision 1.13  2003/06/11 14:21:35  mohor
406
-- When switching to tx, sync stage is overjumped.
407
--
408
-- Revision 1.12  2003/02/14 20:17:01  mohor
409
-- Several registers added. Not finished, yet.
410
--
411
-- Revision 1.11  2003/02/09 18:40:29  mohor
412
-- Overload fixed. Hard synchronization also enabled at the last bit of
413
-- interframe.
414
--
415
-- Revision 1.10  2003/02/09 02:24:33  mohor
416
-- Bosch license warning added. Error counters finished. Overload frames
417
-- still need to be fixed.
418
--
419
-- Revision 1.9  2003/01/31 01:13:38  mohor
420
-- backup.
421
--
422
-- Revision 1.8  2003/01/10 17:51:34  mohor
423
-- Temporary version (backup).
424
--
425
-- Revision 1.7  2003/01/08 02:10:53  mohor
426
-- Acceptance filter added.
427
--
428
-- Revision 1.6  2002/12/28 04:13:23  mohor
429
-- Backup version.
430
--
431
-- Revision 1.5  2002/12/27 00:12:52  mohor
432
-- Header changed, testbench improved to send a frame (crc still missing).
433
--
434
-- Revision 1.4  2002/12/26 01:33:05  mohor
435
-- Tripple sampling supported.
436
--
437
-- Revision 1.3  2002/12/25 23:44:16  mohor
438
-- Commented lines removed.
439
--
440
-- Revision 1.2  2002/12/25 14:17:00  mohor
441
-- Synchronization working.
442
--
443
-- Revision 1.1.1.1  2002/12/20 16:39:21  mohor
444
-- Initial
445
--
446
--
447
--
448
-- synopsys translate_off
449
--`include "can_defines.v"
450
-- synopsys translate_on
451
 
452
LIBRARY ieee;
453
USE ieee.std_logic_1164.all;
454
USE ieee.numeric_std.all;
455
library grlib;
456
use grlib.stdlib.all;
457
 
458
ENTITY can_btl IS
459
   PORT (
460
      clk                     : IN std_logic;
461
      rst                     : IN std_logic;
462
      rx                      : IN std_logic;
463
      tx                      : IN std_logic;
464
      -- Bus Timing 0 register 
465
      baud_r_presc            : IN std_logic_vector(5 DOWNTO 0);
466
      sync_jump_width         : IN std_logic_vector(1 DOWNTO 0);
467
      -- Bus Timing 1 register 
468
      time_segment1           : IN std_logic_vector(3 DOWNTO 0);
469
      time_segment2           : IN std_logic_vector(2 DOWNTO 0);
470
      triple_sampling         : IN std_logic;
471
      -- Output signals from this module 
472
      sample_point            : OUT std_logic;
473
      sampled_bit             : OUT std_logic;
474
      sampled_bit_q           : OUT std_logic;
475
      tx_point                : OUT std_logic;
476
      hard_sync               : OUT std_logic;
477
      -- Output from can_bsp module 
478
      rx_idle                 : IN std_logic;
479
      rx_inter                : IN std_logic;
480
      transmitting            : IN std_logic;
481
      transmitter             : IN std_logic;
482
      go_rx_inter             : IN std_logic;
483
      tx_next                 : IN std_logic;
484
      go_overload_frame       : IN std_logic;
485
      go_error_frame          : IN std_logic;
486
      go_tx                   : IN std_logic;
487
      send_ack                : IN std_logic;
488
      node_error_passive      : IN std_logic);
489
END ENTITY can_btl;
490
 
491
ARCHITECTURE RTL OF can_btl IS
492
 
493
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
494
 
495
   SIGNAL clk_cnt                  :  std_logic_vector(6 DOWNTO 0);
496
   SIGNAL clk_en                   :  std_logic;
497
   SIGNAL clk_en_q                 :  std_logic;
498
   SIGNAL sync_blocked             :  std_logic;
499
   SIGNAL hard_sync_blocked        :  std_logic;
500
   SIGNAL quant_cnt                :  std_logic_vector(4 DOWNTO 0);
501
   SIGNAL delay                    :  std_logic_vector(3 DOWNTO 0);
502
   SIGNAL sync                     :  std_logic;
503
   SIGNAL seg1                     :  std_logic;
504
   SIGNAL seg2                     :  std_logic;
505
   SIGNAL resync_latched           :  std_logic;
506
   SIGNAL sample                   :  std_logic_vector(1 DOWNTO 0);
507
   SIGNAL tx_next_sp               :  std_logic;
508
   SIGNAL go_sync                  :  std_logic;
509
   SIGNAL go_seg1                  :  std_logic;
510
   SIGNAL go_seg2                  :  std_logic;
511
   SIGNAL preset_cnt               :  std_logic_vector(7 DOWNTO 0);
512
   SIGNAL sync_window              :  std_logic;
513
   SIGNAL resync                   :  std_logic;
514
   -- when transmitting 0 with positive error delay is set to 0
515
   SIGNAL temp_xhdl6               :  std_logic_vector(4 DOWNTO 0);
516
   SIGNAL sample_point_xhdl1       :  std_logic;
517
   SIGNAL sampled_bit_xhdl2        :  std_logic;
518
   SIGNAL sampled_bit_q_xhdl3      :  std_logic;
519
   SIGNAL tx_point_xhdl4           :  std_logic;
520
   SIGNAL hard_sync_xhdl5          :  std_logic;
521
 
522
BEGIN
523
   sample_point <= sample_point_xhdl1;
524
   sampled_bit <= sampled_bit_xhdl2;
525
   sampled_bit_q <= sampled_bit_q_xhdl3;
526
   tx_point <= tx_point_xhdl4;
527
   hard_sync <= hard_sync_xhdl5;
528
   preset_cnt <=  (('0' & baud_r_presc) + 1) & "0" ;
529
   hard_sync_xhdl5 <= (((rx_idle OR rx_inter) AND (NOT rx)) AND sampled_bit_xhdl2) AND (NOT hard_sync_blocked) ;
530
   resync <= ((((NOT rx_idle) AND (NOT rx_inter)) AND (NOT rx)) AND sampled_bit_xhdl2) AND (NOT sync_blocked) ;
531
 
532
   -- Generating general enable signal that defines baud rate. 
533
   PROCESS (clk, rst)
534
   BEGIN
535
      IF (rst = '1') THEN
536
         clk_cnt <= "0000000";
537
      ELSIF (clk'EVENT AND clk = '1') THEN
538
         IF (('0' & clk_cnt) >= (preset_cnt - "00000001")) THEN
539
            clk_cnt <= "0000000" ;
540
         ELSE
541
            clk_cnt <= clk_cnt + "0000001" ;
542
         END IF;
543
      END IF;
544
   END PROCESS;
545
 
546
   PROCESS (clk, rst)
547
   BEGIN
548
      IF (rst = '1') THEN
549
         clk_en <= '0';
550
      ELSIF (clk'EVENT AND clk = '1') THEN
551
         IF (('0' & clk_cnt) = (preset_cnt - "00000001")) THEN
552
            clk_en <= '1' ;
553
         ELSE
554
            clk_en <= '0' ;
555
         END IF;
556
      END IF;
557
   END PROCESS;
558
 
559
   PROCESS (clk, rst)
560
   BEGIN
561
      IF (rst = '1') THEN
562
         clk_en_q <= '0';
563
      ELSIF (clk'EVENT AND clk = '1') THEN
564
         clk_en_q <= clk_en ;
565
      END IF;
566
   END PROCESS;
567
   -- Changing states 
568
   go_sync <= (((clk_en_q AND seg2) AND CONV_STD_LOGIC(quant_cnt(2 DOWNTO 0) = time_segment2)) AND (NOT hard_sync_xhdl5)) AND (NOT resync) ;
569
   go_seg1 <= clk_en_q AND (sync OR hard_sync_xhdl5 OR ((resync AND seg2) AND sync_window) OR (resync_latched AND sync_window)) ;
570
   go_seg2 <= clk_en_q AND ((seg1 AND (NOT hard_sync_xhdl5)) AND CONV_STD_LOGIC(quant_cnt = ( '0' & (time_segment1 + delay)))) ;
571
 
572
   PROCESS (clk, rst)
573
   BEGIN
574
      IF (rst = '1') THEN
575
         tx_point_xhdl4 <= '0';
576
      ELSIF (clk'EVENT AND clk = '1') THEN
577
         tx_point_xhdl4 <= (NOT tx_point_xhdl4 AND seg2) AND ((clk_en AND CONV_STD_LOGIC(quant_cnt(2 DOWNTO 0) = time_segment2)) OR ((clk_en OR clk_en_q) AND (resync OR hard_sync_xhdl5))) ;    --  When transmitter we should transmit as soon as possible.
578
      END IF;
579
   END PROCESS;
580
 
581
   -- When early edge is detected outside of the SJW field, synchronization request is latched and performed when
582
   --  When early edge is detected outside of the SJW field, synchronization request is latched and performed when
583
   --    SJW is reached 
584
 
585
   PROCESS (clk, rst)
586
   BEGIN
587
      IF (rst = '1') THEN
588
         resync_latched <= '0';
589
      ELSIF (clk'EVENT AND clk = '1') THEN
590
         IF (((resync AND seg2) AND (NOT sync_window)) = '1') THEN
591
            resync_latched <= '1' ;
592
         ELSE
593
            IF (go_seg1 = '1') THEN
594
               resync_latched <= '0';
595
            END IF;
596
         END IF;
597
      END IF;
598
   END PROCESS;
599
 
600
   -- Synchronization stage/segment 
601
   PROCESS (clk, rst)
602
   BEGIN
603
      IF (rst = '1') THEN
604
         sync <= '0';
605
      ELSIF (clk'EVENT AND clk = '1') THEN
606
         IF (clk_en_q = '1') THEN
607
            sync <= go_sync ;
608
         END IF;
609
      END IF;
610
   END PROCESS;
611
 
612
   -- Seg1 stage/segment (together with propagation segment which is 1 quant long) 
613
   PROCESS (clk, rst)
614
   BEGIN
615
      IF (rst = '1') THEN
616
         seg1 <= '1';
617
      ELSIF (clk'EVENT AND clk = '1') THEN
618
         IF (go_seg1 = '1') THEN
619
            seg1 <= '1' ;
620
         ELSE
621
            IF (go_seg2 = '1') THEN
622
               seg1 <= '0' ;
623
            END IF;
624
         END IF;
625
      END IF;
626
   END PROCESS;
627
 
628
   -- Seg2 stage/segment 
629
   PROCESS (clk, rst)
630
   BEGIN
631
      IF (rst = '1') THEN
632
         seg2 <= '0';
633
      ELSIF (clk'EVENT AND clk = '1') THEN
634
         IF (go_seg2 = '1') THEN
635
            seg2 <= '1' ;
636
         ELSE
637
            IF ((go_sync OR go_seg1) = '1') THEN
638
               seg2 <= '0' ;
639
            END IF;
640
         END IF;
641
      END IF;
642
   END PROCESS;
643
 
644
   -- Quant counter 
645
   PROCESS (clk, rst)
646
   BEGIN
647
      IF (rst = '1') THEN
648
         quant_cnt <= "00000";
649
      ELSIF (clk'EVENT AND clk = '1') THEN
650
         IF ((go_sync OR go_seg1 OR go_seg2) = '1') THEN
651
            quant_cnt <= "00000" ;
652
         ELSE
653
            IF (clk_en_q = '1') THEN
654
               quant_cnt <= quant_cnt + "00001" ;
655
            END IF;
656
         END IF;
657
      END IF;
658
   END PROCESS;
659
   temp_xhdl6 <= ("0" & ("00" & sync_jump_width + "0001")) WHEN (quant_cnt > "000" & sync_jump_width) ELSE (quant_cnt + "00001");
660
 
661
   -- When late edge is detected (in seg1 stage), stage seg1 is prolonged. 
662
   PROCESS (clk, rst)
663
   BEGIN
664
      IF (rst = '1') THEN
665
         delay <= "0000";
666
      ELSIF (clk'EVENT AND clk = '1') THEN
667
         IF (((resync AND seg1) AND (NOT transmitting OR (transmitting AND (tx_next_sp OR (tx AND (NOT rx)))))) = '1') THEN
668
            delay <= temp_xhdl6(3 DOWNTO 0) ;
669
         ELSE
670
            IF ((go_sync OR go_seg1) = '1') THEN
671
               delay <= "0000" ;
672
            END IF;
673
         END IF;
674
      END IF;
675
   END PROCESS;
676
   -- If early edge appears within this window (in seg2 stage), phase error is fully compensated
677
   sync_window <= CONV_STD_LOGIC((time_segment2 - quant_cnt(2 DOWNTO 0)) < ('0' & (sync_jump_width + "01"))) ;
678
 
679
   -- Sampling data (memorizing two samples all the time).
680
 
681
   PROCESS (clk, rst)
682
   BEGIN
683
      IF (rst = '1') THEN
684
         sample <= "11";
685
      ELSIF (clk'EVENT AND clk = '1') THEN
686
         IF (clk_en_q = '1') THEN
687
            sample <= sample(0) & rx;
688
         END IF;
689
      END IF;
690
   END PROCESS;
691
 
692
   -- When enabled, tripple sampling is done here.
693
 
694
   PROCESS (clk, rst)
695
   BEGIN
696
      IF (rst = '1') THEN
697
         sampled_bit_xhdl2 <= '1';
698
         sampled_bit_q_xhdl3 <= '1';
699
         sample_point_xhdl1 <= '0';
700
      ELSIF (clk'EVENT AND clk = '1') THEN
701
         IF (go_error_frame = '1') THEN
702
            sampled_bit_q_xhdl3 <= sampled_bit_xhdl2 ;
703
            sample_point_xhdl1 <= '0' ;
704
         ELSE
705
            IF ((clk_en_q AND (NOT hard_sync_xhdl5)) = '1') THEN
706
               IF ((seg1 AND CONV_STD_LOGIC(quant_cnt = ('0' & (time_segment1 + delay)))) = '1') THEN
707
                  sample_point_xhdl1 <= '1' ;
708
                  sampled_bit_q_xhdl3 <= sampled_bit_xhdl2 ;
709
                  IF (triple_sampling = '1') THEN
710
                     sampled_bit_xhdl2 <= (sample(0) AND sample(1)) OR (sample(0) AND rx) OR (sample(1) AND rx) ;
711
                  ELSE
712
                     sampled_bit_xhdl2 <= rx ;
713
                  END IF;
714
               END IF;
715
            ELSE
716
               sample_point_xhdl1 <= '0' ;
717
            END IF;
718
         END IF;
719
      END IF;
720
   END PROCESS;
721
 
722
   -- tx_next_sp shows next value that will be driven on the TX. When driving 1 and receiving 0 we
723
   -- need to synchronize (even when we are a transmitter)
724
 
725
   PROCESS (clk, rst)
726
   BEGIN
727
      IF (rst = '1') THEN
728
         tx_next_sp <= '0';
729
      ELSIF (clk'EVENT AND clk = '1') THEN
730
         IF ((go_overload_frame OR (go_error_frame AND (NOT node_error_passive)) OR go_tx OR send_ack) = '1') THEN
731
            tx_next_sp <= '0' ;
732
         ELSE
733
            IF ((go_error_frame AND node_error_passive) = '1') THEN
734
               tx_next_sp <= '1' ;
735
            ELSE
736
               IF (sample_point_xhdl1 = '1') THEN
737
                  tx_next_sp <= tx_next ;
738
               END IF;
739
            END IF;
740
         END IF;
741
      END IF;
742
   END PROCESS;
743
 
744
   -- Blocking synchronization (can occur only once in a bit time) 
745
   PROCESS (clk, rst)
746
   BEGIN
747
      IF (rst = '1') THEN
748
         sync_blocked <= '1' ;
749
      ELSIF (clk'EVENT AND clk = '1') THEN
750
         IF (clk_en_q = '1') THEN
751
            IF (resync = '1') THEN
752
               sync_blocked <= '1' ;
753
            ELSE
754
               IF (go_seg2 = '1') THEN
755
                  sync_blocked <= '0' ;
756
               END IF;
757
            END IF;
758
         END IF;
759
      END IF;
760
   END PROCESS;
761
 
762
   -- Blocking hard synchronization when occurs once or when we are transmitting a msg 
763
   PROCESS (clk, rst)
764
   BEGIN
765
      IF (rst = '1') THEN
766
         hard_sync_blocked <= '0' ;
767
      ELSIF (clk'EVENT AND clk = '1') THEN
768
         IF (((hard_sync_xhdl5 AND clk_en_q) OR ((((transmitting AND transmitter) OR go_tx) AND tx_point_xhdl4) AND (NOT tx_next))) = '1') THEN
769
            hard_sync_blocked <= '1' ;
770
         ELSE
771
            IF ((go_rx_inter OR (((rx_idle OR rx_inter) AND sample_point_xhdl1) AND sampled_bit_xhdl2)) = '1') THEN
772
               -- When a glitch performed synchronization
773
 
774
               hard_sync_blocked <= '0' ;
775
            END IF;
776
         END IF;
777
      END IF;
778
   END PROCESS;
779
 
780
END ARCHITECTURE RTL;
781
----------------------------------------------------------------------------------------------
782
--
783
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
784
-- Tue Aug  9 07:33:51 2005
785
--
786
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
787
--      Design name        : can_fifo
788
--      Author             : 
789
--      Company            : Actel
790
--
791
--      Description        : 
792
--
793
--
794
----------------------------------------------------------------------------------------------
795
--
796
--////////////////////////////////////////////////////////////////////
797
--//                                                              ////
798
--//  can_fifo.v                                                  ////
799
--//                                                              ////
800
--//                                                              ////
801
--//  This file is part of the CAN Protocol Controller            ////
802
--//  http://www.opencores.org/projects/can/                      ////
803
--//                                                              ////
804
--//                                                              ////
805
--//  Author(s):                                                  ////
806
--//       Igor Mohor                                             ////
807
--//       igorm@opencores.org                                    ////
808
--//                                                              ////
809
--//                                                              ////
810
--//  All additional information is available in the README.txt   ////
811
--//  file.                                                       ////
812
--//                                                              ////
813
--////////////////////////////////////////////////////////////////////
814
--//                                                              ////
815
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
816
--//                                                              ////
817
--// This source file may be used and distributed without         ////
818
--// restriction provided that this copyright statement is not    ////
819
--// removed from the file and that any derivative work contains  ////
820
--// the original copyright notice and the associated disclaimer. ////
821
--//                                                              ////
822
--// This source file is free software; you can redistribute it   ////
823
--// and/or modify it under the terms of the GNU Lesser General   ////
824
--// Public License as published by the Free Software Foundation; ////
825
--// either version 2.1 of the License, or (at your option) any   ////
826
--// later version.                                               ////
827
--//                                                              ////
828
--// This source is distributed in the hope that it will be       ////
829
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
830
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
831
--// PURPOSE.  See the GNU Lesser General Public License for more ////
832
--// details.                                                     ////
833
--//                                                              ////
834
--// You should have received a copy of the GNU Lesser General    ////
835
--// Public License along with this source; if not, download it   ////
836
--// from http://www.opencores.org/lgpl.shtml                     ////
837
--//                                                              ////
838
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
839
--// protected by patents. Anybody who wants to implement this    ////
840
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
841
--// from Bosch.                                                  ////
842
--//                                                              ////
843
--////////////////////////////////////////////////////////////////////
844
--
845
-- CVS Revision History
846
--
847
-- Rev 1.28 rd_info_pointer fix from opencores merged. /Kristoffer
848
--
849
-- $Log: can_fifo.v,v $
850
-- Revision 1.27  2004/11/18 12:39:34  igorm
851
-- Fixes for compatibility after the SW reset.
852
--
853
-- Revision 1.26  2004/02/08 14:30:57  mohor
854
-- Header changed.
855
--
856
-- Revision 1.25  2003/10/23 16:52:17  mohor
857
-- Active high/low problem when Altera devices are used. Bug fixed by
858
-- Rojhalat Ibrahim.
859
--
860
-- Revision 1.24  2003/10/17 05:55:20  markom
861
-- mbist signals updated according to newest convention
862
--
863
-- Revision 1.23  2003/09/05 12:46:41  mohor
864
-- ALTERA_RAM supported.
865
--
866
-- Revision 1.22  2003/08/20 09:59:16  mohor
867
-- Artisan RAM fixed (when not using BIST).
868
--
869
-- Revision 1.21  2003/08/14 16:04:52  simons
870
-- Artisan ram instances added.
871
--
872
-- Revision 1.20  2003/07/16 14:00:45  mohor
873
-- Fixed according to the linter.
874
--
875
-- Revision 1.19  2003/07/03 09:30:44  mohor
876
-- PCI_BIST replaced with CAN_BIST.
877
--
878
-- Revision 1.18  2003/06/27 22:14:23  simons
879
-- Overrun fifo implemented with FFs, because it is not possible to create such a memory.
880
--
881
-- Revision 1.17  2003/06/27 20:56:15  simons
882
-- Virtual silicon ram instances added.
883
--
884
-- Revision 1.16  2003/06/18 23:03:44  mohor
885
-- Typo fixed.
886
--
887
-- Revision 1.15  2003/06/11 09:37:05  mohor
888
-- overrun and length_info fifos are initialized at the end of reset.
889
--
890
-- Revision 1.14  2003/03/05 15:02:30  mohor
891
-- Xilinx RAM added.
892
--
893
-- Revision 1.13  2003/03/01 22:53:33  mohor
894
-- Actel APA ram supported.
895
--
896
-- Revision 1.12  2003/02/19 14:44:03  mohor
897
-- CAN core finished. Host interface added. Registers finished.
898
-- Synchronization to the wishbone finished.
899
--
900
-- Revision 1.11  2003/02/14 20:17:01  mohor
901
-- Several registers added. Not finished, yet.
902
--
903
-- Revision 1.10  2003/02/11 00:56:06  mohor
904
-- Wishbone interface added.
905
--
906
-- Revision 1.9  2003/02/09 02:24:33  mohor
907
-- Bosch license warning added. Error counters finished. Overload frames
908
-- still need to be fixed.
909
--
910
-- Revision 1.8  2003/01/31 01:13:38  mohor
911
-- backup.
912
--
913
-- Revision 1.7  2003/01/17 17:44:31  mohor
914
-- Fifo corrected to be synthesizable.
915
--
916
-- Revision 1.6  2003/01/15 13:16:47  mohor
917
-- When a frame with "remote request" is received, no data is stored
918
-- to fifo, just the frame information (identifier, ...). Data length
919
-- that is stored is the received data length and not the actual data
920
-- length that is stored to fifo.
921
--
922
-- Revision 1.5  2003/01/14 17:25:09  mohor
923
-- Addresses corrected to decimal values (previously hex).
924
--
925
-- Revision 1.4  2003/01/14 12:19:35  mohor
926
-- rx_fifo is now working.
927
--
928
-- Revision 1.3  2003/01/09 21:54:45  mohor
929
-- rx fifo added. Not 100 % verified, yet.
930
--
931
-- Revision 1.2  2003/01/09 14:46:58  mohor
932
-- Temporary files (backup).
933
--
934
-- Revision 1.1  2003/01/08 02:10:55  mohor
935
-- Acceptance filter added.
936
--
937
--
938
--
939
--
940
-- synopsys translate_off
941
--`include "can_defines.v"
942
-- synopsys translate_on
943
 
944
LIBRARY ieee;
945
USE ieee.std_logic_1164.all;
946
USE ieee.numeric_std.all;
947
library grlib;
948
use grlib.stdlib.all;
949
 
950
ENTITY can_fifo IS
951
   PORT (
952
      clk                     : IN std_logic;
953
      rst                     : IN std_logic;
954
      wr                      : IN std_logic;
955
      data_in                 : IN std_logic_vector(7 DOWNTO 0);
956
      addr                    : IN std_logic_vector(5 DOWNTO 0);
957
      data_out                : OUT std_logic_vector(7 DOWNTO 0);
958
      fifo_selected           : IN std_logic;
959
      reset_mode              : IN std_logic;
960
      release_buffer          : IN std_logic;
961
      extended_mode           : IN std_logic;
962
      overrun                 : OUT std_logic;
963
      info_empty              : OUT std_logic;
964
      info_cnt                : OUT std_logic_vector(6 DOWNTO 0);
965
      --------------------------------------------------
966
-- port connections for Ram
967
--64x8
968
 
969
      q_dp_64x8               : IN std_logic_vector(7 DOWNTO 0);
970
      data_64x8               : OUT std_logic_vector(7 DOWNTO 0);
971
      wren_64x8               : OUT std_logic;
972
      rden_64x8               : OUT std_logic;
973
      wraddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
974
      rdaddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
975
      --64x4
976
 
977
      q_dp_64x4               : IN std_logic_vector(3 DOWNTO 0);
978
      data_64x4               : OUT std_logic_vector(3 DOWNTO 0);
979
      wren_64x4x1             : OUT std_logic;
980
      wraddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
981
      rdaddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
982
      --64x1
983
 
984
      q_dp_64x1               : IN std_logic;
985
      data_64x1               : OUT std_logic);
986
END ENTITY can_fifo;
987
 
988
ARCHITECTURE RTL OF can_fifo IS
989
 
990
   TYPE xhdl_15 IS ARRAY (0 TO 63) OF std_logic_vector(7 DOWNTO 0);
991
   TYPE xhdl_16 IS ARRAY (0 TO 63) OF std_logic_vector(3 DOWNTO 0);
992
   TYPE xhdl_17 IS ARRAY (0 TO 63) OF std_logic;
993
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
994
 
995
   --------------------------------------------------
996
   SIGNAL fifo                     :  xhdl_15;
997
   SIGNAL length_fifo              :  xhdl_16;
998
   SIGNAL overrun_info             :  xhdl_17;
999
   SIGNAL rd_pointer               :  std_logic_vector(5 DOWNTO 0);
1000
   SIGNAL wr_pointer               :  std_logic_vector(5 DOWNTO 0);
1001
   SIGNAL read_address             :  std_logic_vector(5 DOWNTO 0);
1002
   SIGNAL wr_info_pointer          :  std_logic_vector(5 DOWNTO 0);
1003
   SIGNAL rd_info_pointer          :  std_logic_vector(5 DOWNTO 0);
1004
   SIGNAL wr_q                     :  std_logic;
1005
   SIGNAL len_cnt                  :  std_logic_vector(3 DOWNTO 0);
1006
   SIGNAL fifo_cnt                 :  std_logic_vector(6 DOWNTO 0);
1007
   SIGNAL latch_overrun            :  std_logic;
1008
   SIGNAL initialize_memories      :  std_logic;
1009
   SIGNAL length_info              :  std_logic_vector(3 DOWNTO 0);
1010
   SIGNAL write_length_info        :  std_logic;
1011
   SIGNAL fifo_empty               :  std_logic;
1012
   SIGNAL fifo_full                :  std_logic;
1013
   SIGNAL info_full                :  std_logic;
1014
   SIGNAL data_out_xhdl1           :  std_logic_vector(7 DOWNTO 0);
1015
   SIGNAL overrun_xhdl2            :  std_logic;
1016
   SIGNAL info_empty_xhdl3         :  std_logic;
1017
   SIGNAL info_cnt_xhdl4           :  std_logic_vector(6 DOWNTO 0);
1018
   SIGNAL data_64x8_xhdl5          :  std_logic_vector(7 DOWNTO 0);
1019
   SIGNAL wren_64x8_xhdl6          :  std_logic;
1020
   SIGNAL rden_64x8_xhdl7          :  std_logic;
1021
   SIGNAL wraddress_64x8_xhdl8     :  std_logic_vector(5 DOWNTO 0);
1022
   SIGNAL rdaddress_64x8_xhdl9     :  std_logic_vector(5 DOWNTO 0);
1023
   SIGNAL data_64x4_xhdl10         :  std_logic_vector(3 DOWNTO 0);
1024
   SIGNAL wren_64x4x1_xhdl11       :  std_logic;
1025
   SIGNAL wraddress_64x4x1_xhdl12  :  std_logic_vector(5 DOWNTO 0);
1026
   SIGNAL rdaddress_64x4x1_xhdl13  :  std_logic_vector(5 DOWNTO 0);
1027
   SIGNAL data_64x1_xhdl14         :  std_logic;
1028
 
1029
BEGIN
1030
   data_out <= data_out_xhdl1;
1031
   overrun <= overrun_xhdl2;
1032
   info_empty <= info_empty_xhdl3;
1033
   info_cnt <= info_cnt_xhdl4;
1034
   data_64x8 <= data_64x8_xhdl5;
1035
   wren_64x8 <= wren_64x8_xhdl6;
1036
   rden_64x8 <= rden_64x8_xhdl7;
1037
   wraddress_64x8 <= wraddress_64x8_xhdl8;
1038
   rdaddress_64x8 <= rdaddress_64x8_xhdl9;
1039
   data_64x4 <= data_64x4_xhdl10;
1040
   wren_64x4x1 <= wren_64x4x1_xhdl11;
1041
   wraddress_64x4x1 <= wraddress_64x4x1_xhdl12;
1042
   rdaddress_64x4x1 <= rdaddress_64x4x1_xhdl13;
1043
   data_64x1 <= data_64x1_xhdl14;
1044
   write_length_info <= (NOT wr) AND wr_q ;
1045
 
1046
   -- Delayed write signal
1047
 
1048
   PROCESS (clk, rst)
1049
   BEGIN
1050
      IF (rst = '1') THEN
1051
         wr_q <= '0' ;
1052
      ELSIF (clk'EVENT AND clk = '1') THEN
1053
         IF (reset_mode = '1') THEN
1054
            wr_q <= '0' ;
1055
         ELSE
1056
            wr_q <= wr ;
1057
         END IF;
1058
      END IF;
1059
   END PROCESS;
1060
 
1061
   -- length counter
1062
 
1063
   PROCESS (clk, rst)
1064
   BEGIN
1065
      IF (rst = '1') THEN
1066
         len_cnt <= "0000";
1067
      ELSIF (clk'EVENT AND clk = '1') THEN
1068
         IF ((reset_mode OR write_length_info) = '1') THEN
1069
            len_cnt <= "0000" ;
1070
         ELSE
1071
            IF ((wr AND (NOT fifo_full)) = '1') THEN
1072
               len_cnt <= len_cnt + "0001" ;
1073
            END IF;
1074
         END IF;
1075
      END IF;
1076
   END PROCESS;
1077
 
1078
   -- wr_info_pointer
1079
 
1080
   PROCESS (clk, rst)
1081
   BEGIN
1082
      IF (rst = '1') THEN
1083
         wr_info_pointer <= "000000";
1084
      ELSIF (clk'EVENT AND clk = '1') THEN
1085
         IF (((write_length_info AND (NOT info_full)) OR initialize_memories) = '1') THEN
1086
            wr_info_pointer <= wr_info_pointer + "000001" ;
1087
         ELSE
1088
            IF (reset_mode = '1') THEN
1089
               wr_info_pointer <= rd_info_pointer ;
1090
            END IF;
1091
         END IF;
1092
      END IF;
1093
   END PROCESS;
1094
 
1095
   -- rd_info_pointer
1096
 
1097
   PROCESS (clk, rst)
1098
   BEGIN
1099
      IF (rst = '1') THEN
1100
         rd_info_pointer <= "000000";
1101
      ELSIF (clk'EVENT AND clk = '1') THEN
1102
        IF ((release_buffer AND (NOT info_empty_xhdl3)) = '1') THEN
1103
--      Fix from opencores rev 1.28
1104
--      IF ((release_buffer AND (NOT fifo_empty)) = '1') THEN
1105
            rd_info_pointer <= rd_info_pointer + "000001" ;
1106
         END IF;
1107
      END IF;
1108
   END PROCESS;
1109
 
1110
   -- rd_pointer
1111
 
1112
   PROCESS (clk, rst)
1113
   BEGIN
1114
      IF (rst = '1') THEN
1115
         rd_pointer <= "000000";
1116
      ELSIF (clk'EVENT AND clk = '1') THEN
1117
         IF ((release_buffer AND (NOT fifo_empty)) = '1') THEN
1118
            rd_pointer <= rd_pointer + ("00" & length_info) ;
1119
         END IF;
1120
      END IF;
1121
   END PROCESS;
1122
 
1123
   -- wr_pointer
1124
 
1125
   PROCESS (clk, rst)
1126
   BEGIN
1127
      IF (rst = '1') THEN
1128
         wr_pointer <= "000000";
1129
      ELSIF (clk'EVENT AND clk = '1') THEN
1130
         IF (reset_mode = '1') THEN
1131
            wr_pointer <= rd_pointer ;
1132
         ELSE
1133
            IF ((wr AND (NOT fifo_full)) = '1') THEN
1134
               wr_pointer <= wr_pointer + "000001" ;
1135
            END IF;
1136
         END IF;
1137
      END IF;
1138
   END PROCESS;
1139
 
1140
   -- latch_overrun
1141
 
1142
   PROCESS (clk, rst)
1143
   BEGIN
1144
      IF (rst = '1') THEN
1145
         latch_overrun <= '0';
1146
      ELSIF (clk'EVENT AND clk = '1') THEN
1147
         IF ((reset_mode OR write_length_info) = '1') THEN
1148
            latch_overrun <= '0' ;
1149
         ELSE
1150
            IF ((wr AND fifo_full) = '1') THEN
1151
               latch_overrun <= '1' ;
1152
            END IF;
1153
         END IF;
1154
      END IF;
1155
   END PROCESS;
1156
 
1157
   -- Counting data in fifo
1158
 
1159
   PROCESS (clk, rst)
1160
   BEGIN
1161
      IF (rst = '1') THEN
1162
         fifo_cnt <= "0000000";
1163
      ELSIF (clk'EVENT AND clk = '1') THEN
1164
         IF (reset_mode = '1') THEN
1165
            fifo_cnt <= "0000000" ;
1166
         ELSE
1167
            IF (((wr AND (NOT release_buffer)) AND (NOT fifo_full)) = '1') THEN
1168
               fifo_cnt <= fifo_cnt + "0000001" ;
1169
            ELSE
1170
               IF ((((NOT wr) AND release_buffer) AND (NOT fifo_empty)) = '1') THEN
1171
                  fifo_cnt <= fifo_cnt - ("000" & length_info) ;
1172
               ELSE
1173
                  IF ((((wr AND release_buffer) AND (NOT fifo_full)) AND (NOT fifo_empty)) = '1') THEN
1174
                     fifo_cnt <= fifo_cnt - ("000" & length_info) + "0000001" ;
1175
                  END IF;
1176
               END IF;
1177
            END IF;
1178
         END IF;
1179
      END IF;
1180
   END PROCESS;
1181
   fifo_full <= CONV_STD_LOGIC(fifo_cnt = "1000000") ;
1182
   fifo_empty <= CONV_STD_LOGIC(fifo_cnt = "0000000") ;
1183
 
1184
   -- Counting data in length_fifo and overrun_info fifo
1185
 
1186
   PROCESS (clk, rst)
1187
   BEGIN
1188
      IF (rst = '1') THEN
1189
         info_cnt_xhdl4 <= "0000000" ;
1190
      ELSIF (clk'EVENT AND clk = '1') THEN
1191
         IF (reset_mode = '1') THEN
1192
            info_cnt_xhdl4 <= "0000000" ;
1193
         ELSE
1194
            IF ((write_length_info XOR release_buffer) = '1') THEN
1195
               IF ((release_buffer AND (NOT info_empty_xhdl3)) = '1') THEN
1196
                  info_cnt_xhdl4 <= info_cnt_xhdl4 - "0000001" ;
1197
               ELSE
1198
                  IF ((write_length_info AND (NOT info_full)) = '1') THEN
1199
                     info_cnt_xhdl4 <= info_cnt_xhdl4 + "0000001" ;
1200
                  END IF;
1201
               END IF;
1202
            END IF;
1203
         END IF;
1204
      END IF;
1205
   END PROCESS;
1206
   info_full <= CONV_STD_LOGIC(info_cnt_xhdl4 = "1000000") ;
1207
   info_empty_xhdl3 <= CONV_STD_LOGIC(info_cnt_xhdl4 = "0000000") ;
1208
 
1209
   -- Selecting which address will be used for reading data from rx fifo
1210
 
1211
   PROCESS (extended_mode, rd_pointer, addr)
1212
      VARIABLE read_address_xhdl18  : std_logic_vector(5 DOWNTO 0);
1213
   BEGIN
1214
      IF (extended_mode = '1') THEN
1215
         -- extended mode
1216
 
1217
         read_address_xhdl18 := rd_pointer + (addr - "010000");
1218
      ELSE
1219
         -- normal mode
1220
 
1221
         read_address_xhdl18 := rd_pointer + (addr - "010100");
1222
      END IF;
1223
      read_address <= read_address_xhdl18;
1224
   END PROCESS;
1225
 
1226
   PROCESS (clk, rst)
1227
   BEGIN
1228
      IF (rst = '1') THEN
1229
         initialize_memories <= '1';
1230
      ELSIF (clk'EVENT AND clk = '1') THEN
1231
         IF (andv(wr_info_pointer) = '1') THEN
1232
            initialize_memories <= '0' ;
1233
         END IF;
1234
      END IF;
1235
   END PROCESS;
1236
   -- port connections for Ram
1237
   --64x8
1238
   data_out_xhdl1 <= q_dp_64x8 ;
1239
   data_64x8_xhdl5 <= data_in ;
1240
   wren_64x8_xhdl6 <= wr AND (NOT fifo_full) ;
1241
   rden_64x8_xhdl7 <= fifo_selected ;
1242
   wraddress_64x8_xhdl8 <= wr_pointer ;
1243
   rdaddress_64x8_xhdl9 <= read_address ;
1244
   --64x4
1245
   length_info <= q_dp_64x4 ;
1246
   data_64x4_xhdl10 <= len_cnt AND NOT initialize_memories & NOT initialize_memories & NOT initialize_memories & NOT initialize_memories ;
1247
   wren_64x4x1_xhdl11 <= (write_length_info AND (NOT info_full)) OR initialize_memories ;
1248
   wraddress_64x4x1_xhdl12 <= wr_info_pointer ;
1249
   rdaddress_64x4x1_xhdl13 <= rd_info_pointer ;
1250
   --64x1
1251
   overrun_xhdl2 <= q_dp_64x1 ;
1252
   data_64x1_xhdl14 <= (latch_overrun OR (wr AND fifo_full)) AND (NOT initialize_memories) ;
1253
   -- `ifdef ALTERA_RAM
1254
   -- //  altera_ram_64x8_sync fifo
1255
   --   lpm_ram_dp fifo
1256
   --   (
1257
   --     .q         (data_out),
1258
   --     .rdclock   (clk),
1259
   --     .wrclock   (clk),
1260
   --     .data      (data_in),
1261
   --     .wren      (wr & (~fifo_full)),
1262
   --     .rden      (fifo_selected),
1263
   --     .wraddress (wr_pointer),
1264
   --     .rdaddress (read_address)
1265
   --   );
1266
   --   defparam fifo.lpm_width = 8;
1267
   --   defparam fifo.lpm_widthad = 6;
1268
   --   defparam fifo.lpm_numwords = 64;
1269
   -- 
1270
   -- 
1271
   -- //  altera_ram_64x4_sync info_fifo
1272
   --   lpm_ram_dp info_fifo
1273
   --   (
1274
   --     .q         (length_info),
1275
   --     .rdclock   (clk),
1276
   --     .wrclock   (clk),
1277
   --     .data      (len_cnt & {4{~initialize_memories}}),
1278
   --     .wren      (write_length_info & (~info_full) | initialize_memories),
1279
   --     .wraddress (wr_info_pointer),
1280
   --     .rdaddress (rd_info_pointer)
1281
   --   );
1282
   --   defparam info_fifo.lpm_width = 4;
1283
   --   defparam info_fifo.lpm_widthad = 6;
1284
   --   defparam info_fifo.lpm_numwords = 64;
1285
   -- 
1286
   -- 
1287
   -- //  altera_ram_64x1_sync overrun_fifo
1288
   --   lpm_ram_dp overrun_fifo
1289
   --   (
1290
   --     .q         (overrun),
1291
   --     .rdclock   (clk),
1292
   --     .wrclock   (clk),
1293
   --     .data      ((latch_overrun | (wr & fifo_full)) & (~initialize_memories)),
1294
   --     .wren      (write_length_info & (~info_full) | initialize_memories),
1295
   --     .wraddress (wr_info_pointer),
1296
   --     .rdaddress (rd_info_pointer)
1297
   --   );
1298
   --   defparam overrun_fifo.lpm_width = 1;
1299
   --   defparam overrun_fifo.lpm_widthad = 6;
1300
   --   defparam overrun_fifo.lpm_numwords = 64;
1301
 
1302
END ARCHITECTURE RTL;
1303
----------------------------------------------------------------------------------------------
1304
--
1305
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
1306
-- Tue Aug  9 07:33:51 2005
1307
--
1308
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
1309
--      Design name        : can_crc
1310
--      Author             : 
1311
--      Company            : Actel
1312
--
1313
--      Description        : 
1314
--
1315
--
1316
----------------------------------------------------------------------------------------------
1317
--
1318
--////////////////////////////////////////////////////////////////////
1319
--//                                                              ////
1320
--//  can_crc.v                                                   ////
1321
--//                                                              ////
1322
--//                                                              ////
1323
--//  This file is part of the CAN Protocol Controller            ////
1324
--//  http://www.opencores.org/projects/can/                      ////
1325
--//                                                              ////
1326
--//                                                              ////
1327
--//  Author(s):                                                  ////
1328
--//       Igor Mohor                                             ////
1329
--//       igorm@opencores.org                                    ////
1330
--//                                                              ////
1331
--//                                                              ////
1332
--//  All additional information is available in the README.txt   ////
1333
--//  file.                                                       ////
1334
--//                                                              ////
1335
--////////////////////////////////////////////////////////////////////
1336
--//                                                              ////
1337
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
1338
--//                                                              ////
1339
--// This source file may be used and distributed without         ////
1340
--// restriction provided that this copyright statement is not    ////
1341
--// removed from the file and that any derivative work contains  ////
1342
--// the original copyright notice and the associated disclaimer. ////
1343
--//                                                              ////
1344
--// This source file is free software; you can redistribute it   ////
1345
--// and/or modify it under the terms of the GNU Lesser General   ////
1346
--// Public License as published by the Free Software Foundation; ////
1347
--// either version 2.1 of the License, or (at your option) any   ////
1348
--// later version.                                               ////
1349
--//                                                              ////
1350
--// This source is distributed in the hope that it will be       ////
1351
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
1352
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
1353
--// PURPOSE.  See the GNU Lesser General Public License for more ////
1354
--// details.                                                     ////
1355
--//                                                              ////
1356
--// You should have received a copy of the GNU Lesser General    ////
1357
--// Public License along with this source; if not, download it   ////
1358
--// from http://www.opencores.org/lgpl.shtml                     ////
1359
--//                                                              ////
1360
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
1361
--// protected by patents. Anybody who wants to implement this    ////
1362
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
1363
--// from Bosch.                                                  ////
1364
--//                                                              ////
1365
--////////////////////////////////////////////////////////////////////
1366
--
1367
-- CVS Revision History
1368
--
1369
-- $Log: can_crc.v,v $
1370
-- Revision 1.5  2004/02/08 14:25:57  mohor
1371
-- Header changed.
1372
--
1373
-- Revision 1.4  2003/07/16 13:16:51  mohor
1374
-- Fixed according to the linter.
1375
--
1376
-- Revision 1.3  2003/02/10 16:02:11  mohor
1377
-- CAN is working according to the specification. WB interface and more
1378
-- registers (status, IRQ, ...) needs to be added.
1379
--
1380
-- Revision 1.2  2003/02/09 02:24:33  mohor
1381
-- Bosch license warning added. Error counters finished. Overload frames
1382
-- still need to be fixed.
1383
--
1384
-- Revision 1.1  2003/01/08 02:10:54  mohor
1385
-- Acceptance filter added.
1386
--
1387
--
1388
--
1389
--
1390
-- synopsys translate_off
1391
--`include "can_defines.v"
1392
-- synopsys translate_on
1393
 
1394
LIBRARY ieee;
1395
USE ieee.std_logic_1164.all;
1396
USE ieee.numeric_std.all;
1397
library grlib;
1398
use grlib.stdlib.all;
1399
 
1400
ENTITY can_crc IS
1401
   PORT (
1402
      clk                     : IN std_logic;
1403
      data                    : IN std_logic;
1404
      enable                  : IN std_logic;
1405
      initialize              : IN std_logic;
1406
      crc                     : OUT std_logic_vector(14 DOWNTO 0));
1407
END ENTITY can_crc;
1408
 
1409
ARCHITECTURE RTL OF can_crc IS
1410
 
1411
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
1412
 
1413
   SIGNAL crc_next                 :  std_logic;
1414
   SIGNAL crc_tmp                  :  std_logic_vector(14 DOWNTO 0);
1415
   SIGNAL crc_xhdl1                :  std_logic_vector(14 DOWNTO 0);
1416
 
1417
BEGIN
1418
   crc <= crc_xhdl1;
1419
   crc_next <= data XOR crc_xhdl1(14) ;
1420
   crc_tmp <= crc_xhdl1(13 DOWNTO 0) & '0' ;
1421
 
1422
   PROCESS (clk)
1423
   BEGIN
1424
      IF (clk'EVENT AND clk = '1') THEN
1425
         IF (initialize = '1') THEN
1426
            crc_xhdl1 <= "000000000000000";
1427
         ELSE
1428
            IF (enable = '1') THEN
1429
               IF (crc_next = '1') THEN
1430
                  crc_xhdl1 <= crc_tmp XOR "100010110011001";
1431
               ELSE
1432
                  crc_xhdl1 <= crc_tmp ;
1433
               END IF;
1434
            END IF;
1435
         END IF;
1436
      END IF;
1437
   END PROCESS;
1438
 
1439
END ARCHITECTURE RTL;
1440
----------------------------------------------------------------------------------------------
1441
--
1442
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
1443
-- Tue Aug  9 07:33:51 2005
1444
--
1445
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
1446
--      Design name        : can_ibo
1447
--      Author             : 
1448
--      Company            : Actel
1449
--
1450
--      Description        : 
1451
--
1452
--
1453
----------------------------------------------------------------------------------------------
1454
--
1455
--////////////////////////////////////////////////////////////////////
1456
--//                                                              ////
1457
--//  can_ibo.v                                                   ////
1458
--//                                                              ////
1459
--//                                                              ////
1460
--//  This file is part of the CAN Protocol Controller            ////
1461
--//  http://www.opencores.org/projects/can/                      ////
1462
--//                                                              ////
1463
--//                                                              ////
1464
--//  Author(s):                                                  ////
1465
--//       Igor Mohor                                             ////
1466
--//       igorm@opencores.org                                    ////
1467
--//                                                              ////
1468
--//                                                              ////
1469
--//  All additional information is available in the README.txt   ////
1470
--//  file.                                                       ////
1471
--//                                                              ////
1472
--////////////////////////////////////////////////////////////////////
1473
--//                                                              ////
1474
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
1475
--//                                                              ////
1476
--// This source file may be used and distributed without         ////
1477
--// restriction provided that this copyright statement is not    ////
1478
--// removed from the file and that any derivative work contains  ////
1479
--// the original copyright notice and the associated disclaimer. ////
1480
--//                                                              ////
1481
--// This source file is free software; you can redistribute it   ////
1482
--// and/or modify it under the terms of the GNU Lesser General   ////
1483
--// Public License as published by the Free Software Foundation; ////
1484
--// either version 2.1 of the License, or (at your option) any   ////
1485
--// later version.                                               ////
1486
--//                                                              ////
1487
--// This source is distributed in the hope that it will be       ////
1488
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
1489
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
1490
--// PURPOSE.  See the GNU Lesser General Public License for more ////
1491
--// details.                                                     ////
1492
--//                                                              ////
1493
--// You should have received a copy of the GNU Lesser General    ////
1494
--// Public License along with this source; if not, download it   ////
1495
--// from http://www.opencores.org/lgpl.shtml                     ////
1496
--//                                                              ////
1497
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
1498
--// protected by patents. Anybody who wants to implement this    ////
1499
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
1500
--// from Bosch.                                                  ////
1501
--//                                                              ////
1502
--////////////////////////////////////////////////////////////////////
1503
--
1504
-- CVS Revision History
1505
--
1506
-- $Log: can_ibo.v,v $
1507
-- Revision 1.3  2004/02/08 14:31:44  mohor
1508
-- Header changed.
1509
--
1510
-- Revision 1.2  2003/02/09 02:24:33  mohor
1511
-- Bosch license warning added. Error counters finished. Overload frames
1512
-- still need to be fixed.
1513
--
1514
-- Revision 1.1  2003/02/04 14:34:52  mohor
1515
-- *** empty log message ***
1516
--
1517
--
1518
--
1519
--
1520
-- synopsys translate_off
1521
--`include "can_defines.v"
1522
-- synopsys translate_on
1523
-- This module only inverts bit order
1524
LIBRARY ieee;
1525
USE ieee.std_logic_1164.all;
1526
 
1527
ENTITY can_ibo IS
1528
   PORT (
1529
      di                      : IN std_logic_vector(7 DOWNTO 0);
1530
      do                      : OUT std_logic_vector(7 DOWNTO 0));
1531
END ENTITY can_ibo;
1532
 
1533
ARCHITECTURE RTL OF can_ibo IS
1534
 
1535
   TYPE xhdl_15 IS ARRAY (0 TO 63) OF std_logic_vector(7 DOWNTO 0);
1536
   TYPE xhdl_16 IS ARRAY (0 TO 63) OF std_logic_vector(3 DOWNTO 0);
1537
   TYPE xhdl_17 IS ARRAY (0 TO 63) OF std_logic;
1538
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
1539
 
1540
   SIGNAL do_xhdl1                 :  std_logic_vector(7 DOWNTO 0);
1541
 
1542
BEGIN
1543
   do <= do_xhdl1;
1544
   do_xhdl1(0) <= di(7) ;
1545
   do_xhdl1(1) <= di(6) ;
1546
   do_xhdl1(2) <= di(5) ;
1547
   do_xhdl1(3) <= di(4) ;
1548
   do_xhdl1(4) <= di(3) ;
1549
   do_xhdl1(5) <= di(2) ;
1550
   do_xhdl1(6) <= di(1) ;
1551
   do_xhdl1(7) <= di(0) ;
1552
 
1553
END ARCHITECTURE RTL;
1554
----------------------------------------------------------------------------------------------
1555
--
1556
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
1557
-- Tue Aug  9 07:33:51 2005
1558
--
1559
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
1560
--      Design name        : can_bsp
1561
--      Author             : 
1562
--      Company            : Actel
1563
--
1564
--      Description        : 
1565
--
1566
--
1567
----------------------------------------------------------------------------------------------
1568
--
1569
--////////////////////////////////////////////////////////////////////
1570
--//                                                              ////
1571
--//  can_bsp.v                                                   ////
1572
--//                                                              ////
1573
--//                                                              ////
1574
--//  This file is part of the CAN Protocol Controller            ////
1575
--//  http://www.opencores.org/projects/can/                      ////
1576
--//                                                              ////
1577
--//                                                              ////
1578
--//  Author(s):                                                  ////
1579
--//       Igor Mohor                                             ////
1580
--//       igorm@opencores.org                                    ////
1581
--//                                                              ////
1582
--//                                                              ////
1583
--//  All additional information is available in the README.txt   ////
1584
--//  file.                                                       ////
1585
--//                                                              ////
1586
--////////////////////////////////////////////////////////////////////
1587
--//                                                              ////
1588
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
1589
--//                                                              ////
1590
--// This source file may be used and distributed without         ////
1591
--// restriction provided that this copyright statement is not    ////
1592
--// removed from the file and that any derivative work contains  ////
1593
--// the original copyright notice and the associated disclaimer. ////
1594
--//                                                              ////
1595
--// This source file is free software; you can redistribute it   ////
1596
--// and/or modify it under the terms of the GNU Lesser General   ////
1597
--// Public License as published by the Free Software Foundation; ////
1598
--// either version 2.1 of the License, or (at your option) any   ////
1599
--// later version.                                               ////
1600
--//                                                              ////
1601
--// This source is distributed in the hope that it will be       ////
1602
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
1603
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
1604
--// PURPOSE.  See the GNU Lesser General Public License for more ////
1605
--// details.                                                     ////
1606
--//                                                              ////
1607
--// You should have received a copy of the GNU Lesser General    ////
1608
--// Public License along with this source; if not, download it   ////
1609
--// from http://www.opencores.org/lgpl.shtml                     ////
1610
--//                                                              ////
1611
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
1612
--// protected by patents. Anybody who wants to implement this    ////
1613
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
1614
--// from Bosch.                                                  ////
1615
--//                                                              ////
1616
--////////////////////////////////////////////////////////////////////
1617
--
1618
-- CVS Revision History
1619
--
1620
-- $Log: can_bsp.v,v $
1621
-- Revision 1.52  2004/11/18 12:39:21  igorm
1622
-- Fixes for compatibility after the SW reset.
1623
--
1624
-- Revision 1.51  2004/11/15 18:23:21  igorm
1625
-- When CAN was reset by setting the reset_mode signal in mode register, it
1626
-- was possible that CAN was blocked for a short period of time. Problem
1627
-- occured very rarly.
1628
--
1629
-- Revision 1.50  2004/10/27 18:51:36  igorm
1630
-- Fixed synchronization problem in real hardware when 0xf is used for TSEG1.
1631
--
1632
-- Revision 1.49  2004/10/25 06:37:51  igorm
1633
-- Arbitration bug fixed.
1634
--
1635
-- Revision 1.48  2004/05/12 15:58:41  igorm
1636
-- Core improved to pass all tests with the Bosch VHDL Reference system.
1637
--
1638
-- Revision 1.47  2004/02/08 14:24:10  mohor
1639
-- Error counters changed.
1640
--
1641
-- Revision 1.46  2003/10/17 05:55:20  markom
1642
-- mbist signals updated according to newest convention
1643
--
1644
-- Revision 1.45  2003/09/30 21:14:33  mohor
1645
-- Error counters changed.
1646
--
1647
-- Revision 1.44  2003/09/30 00:55:12  mohor
1648
-- Error counters fixed to be compatible with Bosch VHDL reference model.
1649
-- Small synchronization changes.
1650
--
1651
-- Revision 1.43  2003/09/25 18:55:49  mohor
1652
-- Synchronization changed, error counters fixed.
1653
--
1654
-- Revision 1.42  2003/08/29 07:01:14  mohor
1655
-- When detecting bus-free, signal bus_free_cnt_en was cleared to zero
1656
-- although the last sampled bit was zero instead of one.
1657
--
1658
-- Revision 1.41  2003/07/18 15:23:31  tadejm
1659
-- Tx and rx length are limited to 8 bytes regardless to the DLC value.
1660
--
1661
-- Revision 1.40  2003/07/16 15:10:17  mohor
1662
-- Fixed according to the linter.
1663
--
1664
-- Revision 1.39  2003/07/16 13:12:46  mohor
1665
-- Fixed according to the linter.
1666
--
1667
-- Revision 1.38  2003/07/10 01:59:04  tadejm
1668
-- Synchronization fixed. In some strange cases it didn't work according to
1669
-- the VHDL reference model.
1670
--
1671
-- Revision 1.37  2003/07/07 11:21:37  mohor
1672
-- Little fixes (to fix warnings).
1673
--
1674
-- Revision 1.36  2003/07/03 09:32:20  mohor
1675
-- Synchronization changed.
1676
--
1677
-- Revision 1.35  2003/06/27 20:56:12  simons
1678
-- Virtual silicon ram instances added.
1679
--
1680
-- Revision 1.34  2003/06/22 09:43:03  mohor
1681
-- synthesi full_case parallel_case fixed.
1682
--
1683
-- Revision 1.33  2003/06/21 12:16:30  mohor
1684
-- paralel_case and full_case compiler directives added to case statements.
1685
--
1686
-- Revision 1.32  2003/06/17 14:28:32  mohor
1687
-- Form error was detected when stuff bit occured at the end of crc.
1688
--
1689
-- Revision 1.31  2003/06/16 14:31:29  tadejm
1690
-- Bit stuffing corrected when stuffing comes at the end of the crc.
1691
--
1692
-- Revision 1.30  2003/06/16 13:57:58  mohor
1693
-- tx_point generated one clk earlier. rx_i registered. Data corrected when
1694
-- using extended mode.
1695
--
1696
-- Revision 1.29  2003/06/11 14:21:35  mohor
1697
-- When switching to tx, sync stage is overjumped.
1698
--
1699
-- Revision 1.28  2003/03/01 22:53:33  mohor
1700
-- Actel APA ram supported.
1701
--
1702
-- Revision 1.27  2003/02/20 00:26:02  mohor
1703
-- When a dominant bit was detected at the third bit of the intermission and
1704
-- node had a message to transmit, bit_stuff error could occur. Fixed.
1705
--
1706
-- Revision 1.26  2003/02/19 23:21:54  mohor
1707
-- When bit error occured while active error flag was transmitted, counter was
1708
-- not incremented.
1709
--
1710
-- Revision 1.25  2003/02/19 14:44:03  mohor
1711
-- CAN core finished. Host interface added. Registers finished.
1712
-- Synchronization to the wishbone finished.
1713
--
1714
-- Revision 1.24  2003/02/18 00:10:15  mohor
1715
-- Most of the registers added. Registers "arbitration lost capture", "error code
1716
-- capture" + few more still need to be added.
1717
--
1718
-- Revision 1.23  2003/02/14 20:17:01  mohor
1719
-- Several registers added. Not finished, yet.
1720
--
1721
-- Revision 1.22  2003/02/12 14:23:59  mohor
1722
-- abort_tx added. Bit destuff fixed.
1723
--
1724
-- Revision 1.21  2003/02/11 00:56:06  mohor
1725
-- Wishbone interface added.
1726
--
1727
-- Revision 1.20  2003/02/10 16:02:11  mohor
1728
-- CAN is working according to the specification. WB interface and more
1729
-- registers (status, IRQ, ...) needs to be added.
1730
--
1731
-- Revision 1.19  2003/02/09 18:40:29  mohor
1732
-- Overload fixed. Hard synchronization also enabled at the last bit of
1733
-- interframe.
1734
--
1735
-- Revision 1.18  2003/02/09 02:24:33  mohor
1736
-- Bosch license warning added. Error counters finished. Overload frames
1737
-- still need to be fixed.
1738
--
1739
-- Revision 1.17  2003/02/04 17:24:41  mohor
1740
-- Backup.
1741
--
1742
-- Revision 1.16  2003/02/04 14:34:52  mohor
1743
-- *** empty log message ***
1744
--
1745
-- Revision 1.15  2003/01/31 01:13:37  mohor
1746
-- backup.
1747
--
1748
-- Revision 1.14  2003/01/16 13:36:19  mohor
1749
-- Form error supported. When receiving messages, last bit of the end-of-frame
1750
-- does not generate form error. Receiver goes to the idle mode one bit sooner.
1751
-- (CAN specification ver 2.0, part B, page 57).
1752
--
1753
-- Revision 1.13  2003/01/15 21:59:45  mohor
1754
-- Data is stored to fifo at the end of ack stage.
1755
--
1756
-- Revision 1.12  2003/01/15 21:05:11  mohor
1757
-- CRC checking fixed (when bitstuff occurs at the end of a CRC sequence).
1758
--
1759
-- Revision 1.11  2003/01/15 14:40:23  mohor
1760
-- RX state machine fixed to receive "remote request" frames correctly.
1761
-- No data bytes are written to fifo when such frames are received.
1762
--
1763
-- Revision 1.10  2003/01/15 13:16:47  mohor
1764
-- When a frame with "remote request" is received, no data is stored to
1765
-- fifo, just the frame information (identifier, ...). Data length that
1766
-- is stored is the received data length and not the actual data length
1767
-- that is stored to fifo.
1768
--
1769
-- Revision 1.9  2003/01/14 12:19:35  mohor
1770
-- rx_fifo is now working.
1771
--
1772
-- Revision 1.8  2003/01/10 17:51:33  mohor
1773
-- Temporary version (backup).
1774
--
1775
-- Revision 1.7  2003/01/09 21:54:45  mohor
1776
-- rx fifo added. Not 100 % verified, yet.
1777
--
1778
-- Revision 1.6  2003/01/09 14:46:58  mohor
1779
-- Temporary files (backup).
1780
--
1781
-- Revision 1.5  2003/01/08 13:30:31  mohor
1782
-- Temp version.
1783
--
1784
-- Revision 1.4  2003/01/08 02:10:53  mohor
1785
-- Acceptance filter added.
1786
--
1787
-- Revision 1.3  2002/12/28 04:13:23  mohor
1788
-- Backup version.
1789
--
1790
-- Revision 1.2  2002/12/27 00:12:52  mohor
1791
-- Header changed, testbench improved to send a frame (crc still missing).
1792
--
1793
-- Revision 1.1.1.1  2002/12/20 16:39:21  mohor
1794
-- Initial
1795
--
1796
--
1797
--
1798
-- synopsys translate_off
1799
--`include "can_defines.v"
1800
-- synopsys translate_on
1801
LIBRARY ieee;
1802
USE ieee.std_logic_1164.all;
1803
USE ieee.numeric_std.all;
1804
library grlib;
1805
use grlib.stdlib.all;
1806
 
1807
ENTITY can_bsp IS
1808
   PORT (
1809
      clk                     : IN std_logic;
1810
      rst                     : IN std_logic;
1811
      sample_point            : IN std_logic;
1812
      sampled_bit             : IN std_logic;
1813
      sampled_bit_q           : IN std_logic;
1814
      tx_point                : IN std_logic;
1815
      hard_sync               : IN std_logic;
1816
      addr                    : IN std_logic_vector(7 DOWNTO 0);
1817
      data_in                 : IN std_logic_vector(7 DOWNTO 0);
1818
      data_out                : OUT std_logic_vector(7 DOWNTO 0);
1819
      fifo_selected           : IN std_logic;
1820
      reset_mode              : IN std_logic;
1821
      listen_only_mode        : IN std_logic;
1822
      acceptance_filter_mode  : IN std_logic;
1823
      self_test_mode          : IN std_logic;
1824
      -- Command register 
1825
      release_buffer          : IN std_logic;
1826
      tx_request              : IN std_logic;
1827
      abort_tx                : IN std_logic;
1828
      self_rx_request         : IN std_logic;
1829
      single_shot_transmission: IN std_logic;
1830
      tx_state                : OUT std_logic;
1831
      tx_state_q              : OUT std_logic;
1832
      overload_request        : IN std_logic;   --  When receiver is busy, it needs to send overload frame. Only 2 overload frames are allowed to
1833
      overload_frame          : OUT std_logic;   --  be send in a row. This is not implemented, yet,  because host can not send an overload request.
1834
      -- Arbitration Lost Capture Register 
1835
      read_arbitration_lost_capture_reg: IN std_logic;
1836
      -- Error Code Capture Register 
1837
      read_error_code_capture_reg: IN std_logic;
1838
      error_capture_code      : OUT std_logic_vector(7 DOWNTO 0);
1839
      -- Error Warning Limit register 
1840
      error_warning_limit     : IN std_logic_vector(7 DOWNTO 0);
1841
      -- Rx Error Counter register 
1842
      we_rx_err_cnt           : IN std_logic;
1843
      -- Tx Error Counter register 
1844
      we_tx_err_cnt           : IN std_logic;
1845
      extended_mode           : IN std_logic;
1846
      rx_idle                 : OUT std_logic;
1847
      transmitting            : OUT std_logic;
1848
      transmitter             : OUT std_logic;
1849
      go_rx_inter             : OUT std_logic;
1850
      not_first_bit_of_inter  : OUT std_logic;
1851
      rx_inter                : OUT std_logic;
1852
      set_reset_mode          : OUT std_logic;
1853
      node_bus_off            : OUT std_logic;
1854
      error_status            : OUT std_logic;
1855
      rx_err_cnt              : OUT std_logic_vector(8 DOWNTO 0);
1856
      tx_err_cnt              : OUT std_logic_vector(8 DOWNTO 0);
1857
      transmit_status         : OUT std_logic;
1858
      receive_status          : OUT std_logic;
1859
      tx_successful           : OUT std_logic;
1860
      need_to_tx              : OUT std_logic;
1861
      overrun                 : OUT std_logic;
1862
      info_empty              : OUT std_logic;
1863
      set_bus_error_irq       : OUT std_logic;
1864
      set_arbitration_lost_irq: OUT std_logic;
1865
      arbitration_lost_capture: OUT std_logic_vector(4 DOWNTO 0);
1866
      node_error_passive      : OUT std_logic;
1867
      node_error_active       : OUT std_logic;
1868
      rx_message_counter      : OUT std_logic_vector(6 DOWNTO 0);
1869
      -- This section is for BASIC and EXTENDED mode -- Acceptance code register 
1870
      acceptance_code_0       : IN std_logic_vector(7 DOWNTO 0);
1871
      -- Acceptance mask register 
1872
      acceptance_mask_0       : IN std_logic_vector(7 DOWNTO 0);
1873
      -- End: This section is for BASIC and EXTENDED mode -- This section is for EXTENDED mode -- Acceptance code register 
1874
      acceptance_code_1       : IN std_logic_vector(7 DOWNTO 0);
1875
      acceptance_code_2       : IN std_logic_vector(7 DOWNTO 0);
1876
      acceptance_code_3       : IN std_logic_vector(7 DOWNTO 0);
1877
      -- Acceptance mask register 
1878
      acceptance_mask_1       : IN std_logic_vector(7 DOWNTO 0);
1879
      acceptance_mask_2       : IN std_logic_vector(7 DOWNTO 0);
1880
      acceptance_mask_3       : IN std_logic_vector(7 DOWNTO 0);
1881
      -- End: This section is for EXTENDED mode -- Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data 
1882
      tx_data_0               : IN std_logic_vector(7 DOWNTO 0);
1883
      tx_data_1               : IN std_logic_vector(7 DOWNTO 0);
1884
      tx_data_2               : IN std_logic_vector(7 DOWNTO 0);
1885
      tx_data_3               : IN std_logic_vector(7 DOWNTO 0);
1886
      tx_data_4               : IN std_logic_vector(7 DOWNTO 0);
1887
      tx_data_5               : IN std_logic_vector(7 DOWNTO 0);
1888
      tx_data_6               : IN std_logic_vector(7 DOWNTO 0);
1889
      tx_data_7               : IN std_logic_vector(7 DOWNTO 0);
1890
      tx_data_8               : IN std_logic_vector(7 DOWNTO 0);
1891
      tx_data_9               : IN std_logic_vector(7 DOWNTO 0);
1892
      tx_data_10              : IN std_logic_vector(7 DOWNTO 0);
1893
      tx_data_11              : IN std_logic_vector(7 DOWNTO 0);
1894
      tx_data_12              : IN std_logic_vector(7 DOWNTO 0);
1895
      -- End: Tx data registers -- Tx signal 
1896
      tx                      : OUT std_logic;
1897
      tx_next                 : OUT std_logic;
1898
      bus_off_on              : OUT std_logic;
1899
      go_overload_frame       : OUT std_logic;
1900
      go_error_frame          : OUT std_logic;
1901
      go_tx                   : OUT std_logic;
1902
      send_ack                : OUT std_logic;
1903
      -- Bist -- port connections for Ram
1904
--64x8
1905
 
1906
      q_dp_64x8               : IN std_logic_vector(7 DOWNTO 0);
1907
      data_64x8               : OUT std_logic_vector(7 DOWNTO 0);
1908
      wren_64x8               : OUT std_logic;
1909
      rden_64x8               : OUT std_logic;
1910
      wraddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
1911
      rdaddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
1912
      --64x4
1913
 
1914
      q_dp_64x4               : IN std_logic_vector(3 DOWNTO 0);
1915
      data_64x4               : OUT std_logic_vector(3 DOWNTO 0);
1916
      wren_64x4x1             : OUT std_logic;
1917
      wraddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
1918
      rdaddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
1919
      --64x1
1920
 
1921
      q_dp_64x1               : IN std_logic;
1922
      data_64x1               : OUT std_logic);
1923
END ENTITY can_bsp;
1924
 
1925
ARCHITECTURE RTL OF can_bsp IS
1926
 
1927
   COMPONENT can_acf
1928
      PORT (
1929
         clk                     : IN  std_logic;
1930
         rst                     : IN  std_logic;
1931
         id                      : IN  std_logic_vector(28 DOWNTO 0);
1932
         reset_mode              : IN  std_logic;
1933
         acceptance_filter_mode  : IN  std_logic;
1934
         extended_mode           : IN  std_logic;
1935
         acceptance_code_0       : IN  std_logic_vector(7 DOWNTO 0);
1936
         acceptance_code_1       : IN  std_logic_vector(7 DOWNTO 0);
1937
         acceptance_code_2       : IN  std_logic_vector(7 DOWNTO 0);
1938
         acceptance_code_3       : IN  std_logic_vector(7 DOWNTO 0);
1939
         acceptance_mask_0       : IN  std_logic_vector(7 DOWNTO 0);
1940
         acceptance_mask_1       : IN  std_logic_vector(7 DOWNTO 0);
1941
         acceptance_mask_2       : IN  std_logic_vector(7 DOWNTO 0);
1942
         acceptance_mask_3       : IN  std_logic_vector(7 DOWNTO 0);
1943
         go_rx_crc_lim           : IN  std_logic;
1944
         go_rx_inter             : IN  std_logic;
1945
         go_error_frame          : IN  std_logic;
1946
         data0                   : IN  std_logic_vector(7 DOWNTO 0);
1947
         data1                   : IN  std_logic_vector(7 DOWNTO 0);
1948
         rtr1                    : IN  std_logic;
1949
         rtr2                    : IN  std_logic;
1950
         ide                     : IN  std_logic;
1951
         no_byte0                : IN  std_logic;
1952
         no_byte1                : IN  std_logic;
1953
         id_ok                   : OUT std_logic);
1954
   END COMPONENT;
1955
 
1956
   COMPONENT can_crc
1957
      PORT (
1958
         clk                     : IN  std_logic;
1959
         data                    : IN  std_logic;
1960
         enable                  : IN  std_logic;
1961
         initialize              : IN  std_logic;
1962
         crc                     : OUT std_logic_vector(14 DOWNTO 0));
1963
   END COMPONENT;
1964
 
1965
   COMPONENT can_fifo
1966
      PORT (
1967
         clk                     : IN  std_logic;
1968
         rst                     : IN  std_logic;
1969
         wr                      : IN  std_logic;
1970
         data_in                 : IN  std_logic_vector(7 DOWNTO 0);
1971
         addr                    : IN  std_logic_vector(5 DOWNTO 0);
1972
         data_out                : OUT std_logic_vector(7 DOWNTO 0);
1973
         fifo_selected           : IN  std_logic;
1974
         reset_mode              : IN  std_logic;
1975
         release_buffer          : IN  std_logic;
1976
         extended_mode           : IN  std_logic;
1977
         overrun                 : OUT std_logic;
1978
         info_empty              : OUT std_logic;
1979
         info_cnt                : OUT std_logic_vector(6 DOWNTO 0);
1980
         q_dp_64x8               : IN  std_logic_vector(7 DOWNTO 0);
1981
         data_64x8               : OUT std_logic_vector(7 DOWNTO 0);
1982
         wren_64x8               : OUT std_logic;
1983
         rden_64x8               : OUT std_logic;
1984
         wraddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
1985
         rdaddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
1986
         q_dp_64x4               : IN  std_logic_vector(3 DOWNTO 0);
1987
         data_64x4               : OUT std_logic_vector(3 DOWNTO 0);
1988
         wren_64x4x1             : OUT std_logic;
1989
         wraddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
1990
         rdaddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
1991
         q_dp_64x1               : IN  std_logic;
1992
         data_64x1               : OUT std_logic);
1993
   END COMPONENT;
1994
 
1995
   COMPONENT can_ibo
1996
      PORT (
1997
         di                      : IN  std_logic_vector(7 DOWNTO 0);
1998
         do                      : OUT std_logic_vector(7 DOWNTO 0));
1999
   END COMPONENT;
2000
 
2001
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
2002
 
2003
   ------------------------------
2004
   SIGNAL reset_mode_q             :  std_logic;
2005
   SIGNAL bit_cnt                  :  std_logic_vector(5 DOWNTO 0);
2006
   SIGNAL data_len                 :  std_logic_vector(3 DOWNTO 0);
2007
   SIGNAL id                       :  std_logic_vector(28 DOWNTO 0);
2008
   SIGNAL bit_stuff_cnt            :  std_logic_vector(2 DOWNTO 0);
2009
   SIGNAL bit_stuff_cnt_tx         :  std_logic_vector(2 DOWNTO 0);
2010
   SIGNAL tx_point_q               :  std_logic;
2011
   SIGNAL rx_id1                   :  std_logic;
2012
   SIGNAL rx_rtr1                  :  std_logic;
2013
   SIGNAL rx_ide                   :  std_logic;
2014
   SIGNAL rx_id2                   :  std_logic;
2015
   SIGNAL rx_rtr2                  :  std_logic;
2016
   SIGNAL rx_r1                    :  std_logic;
2017
   SIGNAL rx_r0                    :  std_logic;
2018
   SIGNAL rx_dlc                   :  std_logic;
2019
   SIGNAL rx_data                  :  std_logic;
2020
   SIGNAL rx_crc                   :  std_logic;
2021
   SIGNAL rx_crc_lim               :  std_logic;
2022
   SIGNAL rx_ack                   :  std_logic;
2023
   SIGNAL rx_ack_lim               :  std_logic;
2024
   SIGNAL rx_eof                   :  std_logic;
2025
   SIGNAL go_early_tx_latched      :  std_logic;
2026
   SIGNAL rtr1                     :  std_logic;
2027
   SIGNAL ide                      :  std_logic;
2028
   SIGNAL rtr2                     :  std_logic;
2029
   SIGNAL crc_in                   :  std_logic_vector(14 DOWNTO 0);
2030
   SIGNAL tmp_data                 :  std_logic_vector(7 DOWNTO 0);
2031
   SIGNAL tmp_fifo                 :  xhdl_46;
2032
   SIGNAL write_data_to_tmp_fifo   :  std_logic;
2033
   SIGNAL byte_cnt                 :  std_logic_vector(2 DOWNTO 0);
2034
   SIGNAL bit_stuff_cnt_en         :  std_logic;
2035
   SIGNAL crc_enable               :  std_logic;
2036
   SIGNAL eof_cnt                  :  std_logic_vector(2 DOWNTO 0);
2037
   SIGNAL passive_cnt              :  std_logic_vector(2 DOWNTO 0);
2038
   SIGNAL error_frame              :  std_logic;
2039
   SIGNAL enable_error_cnt2        :  std_logic;
2040
   SIGNAL error_cnt1               :  std_logic_vector(2 DOWNTO 0);
2041
   SIGNAL error_cnt2               :  std_logic_vector(2 DOWNTO 0);
2042
   SIGNAL delayed_dominant_cnt     :  std_logic_vector(2 DOWNTO 0);
2043
   SIGNAL enable_overload_cnt2     :  std_logic;
2044
   SIGNAL overload_frame_blocked   :  std_logic;
2045
   SIGNAL overload_request_cnt     :  std_logic_vector(1 DOWNTO 0);
2046
   SIGNAL overload_cnt1            :  std_logic_vector(2 DOWNTO 0);
2047
   SIGNAL overload_cnt2            :  std_logic_vector(2 DOWNTO 0);
2048
   SIGNAL crc_err                  :  std_logic;
2049
   SIGNAL arbitration_lost         :  std_logic;
2050
   SIGNAL arbitration_lost_q       :  std_logic;
2051
   SIGNAL read_arbitration_lost_capture_reg_q:  std_logic;
2052
   signal read_error_code_capture_reg_q : std_logic;
2053
   signal reset_error_code_capture_reg : std_logic;
2054
   SIGNAL arbitration_cnt_en       :  std_logic;
2055
   SIGNAL arbitration_blocked      :  std_logic;
2056
   SIGNAL tx_q                     :  std_logic;
2057
   SIGNAL data_cnt                 :  std_logic_vector(3 DOWNTO 0);   --  Counting the data bytes that are written to FIFO
2058
   SIGNAL header_cnt               :  std_logic_vector(2 DOWNTO 0);   --  Counting header length
2059
   SIGNAL wr_fifo                  :  std_logic;   --  Write data and header to 64-byte fifo
2060
   SIGNAL data_for_fifo            :  std_logic_vector(7 DOWNTO 0);   --  Multiplexed data that is stored to 64-byte fifo
2061
   SIGNAL tx_pointer               :  std_logic_vector(5 DOWNTO 0);
2062
   SIGNAL tx_bit                   :  std_logic;
2063
   SIGNAL finish_msg               :  std_logic;
2064
   SIGNAL bus_free_cnt             :  std_logic_vector(3 DOWNTO 0);
2065
   SIGNAL bus_free_cnt_en          :  std_logic;
2066
   SIGNAL bus_free                 :  std_logic;
2067
   SIGNAL waiting_for_bus_free     :  std_logic;
2068
   SIGNAL node_bus_off_q           :  std_logic;
2069
   SIGNAL ack_err_latched          :  std_logic;
2070
   SIGNAL bit_err_latched          :  std_logic;
2071
   SIGNAL stuff_err_latched        :  std_logic;
2072
   SIGNAL form_err_latched         :  std_logic;
2073
   SIGNAL rule3_exc1_1             :  std_logic;
2074
   SIGNAL rule3_exc1_2             :  std_logic;
2075
   SIGNAL suspend                  :  std_logic;
2076
   SIGNAL susp_cnt_en              :  std_logic;
2077
   SIGNAL susp_cnt                 :  std_logic_vector(2 DOWNTO 0);
2078
   SIGNAL error_flag_over_latched  :  std_logic;
2079
   SIGNAL error_capture_code_type  :  std_logic_vector(7 DOWNTO 6);
2080
   SIGNAL error_capture_code_blocked      :  std_logic;
2081
   SIGNAL first_compare_bit        :  std_logic;
2082
   SIGNAL error_capture_code_segment      :  std_logic_vector(4 DOWNTO 0);
2083
   SIGNAL error_capture_code_direction    :  std_logic;
2084
   SIGNAL bit_de_stuff             :  std_logic;
2085
   SIGNAL bit_de_stuff_tx          :  std_logic;
2086
   SIGNAL rule5                    :  std_logic;
2087
   -- Rx state machine 
2088
   SIGNAL go_rx_idle               :  std_logic;
2089
   SIGNAL go_rx_id1                :  std_logic;
2090
   SIGNAL go_rx_rtr1               :  std_logic;
2091
   SIGNAL go_rx_ide                :  std_logic;
2092
   SIGNAL go_rx_id2                :  std_logic;
2093
   SIGNAL go_rx_rtr2               :  std_logic;
2094
   SIGNAL go_rx_r1                 :  std_logic;
2095
   SIGNAL go_rx_r0                 :  std_logic;
2096
   SIGNAL go_rx_dlc                :  std_logic;
2097
   SIGNAL go_rx_data               :  std_logic;
2098
   SIGNAL go_rx_crc                :  std_logic;
2099
   SIGNAL go_rx_crc_lim            :  std_logic;
2100
   SIGNAL go_rx_ack                :  std_logic;
2101
   SIGNAL go_rx_ack_lim            :  std_logic;
2102
   SIGNAL go_rx_eof                :  std_logic;
2103
   SIGNAL last_bit_of_inter        :  std_logic;
2104
   SIGNAL go_crc_enable            :  std_logic;
2105
   SIGNAL rst_crc_enable           :  std_logic;
2106
   SIGNAL bit_de_stuff_set         :  std_logic;
2107
   SIGNAL bit_de_stuff_reset       :  std_logic;
2108
   SIGNAL go_early_tx              :  std_logic;
2109
   SIGNAL calculated_crc           :  std_logic_vector(14 DOWNTO 0);
2110
   SIGNAL r_calculated_crc         :  std_logic_vector(15 DOWNTO 0);
2111
   SIGNAL remote_rq                :  std_logic;
2112
   SIGNAL limited_data_len         :  std_logic_vector(3 DOWNTO 0);
2113
   SIGNAL form_err                 :  std_logic;
2114
   SIGNAL error_frame_ended        :  std_logic;
2115
   SIGNAL overload_frame_ended     :  std_logic;
2116
   SIGNAL bit_err                  :  std_logic;
2117
   SIGNAL ack_err                  :  std_logic;
2118
   SIGNAL stuff_err                :  std_logic;
2119
   SIGNAL id_ok                    :  std_logic;   --  If received ID matches ID set in registers
2120
   SIGNAL no_byte0                 :  std_logic;   --  There is no byte 0 (RTR bit set to 1 or DLC field equal to 0). Signal used for acceptance filter.
2121
   SIGNAL no_byte1                 :  std_logic;   --  There is no byte 1 (RTR bit set to 1 or DLC field equal to 1). Signal used for acceptance filter.
2122
   SIGNAL header_len               :  std_logic_vector(2 DOWNTO 0);
2123
   SIGNAL storing_header           :  std_logic;
2124
   SIGNAL limited_data_len_minus1  :  std_logic_vector(3 DOWNTO 0);
2125
   SIGNAL reset_wr_fifo            :  std_logic;
2126
   SIGNAL err                      :  std_logic;
2127
   SIGNAL arbitration_field        :  std_logic;
2128
   SIGNAL basic_chain              :  std_logic_vector(18 DOWNTO 0);
2129
   SIGNAL basic_chain_data         :  std_logic_vector(63 DOWNTO 0);
2130
   SIGNAL extended_chain_std       :  std_logic_vector(18 DOWNTO 0);
2131
   SIGNAL extended_chain_ext       :  std_logic_vector(38 DOWNTO 0);
2132
   SIGNAL extended_chain_data_std  :  std_logic_vector(63 DOWNTO 0);
2133
   SIGNAL extended_chain_data_ext  :  std_logic_vector(63 DOWNTO 0);
2134
   SIGNAL rst_tx_pointer           :  std_logic;
2135
   SIGNAL r_tx_data_0              :  std_logic_vector(7 DOWNTO 0);
2136
   SIGNAL r_tx_data_1              :  std_logic_vector(7 DOWNTO 0);
2137
   SIGNAL r_tx_data_2              :  std_logic_vector(7 DOWNTO 0);
2138
   SIGNAL r_tx_data_3              :  std_logic_vector(7 DOWNTO 0);
2139
   SIGNAL r_tx_data_4              :  std_logic_vector(7 DOWNTO 0);
2140
   SIGNAL r_tx_data_5              :  std_logic_vector(7 DOWNTO 0);
2141
   SIGNAL r_tx_data_6              :  std_logic_vector(7 DOWNTO 0);
2142
   SIGNAL r_tx_data_7              :  std_logic_vector(7 DOWNTO 0);
2143
   SIGNAL r_tx_data_8              :  std_logic_vector(7 DOWNTO 0);
2144
   SIGNAL r_tx_data_9              :  std_logic_vector(7 DOWNTO 0);
2145
   SIGNAL r_tx_data_10             :  std_logic_vector(7 DOWNTO 0);
2146
   SIGNAL r_tx_data_11             :  std_logic_vector(7 DOWNTO 0);
2147
   SIGNAL r_tx_data_12             :  std_logic_vector(7 DOWNTO 0);
2148
   SIGNAL bit_err_exc1             :  std_logic;
2149
   SIGNAL bit_err_exc2             :  std_logic;
2150
   SIGNAL bit_err_exc3             :  std_logic;
2151
   SIGNAL bit_err_exc4             :  std_logic;
2152
   SIGNAL bit_err_exc5             :  std_logic;
2153
   SIGNAL bit_err_exc6             :  std_logic;
2154
   SIGNAL error_flag_over          :  std_logic;
2155
   SIGNAL overload_flag_over       :  std_logic;
2156
   SIGNAL limited_tx_cnt_ext       :  std_logic_vector(5 DOWNTO 0);
2157
   SIGNAL limited_tx_cnt_std       :  std_logic_vector(5 DOWNTO 0);
2158
   -- port connections for Ram
2159
   --64x8
2160
   SIGNAL w_q_dp_64x8              :  std_logic_vector(7 DOWNTO 0);
2161
   SIGNAL w_data_64x8              :  std_logic_vector(7 DOWNTO 0);
2162
   SIGNAL w_wren_64x8              :  std_logic;
2163
   SIGNAL w_rden_64x8              :  std_logic;
2164
   SIGNAL w_wraddress_64x8         :  std_logic_vector(5 DOWNTO 0);
2165
   SIGNAL w_rdaddress_64x8         :  std_logic_vector(5 DOWNTO 0);
2166
   --64x4
2167
   SIGNAL w_q_dp_64x4              :  std_logic_vector(3 DOWNTO 0);
2168
   SIGNAL w_data_64x4              :  std_logic_vector(3 DOWNTO 0);
2169
   SIGNAL w_wren_64x4x1            :  std_logic;
2170
   SIGNAL w_wraddress_64x4x1       :  std_logic_vector(5 DOWNTO 0);
2171
   SIGNAL w_rdaddress_64x4x1       :  std_logic_vector(5 DOWNTO 0);
2172
   --64x1
2173
   SIGNAL w_q_dp_64x1              :  std_logic;
2174
   SIGNAL w_data_64x1              :  std_logic;
2175
   SIGNAL temp_xhdl47              :  std_logic_vector(3 DOWNTO 0);
2176
   -- Instantiation of the RX CRC module
2177
   SIGNAL xhdl_49                  :  std_logic;
2178
   -- Mode register 
2179
   -- Clock Divider register
2180
   -- This section is for BASIC and EXTENDED mode 
2181
   -- Acceptance code register 
2182
   -- Acceptance mask register 
2183
   -- End: This section is for BASIC and EXTENDED mode 
2184
   -- This section is for EXTENDED mode 
2185
   -- Acceptance code register 
2186
   -- Acceptance mask register 
2187
   -- End: This section is for EXTENDED mode 
2188
   SIGNAL port_xhdl73              :  std_logic_vector(7 DOWNTO 0);
2189
   SIGNAL port_xhdl74              :  std_logic_vector(7 DOWNTO 0);
2190
   SIGNAL temp_xhdl75              :  std_logic_vector(2 DOWNTO 0);
2191
   SIGNAL temp_xhdl76              :  std_logic_vector(2 DOWNTO 0);
2192
   SIGNAL temp_xhdl77              :  std_logic_vector(3 DOWNTO 0);
2193
   SIGNAL temp_xhdl78              :  std_logic_vector(3 DOWNTO 0);   --  - 1 because counter counts from 0
2194
   SIGNAL xhdl_106                 :  std_logic_vector(7 DOWNTO 0);
2195
   SIGNAL temp_xhdl108             :  std_logic_vector(5 DOWNTO 0);
2196
   SIGNAL temp_xhdl109             :  std_logic_vector(5 DOWNTO 0);
2197
   SIGNAL temp_xhdl110             :  boolean;
2198
   SIGNAL temp_xhdl111             :  std_logic;
2199
   SIGNAL data_out_xhdl1           :  std_logic_vector(7 DOWNTO 0);
2200
   SIGNAL tx_state_xhdl2           :  std_logic;
2201
   SIGNAL tx_state_q_xhdl3         :  std_logic;
2202
   SIGNAL overload_frame_xhdl4     :  std_logic;
2203
   SIGNAL error_capture_code_xhdl5 :  std_logic_vector(7 DOWNTO 0);
2204
   SIGNAL rx_idle_xhdl6            :  std_logic;
2205
   SIGNAL transmitting_xhdl7       :  std_logic;
2206
   SIGNAL transmitter_xhdl8        :  std_logic;
2207
   SIGNAL go_rx_inter_xhdl9        :  std_logic;
2208
   SIGNAL not_first_bit_of_inter_xhdl10   :  std_logic;
2209
   SIGNAL rx_inter_xhdl11          :  std_logic;
2210
   SIGNAL set_reset_mode_xhdl12    :  std_logic;
2211
   SIGNAL node_bus_off_xhdl13      :  std_logic;
2212
   SIGNAL error_status_xhdl14      :  std_logic;
2213
   SIGNAL rx_err_cnt_xhdl15        :  std_logic_vector(8 DOWNTO 0);
2214
   SIGNAL tx_err_cnt_xhdl16        :  std_logic_vector(8 DOWNTO 0);
2215
   SIGNAL transmit_status_xhdl17   :  std_logic;
2216
   SIGNAL receive_status_xhdl18    :  std_logic;
2217
   SIGNAL tx_successful_xhdl19     :  std_logic;
2218
   SIGNAL need_to_tx_xhdl20        :  std_logic;
2219
   SIGNAL overrun_xhdl21           :  std_logic;
2220
   SIGNAL info_empty_xhdl22        :  std_logic;
2221
   SIGNAL set_bus_error_irq_xhdl23 :  std_logic;
2222
   SIGNAL set_arbitration_lost_irq_xhdl24 :  std_logic;
2223
   SIGNAL arbitration_lost_capture_xhdl25 :  std_logic_vector(4 DOWNTO 0);
2224
   SIGNAL node_error_passive_xhdl26:  std_logic;
2225
   SIGNAL node_error_active_xhdl27 :  std_logic;
2226
   SIGNAL rx_message_counter_xhdl28:  std_logic_vector(6 DOWNTO 0);
2227
   SIGNAL tx_xhdl29                :  std_logic;
2228
   SIGNAL tx_next_xhdl30           :  std_logic;
2229
   SIGNAL bus_off_on_xhdl31        :  std_logic;
2230
   SIGNAL go_overload_frame_xhdl32 :  std_logic;
2231
   SIGNAL go_error_frame_xhdl33    :  std_logic;
2232
   SIGNAL go_tx_xhdl34             :  std_logic;
2233
   SIGNAL send_ack_xhdl35          :  std_logic;
2234
   SIGNAL data_64x8_xhdl36         :  std_logic_vector(7 DOWNTO 0);
2235
   SIGNAL wren_64x8_xhdl37         :  std_logic;
2236
   SIGNAL rden_64x8_xhdl38         :  std_logic;
2237
   SIGNAL wraddress_64x8_xhdl39    :  std_logic_vector(5 DOWNTO 0);
2238
   SIGNAL rdaddress_64x8_xhdl40    :  std_logic_vector(5 DOWNTO 0);
2239
   SIGNAL data_64x4_xhdl41         :  std_logic_vector(3 DOWNTO 0);
2240
   SIGNAL wren_64x4x1_xhdl42       :  std_logic;
2241
   SIGNAL wraddress_64x4x1_xhdl43  :  std_logic_vector(5 DOWNTO 0);
2242
   SIGNAL rdaddress_64x4x1_xhdl44  :  std_logic_vector(5 DOWNTO 0);
2243
   SIGNAL data_64x1_xhdl45         :  std_logic;
2244
 
2245
BEGIN
2246
   data_out <= data_out_xhdl1;
2247
   tx_state <= tx_state_xhdl2;
2248
   tx_state_q <= tx_state_q_xhdl3;
2249
   overload_frame <= overload_frame_xhdl4;
2250
   error_capture_code <= error_capture_code_xhdl5;
2251
   rx_idle <= rx_idle_xhdl6;
2252
   transmitting <= transmitting_xhdl7;
2253
   transmitter <= transmitter_xhdl8;
2254
   go_rx_inter <= go_rx_inter_xhdl9;
2255
   not_first_bit_of_inter <= not_first_bit_of_inter_xhdl10;
2256
   rx_inter <= rx_inter_xhdl11;
2257
   set_reset_mode <= set_reset_mode_xhdl12;
2258
   node_bus_off <= node_bus_off_xhdl13;
2259
   error_status <= error_status_xhdl14;
2260
   rx_err_cnt <= rx_err_cnt_xhdl15;
2261
   tx_err_cnt <= tx_err_cnt_xhdl16;
2262
   transmit_status <= transmit_status_xhdl17;
2263
   receive_status <= receive_status_xhdl18;
2264
   tx_successful <= tx_successful_xhdl19;
2265
   need_to_tx <= need_to_tx_xhdl20;
2266
   overrun <= overrun_xhdl21;
2267
   info_empty <= info_empty_xhdl22;
2268
   set_bus_error_irq <= set_bus_error_irq_xhdl23;
2269
   set_arbitration_lost_irq <= set_arbitration_lost_irq_xhdl24;
2270
   arbitration_lost_capture <= arbitration_lost_capture_xhdl25;
2271
   node_error_passive <= node_error_passive_xhdl26;
2272
   node_error_active <= node_error_active_xhdl27;
2273
   rx_message_counter <= rx_message_counter_xhdl28;
2274
   tx <= tx_xhdl29;
2275
   tx_next <= tx_next_xhdl30;
2276
   bus_off_on <= bus_off_on_xhdl31;
2277
   go_overload_frame <= go_overload_frame_xhdl32;
2278
   go_error_frame <= go_error_frame_xhdl33;
2279
   go_tx <= go_tx_xhdl34;
2280
   send_ack <= send_ack_xhdl35;
2281
   data_64x8 <= data_64x8_xhdl36;
2282
   wren_64x8 <= wren_64x8_xhdl37;
2283
   rden_64x8 <= rden_64x8_xhdl38;
2284
   wraddress_64x8 <= wraddress_64x8_xhdl39;
2285
   rdaddress_64x8 <= rdaddress_64x8_xhdl40;
2286
   data_64x4 <= data_64x4_xhdl41;
2287
   wren_64x4x1 <= wren_64x4x1_xhdl42;
2288
   wraddress_64x4x1 <= wraddress_64x4x1_xhdl43;
2289
   rdaddress_64x4x1 <= rdaddress_64x4x1_xhdl44;
2290
   data_64x1 <= data_64x1_xhdl45;
2291
   -- port connections for Ram
2292
   --64x8
2293
   w_q_dp_64x8 <= q_dp_64x8 ;
2294
   data_64x8_xhdl36 <= w_data_64x8 ;
2295
   wren_64x8_xhdl37 <= w_wren_64x8 ;
2296
   rden_64x8_xhdl38 <= w_rden_64x8 ;
2297
   wraddress_64x8_xhdl39 <= w_wraddress_64x8 ;
2298
   rdaddress_64x8_xhdl40 <= w_rdaddress_64x8 ;
2299
   --64x4
2300
   w_q_dp_64x4 <= q_dp_64x4 ;
2301
   data_64x4_xhdl41 <= w_data_64x4 ;
2302
   wren_64x4x1_xhdl42 <= w_wren_64x4x1 ;
2303
   wraddress_64x4x1_xhdl43 <= w_wraddress_64x4x1 ;
2304
   rdaddress_64x4x1_xhdl44 <= w_rdaddress_64x4x1 ;
2305
   --64x1
2306
   w_q_dp_64x1 <= q_dp_64x1 ;
2307
   data_64x1_xhdl45 <= w_data_64x1 ;
2308
   -- ----------------------
2309
   go_rx_idle <= ((sample_point AND sampled_bit) AND last_bit_of_inter) OR (bus_free AND (NOT node_bus_off_xhdl13)) ;
2310
   go_rx_id1 <= (sample_point AND (NOT sampled_bit)) AND (rx_idle_xhdl6 OR last_bit_of_inter) ;
2311
   go_rx_rtr1 <= (((NOT bit_de_stuff) AND sample_point) AND rx_id1) AND CONV_STD_LOGIC(bit_cnt(3 DOWNTO 0) = "1010") ;
2312
   go_rx_ide <= ((NOT bit_de_stuff) AND sample_point) AND rx_rtr1 ;
2313
   go_rx_id2 <= (((NOT bit_de_stuff) AND sample_point) AND rx_ide) AND sampled_bit ;
2314
   go_rx_rtr2 <= (((NOT bit_de_stuff) AND sample_point) AND rx_id2) AND CONV_STD_LOGIC(bit_cnt(4 DOWNTO 0) = "10001") ;
2315
   go_rx_r1 <= ((NOT bit_de_stuff) AND sample_point) AND rx_rtr2 ;
2316
   go_rx_r0 <= ((NOT bit_de_stuff) AND sample_point) AND ((rx_ide AND (NOT sampled_bit)) OR rx_r1) ;
2317
   go_rx_dlc <= ((NOT bit_de_stuff) AND sample_point) AND rx_r0 ;
2318
   go_rx_data <= (((((NOT bit_de_stuff) AND sample_point) AND rx_dlc) AND CONV_STD_LOGIC(bit_cnt(1 DOWNTO 0) = "11")) AND (sampled_bit OR (orv(data_len(2 DOWNTO 0))))) AND (NOT remote_rq) ;
2319
   go_rx_crc <= ((NOT bit_de_stuff) AND sample_point) AND (((rx_dlc AND CONV_STD_LOGIC(bit_cnt(1 DOWNTO 0) = "11")) AND (((NOT sampled_bit) AND (NOT (orv(data_len(2 DOWNTO 0))))) OR remote_rq)) OR (rx_data AND CONV_STD_LOGIC('0' & bit_cnt(5 DOWNTO 0) = ((limited_data_len & "000") - 1)))) ;
2320
   go_rx_crc_lim <= (((NOT bit_de_stuff) AND sample_point) AND rx_crc) AND CONV_STD_LOGIC(bit_cnt(3 DOWNTO 0) = "1110") ;
2321
   go_rx_ack <= ((NOT bit_de_stuff) AND sample_point) AND rx_crc_lim ;
2322
   go_rx_ack_lim <= sample_point AND rx_ack ;
2323
   go_rx_eof <= sample_point AND rx_ack_lim ;
2324
   go_rx_inter_xhdl9 <= (((sample_point AND rx_eof) AND CONV_STD_LOGIC(eof_cnt = "110")) OR error_frame_ended OR overload_frame_ended) AND (NOT overload_request) ;
2325
   go_error_frame_xhdl33 <= form_err OR stuff_err OR bit_err OR ack_err OR (crc_err AND go_rx_eof) ;
2326
   error_frame_ended <= CONV_STD_LOGIC(error_cnt2 = "111") AND tx_point ;
2327
   overload_frame_ended <= CONV_STD_LOGIC(overload_cnt2 = "111") AND tx_point ;
2328
   go_overload_frame_xhdl32 <= (((sample_point AND ((NOT sampled_bit) OR overload_request)) AND (((rx_eof AND (NOT transmitter_xhdl8)) AND CONV_STD_LOGIC(eof_cnt = "110")) OR error_frame_ended OR overload_frame_ended)) OR (((sample_point AND (NOT sampled_bit)) AND rx_inter_xhdl11) AND CONV_STD_LOGIC(bit_cnt(1 DOWNTO 0) < "10")) OR ((sample_point AND (NOT sampled_bit)) AND CONV_STD_LOGIC((error_cnt2 = "111") OR (overload_cnt2 = "111")))) AND (NOT overload_frame_blocked) ;
2329
   go_crc_enable <= hard_sync OR go_tx_xhdl34 ;
2330
   rst_crc_enable <= go_rx_crc ;
2331
   bit_de_stuff_set <= go_rx_id1 AND (NOT go_error_frame_xhdl33) ;
2332
   bit_de_stuff_reset <= go_rx_ack OR reset_mode OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32 ;
2333
   remote_rq <= ((NOT ide) AND rtr1) OR (ide AND rtr2) ;
2334
   temp_xhdl47 <= data_len WHEN (data_len < "1000") ELSE "1000";
2335
   limited_data_len <= temp_xhdl47 ;
2336
   ack_err <= (((rx_ack AND sample_point) AND sampled_bit) AND tx_state_xhdl2) AND (NOT self_test_mode) ;
2337
   bit_err <= ((((((((tx_state_xhdl2 OR error_frame OR overload_frame_xhdl4 OR rx_ack) AND sample_point) AND CONV_STD_LOGIC(tx_xhdl29 /= sampled_bit)) AND (NOT bit_err_exc1)) AND (NOT bit_err_exc2)) AND (NOT bit_err_exc3)) AND (NOT bit_err_exc4)) AND (NOT bit_err_exc5)) AND (NOT bit_err_exc6) ;
2338
   bit_err_exc1 <= (tx_state_xhdl2 AND arbitration_field) AND tx_xhdl29 ;
2339
   bit_err_exc2 <= rx_ack AND tx_xhdl29 ;
2340
   bit_err_exc3 <= (error_frame AND node_error_passive_xhdl26) AND CONV_STD_LOGIC(error_cnt1 < "111") ;
2341
   bit_err_exc4 <= ((error_frame AND CONV_STD_LOGIC(error_cnt1 = "111")) AND (NOT enable_error_cnt2)) OR ((overload_frame_xhdl4 AND CONV_STD_LOGIC(overload_cnt1 = "111")) AND (NOT enable_overload_cnt2)) ;
2342
   bit_err_exc5 <= (error_frame AND CONV_STD_LOGIC(error_cnt2 = "111")) OR (overload_frame_xhdl4 AND CONV_STD_LOGIC(overload_cnt2 = "111")) ;
2343
   bit_err_exc6 <= (CONV_STD_LOGIC(eof_cnt = "110") AND rx_eof) AND (NOT transmitter_xhdl8) ;
2344
   arbitration_field <= rx_id1 OR rx_rtr1 OR rx_ide OR rx_id2 OR rx_rtr2 ;
2345
   last_bit_of_inter <= rx_inter_xhdl11 AND CONV_STD_LOGIC(bit_cnt(1 DOWNTO 0) = "10") ;
2346
   not_first_bit_of_inter_xhdl10 <= rx_inter_xhdl11 AND CONV_STD_LOGIC(bit_cnt(1 DOWNTO 0) /= "00") ;
2347
 
2348
   -- Rx idle state
2349
 
2350
   PROCESS (clk, rst)
2351
   BEGIN
2352
      IF (rst = '1') THEN
2353
         rx_idle_xhdl6 <= '0';
2354
      ELSIF (clk'EVENT AND clk = '1') THEN
2355
         IF ((reset_mode OR go_rx_id1 OR go_error_frame_xhdl33) = '1') THEN
2356
            rx_idle_xhdl6 <= '0' ;
2357
         ELSE
2358
            IF (go_rx_idle = '1') THEN
2359
               rx_idle_xhdl6 <= '1' ;
2360
            END IF;
2361
         END IF;
2362
      END IF;
2363
   END PROCESS;
2364
 
2365
   -- Rx id1 state
2366
 
2367
   PROCESS (clk, rst)
2368
   BEGIN
2369
      IF (rst = '1') THEN
2370
         rx_id1 <= '0';
2371
      ELSIF (clk'EVENT AND clk = '1') THEN
2372
         IF ((reset_mode OR go_rx_rtr1 OR go_error_frame_xhdl33) = '1') THEN
2373
            rx_id1 <= '0' ;
2374
         ELSE
2375
            IF (go_rx_id1 = '1') THEN
2376
               rx_id1 <= '1' ;
2377
            END IF;
2378
         END IF;
2379
      END IF;
2380
   END PROCESS;
2381
 
2382
   -- Rx rtr1 state
2383
 
2384
   PROCESS (clk, rst)
2385
   BEGIN
2386
      IF (rst = '1') THEN
2387
         rx_rtr1 <= '0';
2388
      ELSIF (clk'EVENT AND clk = '1') THEN
2389
         IF ((reset_mode OR go_rx_ide OR go_error_frame_xhdl33) = '1') THEN
2390
            rx_rtr1 <= '0' ;
2391
         ELSE
2392
            IF (go_rx_rtr1 = '1') THEN
2393
               rx_rtr1 <= '1' ;
2394
            END IF;
2395
         END IF;
2396
      END IF;
2397
   END PROCESS;
2398
 
2399
   -- Rx ide state
2400
 
2401
   PROCESS (clk, rst)
2402
   BEGIN
2403
      IF (rst = '1') THEN
2404
         rx_ide <= '0';
2405
      ELSIF (clk'EVENT AND clk = '1') THEN
2406
         IF ((reset_mode OR go_rx_r0 OR go_rx_id2 OR go_error_frame_xhdl33) = '1') THEN
2407
            rx_ide <= '0' ;
2408
         ELSE
2409
            IF (go_rx_ide = '1') THEN
2410
               rx_ide <= '1' ;
2411
            END IF;
2412
         END IF;
2413
      END IF;
2414
   END PROCESS;
2415
 
2416
   -- Rx id2 state
2417
 
2418
   PROCESS (clk, rst)
2419
   BEGIN
2420
      IF (rst = '1') THEN
2421
         rx_id2 <= '0';
2422
      ELSIF (clk'EVENT AND clk = '1') THEN
2423
         IF ((reset_mode OR go_rx_rtr2 OR go_error_frame_xhdl33) = '1') THEN
2424
            rx_id2 <= '0' ;
2425
         ELSE
2426
            IF (go_rx_id2 = '1') THEN
2427
               rx_id2 <= '1' ;
2428
            END IF;
2429
         END IF;
2430
      END IF;
2431
   END PROCESS;
2432
 
2433
   -- Rx rtr2 state
2434
 
2435
   PROCESS (clk, rst)
2436
   BEGIN
2437
      IF (rst = '1') THEN
2438
         rx_rtr2 <= '0';
2439
      ELSIF (clk'EVENT AND clk = '1') THEN
2440
         IF ((reset_mode OR go_rx_r1 OR go_error_frame_xhdl33) = '1') THEN
2441
            rx_rtr2 <= '0' ;
2442
         ELSE
2443
            IF (go_rx_rtr2 = '1') THEN
2444
               rx_rtr2 <= '1' ;
2445
            END IF;
2446
         END IF;
2447
      END IF;
2448
   END PROCESS;
2449
 
2450
   -- Rx r0 state
2451
 
2452
   PROCESS (clk, rst)
2453
   BEGIN
2454
      IF (rst = '1') THEN
2455
         rx_r1 <= '0';
2456
      ELSIF (clk'EVENT AND clk = '1') THEN
2457
         IF ((reset_mode OR go_rx_r0 OR go_error_frame_xhdl33) = '1') THEN
2458
            rx_r1 <= '0' ;
2459
         ELSE
2460
            IF (go_rx_r1 = '1') THEN
2461
               rx_r1 <= '1' ;
2462
            END IF;
2463
         END IF;
2464
      END IF;
2465
   END PROCESS;
2466
 
2467
   -- Rx r0 state
2468
 
2469
   PROCESS (clk, rst)
2470
   BEGIN
2471
      IF (rst = '1') THEN
2472
         rx_r0 <= '0';
2473
      ELSIF (clk'EVENT AND clk = '1') THEN
2474
         IF ((reset_mode OR go_rx_dlc OR go_error_frame_xhdl33) = '1') THEN
2475
            rx_r0 <= '0' ;
2476
         ELSE
2477
            IF (go_rx_r0 = '1') THEN
2478
               rx_r0 <= '1' ;
2479
            END IF;
2480
         END IF;
2481
      END IF;
2482
   END PROCESS;
2483
 
2484
   -- Rx dlc state
2485
 
2486
   PROCESS (clk, rst)
2487
   BEGIN
2488
      IF (rst = '1') THEN
2489
         rx_dlc <= '0';
2490
      ELSIF (clk'EVENT AND clk = '1') THEN
2491
         IF ((reset_mode OR go_rx_data OR go_rx_crc OR go_error_frame_xhdl33) = '1') THEN
2492
            rx_dlc <= '0' ;
2493
         ELSE
2494
            IF (go_rx_dlc = '1') THEN
2495
               rx_dlc <= '1' ;
2496
            END IF;
2497
         END IF;
2498
      END IF;
2499
   END PROCESS;
2500
 
2501
   -- Rx data state
2502
 
2503
   PROCESS (clk, rst)
2504
   BEGIN
2505
      IF (rst = '1') THEN
2506
         rx_data <= '0';
2507
      ELSIF (clk'EVENT AND clk = '1') THEN
2508
         IF ((reset_mode OR go_rx_crc OR go_error_frame_xhdl33) = '1') THEN
2509
            rx_data <= '0' ;
2510
         ELSE
2511
            IF (go_rx_data = '1') THEN
2512
               rx_data <= '1' ;
2513
            END IF;
2514
         END IF;
2515
      END IF;
2516
   END PROCESS;
2517
 
2518
   -- Rx crc state
2519
 
2520
   PROCESS (clk, rst)
2521
   BEGIN
2522
      IF (rst = '1') THEN
2523
         rx_crc <= '0';
2524
      ELSIF (clk'EVENT AND clk = '1') THEN
2525
         IF ((reset_mode OR go_rx_crc_lim OR go_error_frame_xhdl33) = '1') THEN
2526
            rx_crc <= '0' ;
2527
         ELSE
2528
            IF (go_rx_crc = '1') THEN
2529
               rx_crc <= '1' ;
2530
            END IF;
2531
         END IF;
2532
      END IF;
2533
   END PROCESS;
2534
 
2535
   -- Rx crc delimiter state
2536
 
2537
   PROCESS (clk, rst)
2538
   BEGIN
2539
      IF (rst = '1') THEN
2540
         rx_crc_lim <= '0';
2541
      ELSIF (clk'EVENT AND clk = '1') THEN
2542
         IF ((reset_mode OR go_rx_ack OR go_error_frame_xhdl33) = '1') THEN
2543
            rx_crc_lim <= '0' ;
2544
         ELSE
2545
            IF (go_rx_crc_lim = '1') THEN
2546
               rx_crc_lim <= '1' ;
2547
            END IF;
2548
         END IF;
2549
      END IF;
2550
   END PROCESS;
2551
 
2552
   -- Rx ack state
2553
 
2554
   PROCESS (clk, rst)
2555
   BEGIN
2556
      IF (rst = '1') THEN
2557
         rx_ack <= '0';
2558
      ELSIF (clk'EVENT AND clk = '1') THEN
2559
         IF ((reset_mode OR go_rx_ack_lim OR go_error_frame_xhdl33) = '1') THEN
2560
            rx_ack <= '0' ;
2561
         ELSE
2562
            IF (go_rx_ack = '1') THEN
2563
               rx_ack <= '1' ;
2564
            END IF;
2565
         END IF;
2566
      END IF;
2567
   END PROCESS;
2568
 
2569
   -- Rx ack delimiter state
2570
 
2571
   PROCESS (clk, rst)
2572
   BEGIN
2573
      IF (rst = '1') THEN
2574
         rx_ack_lim <= '0';
2575
      ELSIF (clk'EVENT AND clk = '1') THEN
2576
         IF ((reset_mode OR go_rx_eof OR go_error_frame_xhdl33) = '1') THEN
2577
            rx_ack_lim <= '0' ;
2578
         ELSE
2579
            IF (go_rx_ack_lim = '1') THEN
2580
               rx_ack_lim <= '1' ;
2581
            END IF;
2582
         END IF;
2583
      END IF;
2584
   END PROCESS;
2585
 
2586
   -- Rx eof state
2587
 
2588
   PROCESS (clk, rst)
2589
   BEGIN
2590
      IF (rst = '1') THEN
2591
         rx_eof <= '0';
2592
      ELSIF (clk'EVENT AND clk = '1') THEN
2593
         IF ((reset_mode OR go_rx_inter_xhdl9 OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
2594
            rx_eof <= '0' ;
2595
         ELSE
2596
            IF (go_rx_eof = '1') THEN
2597
               rx_eof <= '1' ;
2598
            END IF;
2599
         END IF;
2600
      END IF;
2601
   END PROCESS;
2602
 
2603
   -- Interframe space
2604
 
2605
   PROCESS (clk, rst)
2606
   BEGIN
2607
      IF (rst = '1') THEN
2608
         rx_inter_xhdl11 <= '0';
2609
      ELSIF (clk'EVENT AND clk = '1') THEN
2610
         IF ((reset_mode OR go_rx_idle OR go_rx_id1 OR go_overload_frame_xhdl32 OR go_error_frame_xhdl33) = '1') THEN
2611
            rx_inter_xhdl11 <= '0' ;
2612
         ELSE
2613
            IF (go_rx_inter_xhdl9 = '1') THEN
2614
               rx_inter_xhdl11 <= '1' ;
2615
            END IF;
2616
         END IF;
2617
      END IF;
2618
   END PROCESS;
2619
 
2620
   -- ID register
2621
 
2622
   PROCESS (clk, rst)
2623
   BEGIN
2624
      IF (rst = '1') THEN
2625
         id <= "00000000000000000000000000000";
2626
      ELSIF (clk'EVENT AND clk = '1') THEN
2627
         IF (reset_mode = '1') THEN
2628
            id <= "00000000000000000000000000000";
2629
         ELSE
2630
            IF (((sample_point AND (rx_id1 OR rx_id2)) AND (NOT bit_de_stuff)) = '1') THEN
2631
               id <= id(27 DOWNTO 0) & sampled_bit ;
2632
            END IF;
2633
         END IF;
2634
      END IF;
2635
   END PROCESS;
2636
 
2637
   -- rtr1 bit
2638
 
2639
   PROCESS (clk, rst)
2640
   BEGIN
2641
      IF (rst = '1') THEN
2642
         rtr1 <= '0';
2643
      ELSIF (clk'EVENT AND clk = '1') THEN
2644
         IF (reset_mode = '1') THEN
2645
            rtr1 <= '0';
2646
         ELSE
2647
            IF (((sample_point AND rx_rtr1) AND (NOT bit_de_stuff)) = '1') THEN
2648
               rtr1 <= sampled_bit ;
2649
            END IF;
2650
         END IF;
2651
      END IF;
2652
   END PROCESS;
2653
 
2654
   -- rtr2 bit
2655
 
2656
   PROCESS (clk, rst)
2657
   BEGIN
2658
      IF (rst = '1') THEN
2659
         rtr2 <= '0';
2660
      ELSIF (clk'EVENT AND clk = '1') THEN
2661
         IF (reset_mode = '1') THEN
2662
            rtr2 <= '0';
2663
         ELSE
2664
            IF (((sample_point AND rx_rtr2) AND (NOT bit_de_stuff)) = '1') THEN
2665
               rtr2 <= sampled_bit ;
2666
            END IF;
2667
         END IF;
2668
      END IF;
2669
   END PROCESS;
2670
 
2671
   -- ide bit
2672
 
2673
   PROCESS (clk, rst)
2674
   BEGIN
2675
      IF (rst = '1') THEN
2676
         ide <= '0';
2677
      ELSIF (clk'EVENT AND clk = '1') THEN
2678
         IF (reset_mode = '1') THEN
2679
            ide <= '0';
2680
         ELSE
2681
            IF (((sample_point AND rx_ide) AND (NOT bit_de_stuff)) = '1') THEN
2682
               ide <= sampled_bit ;
2683
            END IF;
2684
         END IF;
2685
      END IF;
2686
   END PROCESS;
2687
 
2688
   -- Data length
2689
 
2690
   PROCESS (clk, rst)
2691
   BEGIN
2692
      IF (rst = '1') THEN
2693
         data_len <= "0000";
2694
      ELSIF (clk'EVENT AND clk = '1') THEN
2695
         IF (reset_mode = '1') THEN
2696
            data_len <= "0000";
2697
         ELSE
2698
            IF (((sample_point AND rx_dlc) AND (NOT bit_de_stuff)) = '1') THEN
2699
               data_len <= data_len(2 DOWNTO 0) & sampled_bit ;
2700
            END IF;
2701
         END IF;
2702
      END IF;
2703
   END PROCESS;
2704
 
2705
   -- Data
2706
 
2707
   PROCESS (clk, rst)
2708
   BEGIN
2709
      IF (rst = '1') THEN
2710
         tmp_data <= "00000000";
2711
      ELSIF (clk'EVENT AND clk = '1') THEN
2712
         IF (reset_mode = '1') THEN
2713
            tmp_data <= "00000000";
2714
         ELSE
2715
            IF (((sample_point AND rx_data) AND (NOT bit_de_stuff)) = '1') THEN
2716
               tmp_data <= tmp_data(6 DOWNTO 0) & sampled_bit ;
2717
            END IF;
2718
         END IF;
2719
      END IF;
2720
   END PROCESS;
2721
 
2722
   PROCESS (clk, rst)
2723
   BEGIN
2724
      IF (rst = '1') THEN
2725
         write_data_to_tmp_fifo <= '0';
2726
      ELSIF (clk'EVENT AND clk = '1') THEN
2727
         IF (reset_mode = '1') THEN
2728
            write_data_to_tmp_fifo <= '0';
2729
         ELSE
2730
            IF ((((sample_point AND rx_data) AND (NOT bit_de_stuff)) AND (andv(bit_cnt(2 DOWNTO 0)))) = '1') THEN
2731
               write_data_to_tmp_fifo <= '1' ;
2732
            ELSE
2733
               write_data_to_tmp_fifo <= '0' ;
2734
            END IF;
2735
         END IF;
2736
      END IF;
2737
   END PROCESS;
2738
 
2739
   PROCESS (clk, rst)
2740
   BEGIN
2741
      IF (rst = '1') THEN
2742
         byte_cnt <= "000";
2743
      ELSIF (clk'EVENT AND clk = '1') THEN
2744
         IF (reset_mode = '1') THEN
2745
            byte_cnt <= "000";
2746
         ELSE
2747
            IF (write_data_to_tmp_fifo = '1') THEN
2748
               byte_cnt <= byte_cnt + "001" ;
2749
            ELSE
2750
               IF ((sample_point AND go_rx_crc_lim) = '1') THEN
2751
                  byte_cnt <= "000" ;
2752
               END IF;
2753
            END IF;
2754
         END IF;
2755
      END IF;
2756
   END PROCESS;
2757
 
2758
   PROCESS (clk)
2759
   BEGIN
2760
      IF (clk'EVENT AND clk = '1') THEN
2761
         IF (write_data_to_tmp_fifo = '1') THEN
2762
            tmp_fifo(conv_integer(byte_cnt)) <= tmp_data ;
2763
         END IF;
2764
      END IF;
2765
   END PROCESS;
2766
 
2767
   -- CRC
2768
 
2769
   PROCESS (clk, rst)
2770
   BEGIN
2771
      IF (rst = '1') THEN
2772
         crc_in <= "000000000000000";
2773
      ELSIF (clk'EVENT AND clk = '1') THEN
2774
         IF (reset_mode = '1') THEN
2775
            crc_in <= "000000000000000";
2776
         ELSE
2777
            IF (((sample_point AND rx_crc) AND (NOT bit_de_stuff)) = '1') THEN
2778
               crc_in <= crc_in(13 DOWNTO 0) & sampled_bit ;
2779
            END IF;
2780
         END IF;
2781
      END IF;
2782
   END PROCESS;
2783
 
2784
   -- bit_cnt
2785
 
2786
   PROCESS (clk, rst)
2787
   BEGIN
2788
      IF (rst = '1') THEN
2789
         bit_cnt <= "000000";
2790
      ELSIF (clk'EVENT AND clk = '1') THEN
2791
         IF (reset_mode = '1') THEN
2792
            bit_cnt <= "000000";
2793
         ELSE
2794
            IF ((go_rx_id1 OR go_rx_id2 OR go_rx_dlc OR go_rx_data OR go_rx_crc OR go_rx_ack OR go_rx_eof OR go_rx_inter_xhdl9 OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
2795
               bit_cnt <= "000000" ;
2796
            ELSE
2797
               IF ((sample_point AND (NOT bit_de_stuff)) = '1') THEN
2798
                  bit_cnt <= bit_cnt + "000001" ;
2799
               END IF;
2800
            END IF;
2801
         END IF;
2802
      END IF;
2803
   END PROCESS;
2804
 
2805
   -- eof_cnt
2806
 
2807
   PROCESS (clk, rst)
2808
   BEGIN
2809
      IF (rst = '1') THEN
2810
         eof_cnt <= "000";
2811
      ELSIF (clk'EVENT AND clk = '1') THEN
2812
         IF (reset_mode = '1') THEN
2813
            eof_cnt <= "000";
2814
         ELSE
2815
            IF (sample_point = '1') THEN
2816
               IF ((go_rx_inter_xhdl9 OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
2817
                  eof_cnt <= "000" ;
2818
               ELSE
2819
                  IF (rx_eof = '1') THEN
2820
                     eof_cnt <= eof_cnt + "001" ;
2821
                  END IF;
2822
               END IF;
2823
            END IF;
2824
         END IF;
2825
      END IF;
2826
   END PROCESS;
2827
 
2828
   -- Enabling bit de-stuffing
2829
 
2830
   PROCESS (clk, rst)
2831
   BEGIN
2832
      IF (rst = '1') THEN
2833
         bit_stuff_cnt_en <= '0';
2834
      ELSIF (clk'EVENT AND clk = '1') THEN
2835
         IF (reset_mode = '1') THEN
2836
            bit_stuff_cnt_en <= '0';
2837
         ELSE
2838
            IF (bit_de_stuff_set = '1') THEN
2839
               bit_stuff_cnt_en <= '1' ;
2840
            ELSE
2841
               IF (bit_de_stuff_reset = '1') THEN
2842
                  bit_stuff_cnt_en <= '0' ;
2843
               END IF;
2844
            END IF;
2845
         END IF;
2846
      END IF;
2847
   END PROCESS;
2848
 
2849
   -- bit_stuff_cnt
2850
 
2851
   PROCESS (clk, rst)
2852
   BEGIN
2853
      IF (rst = '1') THEN
2854
         bit_stuff_cnt <= "001";
2855
      ELSIF (clk'EVENT AND clk = '1') THEN
2856
         IF (reset_mode = '1') THEN
2857
            bit_stuff_cnt <= "001";
2858
         ELSE
2859
            IF (bit_de_stuff_reset = '1') THEN
2860
               bit_stuff_cnt <= "001" ;
2861
            ELSE
2862
               IF ((sample_point AND bit_stuff_cnt_en) = '1') THEN
2863
                  IF (bit_stuff_cnt = "101") THEN
2864
                     bit_stuff_cnt <= "001" ;
2865
                  ELSE
2866
                     IF (sampled_bit = sampled_bit_q) THEN
2867
                        bit_stuff_cnt <= bit_stuff_cnt + "001" ;
2868
                     ELSE
2869
                        bit_stuff_cnt <= "001" ;
2870
                     END IF;
2871
                  END IF;
2872
               END IF;
2873
            END IF;
2874
         END IF;
2875
      END IF;
2876
   END PROCESS;
2877
 
2878
   -- bit_stuff_cnt_tx
2879
 
2880
   PROCESS (clk, rst)
2881
   BEGIN
2882
      IF (rst = '1') THEN
2883
         bit_stuff_cnt_tx <= "001";
2884
      ELSIF (clk'EVENT AND clk = '1') THEN
2885
         IF (reset_mode = '1') THEN
2886
            bit_stuff_cnt_tx <= "001";
2887
         ELSE
2888
            IF (bit_de_stuff_reset = '1') THEN
2889
               bit_stuff_cnt_tx <= "001" ;
2890
            ELSE
2891
               IF ((tx_point_q AND bit_stuff_cnt_en) = '1') THEN
2892
                  IF (bit_stuff_cnt_tx = "101") THEN
2893
                     bit_stuff_cnt_tx <= "001" ;
2894
                  ELSE
2895
                     IF (tx_xhdl29 = tx_q) THEN
2896
                        bit_stuff_cnt_tx <= bit_stuff_cnt_tx + "001" ;
2897
                     ELSE
2898
                        bit_stuff_cnt_tx <= "001" ;
2899
                     END IF;
2900
                  END IF;
2901
               END IF;
2902
            END IF;
2903
         END IF;
2904
      END IF;
2905
   END PROCESS;
2906
   bit_de_stuff <= CONV_STD_LOGIC(bit_stuff_cnt = "101") ;
2907
   bit_de_stuff_tx <= CONV_STD_LOGIC(bit_stuff_cnt_tx = "101") ;
2908
   -- stuff_err
2909
   stuff_err <= ((sample_point AND bit_stuff_cnt_en) AND bit_de_stuff) AND CONV_STD_LOGIC(sampled_bit = sampled_bit_q) ;
2910
 
2911
   -- Generating delayed signals
2912
 
2913
   PROCESS (clk, rst)
2914
   BEGIN
2915
      IF (rst = '1') THEN
2916
         reset_mode_q <= '0' ;
2917
         node_bus_off_q <= '0' ;
2918
      ELSIF (clk'EVENT AND clk = '1') THEN
2919
         reset_mode_q <= reset_mode ;
2920
         node_bus_off_q <= node_bus_off_xhdl13 ;
2921
      END IF;
2922
   END PROCESS;
2923
 
2924
   PROCESS (clk, rst)
2925
   BEGIN
2926
      IF (rst = '1') THEN
2927
         crc_enable <= '0';
2928
      ELSIF (clk'EVENT AND clk = '1') THEN
2929
         IF ((reset_mode OR rst_crc_enable) = '1') THEN
2930
            crc_enable <= '0' ;
2931
         ELSE
2932
            IF (go_crc_enable = '1') THEN
2933
               crc_enable <= '1' ;
2934
            END IF;
2935
         END IF;
2936
      END IF;
2937
   END PROCESS;
2938
 
2939
   -- CRC error generation
2940
 
2941
   PROCESS (clk, rst)
2942
   BEGIN
2943
      IF (rst = '1') THEN
2944
         crc_err <= '0';
2945
      ELSIF (clk'EVENT AND clk = '1') THEN
2946
         IF ((reset_mode OR error_frame_ended) = '1') THEN
2947
            crc_err <= '0' ;
2948
         ELSE
2949
            IF (go_rx_ack = '1') THEN
2950
               crc_err <= CONV_STD_LOGIC(crc_in /= calculated_crc) ;
2951
            END IF;
2952
         END IF;
2953
      END IF;
2954
   END PROCESS;
2955
   -- Conditions for form error
2956
   form_err <= sample_point AND ((((NOT bit_de_stuff) AND rx_crc_lim) AND (NOT sampled_bit)) OR (rx_ack_lim AND (NOT sampled_bit)) OR (((CONV_STD_LOGIC(eof_cnt < "110") AND rx_eof) AND (NOT sampled_bit)) AND (NOT transmitter_xhdl8)) OR (((rx_eof) AND (NOT sampled_bit)) AND transmitter_xhdl8)) ;
2957
 
2958
   PROCESS (clk, rst)
2959
   BEGIN
2960
      IF (rst = '1') THEN
2961
         ack_err_latched <= '0';
2962
      ELSIF (clk'EVENT AND clk = '1') THEN
2963
         IF ((reset_mode OR error_frame_ended OR go_overload_frame_xhdl32) = '1') THEN
2964
            ack_err_latched <= '0' ;
2965
         ELSE
2966
            IF (ack_err = '1') THEN
2967
               ack_err_latched <= '1' ;
2968
            END IF;
2969
         END IF;
2970
      END IF;
2971
   END PROCESS;
2972
 
2973
   PROCESS (clk, rst)
2974
   BEGIN
2975
      IF (rst = '1') THEN
2976
         bit_err_latched <= '0';
2977
      ELSIF (clk'EVENT AND clk = '1') THEN
2978
         IF ((reset_mode OR error_frame_ended OR go_overload_frame_xhdl32) = '1') THEN
2979
            bit_err_latched <= '0' ;
2980
         ELSE
2981
            IF (bit_err = '1') THEN
2982
               bit_err_latched <= '1' ;
2983
            END IF;
2984
         END IF;
2985
      END IF;
2986
   END PROCESS;
2987
   -- Rule 5 (Fault confinement).
2988
   rule5 <= bit_err AND ((((NOT node_error_passive_xhdl26) AND error_frame) AND CONV_STD_LOGIC(error_cnt1 < "111")) OR (overload_frame_xhdl4 AND CONV_STD_LOGIC(overload_cnt1 < "111"))) ;
2989
 
2990
   -- Rule 3 exception 1 - first part (Fault confinement).
2991
 
2992
   PROCESS (clk, rst)
2993
   BEGIN
2994
      IF (rst = '1') THEN
2995
         rule3_exc1_1 <= '0';
2996
      ELSIF (clk'EVENT AND clk = '1') THEN
2997
         IF ((reset_mode OR error_flag_over OR rule3_exc1_2) = '1') THEN
2998
            rule3_exc1_1 <= '0' ;
2999
         ELSE
3000
            IF (((transmitter_xhdl8 AND node_error_passive_xhdl26) AND ack_err) = '1') THEN
3001
               rule3_exc1_1 <= '1' ;
3002
            END IF;
3003
         END IF;
3004
      END IF;
3005
   END PROCESS;
3006
 
3007
   -- Rule 3 exception 1 - second part (Fault confinement).
3008
 
3009
   PROCESS (clk, rst)
3010
   BEGIN
3011
      IF (rst = '1') THEN
3012
         rule3_exc1_2 <= '0';
3013
      ELSIF (clk'EVENT AND clk = '1') THEN
3014
         IF ((reset_mode OR go_error_frame_xhdl33 OR rule3_exc1_2) = '1') THEN
3015
            rule3_exc1_2 <= '0' ;
3016
         ELSE
3017
            IF ((((rule3_exc1_1 AND CONV_STD_LOGIC(error_cnt1 < "111")) AND sample_point) AND (NOT sampled_bit)) = '1') THEN
3018
               rule3_exc1_2 <= '1' ;
3019
            END IF;
3020
         END IF;
3021
      END IF;
3022
   END PROCESS;
3023
 
3024
   PROCESS (clk, rst)
3025
   BEGIN
3026
      IF (rst = '1') THEN
3027
         stuff_err_latched <= '0';
3028
      ELSIF (clk'EVENT AND clk = '1') THEN
3029
         IF ((reset_mode OR error_frame_ended OR go_overload_frame_xhdl32) = '1') THEN
3030
            stuff_err_latched <= '0' ;
3031
         ELSE
3032
            IF (stuff_err = '1') THEN
3033
               stuff_err_latched <= '1' ;
3034
            END IF;
3035
         END IF;
3036
      END IF;
3037
   END PROCESS;
3038
 
3039
   PROCESS (clk, rst)
3040
   BEGIN
3041
      IF (rst = '1') THEN
3042
         form_err_latched <= '0';
3043
      ELSIF (clk'EVENT AND clk = '1') THEN
3044
         IF ((reset_mode OR error_frame_ended OR go_overload_frame_xhdl32) = '1') THEN
3045
            form_err_latched <= '0' ;
3046
         ELSE
3047
            IF (form_err = '1') THEN
3048
               form_err_latched <= '1' ;
3049
            END IF;
3050
         END IF;
3051
      END IF;
3052
   END PROCESS;
3053
   xhdl_49 <= ((crc_enable AND sample_point) AND (NOT bit_de_stuff));
3054
   i_can_crc_rx : can_crc
3055
      PORT MAP (
3056
         clk => clk,
3057
         data => sampled_bit,
3058
         enable => xhdl_49,
3059
         initialize => go_crc_enable,
3060
         crc => calculated_crc);
3061
 
3062
   no_byte0 <= rtr1 OR CONV_STD_LOGIC(data_len < "0001") ;
3063
   no_byte1 <= rtr1 OR CONV_STD_LOGIC(data_len < "0010") ;
3064
   port_xhdl73 <= tmp_fifo(0);
3065
   port_xhdl74 <= tmp_fifo(1);
3066
   i_can_acf : can_acf
3067
      PORT MAP (
3068
         clk => clk,
3069
         rst => rst,
3070
         id => id,
3071
         reset_mode => reset_mode,
3072
         acceptance_filter_mode => acceptance_filter_mode,
3073
         extended_mode => extended_mode,
3074
         acceptance_code_0 => acceptance_code_0,
3075
         acceptance_mask_0 => acceptance_mask_0,
3076
         acceptance_code_1 => acceptance_code_1,
3077
         acceptance_code_2 => acceptance_code_2,
3078
         acceptance_code_3 => acceptance_code_3,
3079
         acceptance_mask_1 => acceptance_mask_1,
3080
         acceptance_mask_2 => acceptance_mask_2,
3081
         acceptance_mask_3 => acceptance_mask_3,
3082
         go_rx_crc_lim => go_rx_crc_lim,
3083
         go_rx_inter => go_rx_inter_xhdl9,
3084
         go_error_frame => go_error_frame_xhdl33,
3085
         data0 => port_xhdl73,
3086
         data1 => port_xhdl74,
3087
         rtr1 => rtr1,
3088
         rtr2 => rtr2,
3089
         ide => ide,
3090
         no_byte0 => no_byte0,
3091
         no_byte1 => no_byte1,
3092
         id_ok => id_ok);
3093
 
3094
   temp_xhdl75 <= "101" WHEN ide = '1' ELSE "011";
3095
   temp_xhdl76 <= (temp_xhdl75) WHEN extended_mode = '1' ELSE "010";
3096
   header_len(2 DOWNTO 0) <= temp_xhdl76 ;
3097
   storing_header <= CONV_STD_LOGIC(header_cnt < header_len) ;
3098
   temp_xhdl77 <= (data_len - "0001") WHEN (data_len < "1000") ELSE "0111";
3099
   temp_xhdl78 <= "1111" WHEN remote_rq = '1' ELSE (temp_xhdl77);
3100
   limited_data_len_minus1(3 DOWNTO 0) <= temp_xhdl78 ;
3101
   reset_wr_fifo <= CONV_STD_LOGIC(data_cnt = (limited_data_len_minus1 + ('0' & header_len))) OR reset_mode ;
3102
   err <= form_err OR stuff_err OR bit_err OR ack_err OR form_err_latched OR stuff_err_latched OR bit_err_latched OR ack_err_latched OR crc_err ;
3103
 
3104
   -- Write enable signal for 64-byte rx fifo
3105
 
3106
   PROCESS (clk, rst)
3107
   BEGIN
3108
      IF (rst = '1') THEN
3109
         wr_fifo <= '0';
3110
      ELSIF (clk'EVENT AND clk = '1') THEN
3111
         IF (reset_wr_fifo = '1') THEN
3112
            wr_fifo <= '0' ;
3113
         ELSE
3114
            IF ((((go_rx_inter_xhdl9 AND id_ok) AND (NOT error_frame_ended)) AND ((NOT tx_state_xhdl2) OR self_rx_request)) = '1') THEN
3115
               wr_fifo <= '1' ;
3116
            END IF;
3117
         END IF;
3118
      END IF;
3119
   END PROCESS;
3120
 
3121
   -- Header counter. Header length depends on the mode of operation and frame format.
3122
 
3123
   PROCESS (clk, rst)
3124
   BEGIN
3125
      IF (rst = '1') THEN
3126
         header_cnt <= "000";
3127
      ELSIF (clk'EVENT AND clk = '1') THEN
3128
         IF (reset_wr_fifo = '1') THEN
3129
            header_cnt <= "000" ;
3130
         ELSE
3131
            IF ((wr_fifo AND storing_header) = '1') THEN
3132
               header_cnt <= header_cnt + "001" ;
3133
            END IF;
3134
         END IF;
3135
      END IF;
3136
   END PROCESS;
3137
 
3138
   -- Data counter. Length of the data is limited to 8 bytes.
3139
 
3140
   PROCESS (clk, rst)
3141
   BEGIN
3142
      IF (rst = '1') THEN
3143
         data_cnt <= "0000";
3144
      ELSIF (clk'EVENT AND clk = '1') THEN
3145
         IF (reset_wr_fifo = '1') THEN
3146
            data_cnt <= "0000" ;
3147
         ELSE
3148
            IF (wr_fifo = '1') THEN
3149
               data_cnt <= data_cnt + "0001" ;
3150
            END IF;
3151
         END IF;
3152
      END IF;
3153
   END PROCESS;
3154
 
3155
   -- Multiplexing data that is stored to 64-byte fifo depends on the mode of operation and frame format
3156
 
3157
   PROCESS (extended_mode, ide, data_cnt, header_cnt, header_len, storing_header, id, rtr1, rtr2, data_len, tmp_fifo)
3158
      VARIABLE data_for_fifo_xhdl79  : std_logic_vector(7 DOWNTO 0);
3159
      VARIABLE temp_xhdl80  : std_logic_vector(5 DOWNTO 0);
3160
   BEGIN
3161
      temp_xhdl80 := storing_header & extended_mode & ide & header_cnt;
3162
      IF (std_match(temp_xhdl80, "111000")) THEN
3163
               data_for_fifo_xhdl79 := '1' & rtr2 & "00" & data_len;    --  extended mode, extended format header
3164
      ELSIF (std_match(temp_xhdl80, "111001")) THEN
3165
               data_for_fifo_xhdl79 := id(28 DOWNTO 21);    --  extended mode, extended format header
3166
      ELSIF (std_match(temp_xhdl80, "111010")) THEN
3167
               data_for_fifo_xhdl79 := id(20 DOWNTO 13);    --  extended mode, extended format header
3168
      ELSIF (std_match(temp_xhdl80, "111011")) THEN
3169
               data_for_fifo_xhdl79 := id(12 DOWNTO 5);    --  extended mode, extended format header
3170
      ELSIF (std_match(temp_xhdl80, "111100")) THEN
3171
               data_for_fifo_xhdl79 := id(4 DOWNTO 0) & rtr2 & "00";    --  extended mode, extended format header
3172
      ELSIF (std_match(temp_xhdl80, "110000")) THEN
3173
               data_for_fifo_xhdl79 := '0' & rtr1 & "00" & data_len;    --  extended mode, standard format header
3174
      ELSIF (std_match(temp_xhdl80, "110001")) THEN
3175
               data_for_fifo_xhdl79 := id(10 DOWNTO 3);    --  extended mode, standard format header
3176
      ELSIF (std_match(temp_xhdl80, "110010")) THEN
3177
               data_for_fifo_xhdl79 := id(2 DOWNTO 0) & rtr1 & "0000";    --  extended mode, standard format header
3178
      ELSIF (std_match(temp_xhdl80, "10-000")) THEN
3179
               data_for_fifo_xhdl79 := id(10 DOWNTO 3);    --  normal mode                    header
3180
      ELSIF (std_match(temp_xhdl80, "10-001")) THEN
3181
               data_for_fifo_xhdl79 := id(2 DOWNTO 0) & rtr1 & data_len;    --  normal mode                    header
3182
      ELSE
3183
               data_for_fifo_xhdl79 := tmp_fifo(conv_integer(data_cnt - ('0' & header_len)) mod 8);    --  data 
3184
 
3185
      END IF;
3186
      data_for_fifo <= data_for_fifo_xhdl79;
3187
   END PROCESS;
3188
 
3189
   -- Instantiation of the RX fifo module
3190
   -- port connections for Ram
3191
   --64x8
3192
   --64x4
3193
   --64x1
3194
   i_can_fifo : can_fifo
3195
      PORT MAP (
3196
         clk => clk,
3197
         rst => rst,
3198
         wr => wr_fifo,
3199
         data_in => data_for_fifo,
3200
         addr => addr(5 DOWNTO 0),
3201
         data_out => data_out_xhdl1,
3202
         fifo_selected => fifo_selected,
3203
         reset_mode => reset_mode,
3204
         release_buffer => release_buffer,
3205
         extended_mode => extended_mode,
3206
         overrun => overrun_xhdl21,
3207
         info_empty => info_empty_xhdl22,
3208
         info_cnt => rx_message_counter_xhdl28,
3209
         q_dp_64x8 => w_q_dp_64x8,
3210
         data_64x8 => w_data_64x8,
3211
         wren_64x8 => w_wren_64x8,
3212
         rden_64x8 => w_rden_64x8,
3213
         wraddress_64x8 => w_wraddress_64x8,
3214
         rdaddress_64x8 => w_rdaddress_64x8,
3215
         q_dp_64x4 => w_q_dp_64x4,
3216
         data_64x4 => w_data_64x4,
3217
         wren_64x4x1 => w_wren_64x4x1,
3218
         wraddress_64x4x1 => w_wraddress_64x4x1,
3219
         rdaddress_64x4x1 => w_rdaddress_64x4x1,
3220
         q_dp_64x1 => w_q_dp_64x1,
3221
         data_64x1 => w_data_64x1);
3222
 
3223
 
3224
   -- Transmitting error frame.
3225
 
3226
   PROCESS (clk, rst)
3227
   BEGIN
3228
      IF (rst = '1') THEN
3229
         error_frame <= '0';
3230
      ELSIF (clk'EVENT AND clk = '1') THEN
3231
         IF ((reset_mode OR error_frame_ended OR go_overload_frame_xhdl32) = '1') THEN
3232
            error_frame <= '0' ;
3233
         ELSE
3234
            IF (go_error_frame_xhdl33 = '1') THEN
3235
               error_frame <= '1' ;
3236
            END IF;
3237
         END IF;
3238
      END IF;
3239
   END PROCESS;
3240
 
3241
   PROCESS (clk, rst)
3242
   BEGIN
3243
      IF (rst = '1') THEN
3244
         error_cnt1 <= "000";
3245
      ELSIF (clk'EVENT AND clk = '1') THEN
3246
         IF ((reset_mode OR error_frame_ended OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
3247
            error_cnt1 <= "000" ;
3248
         ELSE
3249
            IF (((error_frame AND tx_point) AND CONV_STD_LOGIC(error_cnt1 < "111")) = '1') THEN
3250
               error_cnt1 <= error_cnt1 + "001" ;
3251
            END IF;
3252
         END IF;
3253
      END IF;
3254
   END PROCESS;
3255
   error_flag_over <= ((((NOT node_error_passive_xhdl26) AND sample_point) AND CONV_STD_LOGIC(error_cnt1 = "111")) OR ((node_error_passive_xhdl26 AND sample_point) AND CONV_STD_LOGIC(passive_cnt = "110"))) AND (NOT enable_error_cnt2) ;
3256
 
3257
   PROCESS (clk, rst)
3258
   BEGIN
3259
      IF (rst = '1') THEN
3260
         error_flag_over_latched <= '0';
3261
      ELSIF (clk'EVENT AND clk = '1') THEN
3262
         IF ((reset_mode OR error_frame_ended OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
3263
            error_flag_over_latched <= '0' ;
3264
         ELSE
3265
            IF (error_flag_over = '1') THEN
3266
               error_flag_over_latched <= '1' ;
3267
            END IF;
3268
         END IF;
3269
      END IF;
3270
   END PROCESS;
3271
 
3272
   PROCESS (clk, rst)
3273
   BEGIN
3274
      IF (rst = '1') THEN
3275
         enable_error_cnt2 <= '0';
3276
      ELSIF (clk'EVENT AND clk = '1') THEN
3277
         IF ((reset_mode OR error_frame_ended OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
3278
            enable_error_cnt2 <= '0' ;
3279
         ELSE
3280
            IF ((error_frame AND (error_flag_over AND sampled_bit)) = '1') THEN
3281
               enable_error_cnt2 <= '1' ;
3282
            END IF;
3283
         END IF;
3284
      END IF;
3285
   END PROCESS;
3286
 
3287
   PROCESS (clk, rst)
3288
   BEGIN
3289
      IF (rst = '1') THEN
3290
         error_cnt2 <= "000";
3291
      ELSIF (clk'EVENT AND clk = '1') THEN
3292
         IF ((reset_mode OR error_frame_ended OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
3293
            error_cnt2 <= "000" ;
3294
         ELSE
3295
            IF ((enable_error_cnt2 AND tx_point) = '1') THEN
3296
               error_cnt2 <= error_cnt2 + "001" ;
3297
            END IF;
3298
         END IF;
3299
      END IF;
3300
   END PROCESS;
3301
 
3302
   PROCESS (clk, rst)
3303
   BEGIN
3304
      IF (rst = '1') THEN
3305
         delayed_dominant_cnt <= "000";
3306
      ELSIF (clk'EVENT AND clk = '1') THEN
3307
         IF ((reset_mode OR enable_error_cnt2 OR go_error_frame_xhdl33 OR enable_overload_cnt2 OR go_overload_frame_xhdl32) = '1') THEN
3308
            delayed_dominant_cnt <= "000" ;
3309
         ELSE
3310
            IF (((sample_point AND (NOT sampled_bit)) AND CONV_STD_LOGIC((error_cnt1 = "111") OR (overload_cnt1 = "111"))) = '1') THEN
3311
               delayed_dominant_cnt <= delayed_dominant_cnt + "001" ;
3312
            END IF;
3313
         END IF;
3314
      END IF;
3315
   END PROCESS;
3316
 
3317
   -- passive_cnt
3318
 
3319
   PROCESS (clk, rst)
3320
   BEGIN
3321
      IF (rst = '1') THEN
3322
         passive_cnt <= "001";
3323
      ELSIF (clk'EVENT AND clk = '1') THEN
3324
         IF ((reset_mode OR error_frame_ended OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32 OR first_compare_bit) = '1') THEN
3325
            passive_cnt <= "001" ;
3326
         ELSE
3327
            IF ((sample_point AND CONV_STD_LOGIC(passive_cnt < "110")) = '1') THEN
3328
               IF (((error_frame AND (NOT enable_error_cnt2)) AND CONV_STD_LOGIC(sampled_bit = sampled_bit_q)) = '1') THEN
3329
                  passive_cnt <= passive_cnt + "001" ;
3330
               ELSE
3331
                  passive_cnt <= "001" ;
3332
               END IF;
3333
            END IF;
3334
         END IF;
3335
      END IF;
3336
   END PROCESS;
3337
 
3338
   -- When comparing 6 equal bits, first is always equal
3339
 
3340
   PROCESS (clk, rst)
3341
   BEGIN
3342
      IF (rst = '1') THEN
3343
         first_compare_bit <= '0';
3344
      ELSIF (clk'EVENT AND clk = '1') THEN
3345
         IF (go_error_frame_xhdl33 = '1') THEN
3346
            first_compare_bit <= '1' ;
3347
         ELSE
3348
            IF (sample_point = '1') THEN
3349
               first_compare_bit <= '0';
3350
            END IF;
3351
         END IF;
3352
      END IF;
3353
   END PROCESS;
3354
 
3355
   -- Transmitting overload frame.
3356
 
3357
   PROCESS (clk, rst)
3358
   BEGIN
3359
      IF (rst = '1') THEN
3360
         overload_frame_xhdl4 <= '0';
3361
      ELSIF (clk'EVENT AND clk = '1') THEN
3362
         IF ((reset_mode OR overload_frame_ended OR go_error_frame_xhdl33) = '1') THEN
3363
            overload_frame_xhdl4 <= '0' ;
3364
         ELSE
3365
            IF (go_overload_frame_xhdl32 = '1') THEN
3366
               overload_frame_xhdl4 <= '1' ;
3367
            END IF;
3368
         END IF;
3369
      END IF;
3370
   END PROCESS;
3371
 
3372
   PROCESS (clk, rst)
3373
   BEGIN
3374
      IF (rst = '1') THEN
3375
         overload_cnt1 <= "000";
3376
      ELSIF (clk'EVENT AND clk = '1') THEN
3377
         IF ((reset_mode OR overload_frame_ended OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
3378
            overload_cnt1 <= "000" ;
3379
         ELSE
3380
            IF (((overload_frame_xhdl4 AND tx_point) AND CONV_STD_LOGIC(overload_cnt1 < "111")) = '1') THEN
3381
               overload_cnt1 <= overload_cnt1 + "001" ;
3382
            END IF;
3383
         END IF;
3384
      END IF;
3385
   END PROCESS;
3386
   overload_flag_over <= (sample_point AND CONV_STD_LOGIC(overload_cnt1 = "111")) AND (NOT enable_overload_cnt2) ;
3387
 
3388
   PROCESS (clk, rst)
3389
   BEGIN
3390
      IF (rst = '1') THEN
3391
         enable_overload_cnt2 <= '0';
3392
      ELSIF (clk'EVENT AND clk = '1') THEN
3393
         IF ((reset_mode OR overload_frame_ended OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
3394
            enable_overload_cnt2 <= '0' ;
3395
         ELSE
3396
            IF ((overload_frame_xhdl4 AND (overload_flag_over AND sampled_bit)) = '1') THEN
3397
               enable_overload_cnt2 <= '1' ;
3398
            END IF;
3399
         END IF;
3400
      END IF;
3401
   END PROCESS;
3402
 
3403
   PROCESS (clk, rst)
3404
   BEGIN
3405
      IF (rst = '1') THEN
3406
         overload_cnt2 <= "000";
3407
      ELSIF (clk'EVENT AND clk = '1') THEN
3408
         IF ((reset_mode OR overload_frame_ended OR go_error_frame_xhdl33 OR go_overload_frame_xhdl32) = '1') THEN
3409
            overload_cnt2 <= "000" ;
3410
         ELSE
3411
            IF ((enable_overload_cnt2 AND tx_point) = '1') THEN
3412
               overload_cnt2 <= overload_cnt2 + "001" ;
3413
            END IF;
3414
         END IF;
3415
      END IF;
3416
   END PROCESS;
3417
 
3418
   PROCESS (clk, rst)
3419
   BEGIN
3420
      IF (rst = '1') THEN
3421
         overload_request_cnt <= "00";
3422
      ELSIF (clk'EVENT AND clk = '1') THEN
3423
         IF ((reset_mode OR go_error_frame_xhdl33 OR go_rx_id1) = '1') THEN
3424
            overload_request_cnt <= "00" ;
3425
         ELSE
3426
            IF ((overload_request AND overload_frame_xhdl4) = '1') THEN
3427
               overload_request_cnt <= overload_request_cnt + "01" ;
3428
            END IF;
3429
         END IF;
3430
      END IF;
3431
   END PROCESS;
3432
 
3433
   PROCESS (clk, rst)
3434
   BEGIN
3435
      IF (rst = '1') THEN
3436
         overload_frame_blocked <= '0';
3437
      ELSIF (clk'EVENT AND clk = '1') THEN
3438
         IF ((reset_mode OR go_error_frame_xhdl33 OR go_rx_id1) = '1') THEN
3439
            overload_frame_blocked <= '0' ;
3440
         ELSE
3441
            IF (((overload_request AND overload_frame_xhdl4) AND CONV_STD_LOGIC(overload_request_cnt = "10")) = '1') THEN
3442
               -- This is a second sequential overload_request
3443
 
3444
               overload_frame_blocked <= '1' ;
3445
            END IF;
3446
         END IF;
3447
      END IF;
3448
   END PROCESS;
3449
   send_ack_xhdl35 <= (((NOT tx_state_xhdl2) AND rx_ack) AND (NOT err)) AND (NOT listen_only_mode) ;
3450
 
3451
   PROCESS (reset_mode, node_bus_off_xhdl13, tx_state_xhdl2, go_tx_xhdl34, bit_de_stuff_tx, tx_bit, tx_q, send_ack_xhdl35, go_overload_frame_xhdl32, overload_frame_xhdl4, overload_cnt1, go_error_frame_xhdl33, error_frame, error_cnt1, node_error_passive_xhdl26)
3452
      VARIABLE tx_next_xhdl30_xhdl105  : std_logic;
3453
   BEGIN
3454
      IF ((reset_mode OR node_bus_off_xhdl13) = '1') THEN
3455
         -- Reset or node_bus_off
3456
 
3457
         tx_next_xhdl30_xhdl105 := '1';
3458
      ELSE
3459
         IF ((go_error_frame_xhdl33 OR error_frame) = '1') THEN
3460
            -- Transmitting error frame
3461
 
3462
            IF (error_cnt1 < "110") THEN
3463
               IF (node_error_passive_xhdl26 = '1') THEN
3464
                  tx_next_xhdl30_xhdl105 := '1';
3465
               ELSE
3466
                  tx_next_xhdl30_xhdl105 := '0';
3467
               END IF;
3468
            ELSE
3469
               tx_next_xhdl30_xhdl105 := '1';
3470
            END IF;
3471
         ELSE
3472
            IF ((go_overload_frame_xhdl32 OR overload_frame_xhdl4) = '1') THEN
3473
               -- Transmitting overload frame
3474
 
3475
               IF (overload_cnt1 < "110") THEN
3476
                  tx_next_xhdl30_xhdl105 := '0';
3477
               ELSE
3478
                  tx_next_xhdl30_xhdl105 := '1';
3479
               END IF;
3480
            ELSE
3481
               IF ((go_tx_xhdl34 OR tx_state_xhdl2) = '1') THEN
3482
                  -- Transmitting message
3483
 
3484
                  tx_next_xhdl30_xhdl105 := ((NOT bit_de_stuff_tx) AND tx_bit) OR (bit_de_stuff_tx AND (NOT tx_q));
3485
               ELSE
3486
                  IF (send_ack_xhdl35 = '1') THEN
3487
                     -- Acknowledge
3488
 
3489
                     tx_next_xhdl30_xhdl105 := '0';
3490
                  ELSE
3491
                     tx_next_xhdl30_xhdl105 := '1';
3492
                  END IF;
3493
               END IF;
3494
            END IF;
3495
         END IF;
3496
      END IF;
3497
      tx_next_xhdl30 <= tx_next_xhdl30_xhdl105;
3498
   END PROCESS;
3499
 
3500
   PROCESS (clk, rst)
3501
   BEGIN
3502
      IF (rst = '1') THEN
3503
         tx_xhdl29 <= '1';
3504
      ELSIF (clk'EVENT AND clk = '1') THEN
3505
         IF (reset_mode = '1') THEN
3506
            tx_xhdl29 <= '1';
3507
         ELSE
3508
            IF (tx_point = '1') THEN
3509
               tx_xhdl29 <= tx_next_xhdl30 ;
3510
            END IF;
3511
         END IF;
3512
      END IF;
3513
   END PROCESS;
3514
 
3515
   PROCESS (clk, rst)
3516
   BEGIN
3517
      IF (rst = '1') THEN
3518
         tx_q <= '0' ;
3519
      ELSIF (clk'EVENT AND clk = '1') THEN
3520
         IF (reset_mode = '1') THEN
3521
            tx_q <= '0' ;
3522
         ELSE
3523
            IF (tx_point = '1') THEN
3524
               tx_q <= tx_xhdl29 AND (NOT go_early_tx_latched) ;
3525
            END IF;
3526
         END IF;
3527
      END IF;
3528
   END PROCESS;
3529
 
3530
   -- Delayed tx point 
3531
   PROCESS (clk, rst)
3532
   BEGIN
3533
      IF (rst = '1') THEN
3534
         tx_point_q <= '0' ;
3535
      ELSIF (clk'EVENT AND clk = '1') THEN
3536
         IF (reset_mode = '1') THEN
3537
            tx_point_q <= '0' ;
3538
         ELSE
3539
            tx_point_q <= tx_point ;
3540
         END IF;
3541
      END IF;
3542
   END PROCESS;
3543
 
3544
   -- Changing bit order from [7:0] to [0:7] 
3545
   i_ibo_tx_data_0 : can_ibo
3546
      PORT MAP (
3547
         di => tx_data_0,
3548
         do => r_tx_data_0);
3549
 
3550
   i_ibo_tx_data_1 : can_ibo
3551
      PORT MAP (
3552
         di => tx_data_1,
3553
         do => r_tx_data_1);
3554
 
3555
   i_ibo_tx_data_2 : can_ibo
3556
      PORT MAP (
3557
         di => tx_data_2,
3558
         do => r_tx_data_2);
3559
 
3560
   i_ibo_tx_data_3 : can_ibo
3561
      PORT MAP (
3562
         di => tx_data_3,
3563
         do => r_tx_data_3);
3564
 
3565
   i_ibo_tx_data_4 : can_ibo
3566
      PORT MAP (
3567
         di => tx_data_4,
3568
         do => r_tx_data_4);
3569
 
3570
   i_ibo_tx_data_5 : can_ibo
3571
      PORT MAP (
3572
         di => tx_data_5,
3573
         do => r_tx_data_5);
3574
 
3575
   i_ibo_tx_data_6 : can_ibo
3576
      PORT MAP (
3577
         di => tx_data_6,
3578
         do => r_tx_data_6);
3579
 
3580
   i_ibo_tx_data_7 : can_ibo
3581
      PORT MAP (
3582
         di => tx_data_7,
3583
         do => r_tx_data_7);
3584
 
3585
   i_ibo_tx_data_8 : can_ibo
3586
      PORT MAP (
3587
         di => tx_data_8,
3588
         do => r_tx_data_8);
3589
 
3590
   i_ibo_tx_data_9 : can_ibo
3591
      PORT MAP (
3592
         di => tx_data_9,
3593
         do => r_tx_data_9);
3594
 
3595
   i_ibo_tx_data_10 : can_ibo
3596
      PORT MAP (
3597
         di => tx_data_10,
3598
         do => r_tx_data_10);
3599
 
3600
   i_ibo_tx_data_11 : can_ibo
3601
      PORT MAP (
3602
         di => tx_data_11,
3603
         do => r_tx_data_11);
3604
 
3605
   i_ibo_tx_data_12 : can_ibo
3606
      PORT MAP (
3607
         di => tx_data_12,
3608
         do => r_tx_data_12);
3609
 
3610
 
3611
   -- Changing bit order from [14:0] to [0:14] 
3612
   i_calculated_crc0 : can_ibo
3613
      PORT MAP (
3614
         di => calculated_crc(14 DOWNTO 7),
3615
         do => r_calculated_crc(7 DOWNTO 0));
3616
 
3617
   xhdl_106 <= calculated_crc(6 DOWNTO 0) & '0';
3618
   i_calculated_crc1 : can_ibo
3619
      PORT MAP (
3620
         di => xhdl_106,
3621
         do => r_calculated_crc(15 DOWNTO 8));
3622
 
3623
   basic_chain <= r_tx_data_1(7 DOWNTO 4) & "00" & r_tx_data_1(3 DOWNTO 0) & r_tx_data_0(7 DOWNTO 0) & '0' ;
3624
   basic_chain_data <= r_tx_data_9 & r_tx_data_8 & r_tx_data_7 & r_tx_data_6 & r_tx_data_5 & r_tx_data_4 & r_tx_data_3 & r_tx_data_2 ;
3625
   extended_chain_std <= r_tx_data_0(7 DOWNTO 4) & "00" & r_tx_data_0(1) & r_tx_data_2(2 DOWNTO 0) & r_tx_data_1(7 DOWNTO 0) & '0' ;
3626
   extended_chain_ext <= r_tx_data_0(7 DOWNTO 4) & "00" & r_tx_data_0(1) & r_tx_data_4(4 DOWNTO 0) & r_tx_data_3(7 DOWNTO 0) & r_tx_data_2(7 DOWNTO 3) & '1' & '1' & r_tx_data_2(2 DOWNTO 0) & r_tx_data_1(7 DOWNTO 0) & '0' ;
3627
   extended_chain_data_std <= r_tx_data_10 & r_tx_data_9 & r_tx_data_8 & r_tx_data_7 & r_tx_data_6 & r_tx_data_5 & r_tx_data_4 & r_tx_data_3 ;
3628
   extended_chain_data_ext <= r_tx_data_12 & r_tx_data_11 & r_tx_data_10 & r_tx_data_9 & r_tx_data_8 & r_tx_data_7 & r_tx_data_6 & r_tx_data_5 ;
3629
 
3630
   PROCESS (extended_mode, rx_data, tx_pointer, extended_chain_data_std, extended_chain_data_ext, rx_crc, r_calculated_crc, r_tx_data_0, extended_chain_ext, extended_chain_std, basic_chain_data, basic_chain, finish_msg)
3631
      VARIABLE tx_bit_xhdl107  : std_logic;
3632
   BEGIN
3633
      IF (extended_mode = '1') THEN
3634
         IF (rx_data = '1') THEN
3635
            -- data stage
3636
 
3637
            IF (r_tx_data_0(0) = '1') THEN
3638
               -- Extended frame
3639
 
3640
               tx_bit_xhdl107 := extended_chain_data_ext(conv_integer(tx_pointer));
3641
            ELSE
3642
               tx_bit_xhdl107 := extended_chain_data_std(conv_integer(tx_pointer));
3643
            END IF;
3644
         ELSE
3645
            IF (rx_crc = '1') THEN
3646
               tx_bit_xhdl107 := r_calculated_crc(conv_integer(tx_pointer(3 downto 0)));
3647
            ELSE
3648
               IF (finish_msg = '1') THEN
3649
                  tx_bit_xhdl107 := '1';
3650
               ELSE
3651
                  IF (r_tx_data_0(0) = '1') THEN
3652
                     -- Extended frame
3653
 
3654
                     tx_bit_xhdl107 := extended_chain_ext(conv_integer(tx_pointer));
3655
                  ELSE
3656
                     tx_bit_xhdl107 := extended_chain_std(conv_integer(tx_pointer));
3657
                  END IF;
3658
               END IF;
3659
            END IF;
3660
         END IF;
3661
      ELSE
3662
         -- Basic mode
3663
 
3664
         IF (rx_data = '1') THEN
3665
            -- data stage
3666
 
3667
            tx_bit_xhdl107 := basic_chain_data(conv_integer(tx_pointer));
3668
         ELSE
3669
            IF (rx_crc = '1') THEN
3670
               tx_bit_xhdl107 := r_calculated_crc(conv_integer(tx_pointer));
3671
            ELSE
3672
               IF (finish_msg = '1') THEN
3673
                  tx_bit_xhdl107 := '1';
3674
               ELSE
3675
                  tx_bit_xhdl107 := basic_chain(conv_integer(tx_pointer));
3676
               END IF;
3677
            END IF;
3678
         END IF;
3679
      END IF;
3680
      tx_bit <= tx_bit_xhdl107;
3681
   END PROCESS;
3682
   temp_xhdl108 <= "111111" WHEN tx_data_0(3) = '1' ELSE ((tx_data_0(2 DOWNTO 0) & "000") - 1);
3683
   limited_tx_cnt_ext <= temp_xhdl108 ;
3684
   temp_xhdl109 <= "111111" WHEN tx_data_1(3) = '1' ELSE ((tx_data_1(2 DOWNTO 0) & "000") - 1);
3685
   limited_tx_cnt_std <= temp_xhdl109 ;
3686
   -- arbitration + control for extended format
3687
   -- arbitration + control for extended format
3688
   -- arbitration + control for standard format
3689
   -- data       (overflow is OK here)
3690
   -- data       (overflow is OK here)
3691
   -- crc
3692
   -- at the end
3693
   rst_tx_pointer <= ((((((NOT bit_de_stuff_tx) AND tx_point) AND (NOT rx_data)) AND extended_mode) AND r_tx_data_0(0)) AND CONV_STD_LOGIC(tx_pointer = "100110")) OR ((((((NOT bit_de_stuff_tx) AND tx_point) AND (NOT rx_data)) AND extended_mode) AND (NOT r_tx_data_0(0))) AND CONV_STD_LOGIC(tx_pointer = "010010")) OR (((((NOT bit_de_stuff_tx) AND tx_point) AND (NOT rx_data)) AND (NOT extended_mode)) AND CONV_STD_LOGIC(tx_pointer = "010010")) OR (((((NOT bit_de_stuff_tx) AND tx_point) AND rx_data) AND extended_mode) AND CONV_STD_LOGIC(tx_pointer = limited_tx_cnt_ext)) OR (((((NOT bit_de_stuff_tx) AND tx_point) AND rx_data) AND (NOT extended_mode)) AND CONV_STD_LOGIC(tx_pointer = limited_tx_cnt_std)) OR (tx_point AND rx_crc_lim) OR (go_rx_idle) OR (reset_mode) OR (overload_frame_xhdl4) OR (error_frame) ;
3694
 
3695
   PROCESS (clk, rst)
3696
   BEGIN
3697
      IF (rst = '1') THEN
3698
         tx_pointer <= "000000";
3699
      ELSIF (clk'EVENT AND clk = '1') THEN
3700
         IF (rst_tx_pointer = '1') THEN
3701
            tx_pointer <= "000000" ;
3702
         ELSE
3703
            IF ((go_early_tx OR ((tx_point AND (tx_state_xhdl2 OR go_tx_xhdl34)) AND (NOT bit_de_stuff_tx))) = '1') THEN
3704
               tx_pointer <= tx_pointer + "000001" ;
3705
            END IF;
3706
         END IF;
3707
      END IF;
3708
   END PROCESS;
3709
   tx_successful_xhdl19 <= ((((transmitter_xhdl8 AND go_rx_inter_xhdl9) AND (NOT go_error_frame_xhdl33)) AND (NOT error_frame_ended)) AND (NOT overload_frame_ended)) AND (NOT arbitration_lost) ;
3710
 
3711
   PROCESS (clk, rst)
3712
   BEGIN
3713
      IF (rst = '1') THEN
3714
         need_to_tx_xhdl20 <= '0';
3715
      ELSIF (clk'EVENT AND clk = '1') THEN
3716
         IF ((tx_successful_xhdl19 OR reset_mode OR (abort_tx AND (NOT transmitting_xhdl7)) OR (((NOT tx_state_xhdl2) AND tx_state_q_xhdl3) AND single_shot_transmission)) = '1') THEN
3717
            need_to_tx_xhdl20 <= '0' ;
3718
         ELSE
3719
            IF ((tx_request AND sample_point) = '1') THEN
3720
               need_to_tx_xhdl20 <= '1' ;
3721
            END IF;
3722
         END IF;
3723
      END IF;
3724
   END PROCESS;
3725
   go_early_tx <= ((((((NOT listen_only_mode) AND need_to_tx_xhdl20) AND (NOT tx_state_xhdl2)) AND (NOT suspend OR CONV_STD_LOGIC(susp_cnt = "111"))) AND sample_point) AND (NOT sampled_bit)) AND (rx_idle_xhdl6 OR last_bit_of_inter) ;
3726
   go_tx_xhdl34 <= ((((NOT listen_only_mode) AND need_to_tx_xhdl20) AND (NOT tx_state_xhdl2)) AND (NOT suspend OR (sample_point AND CONV_STD_LOGIC(susp_cnt = "111")))) AND (go_early_tx OR rx_idle_xhdl6) ;
3727
 
3728
   -- go_early_tx latched (for proper bit_de_stuff generation)
3729
 
3730
   PROCESS (clk, rst)
3731
   BEGIN
3732
      IF (rst = '1') THEN
3733
         go_early_tx_latched <= '0';
3734
      ELSIF (clk'EVENT AND clk = '1') THEN
3735
         IF ((reset_mode OR tx_point) = '1') THEN
3736
            go_early_tx_latched <= '0' ;
3737
         ELSE
3738
            IF (go_early_tx = '1') THEN
3739
               go_early_tx_latched <= '1' ;
3740
            END IF;
3741
         END IF;
3742
      END IF;
3743
   END PROCESS;
3744
 
3745
   -- Tx state
3746
 
3747
   PROCESS (clk, rst)
3748
   BEGIN
3749
      IF (rst = '1') THEN
3750
         tx_state_xhdl2 <= '0';
3751
      ELSIF (clk'EVENT AND clk = '1') THEN
3752
         IF ((reset_mode OR go_rx_inter_xhdl9 OR error_frame OR arbitration_lost) = '1') THEN
3753
            tx_state_xhdl2 <= '0' ;
3754
         ELSE
3755
            IF (go_tx_xhdl34 = '1') THEN
3756
               tx_state_xhdl2 <= '1' ;
3757
            END IF;
3758
         END IF;
3759
      END IF;
3760
   END PROCESS;
3761
 
3762
   PROCESS (clk, rst)
3763
   BEGIN
3764
      IF (rst = '1') THEN
3765
         tx_state_q_xhdl3 <= '0' ;
3766
      ELSIF (clk'EVENT AND clk = '1') THEN
3767
         IF (reset_mode = '1') THEN
3768
            tx_state_q_xhdl3 <= '0' ;
3769
         ELSE
3770
            tx_state_q_xhdl3 <= tx_state_xhdl2 ;
3771
         END IF;
3772
      END IF;
3773
   END PROCESS;
3774
 
3775
   -- Node is a transmitter
3776
 
3777
   PROCESS (clk, rst)
3778
   BEGIN
3779
      IF (rst = '1') THEN
3780
         transmitter_xhdl8 <= '0';
3781
      ELSIF (clk'EVENT AND clk = '1') THEN
3782
         IF (go_tx_xhdl34 = '1') THEN
3783
            transmitter_xhdl8 <= '1' ;
3784
         ELSE
3785
            IF ((reset_mode OR go_rx_idle OR (suspend AND go_rx_id1)) = '1') THEN
3786
               transmitter_xhdl8 <= '0' ;
3787
            END IF;
3788
         END IF;
3789
      END IF;
3790
   END PROCESS;
3791
 
3792
   -- Signal "transmitting" signals that the core is a transmitting (message, error frame or overload frame). No synchronization is done meanwhile.
3793
   -- Node might be both transmitter or receiver (sending error or overload frame)
3794
 
3795
   PROCESS (clk, rst)
3796
   BEGIN
3797
      IF (rst = '1') THEN
3798
         transmitting_xhdl7 <= '0';
3799
      ELSIF (clk'EVENT AND clk = '1') THEN
3800
         IF ((go_error_frame_xhdl33 OR go_overload_frame_xhdl32 OR go_tx_xhdl34 OR send_ack_xhdl35) = '1') THEN
3801
            transmitting_xhdl7 <= '1' ;
3802
         ELSE
3803
            IF ((reset_mode OR go_rx_idle OR (go_rx_id1 AND (NOT tx_state_xhdl2)) OR (arbitration_lost AND tx_state_xhdl2)) = '1') THEN
3804
               transmitting_xhdl7 <= '0' ;
3805
            END IF;
3806
         END IF;
3807
      END IF;
3808
   END PROCESS;
3809
 
3810
   PROCESS (clk, rst)
3811
   BEGIN
3812
      IF (rst = '1') THEN
3813
         suspend <= '0';
3814
      ELSIF (clk'EVENT AND clk = '1') THEN
3815
         IF ((reset_mode OR (sample_point AND CONV_STD_LOGIC(susp_cnt = "111"))) = '1') THEN
3816
            suspend <= '0' ;
3817
         ELSE
3818
            IF (((not_first_bit_of_inter_xhdl10 AND transmitter_xhdl8) AND node_error_passive_xhdl26) = '1') THEN
3819
               suspend <= '1' ;
3820
            END IF;
3821
         END IF;
3822
      END IF;
3823
   END PROCESS;
3824
 
3825
   PROCESS (clk, rst)
3826
   BEGIN
3827
      IF (rst = '1') THEN
3828
         susp_cnt_en <= '0';
3829
      ELSIF (clk'EVENT AND clk = '1') THEN
3830
         IF ((reset_mode OR (sample_point AND CONV_STD_LOGIC(susp_cnt = "111"))) = '1') THEN
3831
            susp_cnt_en <= '0' ;
3832
         ELSE
3833
            IF (((suspend AND sample_point) AND last_bit_of_inter) = '1') THEN
3834
               susp_cnt_en <= '1' ;
3835
            END IF;
3836
         END IF;
3837
      END IF;
3838
   END PROCESS;
3839
 
3840
   PROCESS (clk, rst)
3841
   BEGIN
3842
      IF (rst = '1') THEN
3843
         susp_cnt <= "000";
3844
      ELSIF (clk'EVENT AND clk = '1') THEN
3845
         IF ((reset_mode OR (sample_point AND CONV_STD_LOGIC(susp_cnt = "111"))) = '1') THEN
3846
            susp_cnt <= "000" ;
3847
         ELSE
3848
            IF ((susp_cnt_en AND sample_point) = '1') THEN
3849
               susp_cnt <= susp_cnt + "001" ;
3850
            END IF;
3851
         END IF;
3852
      END IF;
3853
   END PROCESS;
3854
 
3855
   PROCESS (clk, rst)
3856
   BEGIN
3857
      IF (rst = '1') THEN
3858
         finish_msg <= '0';
3859
      ELSIF (clk'EVENT AND clk = '1') THEN
3860
         IF ((go_rx_idle OR go_rx_id1 OR error_frame OR reset_mode) = '1') THEN
3861
            finish_msg <= '0' ;
3862
         ELSE
3863
            IF (go_rx_crc_lim = '1') THEN
3864
               finish_msg <= '1' ;
3865
            END IF;
3866
         END IF;
3867
      END IF;
3868
   END PROCESS;
3869
 
3870
   PROCESS (clk, rst)
3871
   BEGIN
3872
      IF (rst = '1') THEN
3873
         arbitration_lost <= '0';
3874
      ELSIF (clk'EVENT AND clk = '1') THEN
3875
         IF ((go_rx_idle OR error_frame_ended OR reset_mode) = '1') THEN
3876
            arbitration_lost <= '0' ;
3877
         ELSE
3878
            IF (((((transmitter_xhdl8 AND sample_point) AND tx_xhdl29) AND arbitration_field) AND NOT sampled_bit) = '1') THEN
3879
               arbitration_lost <= '1' ;
3880
            END IF;
3881
         END IF;
3882
      END IF;
3883
   END PROCESS;
3884
 
3885
   PROCESS (clk, rst)
3886
   BEGIN
3887
      IF (rst = '1') THEN
3888
         arbitration_lost_q <= '0' ;
3889
         read_arbitration_lost_capture_reg_q <= '0';
3890
      ELSIF (clk'EVENT AND clk = '1') THEN
3891
         IF (reset_mode = '1') THEN
3892
            arbitration_lost_q <= '0';
3893
            read_arbitration_lost_capture_reg_q <= '0';
3894
         ELSE
3895
            arbitration_lost_q <= arbitration_lost;
3896
            read_arbitration_lost_capture_reg_q <= read_arbitration_lost_capture_reg ;
3897
         END IF;
3898
      END IF;
3899
   END PROCESS;
3900
   set_arbitration_lost_irq_xhdl24 <= (arbitration_lost AND (NOT arbitration_lost_q)) AND (NOT arbitration_blocked) ;
3901
 
3902
   PROCESS (clk, rst)
3903
   BEGIN
3904
     IF (rst = '1') THEN
3905
       read_error_code_capture_reg_q <= '0';
3906
     ELSIF (clk'EVENT AND clk = '1') THEN
3907
       read_error_code_capture_reg_q <= read_error_code_capture_reg;
3908
     END IF;
3909
   END PROCESS;
3910
 
3911
   reset_error_code_capture_reg <= read_error_code_capture_reg_q and not read_error_code_capture_reg;
3912
 
3913
   PROCESS (clk, rst)
3914
   BEGIN
3915
      IF (rst = '1') THEN
3916
         arbitration_cnt_en <= '0';
3917
      ELSIF (clk'EVENT AND clk = '1') THEN
3918
         IF ((reset_mode OR arbitration_blocked) = '1') THEN
3919
            arbitration_cnt_en <= '0' ;
3920
         ELSE
3921
            IF (((rx_id1 AND sample_point) AND (NOT arbitration_blocked)) = '1') THEN
3922
               arbitration_cnt_en <= '1' ;
3923
            END IF;
3924
         END IF;
3925
      END IF;
3926
   END PROCESS;
3927
 
3928
   PROCESS (clk, rst)
3929
   BEGIN
3930
      IF (rst = '1') THEN
3931
         arbitration_blocked <= '0';
3932
      ELSIF (clk'EVENT AND clk = '1') THEN
3933
         IF ((reset_mode OR read_arbitration_lost_capture_reg) = '1') THEN
3934
            arbitration_blocked <= '0' ;
3935
         ELSE
3936
            IF (set_arbitration_lost_irq_xhdl24 = '1') THEN
3937
               arbitration_blocked <= '1' ;
3938
            END IF;
3939
         END IF;
3940
      END IF;
3941
   END PROCESS;
3942
 
3943
   PROCESS (clk, rst)
3944
   BEGIN
3945
      IF (rst = '1') THEN
3946
         arbitration_lost_capture_xhdl25 <= "00000";
3947
      ELSIF (clk'EVENT AND clk = '1') THEN
3948
         IF (read_arbitration_lost_capture_reg_q = '1') THEN
3949
            arbitration_lost_capture_xhdl25 <= "00000" ;
3950
         ELSE
3951
            IF ((((sample_point AND (NOT arbitration_blocked)) AND arbitration_cnt_en) AND (NOT bit_de_stuff)) = '1') THEN
3952
               arbitration_lost_capture_xhdl25 <= arbitration_lost_capture_xhdl25 + "00001" ;
3953
            END IF;
3954
         END IF;
3955
      END IF;
3956
   END PROCESS;
3957
 
3958
   PROCESS (clk, rst)
3959
   BEGIN
3960
      IF (rst = '1') THEN
3961
         rx_err_cnt_xhdl15 <= "000000000";
3962
      ELSIF (clk'EVENT AND clk = '1') THEN
3963
         IF ((we_rx_err_cnt AND (NOT node_bus_off_xhdl13)) = '1') THEN
3964
            rx_err_cnt_xhdl15 <= '0' & data_in ;
3965
         ELSE
3966
            IF (set_reset_mode_xhdl12 = '1') THEN
3967
               rx_err_cnt_xhdl15 <= "000000000" ;
3968
            ELSE
3969
               IF (((NOT listen_only_mode) AND (NOT transmitter_xhdl8 OR arbitration_lost)) = '1') THEN
3970
                  IF ((((go_rx_ack_lim AND (NOT go_error_frame_xhdl33)) AND (NOT crc_err)) AND CONV_STD_LOGIC(rx_err_cnt_xhdl15 > "000000000")) = '1') THEN
3971
                     IF (rx_err_cnt_xhdl15 > "001111111") THEN
3972
                        rx_err_cnt_xhdl15 <= "001111111" ;
3973
                     ELSE
3974
                        rx_err_cnt_xhdl15 <= rx_err_cnt_xhdl15 - "000000001" ;
3975
                     END IF;
3976
                  ELSE
3977
                     IF (rx_err_cnt_xhdl15 < "010000000") THEN
3978
                        IF ((go_error_frame_xhdl33 AND (NOT rule5)) = '1') THEN
3979
                           -- 1  (rule 5 is just the opposite then rule 1 exception
3980
 
3981
                           rx_err_cnt_xhdl15 <= rx_err_cnt_xhdl15 + "000000001" ;
3982
                        ELSE
3983
                           IF ((((((error_flag_over AND (NOT error_flag_over_latched)) AND sample_point) AND (NOT sampled_bit)) AND CONV_STD_LOGIC(error_cnt1 = "111")) OR (go_error_frame_xhdl33 AND rule5) OR ((sample_point AND (NOT sampled_bit)) AND CONV_STD_LOGIC(delayed_dominant_cnt = "111"))) = '1') THEN
3984
                              -- 2
3985
                              -- 5
3986
                              -- 6
3987
 
3988
                              rx_err_cnt_xhdl15 <= rx_err_cnt_xhdl15 + "000001000" ;
3989
                           END IF;
3990
                        END IF;
3991
                     END IF;
3992
                  END IF;
3993
               END IF;
3994
            END IF;
3995
         END IF;
3996
      END IF;
3997
   END PROCESS;
3998
 
3999
   PROCESS (clk, rst)
4000
   BEGIN
4001
      IF (rst = '1') THEN
4002
         tx_err_cnt_xhdl16 <= "000000000";
4003
      ELSIF (clk'EVENT AND clk = '1') THEN
4004
         IF (we_tx_err_cnt = '1') THEN
4005
            tx_err_cnt_xhdl16 <= '0' & data_in ;
4006
         ELSE
4007
            IF (set_reset_mode_xhdl12 = '1') THEN
4008
               tx_err_cnt_xhdl16 <= "010000000" ;
4009
            ELSE
4010
               IF ((CONV_STD_LOGIC(tx_err_cnt_xhdl16 > "000000000") AND (tx_successful_xhdl19 OR bus_free)) = '1') THEN
4011
                  tx_err_cnt_xhdl16 <= tx_err_cnt_xhdl16 - "000000001" ;
4012
               ELSE
4013
                  IF ((transmitter_xhdl8 AND (NOT arbitration_lost)) = '1') THEN
4014
                     IF ((((sample_point AND (NOT sampled_bit)) AND CONV_STD_LOGIC(delayed_dominant_cnt = "111")) OR (go_error_frame_xhdl33 AND rule5) OR ((go_error_frame_xhdl33 AND (NOT ((transmitter_xhdl8 AND node_error_passive_xhdl26) AND ack_err))) AND (NOT (((((transmitter_xhdl8 AND stuff_err) AND arbitration_field) AND sample_point) AND tx_xhdl29) AND (NOT sampled_bit)))) OR (error_frame AND rule3_exc1_2)) = '1') THEN
4015
                        -- 6
4016
                        -- 4  (rule 5 is the same as rule 4)
4017
                        -- 3 
4018
                        -- 3
4019
 
4020
                        tx_err_cnt_xhdl16 <= tx_err_cnt_xhdl16 + "000001000" ;
4021
                     END IF;
4022
                  END IF;
4023
               END IF;
4024
            END IF;
4025
         END IF;
4026
      END IF;
4027
   END PROCESS;
4028
 
4029
   PROCESS (clk, rst)
4030
   BEGIN
4031
      IF (rst = '1') THEN
4032
         node_error_passive_xhdl26 <= '0';
4033
      ELSIF (clk'EVENT AND clk = '1') THEN
4034
         IF ((rx_err_cnt_xhdl15 < "010000000") AND (tx_err_cnt_xhdl16 < "010000000")) THEN
4035
            node_error_passive_xhdl26 <= '0' ;
4036
         ELSE
4037
            IF (((CONV_STD_LOGIC((rx_err_cnt_xhdl15 >= "010000000") OR (tx_err_cnt_xhdl16 >= "010000000")) AND (error_frame_ended OR go_error_frame_xhdl33 OR ((NOT reset_mode) AND reset_mode_q))) AND (NOT node_bus_off_xhdl13)) = '1') THEN
4038
               node_error_passive_xhdl26 <= '1' ;
4039
            END IF;
4040
         END IF;
4041
      END IF;
4042
   END PROCESS;
4043
   node_error_active_xhdl27 <= NOT (node_error_passive_xhdl26 OR node_bus_off_xhdl13) ;
4044
 
4045
   PROCESS (clk, rst)
4046
   BEGIN
4047
      IF (rst = '1') THEN
4048
         node_bus_off_xhdl13 <= '0';
4049
      ELSIF (clk'EVENT AND clk = '1') THEN
4050
         IF (((CONV_STD_LOGIC((rx_err_cnt_xhdl15 = "000000000") AND (tx_err_cnt_xhdl16 = "000000000")) AND (NOT reset_mode)) OR (we_tx_err_cnt AND CONV_STD_LOGIC(data_in < "11111111"))) = '1') THEN
4051
            node_bus_off_xhdl13 <= '0' ;
4052
         ELSE
4053
            IF ((CONV_STD_LOGIC(tx_err_cnt_xhdl16 >= "100000000") OR (we_tx_err_cnt AND CONV_STD_LOGIC(data_in = "11111111"))) = '1') THEN
4054
               node_bus_off_xhdl13 <= '1' ;
4055
            END IF;
4056
         END IF;
4057
      END IF;
4058
   END PROCESS;
4059
 
4060
   PROCESS (clk, rst)
4061
   BEGIN
4062
      IF (rst = '1') THEN
4063
         bus_free_cnt <= "0000";
4064
      ELSIF (clk'EVENT AND clk = '1') THEN
4065
         IF (reset_mode = '1') THEN
4066
            bus_free_cnt <= "0000" ;
4067
         ELSE
4068
            IF (sample_point = '1') THEN
4069
               IF (((sampled_bit AND bus_free_cnt_en) AND CONV_STD_LOGIC(bus_free_cnt < "1010")) = '1') THEN
4070
                  bus_free_cnt <= bus_free_cnt + "0001" ;
4071
               ELSE
4072
                  bus_free_cnt <= "0000" ;
4073
               END IF;
4074
            END IF;
4075
         END IF;
4076
      END IF;
4077
   END PROCESS;
4078
 
4079
   PROCESS (clk, rst)
4080
   BEGIN
4081
      IF (rst = '1') THEN
4082
         bus_free_cnt_en <= '0';
4083
      ELSIF (clk'EVENT AND clk = '1') THEN
4084
         IF ((((NOT reset_mode) AND reset_mode_q) OR (node_bus_off_q AND (NOT reset_mode))) = '1') THEN
4085
            bus_free_cnt_en <= '1' ;
4086
         ELSE
4087
            IF ((((sample_point AND sampled_bit) AND CONV_STD_LOGIC(bus_free_cnt = "1010")) AND (NOT node_bus_off_xhdl13)) = '1') THEN
4088
               bus_free_cnt_en <= '0' ;
4089
            END IF;
4090
         END IF;
4091
      END IF;
4092
   END PROCESS;
4093
 
4094
   PROCESS (clk, rst)
4095
   BEGIN
4096
      IF (rst = '1') THEN
4097
         bus_free <= '0';
4098
      ELSIF (clk'EVENT AND clk = '1') THEN
4099
         IF (reset_mode = '1') THEN
4100
            bus_free <= '0';
4101
         ELSE
4102
            IF (((sample_point AND sampled_bit) AND CONV_STD_LOGIC(bus_free_cnt = "1010")) = '1') THEN
4103
               bus_free <= '1' ;
4104
            ELSE
4105
               bus_free <= '0' ;
4106
            END IF;
4107
         END IF;
4108
      END IF;
4109
   END PROCESS;
4110
 
4111
   PROCESS (clk, rst)
4112
   BEGIN
4113
      IF (rst = '1') THEN
4114
         waiting_for_bus_free <= '1';
4115
      ELSIF (clk'EVENT AND clk = '1') THEN
4116
         IF (reset_mode = '1') THEN
4117
            waiting_for_bus_free <= '1';
4118
         ELSE
4119
            IF ((bus_free AND (NOT node_bus_off_xhdl13)) = '1') THEN
4120
               waiting_for_bus_free <= '0' ;
4121
            ELSE
4122
               IF ((((NOT reset_mode) AND reset_mode_q) OR (node_bus_off_q AND (NOT reset_mode))) = '1') THEN
4123
                  waiting_for_bus_free <= '1' ;
4124
               END IF;
4125
            END IF;
4126
         END IF;
4127
      END IF;
4128
   END PROCESS;
4129
   bus_off_on_xhdl31 <= NOT node_bus_off_xhdl13 ;
4130
   set_reset_mode_xhdl12 <= node_bus_off_xhdl13 AND (NOT node_bus_off_q) ;
4131
   temp_xhdl110 <= ((rx_err_cnt_xhdl15 >= ('0' & error_warning_limit)) OR (tx_err_cnt_xhdl16 >= ('0' & error_warning_limit))) WHEN extended_mode = '1' ELSE ((rx_err_cnt_xhdl15 >= "001100000") OR (tx_err_cnt_xhdl16 >= "001100000"));
4132
   error_status_xhdl14 <= CONV_STD_LOGIC(temp_xhdl110) ;
4133
   transmit_status_xhdl17 <= transmitting_xhdl7 OR (extended_mode AND waiting_for_bus_free) ;
4134
   temp_xhdl111 <= (waiting_for_bus_free OR ((NOT rx_idle_xhdl6) AND (NOT transmitting_xhdl7))) WHEN extended_mode = '1' ELSE (((NOT waiting_for_bus_free) AND (NOT rx_idle_xhdl6)) AND (NOT transmitting_xhdl7));
4135
   receive_status_xhdl18 <= temp_xhdl111 ;
4136
 
4137
   -- Error code capture register 
4138
   PROCESS (clk, rst)
4139
   BEGIN
4140
      IF (rst = '1') THEN
4141
         error_capture_code_xhdl5 <= "00000000";
4142
      ELSIF (clk'EVENT AND clk = '1') THEN
4143
         IF (reset_error_code_capture_reg = '1') THEN
4144
            error_capture_code_xhdl5 <= "00000000" ;
4145
         ELSE
4146
            IF (set_bus_error_irq_xhdl23 = '1') THEN
4147
               error_capture_code_xhdl5 <= error_capture_code_type(7 DOWNTO 6) & error_capture_code_direction & error_capture_code_segment(4 DOWNTO 0) ;
4148
            END IF;
4149
         END IF;
4150
      END IF;
4151
   END PROCESS;
4152
   error_capture_code_segment(0) <= rx_idle_xhdl6 OR rx_ide OR (rx_id2 AND CONV_STD_LOGIC(bit_cnt < "001101")) OR rx_r1 OR rx_r0 OR rx_dlc OR rx_ack OR rx_ack_lim OR (error_frame AND node_error_active_xhdl27) ;
4153
   error_capture_code_segment(1) <= rx_idle_xhdl6 OR rx_id1 OR rx_id2 OR rx_dlc OR rx_data OR rx_ack_lim OR rx_eof OR rx_inter_xhdl11 OR (error_frame AND node_error_passive_xhdl26) ;
4154
   error_capture_code_segment(2) <= (rx_id1 AND CONV_STD_LOGIC(bit_cnt > "000111")) OR rx_rtr1 OR rx_ide OR rx_id2 OR rx_rtr2 OR rx_r1 OR (error_frame AND node_error_passive_xhdl26) OR overload_frame_xhdl4 ;
4155
   error_capture_code_segment(3) <= (rx_id2 AND CONV_STD_LOGIC(bit_cnt > "000100")) OR rx_rtr2 OR rx_r1 OR rx_r0 OR rx_dlc OR rx_data OR rx_crc OR rx_crc_lim OR rx_ack OR rx_ack_lim OR rx_eof OR overload_frame_xhdl4 ;
4156
   error_capture_code_segment(4) <= rx_crc_lim OR rx_ack OR rx_ack_lim OR rx_eof OR rx_inter_xhdl11 OR error_frame OR overload_frame_xhdl4 ;
4157
   error_capture_code_direction <= NOT transmitting_xhdl7 ;
4158
 
4159
   PROCESS (bit_err, form_err, stuff_err)
4160
      VARIABLE error_capture_code_type_xhdl112  : std_logic_vector(7 DOWNTO 6);
4161
   BEGIN
4162
      IF (bit_err = '1') THEN
4163
         error_capture_code_type_xhdl112(7 DOWNTO 6) := "00";
4164
      ELSE
4165
         IF (form_err = '1') THEN
4166
            error_capture_code_type_xhdl112(7 DOWNTO 6) := "01";
4167
         ELSE
4168
            IF (stuff_err = '1') THEN
4169
               error_capture_code_type_xhdl112(7 DOWNTO 6) := "10";
4170
            ELSE
4171
               error_capture_code_type_xhdl112(7 DOWNTO 6) := "11";
4172
            END IF;
4173
         END IF;
4174
      END IF;
4175
      error_capture_code_type <= error_capture_code_type_xhdl112;
4176
   END PROCESS;
4177
   set_bus_error_irq_xhdl23 <= go_error_frame_xhdl33 AND (NOT error_capture_code_blocked) ;
4178
 
4179
   PROCESS (clk, rst)
4180
   BEGIN
4181
      IF (rst = '1') THEN
4182
         error_capture_code_blocked <= '0';
4183
      ELSIF (clk'EVENT AND clk = '1') THEN
4184
         IF (read_error_code_capture_reg = '1') THEN
4185
            error_capture_code_blocked <= '0' ;
4186
         ELSE
4187
            IF (set_bus_error_irq_xhdl23 = '1') THEN
4188
               error_capture_code_blocked <= '1' ;
4189
            END IF;
4190
         END IF;
4191
      END IF;
4192
   END PROCESS;
4193
 
4194
END ARCHITECTURE RTL;
4195
----------------------------------------------------------------------------------------------
4196
--
4197
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
4198
-- Tue Aug  9 07:33:51 2005
4199
--
4200
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
4201
--      Design name        : can_register
4202
--      Author             : 
4203
--      Company            : Actel
4204
--
4205
--      Description        : 
4206
--
4207
--
4208
----------------------------------------------------------------------------------------------
4209
--
4210
--////////////////////////////////////////////////////////////////////
4211
--//                                                              ////
4212
--//  can_register.v                                              ////
4213
--//                                                              ////
4214
--//                                                              ////
4215
--//  This file is part of the CAN Protocol Controller            ////
4216
--//  http://www.opencores.org/projects/can/                      ////
4217
--//                                                              ////
4218
--//                                                              ////
4219
--//  Author(s):                                                  ////
4220
--//       Igor Mohor                                             ////
4221
--//       igorm@opencores.org                                    ////
4222
--//                                                              ////
4223
--//                                                              ////
4224
--//  All additional information is available in the README.txt   ////
4225
--//  file.                                                       ////
4226
--//                                                              ////
4227
--////////////////////////////////////////////////////////////////////
4228
--//                                                              ////
4229
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
4230
--//                                                              ////
4231
--// This source file may be used and distributed without         ////
4232
--// restriction provided that this copyright statement is not    ////
4233
--// removed from the file and that any derivative work contains  ////
4234
--// the original copyright notice and the associated disclaimer. ////
4235
--//                                                              ////
4236
--// This source file is free software; you can redistribute it   ////
4237
--// and/or modify it under the terms of the GNU Lesser General   ////
4238
--// Public License as published by the Free Software Foundation; ////
4239
--// either version 2.1 of the License, or (at your option) any   ////
4240
--// later version.                                               ////
4241
--//                                                              ////
4242
--// This source is distributed in the hope that it will be       ////
4243
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
4244
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
4245
--// PURPOSE.  See the GNU Lesser General Public License for more ////
4246
--// details.                                                     ////
4247
--//                                                              ////
4248
--// You should have received a copy of the GNU Lesser General    ////
4249
--// Public License along with this source; if not, download it   ////
4250
--// from http://www.opencores.org/lgpl.shtml                     ////
4251
--//                                                              ////
4252
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
4253
--// protected by patents. Anybody who wants to implement this    ////
4254
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
4255
--// from Bosch.                                                  ////
4256
--//                                                              ////
4257
--////////////////////////////////////////////////////////////////////
4258
--
4259
-- CVS Revision History
4260
--
4261
-- $Log: can_register.v,v $
4262
-- Revision 1.7  2004/02/08 14:32:31  mohor
4263
-- Header changed.
4264
--
4265
-- Revision 1.6  2003/03/20 16:58:50  mohor
4266
-- unix.
4267
--
4268
-- Revision 1.4  2003/03/11 16:32:34  mohor
4269
-- timescale.v is used for simulation only.
4270
--
4271
-- Revision 1.3  2003/02/09 02:24:33  mohor
4272
-- Bosch license warning added. Error counters finished. Overload frames
4273
-- still need to be fixed.
4274
--
4275
-- Revision 1.2  2002/12/27 00:12:52  mohor
4276
-- Header changed, testbench improved to send a frame (crc still missing).
4277
--
4278
-- Revision 1.1.1.1  2002/12/20 16:39:21  mohor
4279
-- Initial
4280
--
4281
--
4282
--
4283
-- synopsys translate_off
4284
--`include "can_defines.v"
4285
-- synopsys translate_on
4286
LIBRARY ieee;
4287
USE ieee.std_logic_1164.all;
4288
 
4289
ENTITY can_register IS
4290
   GENERIC (
4291
      WIDTH                          :  integer := 8);    --  default parameter of the register width
4292
   PORT (
4293
      data_in                 : IN std_logic_vector(WIDTH - 1 DOWNTO 0);
4294
      data_out                : OUT std_logic_vector(WIDTH - 1 DOWNTO 0);
4295
      we                      : IN std_logic;
4296
      clk                     : IN std_logic);
4297
END ENTITY can_register;
4298
 
4299
ARCHITECTURE RTL OF can_register IS
4300
 
4301
   TYPE xhdl_15 IS ARRAY (0 TO 63) OF std_logic_vector(7 DOWNTO 0);
4302
   TYPE xhdl_16 IS ARRAY (0 TO 63) OF std_logic_vector(3 DOWNTO 0);
4303
   TYPE xhdl_17 IS ARRAY (0 TO 63) OF std_logic;
4304
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
4305
 
4306
   SIGNAL data_out_xhdl1           :  std_logic_vector(WIDTH - 1 DOWNTO 0);
4307
 
4308
BEGIN
4309
   data_out <= data_out_xhdl1;
4310
 
4311
   PROCESS (clk)
4312
   BEGIN
4313
      IF (clk'EVENT AND clk = '1') THEN
4314
         IF (we = '1') THEN
4315
            -- write
4316
 
4317
            data_out_xhdl1 <= data_in;
4318
         END IF;
4319
      END IF;
4320
   END PROCESS;
4321
 
4322
END ARCHITECTURE RTL;
4323
----------------------------------------------------------------------------------------------
4324
--
4325
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
4326
-- Tue Aug  9 07:33:51 2005
4327
--
4328
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
4329
--      Design name        : can_register_asyn
4330
--      Author             : 
4331
--      Company            : Actel
4332
--
4333
--      Description        : 
4334
--
4335
--
4336
----------------------------------------------------------------------------------------------
4337
--
4338
--////////////////////////////////////////////////////////////////////
4339
--//                                                              ////
4340
--//  can_register_asyn.v                                         ////
4341
--//                                                              ////
4342
--//                                                              ////
4343
--//  This file is part of the CAN Protocol Controller            ////
4344
--//  http://www.opencores.org/projects/can/                      ////
4345
--//                                                              ////
4346
--//                                                              ////
4347
--//  Author(s):                                                  ////
4348
--//       Igor Mohor                                             ////
4349
--//       igorm@opencores.org                                    ////
4350
--//                                                              ////
4351
--//                                                              ////
4352
--//  All additional information is available in the README.txt   ////
4353
--//  file.                                                       ////
4354
--//                                                              ////
4355
--////////////////////////////////////////////////////////////////////
4356
--//                                                              ////
4357
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
4358
--//                                                              ////
4359
--// This source file may be used and distributed without         ////
4360
--// restriction provided that this copyright statement is not    ////
4361
--// removed from the file and that any derivative work contains  ////
4362
--// the original copyright notice and the associated disclaimer. ////
4363
--//                                                              ////
4364
--// This source file is free software; you can redistribute it   ////
4365
--// and/or modify it under the terms of the GNU Lesser General   ////
4366
--// Public License as published by the Free Software Foundation; ////
4367
--// either version 2.1 of the License, or (at your option) any   ////
4368
--// later version.                                               ////
4369
--//                                                              ////
4370
--// This source is distributed in the hope that it will be       ////
4371
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
4372
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
4373
--// PURPOSE.  See the GNU Lesser General Public License for more ////
4374
--// details.                                                     ////
4375
--//                                                              ////
4376
--// You should have received a copy of the GNU Lesser General    ////
4377
--// Public License along with this source; if not, download it   ////
4378
--// from http://www.opencores.org/lgpl.shtml                     ////
4379
--//                                                              ////
4380
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
4381
--// protected by patents. Anybody who wants to implement this    ////
4382
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
4383
--// from Bosch.                                                  ////
4384
--//                                                              ////
4385
--////////////////////////////////////////////////////////////////////
4386
--
4387
-- CVS Revision History
4388
--
4389
-- $Log: can_register_asyn.v,v $
4390
-- Revision 1.7  2004/02/08 14:33:19  mohor
4391
-- Header changed.
4392
--
4393
-- Revision 1.6  2003/03/20 16:58:50  mohor
4394
-- unix.
4395
--
4396
-- Revision 1.4  2003/03/11 16:32:34  mohor
4397
-- timescale.v is used for simulation only.
4398
--
4399
-- Revision 1.3  2003/02/09 02:24:33  mohor
4400
-- Bosch license warning added. Error counters finished. Overload frames
4401
-- still need to be fixed.
4402
--
4403
-- Revision 1.2  2002/12/27 00:12:52  mohor
4404
-- Header changed, testbench improved to send a frame (crc still missing).
4405
--
4406
-- Revision 1.1.1.1  2002/12/20 16:39:21  mohor
4407
-- Initial
4408
--
4409
--
4410
--
4411
-- synopsys translate_off
4412
--`include "can_defines.v"
4413
-- synopsys translate_on
4414
 
4415
LIBRARY ieee;
4416
USE ieee.std_logic_1164.all;
4417
USE ieee.numeric_std.all;
4418
library grlib;
4419
use grlib.stdlib.all;
4420
 
4421
 
4422
ENTITY can_register_asyn IS
4423
   GENERIC (
4424
      WIDTH                          :  integer := 8;    --  default parameter of the register width
4425
      RESET_VALUE                    :  integer := 0);
4426
   PORT (
4427
      data_in                 : IN std_logic_vector(WIDTH - 1 DOWNTO 0);
4428
      data_out                : OUT std_logic_vector(WIDTH - 1 DOWNTO 0);
4429
      we                      : IN std_logic;
4430
      clk                     : IN std_logic;
4431
      rst                     : IN std_logic);
4432
END ENTITY can_register_asyn;
4433
 
4434
ARCHITECTURE RTL OF can_register_asyn IS
4435
 
4436
   TYPE xhdl_15 IS ARRAY (0 TO 63) OF std_logic_vector(7 DOWNTO 0);
4437
   TYPE xhdl_16 IS ARRAY (0 TO 63) OF std_logic_vector(3 DOWNTO 0);
4438
   TYPE xhdl_17 IS ARRAY (0 TO 63) OF std_logic;
4439
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
4440
 
4441
   SIGNAL data_out_xhdl1           :  std_logic_vector(WIDTH - 1 DOWNTO 0);
4442
 
4443
BEGIN
4444
   data_out <= data_out_xhdl1;
4445
 
4446
   PROCESS (clk, rst)
4447
   BEGIN
4448
      IF (rst = '1') THEN
4449
         -- asynchronous reset
4450
 
4451
         data_out_xhdl1 <= CONV_STD_LOGIC_VECTOR(RESET_VALUE, WIDTH);
4452
      ELSIF (clk'EVENT AND clk = '1') THEN
4453
         IF (we = '1') THEN
4454
            -- write
4455
 
4456
            data_out_xhdl1 <= data_in ;
4457
         END IF;
4458
      END IF;
4459
   END PROCESS;
4460
 
4461
END ARCHITECTURE RTL;
4462
----------------------------------------------------------------------------------------------
4463
--
4464
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
4465
-- Tue Aug  9 07:33:52 2005
4466
--
4467
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
4468
--      Design name        : can_register_asyn_syn
4469
--      Author             : 
4470
--      Company            : Actel
4471
--
4472
--      Description        : 
4473
--
4474
--
4475
----------------------------------------------------------------------------------------------
4476
--
4477
--////////////////////////////////////////////////////////////////////
4478
--//                                                              ////
4479
--//  can_register_asyn_syn.v                                     ////
4480
--//                                                              ////
4481
--//                                                              ////
4482
--//  This file is part of the CAN Protocol Controller            ////
4483
--//  http://www.opencores.org/projects/can/                      ////
4484
--//                                                              ////
4485
--//                                                              ////
4486
--//  Author(s):                                                  ////
4487
--//       Igor Mohor                                             ////
4488
--//       igorm@opencores.org                                    ////
4489
--//                                                              ////
4490
--//                                                              ////
4491
--//  All additional information is available in the README.txt   ////
4492
--//  file.                                                       ////
4493
--//                                                              ////
4494
--////////////////////////////////////////////////////////////////////
4495
--//                                                              ////
4496
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
4497
--//                                                              ////
4498
--// This source file may be used and distributed without         ////
4499
--// restriction provided that this copyright statement is not    ////
4500
--// removed from the file and that any derivative work contains  ////
4501
--// the original copyright notice and the associated disclaimer. ////
4502
--//                                                              ////
4503
--// This source file is free software; you can redistribute it   ////
4504
--// and/or modify it under the terms of the GNU Lesser General   ////
4505
--// Public License as published by the Free Software Foundation; ////
4506
--// either version 2.1 of the License, or (at your option) any   ////
4507
--// later version.                                               ////
4508
--//                                                              ////
4509
--// This source is distributed in the hope that it will be       ////
4510
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
4511
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
4512
--// PURPOSE.  See the GNU Lesser General Public License for more ////
4513
--// details.                                                     ////
4514
--//                                                              ////
4515
--// You should have received a copy of the GNU Lesser General    ////
4516
--// Public License along with this source; if not, download it   ////
4517
--// from http://www.opencores.org/lgpl.shtml                     ////
4518
--//                                                              ////
4519
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
4520
--// protected by patents. Anybody who wants to implement this    ////
4521
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
4522
--// from Bosch.                                                  ////
4523
--//                                                              ////
4524
--////////////////////////////////////////////////////////////////////
4525
--
4526
-- CVS Revision History
4527
--
4528
-- $Log: can_register_asyn_syn.v,v $
4529
-- Revision 1.7  2004/02/08 14:33:59  mohor
4530
-- Header changed.
4531
--
4532
-- Revision 1.6  2003/03/20 16:52:43  mohor
4533
-- unix.
4534
--
4535
-- Revision 1.4  2003/03/11 16:32:34  mohor
4536
-- timescale.v is used for simulation only.
4537
--
4538
-- Revision 1.3  2003/02/09 02:24:33  mohor
4539
-- Bosch license warning added. Error counters finished. Overload frames
4540
-- still need to be fixed.
4541
--
4542
-- Revision 1.2  2002/12/27 00:12:52  mohor
4543
-- Header changed, testbench improved to send a frame (crc still missing).
4544
--
4545
-- Revision 1.1.1.1  2002/12/20 16:39:21  mohor
4546
-- Initial
4547
--
4548
--
4549
--
4550
-- synopsys translate_off
4551
--`include "can_defines.v"
4552
-- synopsys translate_on
4553
 
4554
LIBRARY ieee;
4555
USE ieee.std_logic_1164.all;
4556
library grlib;
4557
use grlib.stdlib.all;
4558
 
4559
ENTITY can_register_asyn_syn IS
4560
   GENERIC (
4561
      WIDTH                          :  integer := 8;    --  default parameter of the register width
4562
      RESET_VALUE                    :  integer := 0);
4563
   PORT (
4564
      data_in                 : IN std_logic_vector(WIDTH - 1 DOWNTO 0);
4565
      data_out                : OUT std_logic_vector(WIDTH - 1 DOWNTO 0);
4566
      we                      : IN std_logic;
4567
      clk                     : IN std_logic;
4568
      rst                     : IN std_logic;
4569
      rst_sync                : IN std_logic);
4570
END ENTITY can_register_asyn_syn;
4571
 
4572
ARCHITECTURE RTL OF can_register_asyn_syn IS
4573
 
4574
   TYPE xhdl_15 IS ARRAY (0 TO 63) OF std_logic_vector(7 DOWNTO 0);
4575
   TYPE xhdl_16 IS ARRAY (0 TO 63) OF std_logic_vector(3 DOWNTO 0);
4576
   TYPE xhdl_17 IS ARRAY (0 TO 63) OF std_logic;
4577
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
4578
 
4579
   SIGNAL data_out_xhdl1           :  std_logic_vector(WIDTH - 1 DOWNTO 0);
4580
 
4581
BEGIN
4582
   data_out <= data_out_xhdl1;
4583
 
4584
   PROCESS (clk, rst)
4585
   BEGIN
4586
      IF (rst = '1') THEN
4587
         data_out_xhdl1 <= CONV_STD_LOGIC_VECTOR(RESET_VALUE, WIDTH);
4588
      ELSIF (clk'EVENT AND clk = '1') THEN
4589
         IF (rst_sync = '1') THEN
4590
            -- synchronous reset
4591
 
4592
            data_out_xhdl1 <= CONV_STD_LOGIC_VECTOR(RESET_VALUE, WIDTH);
4593
         ELSE
4594
            IF (we = '1') THEN
4595
               -- write
4596
 
4597
               data_out_xhdl1 <= data_in ;
4598
            END IF;
4599
         END IF;
4600
      END IF;
4601
   END PROCESS;
4602
 
4603
END ARCHITECTURE RTL;
4604
----------------------------------------------------------------------------------------------
4605
--
4606
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
4607
-- Tue Aug  9 07:33:52 2005
4608
--
4609
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
4610
--      Design name        : can_register_syn
4611
--      Author             : 
4612
--      Company            : Actel
4613
--
4614
--      Description        : 
4615
--
4616
--
4617
----------------------------------------------------------------------------------------------
4618
--
4619
--////////////////////////////////////////////////////////////////////
4620
--//                                                              ////
4621
--//  can_register_syn.v                                          ////
4622
--//                                                              ////
4623
--//                                                              ////
4624
--//  This file is part of the CAN Protocol Controller            ////
4625
--//  http://www.opencores.org/projects/can/                      ////
4626
--//                                                              ////
4627
--//                                                              ////
4628
--//  Author(s):                                                  ////
4629
--//       Igor Mohor                                             ////
4630
--//       igorm@opencores.org                                    ////
4631
--//                                                              ////
4632
--//                                                              ////
4633
--//  All additional information is available in the README.txt   ////
4634
--//  file.                                                       ////
4635
--//                                                              ////
4636
--////////////////////////////////////////////////////////////////////
4637
--//                                                              ////
4638
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
4639
--//                                                              ////
4640
--// This source file may be used and distributed without         ////
4641
--// restriction provided that this copyright statement is not    ////
4642
--// removed from the file and that any derivative work contains  ////
4643
--// the original copyright notice and the associated disclaimer. ////
4644
--//                                                              ////
4645
--// This source file is free software; you can redistribute it   ////
4646
--// and/or modify it under the terms of the GNU Lesser General   ////
4647
--// Public License as published by the Free Software Foundation; ////
4648
--// either version 2.1 of the License, or (at your option) any   ////
4649
--// later version.                                               ////
4650
--//                                                              ////
4651
--// This source is distributed in the hope that it will be       ////
4652
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
4653
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
4654
--// PURPOSE.  See the GNU Lesser General Public License for more ////
4655
--// details.                                                     ////
4656
--//                                                              ////
4657
--// You should have received a copy of the GNU Lesser General    ////
4658
--// Public License along with this source; if not, download it   ////
4659
--// from http://www.opencores.org/lgpl.shtml                     ////
4660
--//                                                              ////
4661
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
4662
--// protected by patents. Anybody who wants to implement this    ////
4663
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
4664
--// from Bosch.                                                  ////
4665
--//                                                              ////
4666
--////////////////////////////////////////////////////////////////////
4667
--
4668
-- CVS Revision History
4669
--
4670
-- $Log: can_register_syn.v,v $
4671
-- Revision 1.5  2004/02/08 14:34:40  mohor
4672
-- Header changed.
4673
--
4674
-- Revision 1.4  2003/03/11 16:31:58  mohor
4675
-- timescale.v is used for simulation only.
4676
--
4677
-- Revision 1.3  2003/02/09 02:24:33  mohor
4678
-- Bosch license warning added. Error counters finished. Overload frames
4679
-- still need to be fixed.
4680
--
4681
-- Revision 1.2  2002/12/27 00:12:52  mohor
4682
-- Header changed, testbench improved to send a frame (crc still missing).
4683
--
4684
-- Revision 1.1.1.1  2002/12/20 16:39:21  mohor
4685
-- Initial
4686
--
4687
--
4688
--
4689
-- synopsys translate_off
4690
--`include "can_defines.v"
4691
-- synopsys translate_on
4692
 
4693
LIBRARY ieee;
4694
USE ieee.std_logic_1164.all;
4695
library grlib;
4696
use grlib.stdlib.all;
4697
 
4698
ENTITY can_register_syn IS
4699
   GENERIC (
4700
      WIDTH                          :  integer := 8;    --  default parameter of the register width
4701
      RESET_VALUE                    :  integer := 0);
4702
   PORT (
4703
      data_in                 : IN std_logic_vector(WIDTH - 1 DOWNTO 0);
4704
      data_out                : OUT std_logic_vector(WIDTH - 1 DOWNTO 0);
4705
      we                      : IN std_logic;
4706
      clk                     : IN std_logic;
4707
      rst_sync                : IN std_logic);
4708
END ENTITY can_register_syn;
4709
 
4710
ARCHITECTURE RTL OF can_register_syn IS
4711
 
4712
   TYPE xhdl_15 IS ARRAY (0 TO 63) OF std_logic_vector(7 DOWNTO 0);
4713
   TYPE xhdl_16 IS ARRAY (0 TO 63) OF std_logic_vector(3 DOWNTO 0);
4714
   TYPE xhdl_17 IS ARRAY (0 TO 63) OF std_logic;
4715
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
4716
 
4717
   SIGNAL data_out_xhdl1           :  std_logic_vector(WIDTH - 1 DOWNTO 0);
4718
 
4719
BEGIN
4720
   data_out <= data_out_xhdl1;
4721
 
4722
   PROCESS (clk)
4723
   BEGIN
4724
      IF (clk'EVENT AND clk = '1') THEN
4725
         IF (rst_sync = '1') THEN
4726
            -- synchronous reset
4727
 
4728
            data_out_xhdl1 <= CONV_STD_LOGIC_VECTOR(RESET_VALUE, 8);
4729
         ELSE
4730
            IF (we = '1') THEN
4731
               -- write
4732
 
4733
               data_out_xhdl1 <= data_in ;
4734
            END IF;
4735
         END IF;
4736
      END IF;
4737
   END PROCESS;
4738
 
4739
END ARCHITECTURE RTL;
4740
----------------------------------------------------------------------------------------------
4741
--
4742
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
4743
-- Tue Aug  9 07:33:52 2005
4744
--
4745
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
4746
--      Design name        : can_registers
4747
--      Author             : 
4748
--      Company            : Actel
4749
--
4750
--      Description        : 
4751
--
4752
--
4753
----------------------------------------------------------------------------------------------
4754
--
4755
--////////////////////////////////////////////////////////////////////
4756
--//                                                              ////
4757
--//  can_registers.v                                             ////
4758
--//                                                              ////
4759
--//                                                              ////
4760
--//  This file is part of the CAN Protocol Controller            ////
4761
--//  http://www.opencores.org/projects/can/                      ////
4762
--//                                                              ////
4763
--//                                                              ////
4764
--//  Author(s):                                                  ////
4765
--//       Igor Mohor                                             ////
4766
--//       igorm@opencores.org                                    ////
4767
--//                                                              ////
4768
--//                                                              ////
4769
--//  All additional information is available in the README.txt   ////
4770
--//  file.                                                       ////
4771
--//                                                              ////
4772
--////////////////////////////////////////////////////////////////////
4773
--//                                                              ////
4774
--// Copyright (C) 2002, 2003 Authors                             ////
4775
--//                                                              ////
4776
--// This source file may be used and distributed without         ////
4777
--// restriction provided that this copyright statement is not    ////
4778
--// removed from the file and that any derivative work contains  ////
4779
--// the original copyright notice and the associated disclaimer. ////
4780
--//                                                              ////
4781
--// This source file is free software; you can redistribute it   ////
4782
--// and/or modify it under the terms of the GNU Lesser General   ////
4783
--// Public License as published by the Free Software Foundation; ////
4784
--// either version 2.1 of the License, or (at your option) any   ////
4785
--// later version.                                               ////
4786
--//                                                              ////
4787
--// This source is distributed in the hope that it will be       ////
4788
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
4789
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
4790
--// PURPOSE.  See the GNU Lesser General Public License for more ////
4791
--// details.                                                     ////
4792
--//                                                              ////
4793
--// You should have received a copy of the GNU Lesser General    ////
4794
--// Public License along with this source; if not, download it   ////
4795
--// from http://www.opencores.org/lgpl.shtml                     ////
4796
--//                                                              ////
4797
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
4798
--// protected by patents. Anybody who wants to implement this    ////
4799
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
4800
--// from Bosch.                                                  ////
4801
--//                                                              ////
4802
--////////////////////////////////////////////////////////////////////
4803
--
4804
-- CVS Revision History
4805
 
4806
-- Revision 1.36  2005/03/18 15:04:05  igorm
4807
-- Wake-up interrupt was generated in some cases.
4808
--
4809
-- Revision 1.35  2004/11/30 15:08:26  igorm
4810
-- irq is cleared after the release_buffer command. This bug was entered with
4811
-- changes for the edge triggered interrupts.
4812
--
4813
-- Revision 1.34  2004/11/18 12:39:43  igorm
4814
-- Fixes for compatibility after the SW reset.
4815
--
4816
-- Revision 1.33  2004/10/25 11:44:38  igorm
4817
-- Interrupt is always cleared for one clock after the irq register is read.
4818
-- This fixes problems when CPU is using IRQs that are edge triggered.
4819
--
4820
-- Revision 1.32  2004/05/12 15:58:41  igorm
4821
-- Core improved to pass all tests with the Bosch VHDL Reference system.
4822
--
4823
-- Revision 1.31  2003/09/25 18:55:49  mohor
4824
-- Synchronization changed, error counters fixed.
4825
--
4826
-- Revision 1.30  2003/07/16 15:19:34  mohor
4827
-- Fixed according to the linter.
4828
-- Case statement for data_out joined.
4829
--
4830
-- Revision 1.29  2003/07/10 01:59:04  tadejm
4831
-- Synchronization fixed. In some strange cases it didn't work according to
4832
-- the VHDL reference model.
4833
--
4834
-- Revision 1.28  2003/07/07 11:21:37  mohor
4835
-- Little fixes (to fix warnings).
4836
--
4837
-- Revision 1.27  2003/06/22 09:43:03  mohor
4838
-- synthesi full_case parallel_case fixed.
4839
--
4840
-- Revision 1.26  2003/06/22 01:33:14  mohor
4841
-- clkout is clk/2 after the reset.
4842
--
4843
-- Revision 1.25  2003/06/21 12:16:30  mohor
4844
-- paralel_case and full_case compiler directives added to case statements.
4845
--
4846
-- Revision 1.24  2003/06/09 11:22:54  mohor
4847
-- data_out is already registered in the can_top.v file.
4848
--
4849
-- Revision 1.23  2003/04/15 15:31:24  mohor
4850
-- Some features are supported in extended mode only (listen_only_mode...).
4851
--
4852
-- Revision 1.22  2003/03/20 16:58:50  mohor
4853
-- unix.
4854
--
4855
-- Revision 1.20  2003/03/11 16:31:05  mohor
4856
-- Mux used for clkout to avoid "gated clocks warning".
4857
--
4858
-- Revision 1.19  2003/03/10 17:34:25  mohor
4859
-- Doubled declarations removed.
4860
--
4861
-- Revision 1.18  2003/03/01 22:52:11  mohor
4862
-- Data is latched on read.
4863
--
4864
-- Revision 1.17  2003/02/19 15:09:02  mohor
4865
-- Incomplete sensitivity list fixed.
4866
--
4867
-- Revision 1.16  2003/02/19 14:44:03  mohor
4868
-- CAN core finished. Host interface added. Registers finished.
4869
-- Synchronization to the wishbone finished.
4870
--
4871
-- Revision 1.15  2003/02/18 00:10:15  mohor
4872
-- Most of the registers added. Registers "arbitration lost capture", "error code
4873
-- capture" + few more still need to be added.
4874
--
4875
-- Revision 1.14  2003/02/14 20:17:01  mohor
4876
-- Several registers added. Not finished, yet.
4877
--
4878
-- Revision 1.13  2003/02/12 14:25:30  mohor
4879
-- abort_tx added.
4880
--
4881
-- Revision 1.12  2003/02/11 00:56:06  mohor
4882
-- Wishbone interface added.
4883
--
4884
-- Revision 1.11  2003/02/09 02:24:33  mohor
4885
-- Bosch license warning added. Error counters finished. Overload frames
4886
-- still need to be fixed.
4887
--
4888
-- Revision 1.10  2003/01/31 01:13:38  mohor
4889
-- backup.
4890
--
4891
-- Revision 1.9  2003/01/15 13:16:48  mohor
4892
-- When a frame with "remote request" is received, no data is stored
4893
-- to fifo, just the frame information (identifier, ...). Data length
4894
-- that is stored is the received data length and not the actual data
4895
-- length that is stored to fifo.
4896
--
4897
-- Revision 1.8  2003/01/14 17:25:09  mohor
4898
-- Addresses corrected to decimal values (previously hex).
4899
--
4900
-- Revision 1.7  2003/01/14 12:19:35  mohor
4901
-- rx_fifo is now working.
4902
--
4903
-- Revision 1.6  2003/01/10 17:51:34  mohor
4904
-- Temporary version (backup).
4905
--
4906
-- Revision 1.5  2003/01/09 14:46:58  mohor
4907
-- Temporary files (backup).
4908
--
4909
-- Revision 1.4  2003/01/08 02:10:55  mohor
4910
-- Acceptance filter added.
4911
--
4912
-- Revision 1.3  2002/12/27 00:12:52  mohor
4913
-- Header changed, testbench improved to send a frame (crc still missing).
4914
--
4915
-- Revision 1.2  2002/12/26 16:00:34  mohor
4916
-- Testbench define file added. Clock divider register added.
4917
--
4918
-- Revision 1.1.1.1  2002/12/20 16:39:21  mohor
4919
-- Initial
4920
--
4921
--
4922
--
4923
-- synopsys translate_off
4924
--`include "can_defines.v"
4925
-- synopsys translate_on
4926
 
4927
LIBRARY ieee;
4928
USE ieee.std_logic_1164.all;
4929
USE ieee.numeric_std.all;
4930
library grlib;
4931
use grlib.stdlib.all;
4932
 
4933
ENTITY can_registers IS
4934
   PORT (
4935
      clk                     : IN std_logic;
4936
      rst                     : IN std_logic;
4937
      cs                      : IN std_logic;
4938
      we                      : IN std_logic;
4939
      addr                    : IN std_logic_vector(7 DOWNTO 0);
4940
      data_in                 : IN std_logic_vector(7 DOWNTO 0);
4941
      data_out                : OUT std_logic_vector(7 DOWNTO 0);
4942
      irq_n                   : OUT std_logic;
4943
      sample_point            : IN std_logic;
4944
      transmitting            : IN std_logic;
4945
      set_reset_mode          : IN std_logic;
4946
      node_bus_off            : IN std_logic;
4947
      error_status            : IN std_logic;
4948
      rx_err_cnt              : IN std_logic_vector(7 DOWNTO 0);
4949
      tx_err_cnt              : IN std_logic_vector(7 DOWNTO 0);
4950
      transmit_status         : IN std_logic;
4951
      receive_status          : IN std_logic;
4952
      tx_successful           : IN std_logic;
4953
      need_to_tx              : IN std_logic;
4954
      overrun                 : IN std_logic;
4955
      info_empty              : IN std_logic;
4956
      set_bus_error_irq       : IN std_logic;
4957
      set_arbitration_lost_irq: IN std_logic;
4958
      arbitration_lost_capture: IN std_logic_vector(4 DOWNTO 0);
4959
      node_error_passive      : IN std_logic;
4960
      node_error_active       : IN std_logic;
4961
      rx_message_counter      : IN std_logic_vector(6 DOWNTO 0);
4962
      -- Mode register 
4963
      reset_mode              : OUT std_logic;
4964
      listen_only_mode        : OUT std_logic;
4965
      acceptance_filter_mode  : OUT std_logic;
4966
      self_test_mode          : OUT std_logic;
4967
      -- Command register 
4968
      clear_data_overrun      : OUT std_logic;
4969
      release_buffer          : OUT std_logic;
4970
      abort_tx                : OUT std_logic;
4971
      tx_request              : OUT std_logic;
4972
      self_rx_request         : OUT std_logic;
4973
      single_shot_transmission: OUT std_logic;
4974
      tx_state                : IN std_logic;
4975
      tx_state_q              : IN std_logic;
4976
      overload_request        : OUT std_logic;
4977
      overload_frame          : IN std_logic;
4978
      -- Arbitration Lost Capture Register 
4979
      read_arbitration_lost_capture_reg: OUT std_logic;
4980
      -- Error Code Capture Register 
4981
      read_error_code_capture_reg: OUT std_logic;
4982
      error_capture_code      : IN std_logic_vector(7 DOWNTO 0);
4983
      -- Bus Timing 0 register 
4984
      baud_r_presc            : OUT std_logic_vector(5 DOWNTO 0);
4985
      sync_jump_width         : OUT std_logic_vector(1 DOWNTO 0);
4986
      -- Bus Timing 1 register 
4987
      time_segment1           : OUT std_logic_vector(3 DOWNTO 0);
4988
      time_segment2           : OUT std_logic_vector(2 DOWNTO 0);
4989
      triple_sampling         : OUT std_logic;
4990
      -- Error Warning Limit register 
4991
      error_warning_limit     : OUT std_logic_vector(7 DOWNTO 0);
4992
      -- Rx Error Counter register 
4993
      we_rx_err_cnt           : OUT std_logic;
4994
      -- Tx Error Counter register 
4995
      we_tx_err_cnt           : OUT std_logic;
4996
      -- Clock Divider register 
4997
      extended_mode           : OUT std_logic;
4998
      clkout                  : OUT std_logic;
4999
      -- This section is for BASIC and EXTENDED mode -- Acceptance code register 
5000
      acceptance_code_0       : OUT std_logic_vector(7 DOWNTO 0);
5001
      -- Acceptance mask register 
5002
      acceptance_mask_0       : OUT std_logic_vector(7 DOWNTO 0);
5003
      -- End: This section is for BASIC and EXTENDED mode -- This section is for EXTENDED mode -- Acceptance code register 
5004
      acceptance_code_1       : OUT std_logic_vector(7 DOWNTO 0);
5005
      acceptance_code_2       : OUT std_logic_vector(7 DOWNTO 0);
5006
      acceptance_code_3       : OUT std_logic_vector(7 DOWNTO 0);
5007
      -- Acceptance mask register 
5008
      acceptance_mask_1       : OUT std_logic_vector(7 DOWNTO 0);
5009
      acceptance_mask_2       : OUT std_logic_vector(7 DOWNTO 0);
5010
      acceptance_mask_3       : OUT std_logic_vector(7 DOWNTO 0);
5011
      -- End: This section is for EXTENDED mode -- Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data 
5012
      tx_data_0               : OUT std_logic_vector(7 DOWNTO 0);
5013
      tx_data_1               : OUT std_logic_vector(7 DOWNTO 0);
5014
      tx_data_2               : OUT std_logic_vector(7 DOWNTO 0);
5015
      tx_data_3               : OUT std_logic_vector(7 DOWNTO 0);
5016
      tx_data_4               : OUT std_logic_vector(7 DOWNTO 0);
5017
      tx_data_5               : OUT std_logic_vector(7 DOWNTO 0);
5018
      tx_data_6               : OUT std_logic_vector(7 DOWNTO 0);
5019
      tx_data_7               : OUT std_logic_vector(7 DOWNTO 0);
5020
      tx_data_8               : OUT std_logic_vector(7 DOWNTO 0);
5021
      tx_data_9               : OUT std_logic_vector(7 DOWNTO 0);
5022
      tx_data_10              : OUT std_logic_vector(7 DOWNTO 0);
5023
      tx_data_11              : OUT std_logic_vector(7 DOWNTO 0);
5024
      tx_data_12              : OUT std_logic_vector(7 DOWNTO 0));
5025
END ENTITY can_registers;
5026
 
5027
ARCHITECTURE RTL OF can_registers IS
5028
 
5029
   CONSTANT xhdl_timescale         : time := 1 ns;
5030
 
5031
   COMPONENT can_register
5032
      GENERIC (
5033
          WIDTH                          :  integer := 8);    --  default parameter of the register width
5034
      PORT (
5035
         data_in                 : IN  std_logic_vector(WIDTH - 1 DOWNTO 0);
5036
         data_out                : OUT std_logic_vector(WIDTH - 1 DOWNTO 0);
5037
         we                      : IN  std_logic;
5038
         clk                     : IN  std_logic);
5039
   END COMPONENT;
5040
 
5041
   COMPONENT can_register_asyn
5042
      GENERIC (
5043
          WIDTH                          :  integer := 8;    --  default parameter of the register width
5044
          RESET_VALUE                    :  integer := 0);
5045
      PORT (
5046
         data_in                 : IN  std_logic_vector(WIDTH - 1 DOWNTO 0);
5047
         data_out                : OUT std_logic_vector(WIDTH - 1 DOWNTO 0);
5048
         we                      : IN  std_logic;
5049
         clk                     : IN  std_logic;
5050
         rst                     : IN  std_logic);
5051
   END COMPONENT;
5052
 
5053
   COMPONENT can_register_asyn_syn
5054
      GENERIC (
5055
          WIDTH                          :  integer := 8;    --  default parameter of the register width
5056
          RESET_VALUE                    :  integer := 0);
5057
      PORT (
5058
         data_in                 : IN  std_logic_vector(WIDTH - 1 DOWNTO 0);
5059
         data_out                : OUT std_logic_vector(WIDTH - 1 DOWNTO 0);
5060
         we                      : IN  std_logic;
5061
         clk                     : IN  std_logic;
5062
         rst                     : IN  std_logic;
5063
         rst_sync                : IN  std_logic);
5064
   END COMPONENT;
5065
 
5066
   TYPE xhdl_15 IS ARRAY (0 TO 63) OF std_logic_vector(7 DOWNTO 0);
5067
   TYPE xhdl_16 IS ARRAY (0 TO 63) OF std_logic_vector(3 DOWNTO 0);
5068
   TYPE xhdl_17 IS ARRAY (0 TO 63) OF std_logic;
5069
   TYPE xhdl_46 IS ARRAY (0 TO 7) OF std_logic_vector(7 DOWNTO 0);
5070
 
5071
   -- End: Tx data registers
5072
   signal read_irq_reg_q           :  std_logic;
5073
   signal reset_irq_reg            :  std_logic;
5074
   SIGNAL tx_successful_q          :  std_logic;
5075
   SIGNAL overrun_q                :  std_logic;
5076
   SIGNAL overrun_status           :  std_logic;
5077
   SIGNAL transmission_complete    :  std_logic;
5078
   SIGNAL transmit_buffer_status_q :  std_logic;
5079
   SIGNAL receive_buffer_status    :  std_logic;
5080
   SIGNAL error_status_q           :  std_logic;
5081
   SIGNAL node_bus_off_q           :  std_logic;
5082
   SIGNAL node_error_passive_q     :  std_logic;
5083
   SIGNAL transmit_buffer_status   :  std_logic;
5084
   -- Some interrupts exist in basic mode and in extended mode. Since they are in different registers they need to be multiplexed.
5085
   SIGNAL data_overrun_irq_en      :  std_logic;
5086
   SIGNAL error_warning_irq_en     :  std_logic;
5087
   SIGNAL transmit_irq_en          :  std_logic;
5088
   SIGNAL receive_irq_en           :  std_logic;
5089
   SIGNAL irq_reg                  :  std_logic_vector(7 DOWNTO 0);
5090
   SIGNAL irq                      :  std_logic;
5091
   SIGNAL we_mode                  :  std_logic;
5092
   SIGNAL we_command               :  std_logic;
5093
   SIGNAL we_bus_timing_0          :  std_logic;
5094
   SIGNAL we_bus_timing_1          :  std_logic;
5095
   SIGNAL we_clock_divider_low     :  std_logic;
5096
   SIGNAL we_clock_divider_hi      :  std_logic;
5097
   SIGNAL read                     :  std_logic;
5098
   SIGNAL read_irq_reg             :  std_logic;
5099
   -- This section is for BASIC and EXTENDED mode 
5100
   SIGNAL we_acceptance_code_0     :  std_logic;
5101
   SIGNAL we_acceptance_mask_0     :  std_logic;
5102
   SIGNAL we_tx_data_0             :  std_logic;
5103
   SIGNAL we_tx_data_1             :  std_logic;
5104
   SIGNAL we_tx_data_2             :  std_logic;
5105
   SIGNAL we_tx_data_3             :  std_logic;
5106
   SIGNAL we_tx_data_4             :  std_logic;
5107
   SIGNAL we_tx_data_5             :  std_logic;
5108
   SIGNAL we_tx_data_6             :  std_logic;
5109
   SIGNAL we_tx_data_7             :  std_logic;
5110
   SIGNAL we_tx_data_8             :  std_logic;
5111
   SIGNAL we_tx_data_9             :  std_logic;
5112
   SIGNAL we_tx_data_10            :  std_logic;
5113
   SIGNAL we_tx_data_11            :  std_logic;
5114
   SIGNAL we_tx_data_12            :  std_logic;
5115
   -- End: This section is for BASIC and EXTENDED mode 
5116
   -- This section is for EXTENDED mode 
5117
   SIGNAL we_interrupt_enable      :  std_logic;
5118
   SIGNAL we_error_warning_limit   :  std_logic;
5119
   SIGNAL we_acceptance_code_1     :  std_logic;
5120
   SIGNAL we_acceptance_code_2     :  std_logic;
5121
   SIGNAL we_acceptance_code_3     :  std_logic;
5122
   SIGNAL we_acceptance_mask_1     :  std_logic;
5123
   SIGNAL we_acceptance_mask_2     :  std_logic;
5124
   SIGNAL we_acceptance_mask_3     :  std_logic;
5125
   -- Mode register 
5126
   SIGNAL mode                     :  std_logic;
5127
   SIGNAL mode_basic               :  std_logic_vector(4 DOWNTO 1);
5128
   SIGNAL mode_ext                 :  std_logic_vector(3 DOWNTO 1);
5129
   SIGNAL receive_irq_en_basic     :  std_logic;
5130
   SIGNAL transmit_irq_en_basic    :  std_logic;
5131
   SIGNAL error_irq_en_basic       :  std_logic;
5132
   SIGNAL overrun_irq_en_basic     :  std_logic;
5133
   SIGNAL port_xhdl52              :  std_logic;
5134
   SIGNAL xhdl_61                  :  std_logic;
5135
   -- End Mode register 
5136
   -- Command register 
5137
   SIGNAL command                  :  std_logic_vector(4 DOWNTO 0);
5138
   SIGNAL xhdl_69                  :  std_logic;
5139
   SIGNAL port_xhdl70              :  std_logic;
5140
   SIGNAL port_xhdl71              :  std_logic;
5141
   SIGNAL xhdl_77                  :  std_logic;
5142
   SIGNAL port_xhdl78              :  std_logic;
5143
   SIGNAL port_xhdl79              :  std_logic;
5144
   SIGNAL xhdl_85                  :  std_logic;
5145
   SIGNAL xhdl_91                  :  std_logic;
5146
   SIGNAL port_xhdl92              :  std_logic;
5147
   SIGNAL port_xhdl93              :  std_logic;
5148
   -- End Command register 
5149
   -- Status register 
5150
   SIGNAL status                   :  std_logic_vector(7 DOWNTO 0);
5151
   -- End Status register 
5152
   -- Interrupt Enable register (extended mode) 
5153
   SIGNAL irq_en_ext               :  std_logic_vector(7 DOWNTO 0);
5154
   SIGNAL bus_error_irq_en         :  std_logic;
5155
   SIGNAL arbitration_lost_irq_en  :  std_logic;
5156
   SIGNAL error_passive_irq_en     :  std_logic;
5157
   SIGNAL data_overrun_irq_en_ext  :  std_logic;
5158
   SIGNAL error_warning_irq_en_ext :  std_logic;
5159
   SIGNAL transmit_irq_en_ext      :  std_logic;
5160
   SIGNAL receive_irq_en_ext       :  std_logic;
5161
   -- End Bus Timing 0 register 
5162
   -- Bus Timing 0 register 
5163
   SIGNAL bus_timing_0             :  std_logic_vector(7 DOWNTO 0);
5164
   -- End Bus Timing 0 register 
5165
   -- Bus Timing 1 register 
5166
   SIGNAL bus_timing_1             :  std_logic_vector(7 DOWNTO 0);
5167
   -- End Error Warning Limit register 
5168
   -- Clock Divider register 
5169
   SIGNAL clock_divider            :  std_logic_vector(7 DOWNTO 0);
5170
   SIGNAL clock_off                :  std_logic;
5171
   SIGNAL cd                       :  std_logic_vector(2 DOWNTO 0);
5172
   SIGNAL clkout_div               :  std_logic_vector(2 DOWNTO 0);
5173
   SIGNAL clkout_cnt               :  std_logic_vector(2 DOWNTO 0);
5174
   SIGNAL clkout_tmp               :  std_logic;
5175
   SIGNAL port_xhdl116             :  std_logic;
5176
   SIGNAL port_xhdl117             :  std_logic;
5177
   SIGNAL port_xhdl123             :  std_logic;
5178
   SIGNAL port_xhdl124             :  std_logic;
5179
   SIGNAL temp_xhdl131             :  std_logic;
5180
   SIGNAL temp_xhdl132             :  std_logic;
5181
   SIGNAL temp_xhdl218             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5182
   SIGNAL temp_xhdl219             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5183
   SIGNAL temp_xhdl220             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5184
   SIGNAL temp_xhdl221             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5185
   SIGNAL temp_xhdl222             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5186
   SIGNAL temp_xhdl223             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5187
   SIGNAL temp_xhdl224             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5188
   SIGNAL temp_xhdl225             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5189
   SIGNAL temp_xhdl226             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5190
   SIGNAL temp_xhdl227             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5191
   SIGNAL temp_xhdl228             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5192
   SIGNAL temp_xhdl229             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5193
   SIGNAL temp_xhdl230             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5194
   SIGNAL temp_xhdl231             :  std_logic_vector(7 DOWNTO 0);   --  basic mode
5195
   -- Some interrupts exist in basic mode and in extended mode. Since they are in different registers they need to be multiplexed.
5196
   SIGNAL temp_xhdl233             :  std_logic;
5197
   SIGNAL temp_xhdl234             :  std_logic;
5198
   SIGNAL temp_xhdl235             :  std_logic;
5199
   SIGNAL temp_xhdl236             :  std_logic;
5200
   SIGNAL data_overrun_irq         :  std_logic;
5201
   SIGNAL transmit_irq             :  std_logic;
5202
   SIGNAL receive_irq              :  std_logic;
5203
   SIGNAL error_irq                :  std_logic;
5204
   SIGNAL bus_error_irq            :  std_logic;
5205
   SIGNAL arbitration_lost_irq     :  std_logic;
5206
   SIGNAL error_passive_irq        :  std_logic;
5207
   SIGNAL data_out_xhdl1           :  std_logic_vector(7 DOWNTO 0);
5208
   SIGNAL irq_n_xhdl2              :  std_logic;
5209
   SIGNAL reset_mode_xhdl3         :  std_logic;
5210
   SIGNAL listen_only_mode_xhdl4   :  std_logic;
5211
   SIGNAL acceptance_filter_mode_xhdl5    :  std_logic;
5212
   SIGNAL self_test_mode_xhdl6     :  std_logic;
5213
   SIGNAL clear_data_overrun_xhdl7 :  std_logic;
5214
   SIGNAL release_buffer_xhdl8     :  std_logic;
5215
   SIGNAL abort_tx_xhdl9           :  std_logic;
5216
   SIGNAL tx_request_xhdl10        :  std_logic;
5217
   SIGNAL self_rx_request_xhdl11   :  std_logic;
5218
   SIGNAL single_shot_transmission_xhdl12 :  std_logic;
5219
   SIGNAL overload_request_xhdl13  :  std_logic;
5220
   SIGNAL read_arbitration_lost_capture_reg_xhdl14:  std_logic;
5221
   SIGNAL read_error_code_capture_reg_xhdl15:  std_logic;
5222
   SIGNAL baud_r_presc_xhdl16      :  std_logic_vector(5 DOWNTO 0);
5223
   SIGNAL sync_jump_width_xhdl17   :  std_logic_vector(1 DOWNTO 0);
5224
   SIGNAL time_segment1_xhdl18     :  std_logic_vector(3 DOWNTO 0);
5225
   SIGNAL time_segment2_xhdl19     :  std_logic_vector(2 DOWNTO 0);
5226
   SIGNAL triple_sampling_xhdl20   :  std_logic;
5227
   SIGNAL error_warning_limit_xhdl21      :  std_logic_vector(7 DOWNTO 0);
5228
   SIGNAL we_rx_err_cnt_xhdl22     :  std_logic;
5229
   SIGNAL we_tx_err_cnt_xhdl23     :  std_logic;
5230
   SIGNAL extended_mode_xhdl24     :  std_logic;
5231
   SIGNAL clkout_xhdl25            :  std_logic;
5232
   SIGNAL acceptance_code_0_xhdl26 :  std_logic_vector(7 DOWNTO 0);
5233
   SIGNAL acceptance_mask_0_xhdl27 :  std_logic_vector(7 DOWNTO 0);
5234
   SIGNAL acceptance_code_1_xhdl28 :  std_logic_vector(7 DOWNTO 0);
5235
   SIGNAL acceptance_code_2_xhdl29 :  std_logic_vector(7 DOWNTO 0);
5236
   SIGNAL acceptance_code_3_xhdl30 :  std_logic_vector(7 DOWNTO 0);
5237
   SIGNAL acceptance_mask_1_xhdl31 :  std_logic_vector(7 DOWNTO 0);
5238
   SIGNAL acceptance_mask_2_xhdl32 :  std_logic_vector(7 DOWNTO 0);
5239
   SIGNAL acceptance_mask_3_xhdl33 :  std_logic_vector(7 DOWNTO 0);
5240
   SIGNAL tx_data_0_xhdl34         :  std_logic_vector(7 DOWNTO 0);
5241
   SIGNAL tx_data_1_xhdl35         :  std_logic_vector(7 DOWNTO 0);
5242
   SIGNAL tx_data_2_xhdl36         :  std_logic_vector(7 DOWNTO 0);
5243
   SIGNAL tx_data_3_xhdl37         :  std_logic_vector(7 DOWNTO 0);
5244
   SIGNAL tx_data_4_xhdl38         :  std_logic_vector(7 DOWNTO 0);
5245
   SIGNAL tx_data_5_xhdl39         :  std_logic_vector(7 DOWNTO 0);
5246
   SIGNAL tx_data_6_xhdl40         :  std_logic_vector(7 DOWNTO 0);
5247
   SIGNAL tx_data_7_xhdl41         :  std_logic_vector(7 DOWNTO 0);
5248
   SIGNAL tx_data_8_xhdl42         :  std_logic_vector(7 DOWNTO 0);
5249
   SIGNAL tx_data_9_xhdl43         :  std_logic_vector(7 DOWNTO 0);
5250
   SIGNAL tx_data_10_xhdl44        :  std_logic_vector(7 DOWNTO 0);
5251
   SIGNAL tx_data_11_xhdl45        :  std_logic_vector(7 DOWNTO 0);
5252
   SIGNAL tx_data_12_xhdl46        :  std_logic_vector(7 DOWNTO 0);
5253
 
5254
BEGIN
5255
   data_out <= data_out_xhdl1;
5256
   irq_n <= irq_n_xhdl2;
5257
   reset_mode <= reset_mode_xhdl3;
5258
   listen_only_mode <= listen_only_mode_xhdl4;
5259
   acceptance_filter_mode <= acceptance_filter_mode_xhdl5;
5260
   self_test_mode <= self_test_mode_xhdl6;
5261
   clear_data_overrun <= clear_data_overrun_xhdl7;
5262
   release_buffer <= release_buffer_xhdl8;
5263
   abort_tx <= abort_tx_xhdl9;
5264
   tx_request <= tx_request_xhdl10;
5265
   self_rx_request <= self_rx_request_xhdl11;
5266
   single_shot_transmission <= single_shot_transmission_xhdl12;
5267
   overload_request <= overload_request_xhdl13;
5268
   read_arbitration_lost_capture_reg <= read_arbitration_lost_capture_reg_xhdl14;
5269
   read_error_code_capture_reg <= read_error_code_capture_reg_xhdl15;
5270
   baud_r_presc <= baud_r_presc_xhdl16;
5271
   sync_jump_width <= sync_jump_width_xhdl17;
5272
   time_segment1 <= time_segment1_xhdl18;
5273
   time_segment2 <= time_segment2_xhdl19;
5274
   triple_sampling <= triple_sampling_xhdl20;
5275
   error_warning_limit <= error_warning_limit_xhdl21;
5276
   we_rx_err_cnt <= we_rx_err_cnt_xhdl22;
5277
   we_tx_err_cnt <= we_tx_err_cnt_xhdl23;
5278
   extended_mode <= extended_mode_xhdl24;
5279
   clkout <= clkout_xhdl25;
5280
   acceptance_code_0 <= acceptance_code_0_xhdl26;
5281
   acceptance_mask_0 <= acceptance_mask_0_xhdl27;
5282
   acceptance_code_1 <= acceptance_code_1_xhdl28;
5283
   acceptance_code_2 <= acceptance_code_2_xhdl29;
5284
   acceptance_code_3 <= acceptance_code_3_xhdl30;
5285
   acceptance_mask_1 <= acceptance_mask_1_xhdl31;
5286
   acceptance_mask_2 <= acceptance_mask_2_xhdl32;
5287
   acceptance_mask_3 <= acceptance_mask_3_xhdl33;
5288
   tx_data_0 <= tx_data_0_xhdl34;
5289
   tx_data_1 <= tx_data_1_xhdl35;
5290
   tx_data_2 <= tx_data_2_xhdl36;
5291
   tx_data_3 <= tx_data_3_xhdl37;
5292
   tx_data_4 <= tx_data_4_xhdl38;
5293
   tx_data_5 <= tx_data_5_xhdl39;
5294
   tx_data_6 <= tx_data_6_xhdl40;
5295
   tx_data_7 <= tx_data_7_xhdl41;
5296
   tx_data_8 <= tx_data_8_xhdl42;
5297
   tx_data_9 <= tx_data_9_xhdl43;
5298
   tx_data_10 <= tx_data_10_xhdl44;
5299
   tx_data_11 <= tx_data_11_xhdl45;
5300
   tx_data_12 <= tx_data_12_xhdl46;
5301
   we_mode <= (cs AND we) AND CONV_STD_LOGIC(addr = "00000000") ;
5302
   we_command <= (cs AND we) AND CONV_STD_LOGIC(addr = "00000001") ;
5303
   we_bus_timing_0 <= ((cs AND we) AND CONV_STD_LOGIC(addr = "00000110")) AND reset_mode_xhdl3 ;
5304
   we_bus_timing_1 <= ((cs AND we) AND CONV_STD_LOGIC(addr = "00000111")) AND reset_mode_xhdl3 ;
5305
   we_clock_divider_low <= (cs AND we) AND CONV_STD_LOGIC(addr = "00011111") ;
5306
   we_clock_divider_hi <= we_clock_divider_low AND reset_mode_xhdl3 ;
5307
   read <= cs AND (NOT we) ;
5308
   read_irq_reg <= read AND CONV_STD_LOGIC(addr = "00000011") ;
5309
 
5310
   reset_irq_reg <= read_irq_reg_q and not read_irq_reg;
5311
 
5312
   read_arbitration_lost_capture_reg_xhdl14 <= (read AND extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00001011") ;
5313
   read_error_code_capture_reg_xhdl15 <= (read AND extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00001100") ;
5314
   we_acceptance_code_0 <= ((cs AND we) AND reset_mode_xhdl3) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00000100")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010000"))) ;
5315
   we_acceptance_mask_0 <= ((cs AND we) AND reset_mode_xhdl3) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00000101")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010100"))) ;
5316
   we_tx_data_0 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00001010")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010000")))) AND transmit_buffer_status ;
5317
   we_tx_data_1 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00001011")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010001")))) AND transmit_buffer_status ;
5318
   we_tx_data_2 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00001100")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010010")))) AND transmit_buffer_status ;
5319
   we_tx_data_3 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00001101")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010011")))) AND transmit_buffer_status ;
5320
   we_tx_data_4 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00001110")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010100")))) AND transmit_buffer_status ;
5321
   we_tx_data_5 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00001111")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010101")))) AND transmit_buffer_status ;
5322
   we_tx_data_6 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00010000")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010110")))) AND transmit_buffer_status ;
5323
   we_tx_data_7 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00010001")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00010111")))) AND transmit_buffer_status ;
5324
   we_tx_data_8 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00010010")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00011000")))) AND transmit_buffer_status ;
5325
   we_tx_data_9 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (((NOT extended_mode_xhdl24) AND CONV_STD_LOGIC(addr = "00010011")) OR (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00011001")))) AND transmit_buffer_status ;
5326
   we_tx_data_10 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00011010"))) AND transmit_buffer_status ;
5327
   we_tx_data_11 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00011011"))) AND transmit_buffer_status ;
5328
   we_tx_data_12 <= (((cs AND we) AND (NOT reset_mode_xhdl3)) AND (extended_mode_xhdl24 AND CONV_STD_LOGIC(addr = "00011100"))) AND transmit_buffer_status ;
5329
   we_interrupt_enable <= ((cs AND we) AND CONV_STD_LOGIC(addr = "00000100")) AND extended_mode_xhdl24 ;
5330
   we_error_warning_limit <= (((cs AND we) AND CONV_STD_LOGIC(addr = "00001101")) AND reset_mode_xhdl3) AND extended_mode_xhdl24 ;
5331
   we_rx_err_cnt_xhdl22 <= (((cs AND we) AND CONV_STD_LOGIC(addr = "00001110")) AND reset_mode_xhdl3) AND extended_mode_xhdl24 ;
5332
   we_tx_err_cnt_xhdl23 <= (((cs AND we) AND CONV_STD_LOGIC(addr = "00001111")) AND reset_mode_xhdl3) AND extended_mode_xhdl24 ;
5333
   we_acceptance_code_1 <= (((cs AND we) AND CONV_STD_LOGIC(addr = "00010001")) AND reset_mode_xhdl3) AND extended_mode_xhdl24 ;
5334
   we_acceptance_code_2 <= (((cs AND we) AND CONV_STD_LOGIC(addr = "00010010")) AND reset_mode_xhdl3) AND extended_mode_xhdl24 ;
5335
   we_acceptance_code_3 <= (((cs AND we) AND CONV_STD_LOGIC(addr = "00010011")) AND reset_mode_xhdl3) AND extended_mode_xhdl24 ;
5336
   we_acceptance_mask_1 <= (((cs AND we) AND CONV_STD_LOGIC(addr = "00010101")) AND reset_mode_xhdl3) AND extended_mode_xhdl24 ;
5337
   we_acceptance_mask_2 <= (((cs AND we) AND CONV_STD_LOGIC(addr = "00010110")) AND reset_mode_xhdl3) AND extended_mode_xhdl24 ;
5338
   we_acceptance_mask_3 <= (((cs AND we) AND CONV_STD_LOGIC(addr = "00010111")) AND reset_mode_xhdl3) AND extended_mode_xhdl24 ;
5339
 
5340
   -- End: This section is for EXTENDED mode 
5341
   PROCESS (clk)
5342
   BEGIN
5343
      IF (clk'EVENT AND clk = '1') THEN
5344
         read_irq_reg_q <= read_irq_reg;
5345
         tx_successful_q <= tx_successful ;
5346
         overrun_q <= overrun ;
5347
         transmit_buffer_status_q <= transmit_buffer_status ;
5348
         error_status_q <= error_status ;
5349
         node_bus_off_q <= node_bus_off ;
5350
         node_error_passive_q <= node_error_passive ;
5351
      END IF;
5352
   END PROCESS;
5353
   port_xhdl52 <= data_in(0);
5354
   MODE_REG0 : can_register_asyn_syn
5355
      GENERIC MAP (1, 1)
5356
         PORT MAP (
5357
            data_in(0) => port_xhdl52,
5358
            data_out(0) => mode,
5359
            we => we_mode,
5360
            clk => clk,
5361
            rst => rst,
5362
            rst_sync => set_reset_mode);
5363
 
5364
      MODE_REG_BASIC : can_register_asyn
5365
         GENERIC MAP (4, 0)
5366
            PORT MAP (
5367
               data_in => data_in(4 DOWNTO 1),
5368
               data_out => mode_basic(4 DOWNTO 1),
5369
               we => we_mode,
5370
               clk => clk,
5371
               rst => rst);
5372
 
5373
         xhdl_61 <= (we_mode AND reset_mode_xhdl3);
5374
         MODE_REG_EXT : can_register_asyn
5375
            GENERIC MAP (3, 0)
5376
               PORT MAP (
5377
                  data_in => data_in(3 DOWNTO 1),
5378
                  data_out => mode_ext(3 DOWNTO 1),
5379
                  we => xhdl_61,
5380
                  clk => clk,
5381
                  rst => rst);
5382
 
5383
            reset_mode_xhdl3 <= mode ;
5384
            listen_only_mode_xhdl4 <= extended_mode_xhdl24 AND mode_ext(1) ;
5385
            self_test_mode_xhdl6 <= extended_mode_xhdl24 AND mode_ext(2) ;
5386
            acceptance_filter_mode_xhdl5 <= extended_mode_xhdl24 AND mode_ext(3) ;
5387
            receive_irq_en_basic <= mode_basic(1) ;
5388
            transmit_irq_en_basic <= mode_basic(2) ;
5389
            error_irq_en_basic <= mode_basic(3) ;
5390
            overrun_irq_en_basic <= mode_basic(4) ;
5391
            xhdl_69 <= (command(0) AND sample_point) OR reset_mode_xhdl3;
5392
            port_xhdl70 <= data_in(0);
5393
            command(0) <= port_xhdl71;
5394
            COMMAND_REG0 : can_register_asyn_syn
5395
               GENERIC MAP (1, 0)
5396
                  PORT MAP (
5397
                     data_in(0) => port_xhdl70,
5398
                     data_out(0) => port_xhdl71,
5399
                     we => we_command,
5400
                     clk => clk,
5401
                     rst => rst,
5402
                     rst_sync => xhdl_69);
5403
 
5404
               xhdl_77 <= (sample_point AND (tx_request_xhdl10 OR (abort_tx_xhdl9 AND NOT transmitting))) OR reset_mode_xhdl3;
5405
               port_xhdl78 <= data_in(1);
5406
               command(1) <= port_xhdl79;
5407
               COMMAND_REG1 : can_register_asyn_syn
5408
                  GENERIC MAP (1, 0)
5409
                     PORT MAP (
5410
                        data_in(0) => port_xhdl78,
5411
                        data_out(0) => port_xhdl79,
5412
                        we => we_command,
5413
                        clk => clk,
5414
                        rst => rst,
5415
                        rst_sync => xhdl_77);
5416
 
5417
                  xhdl_85 <= orv(command(3 DOWNTO 2)) OR reset_mode_xhdl3;
5418
                  COMMAND_REG : can_register_asyn_syn
5419
                     GENERIC MAP (2, 0)
5420
                        PORT MAP (
5421
                           data_in => data_in(3 DOWNTO 2),
5422
                           data_out => command(3 DOWNTO 2),
5423
                           we => we_command,
5424
                           clk => clk,
5425
                           rst => rst,
5426
                           rst_sync => xhdl_85);
5427
 
5428
                     xhdl_91 <= (command(4) AND sample_point) OR reset_mode_xhdl3;
5429
                     port_xhdl92 <= data_in(4);
5430
                     command(4) <= port_xhdl93;
5431
                     COMMAND_REG4 : can_register_asyn_syn
5432
                        GENERIC MAP (1, 0)
5433
                           PORT MAP (
5434
                              data_in(0) => port_xhdl92,
5435
                              data_out(0) => port_xhdl93,
5436
                              we => we_command,
5437
                              clk => clk,
5438
                              rst => rst,
5439
                              rst_sync => xhdl_91);
5440
 
5441
 
5442
                        PROCESS (clk, rst)
5443
                        BEGIN
5444
                           IF (rst = '1') THEN
5445
                              self_rx_request_xhdl11 <= '0';
5446
                           ELSif clk'event and clk = '1' then
5447
                              IF ((command(4) AND (NOT command(0))) = '1') THEN
5448
                                 self_rx_request_xhdl11 <= '1' ;
5449
                              ELSE
5450
                                 IF (((NOT tx_state) AND tx_state_q) = '1') THEN
5451
                                    self_rx_request_xhdl11 <= '0' ;
5452
                                 END IF;
5453
                              END IF;
5454
                           END IF;
5455
                        END PROCESS;
5456
                        clear_data_overrun_xhdl7 <= command(3) ;
5457
                        release_buffer_xhdl8 <= command(2) ;
5458
                        tx_request_xhdl10 <= command(0) OR command(4) ;
5459
                        abort_tx_xhdl9 <= command(1) AND (NOT tx_request_xhdl10) ;
5460
 
5461
                        PROCESS (clk, rst)
5462
                        BEGIN
5463
                           IF (rst = '1') THEN
5464
                              single_shot_transmission_xhdl12 <= '0';
5465
                           ELSif clk'event and clk = '1' then
5466
                              IF (((tx_request_xhdl10 AND command(1)) AND sample_point) = '1') THEN
5467
                                 single_shot_transmission_xhdl12 <= '1' ;
5468
                              ELSE
5469
                                 IF (((NOT tx_state) AND tx_state_q) = '1') THEN
5470
                                    single_shot_transmission_xhdl12 <= '0' ;
5471
                                 END IF;
5472
                              END IF;
5473
                           END IF;
5474
                        END PROCESS;
5475
                        --
5476
                        -- can_register_asyn_syn #(1, 1'h0) COMMAND_REG_OVERLOAD  // Uncomment this to enable overload requests !!!
5477
                        -- ( .data_in(data_in[5]),
5478
                        --   .data_out(overload_request),
5479
                        --   .we(we_command),
5480
                        --   .clk(clk),
5481
                        --   .rst(rst),
5482
                        --   .rst_sync(overload_frame & ~overload_frame_q)
5483
                        -- );
5484
                        -- reg           overload_frame_q;
5485
                        -- always @ (posedge clk or posedge rst)
5486
                        -- begin
5487
                        --   if (rst)
5488
                        --     overload_frame_q <= 1'b0;
5489
                        --   else
5490
                        --     overload_frame_q <=#Tp overload_frame;
5491
                        -- end
5492
                        -- 
5493
                        overload_request_xhdl13 <= '0' ;
5494
                        status(7) <= node_bus_off ;
5495
                        status(6) <= error_status ;
5496
                        status(5) <= transmit_status ;
5497
                        status(4) <= receive_status ;
5498
                        status(3) <= transmission_complete ;
5499
                        status(2) <= transmit_buffer_status ;
5500
                        status(1) <= overrun_status ;
5501
                        status(0) <= receive_buffer_status ;
5502
 
5503
                        PROCESS (clk, rst)
5504
                        BEGIN
5505
                           IF (rst = '1') THEN
5506
                              transmission_complete <= '1';
5507
                           ELSif clk'event and clk = '1' then
5508
                              IF ((tx_successful AND ((NOT tx_successful_q) OR abort_tx_xhdl9)) = '1') THEN
5509
--                              transmission_complete was always set when abort_tx=1
5510
--                              Original code:                                
5511
--                              IF (((tx_successful AND (NOT tx_successful_q)) OR abort_tx_xhdl9) = '1') THEN                                
5512
                                 transmission_complete <= '1' ;
5513
                              ELSE
5514
                                 IF (tx_request_xhdl10 = '1') THEN
5515
                                    transmission_complete <= '0' ;
5516
                                 END IF;
5517
                              END IF;
5518
                           END IF;
5519
                        END PROCESS;
5520
 
5521
                        PROCESS (clk, rst)
5522
                        BEGIN
5523
                           IF (rst = '1') THEN
5524
                              transmit_buffer_status <= '1';
5525
                           ELSif clk'event and clk = '1' then
5526
                              IF (tx_request_xhdl10 = '1') THEN
5527
                                 transmit_buffer_status <= '0' ;
5528
                              ELSE
5529
                                 IF ((reset_mode_xhdl3 OR NOT need_to_tx) = '1') THEN
5530
                                    transmit_buffer_status <= '1' ;
5531
                                 END IF;
5532
                              END IF;
5533
                           END IF;
5534
                        END PROCESS;
5535
 
5536
                        PROCESS (clk, rst)
5537
                        BEGIN
5538
                           IF (rst = '1') THEN
5539
                              overrun_status <= '0';
5540
                           ELSif clk'event and clk = '1' then
5541
                              IF ((overrun AND (NOT overrun_q)) = '1') THEN
5542
                                 overrun_status <= '1' ;
5543
                              ELSE
5544
                                 IF ((reset_mode_xhdl3 OR clear_data_overrun_xhdl7) = '1') THEN
5545
                                    overrun_status <= '0' ;
5546
                                 END IF;
5547
                              END IF;
5548
                           END IF;
5549
                        END PROCESS;
5550
 
5551
                        PROCESS (clk, rst)
5552
                        BEGIN
5553
                           IF (rst = '1') THEN
5554
                              receive_buffer_status <= '0';
5555
                           ELSif clk'event and clk = '1' then
5556
                              IF ((reset_mode_xhdl3 OR release_buffer_xhdl8) = '1') THEN
5557
                                 receive_buffer_status <= '0' ;
5558
                              ELSE
5559
                                 IF (NOT info_empty = '1') THEN
5560
                                    receive_buffer_status <= '1' ;
5561
                                 END IF;
5562
                              END IF;
5563
                           END IF;
5564
                        END PROCESS;
5565
                        IRQ_EN_REG : can_register
5566
                           GENERIC MAP (8)
5567
                              PORT MAP (
5568
                                 data_in => data_in,
5569
                                 data_out => irq_en_ext,
5570
                                 we => we_interrupt_enable,
5571
                                 clk => clk);
5572
 
5573
                           bus_error_irq_en <= irq_en_ext(7) ;
5574
                           arbitration_lost_irq_en <= irq_en_ext(6) ;
5575
                           error_passive_irq_en <= irq_en_ext(5) ;
5576
                           data_overrun_irq_en_ext <= irq_en_ext(3) ;
5577
                           error_warning_irq_en_ext <= irq_en_ext(2) ;
5578
                           transmit_irq_en_ext <= irq_en_ext(1) ;
5579
                           receive_irq_en_ext <= irq_en_ext(0) ;
5580
                           BUS_TIMING_0_REG : can_register
5581
                              GENERIC MAP (8)
5582
                                 PORT MAP (
5583
                                    data_in => data_in,
5584
                                    data_out => bus_timing_0,
5585
                                    we => we_bus_timing_0,
5586
                                    clk => clk);
5587
 
5588
                              baud_r_presc_xhdl16 <= bus_timing_0(5 DOWNTO 0) ;
5589
                              sync_jump_width_xhdl17 <= bus_timing_0(7 DOWNTO 6) ;
5590
                              BUS_TIMING_1_REG : can_register
5591
                                 GENERIC MAP (8)
5592
                                    PORT MAP (
5593
                                       data_in => data_in,
5594
                                       data_out => bus_timing_1,
5595
                                       we => we_bus_timing_1,
5596
                                       clk => clk);
5597
 
5598
                                 time_segment1_xhdl18 <= bus_timing_1(3 DOWNTO 0) ;
5599
                                 time_segment2_xhdl19 <= bus_timing_1(6 DOWNTO 4) ;
5600
                                 triple_sampling_xhdl20 <= bus_timing_1(7) ;
5601
 
5602
                                 -- End Bus Timing 1 register -- Error Warning Limit register 
5603
                                 ERROR_WARNING_REG : can_register_asyn
5604
                                    GENERIC MAP (8, 96)
5605
                                       PORT MAP (
5606
                                          data_in => data_in,
5607
                                          data_out => error_warning_limit_xhdl21,
5608
                                          we => we_error_warning_limit,
5609
                                          clk => clk,
5610
                                          rst => rst);
5611
 
5612
                                    port_xhdl116 <= data_in(7);
5613
                                    clock_divider(7) <= port_xhdl117;
5614
                                    CLOCK_DIVIDER_REG_7 : can_register_asyn
5615
                                       GENERIC MAP (1, 0)
5616
                                          PORT MAP (
5617
                                             data_in(0) => port_xhdl116,
5618
                                             data_out(0) => port_xhdl117,
5619
                                             we => we_clock_divider_hi,
5620
                                             clk => clk,
5621
                                             rst => rst);
5622
 
5623
                                       clock_divider(6 DOWNTO 4) <= "000" ;
5624
                                       port_xhdl123 <= data_in(3);
5625
                                       clock_divider(3) <= port_xhdl124;
5626
                                       CLOCK_DIVIDER_REG_3 : can_register_asyn
5627
                                          GENERIC MAP (1, 0)
5628
                                             PORT MAP (
5629
                                                data_in(0) => port_xhdl123,
5630
                                                data_out(0) => port_xhdl124,
5631
                                                we => we_clock_divider_hi,
5632
                                                clk => clk,
5633
                                                rst => rst);
5634
 
5635
                                          CLOCK_DIVIDER_REG_LOW : can_register_asyn
5636
                                             GENERIC MAP (3, 0)
5637
                                                PORT MAP (
5638
                                                   data_in => data_in(2 DOWNTO 0),
5639
                                                   data_out => clock_divider(2 DOWNTO 0),
5640
                                                   we => we_clock_divider_low,
5641
                                                   clk => clk,
5642
                                                   rst => rst);
5643
 
5644
                                             extended_mode_xhdl24 <= clock_divider(7) ;
5645
                                             clock_off <= clock_divider(3) ;
5646
                                             cd(2 DOWNTO 0) <= clock_divider(2 DOWNTO 0) ;
5647
 
5648
                                             PROCESS (cd)
5649
                                                VARIABLE clkout_div_xhdl130  : std_logic_vector(2 DOWNTO 0);
5650
                                             BEGIN
5651
                                                CASE cd IS
5652
                                                   -- synthesis full_case parallel_case 
5653
                                                   WHEN "000" =>
5654
                                                            clkout_div_xhdl130 := "000";
5655
                                                   WHEN "001" =>
5656
                                                            clkout_div_xhdl130 := "001";
5657
                                                   WHEN "010" =>
5658
                                                            clkout_div_xhdl130 := "010";
5659
                                                   WHEN "011" =>
5660
                                                            clkout_div_xhdl130 := "011";
5661
                                                   WHEN "100" =>
5662
                                                            clkout_div_xhdl130 := "100";
5663
                                                   WHEN "101" =>
5664
                                                            clkout_div_xhdl130 := "101";
5665
                                                   WHEN "110" =>
5666
                                                            clkout_div_xhdl130 := "110";
5667
                                                   WHEN "111" =>
5668
                                                            clkout_div_xhdl130 := "000";
5669
                                                   WHEN OTHERS =>
5670
                                                            NULL;
5671
 
5672
                                                END CASE;
5673
                                                clkout_div <= clkout_div_xhdl130;
5674
                                             END PROCESS;
5675
 
5676
                                             PROCESS (clk, rst)
5677
                                             BEGIN
5678
                                                IF (rst = '1') THEN
5679
                                                   clkout_cnt <= "000";
5680
                                                ELSif clk'event and clk = '1' then
5681
                                                   IF (clkout_cnt = clkout_div) THEN
5682
                                                      clkout_cnt <= "000" ;
5683
                                                   ELSE
5684
                                                      clkout_cnt <= clkout_cnt + "001";
5685
                                                   END IF;
5686
                                                END IF;
5687
                                             END PROCESS;
5688
 
5689
                                             PROCESS (clk, rst)
5690
                                             BEGIN
5691
                                                IF (rst = '1') THEN
5692
                                                   clkout_tmp <= '0';
5693
                                                ELSif clk'event and clk = '1' then
5694
                                                   IF (clkout_cnt = clkout_div) THEN
5695
                                                      clkout_tmp <= NOT clkout_tmp ;
5696
                                                   END IF;
5697
                                                END IF;
5698
                                             END PROCESS;
5699
                                             temp_xhdl131 <= clk WHEN (andv(cd)) = '1' ELSE clkout_tmp;
5700
                                             temp_xhdl132 <= '1' WHEN clock_off = '1' ELSE (temp_xhdl131);
5701
                                             clkout_xhdl25 <= temp_xhdl132 ;
5702
 
5703
                                             -- End Clock Divider register -- This section is for BASIC and EXTENDED mode -- Acceptance code register 
5704
                                             ACCEPTANCE_CODE_REG0 : can_register
5705
                                                GENERIC MAP (8)
5706
                                                   PORT MAP (
5707
                                                      data_in => data_in,
5708
                                                      data_out => acceptance_code_0_xhdl26,
5709
                                                      we => we_acceptance_code_0,
5710
                                                      clk => clk);
5711
 
5712
 
5713
                                                -- End: Acceptance code register -- Acceptance mask register 
5714
                                                ACCEPTANCE_MASK_REG0 : can_register
5715
                                                   GENERIC MAP (8)
5716
                                                      PORT MAP (
5717
                                                         data_in => data_in,
5718
                                                         data_out => acceptance_mask_0_xhdl27,
5719
                                                         we => we_acceptance_mask_0,
5720
                                                         clk => clk);
5721
 
5722
 
5723
                                                   -- End: Acceptance mask register -- End: This section is for BASIC and EXTENDED mode -- Tx data 0 register. 
5724
                                                   TX_DATA_REG0 : can_register
5725
                                                      GENERIC MAP (8)
5726
                                                         PORT MAP (
5727
                                                            data_in => data_in,
5728
                                                            data_out => tx_data_0_xhdl34,
5729
                                                            we => we_tx_data_0,
5730
                                                            clk => clk);
5731
 
5732
 
5733
                                                      -- End: Tx data 0 register. -- Tx data 1 register. 
5734
                                                      TX_DATA_REG1 : can_register
5735
                                                         GENERIC MAP (8)
5736
                                                            PORT MAP (
5737
                                                               data_in => data_in,
5738
                                                               data_out => tx_data_1_xhdl35,
5739
                                                               we => we_tx_data_1,
5740
                                                               clk => clk);
5741
 
5742
 
5743
                                                         -- End: Tx data 1 register. -- Tx data 2 register. 
5744
                                                         TX_DATA_REG2 : can_register
5745
                                                            GENERIC MAP (8)
5746
                                                               PORT MAP (
5747
                                                                  data_in => data_in,
5748
                                                                  data_out => tx_data_2_xhdl36,
5749
                                                                  we => we_tx_data_2,
5750
                                                                  clk => clk);
5751
 
5752
 
5753
                                                            -- End: Tx data 2 register. -- Tx data 3 register. 
5754
                                                            TX_DATA_REG3 : can_register
5755
                                                               GENERIC MAP (8)
5756
                                                                  PORT MAP (
5757
                                                                     data_in => data_in,
5758
                                                                     data_out => tx_data_3_xhdl37,
5759
                                                                     we => we_tx_data_3,
5760
                                                                     clk => clk);
5761
 
5762
 
5763
                                                               -- End: Tx data 3 register. -- Tx data 4 register. 
5764
                                                               TX_DATA_REG4 : can_register
5765
                                                                  GENERIC MAP (8)
5766
                                                                     PORT MAP (
5767
                                                                        data_in => data_in,
5768
                                                                        data_out => tx_data_4_xhdl38,
5769
                                                                        we => we_tx_data_4,
5770
                                                                        clk => clk);
5771
 
5772
 
5773
                                                                  -- End: Tx data 4 register. -- Tx data 5 register. 
5774
                                                                  TX_DATA_REG5 : can_register
5775
                                                                     GENERIC MAP (8)
5776
                                                                        PORT MAP (
5777
                                                                           data_in => data_in,
5778
                                                                           data_out => tx_data_5_xhdl39,
5779
                                                                           we => we_tx_data_5,
5780
                                                                           clk => clk);
5781
 
5782
 
5783
                                                                     -- End: Tx data 5 register. -- Tx data 6 register. 
5784
                                                                     TX_DATA_REG6 : can_register
5785
                                                                        GENERIC MAP (8)
5786
                                                                           PORT MAP (
5787
                                                                              data_in => data_in,
5788
                                                                              data_out => tx_data_6_xhdl40,
5789
                                                                              we => we_tx_data_6,
5790
                                                                              clk => clk);
5791
 
5792
 
5793
                                                                        -- End: Tx data 6 register. -- Tx data 7 register. 
5794
                                                                        TX_DATA_REG7 : can_register
5795
                                                                           GENERIC MAP (8)
5796
                                                                              PORT MAP (
5797
                                                                                 data_in => data_in,
5798
                                                                                 data_out => tx_data_7_xhdl41,
5799
                                                                                 we => we_tx_data_7,
5800
                                                                                 clk => clk);
5801
 
5802
 
5803
                                                                           -- End: Tx data 7 register. -- Tx data 8 register. 
5804
                                                                           TX_DATA_REG8 : can_register
5805
                                                                              GENERIC MAP (8)
5806
                                                                                 PORT MAP (
5807
                                                                                    data_in => data_in,
5808
                                                                                    data_out => tx_data_8_xhdl42,
5809
                                                                                    we => we_tx_data_8,
5810
                                                                                    clk => clk);
5811
 
5812
 
5813
                                                                              -- End: Tx data 8 register. -- Tx data 9 register. 
5814
                                                                              TX_DATA_REG9 : can_register
5815
                                                                                 GENERIC MAP (8)
5816
                                                                                    PORT MAP (
5817
                                                                                       data_in => data_in,
5818
                                                                                       data_out => tx_data_9_xhdl43,
5819
                                                                                       we => we_tx_data_9,
5820
                                                                                       clk => clk);
5821
 
5822
 
5823
                                                                                 -- End: Tx data 9 register. -- Tx data 10 register. 
5824
                                                                                 TX_DATA_REG10 : can_register
5825
                                                                                    GENERIC MAP (8)
5826
                                                                                       PORT MAP (
5827
                                                                                          data_in => data_in,
5828
                                                                                          data_out => tx_data_10_xhdl44,
5829
                                                                                          we => we_tx_data_10,
5830
                                                                                          clk => clk);
5831
 
5832
 
5833
                                                                                    -- End: Tx data 10 register. -- Tx data 11 register. 
5834
                                                                                    TX_DATA_REG11 : can_register
5835
                                                                                       GENERIC MAP (8)
5836
                                                                                          PORT MAP (
5837
                                                                                             data_in => data_in,
5838
                                                                                             data_out => tx_data_11_xhdl45,
5839
                                                                                             we => we_tx_data_11,
5840
                                                                                             clk => clk);
5841
 
5842
 
5843
                                                                                       -- End: Tx data 11 register. -- Tx data 12 register. 
5844
                                                                                       TX_DATA_REG12 : can_register
5845
                                                                                          GENERIC MAP (8)
5846
                                                                                             PORT MAP (
5847
                                                                                                data_in => data_in,
5848
                                                                                                data_out => tx_data_12_xhdl46,
5849
                                                                                                we => we_tx_data_12,
5850
                                                                                                clk => clk);
5851
 
5852
 
5853
                                                                                          -- End: Tx data 12 register. -- This section is for EXTENDED mode -- Acceptance code register 1 
5854
                                                                                          ACCEPTANCE_CODE_REG1 : can_register
5855
                                                                                             GENERIC MAP (8)
5856
                                                                                                PORT MAP (
5857
                                                                                                   data_in => data_in,
5858
                                                                                                   data_out => acceptance_code_1_xhdl28,
5859
                                                                                                   we => we_acceptance_code_1,
5860
                                                                                                   clk => clk);
5861
 
5862
 
5863
                                                                                             -- End: Acceptance code register -- Acceptance code register 2 
5864
                                                                                             ACCEPTANCE_CODE_REG2 : can_register
5865
                                                                                                GENERIC MAP (8)
5866
                                                                                                   PORT MAP (
5867
                                                                                                      data_in => data_in,
5868
                                                                                                      data_out => acceptance_code_2_xhdl29,
5869
                                                                                                      we => we_acceptance_code_2,
5870
                                                                                                      clk => clk);
5871
 
5872
 
5873
                                                                                                -- End: Acceptance code register -- Acceptance code register 3 
5874
                                                                                                ACCEPTANCE_CODE_REG3 : can_register
5875
                                                                                                   GENERIC MAP (8)
5876
                                                                                                      PORT MAP (
5877
                                                                                                         data_in => data_in,
5878
                                                                                                         data_out => acceptance_code_3_xhdl30,
5879
                                                                                                         we => we_acceptance_code_3,
5880
                                                                                                         clk => clk);
5881
 
5882
 
5883
                                                                                                   -- End: Acceptance code register -- Acceptance mask register 1 
5884
                                                                                                   ACCEPTANCE_MASK_REG1 : can_register
5885
                                                                                                      GENERIC MAP (8)
5886
                                                                                                         PORT MAP (
5887
                                                                                                            data_in => data_in,
5888
                                                                                                            data_out => acceptance_mask_1_xhdl31,
5889
                                                                                                            we => we_acceptance_mask_1,
5890
                                                                                                            clk => clk);
5891
 
5892
 
5893
                                                                                                      -- End: Acceptance code register -- Acceptance mask register 2 
5894
                                                                                                      ACCEPTANCE_MASK_REG2 : can_register
5895
                                                                                                         GENERIC MAP (8)
5896
                                                                                                            PORT MAP (
5897
                                                                                                               data_in => data_in,
5898
                                                                                                               data_out => acceptance_mask_2_xhdl32,
5899
                                                                                                               we => we_acceptance_mask_2,
5900
                                                                                                               clk => clk);
5901
 
5902
 
5903
                                                                                                         -- End: Acceptance code register -- Acceptance mask register 3 
5904
                                                                                                         ACCEPTANCE_MASK_REG3 : can_register
5905
                                                                                                            GENERIC MAP (8)
5906
                                                                                                               PORT MAP (
5907
                                                                                                                  data_in => data_in,
5908
                                                                                                                  data_out => acceptance_mask_3_xhdl33,
5909
                                                                                                                  we => we_acceptance_mask_3,
5910
                                                                                                                  clk => clk);
5911
 
5912
                                                                                                            temp_xhdl218 <= acceptance_code_0_xhdl26 WHEN reset_mode_xhdl3 = '1' ELSE "11111111";
5913
                                                                                                            temp_xhdl219 <= acceptance_mask_0_xhdl27 WHEN reset_mode_xhdl3 = '1' ELSE "11111111";
5914
                                                                                                            temp_xhdl220 <= bus_timing_0 WHEN reset_mode_xhdl3 = '1' ELSE "11111111";
5915
                                                                                                            temp_xhdl221 <= bus_timing_1 WHEN reset_mode_xhdl3 = '1' ELSE "11111111";
5916
                                                                                                            temp_xhdl222 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_0_xhdl34;
5917
                                                                                                            temp_xhdl223 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_1_xhdl35;
5918
                                                                                                            temp_xhdl224 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_2_xhdl36;
5919
                                                                                                            temp_xhdl225 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_3_xhdl37;
5920
                                                                                                            temp_xhdl226 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_4_xhdl38;
5921
                                                                                                            temp_xhdl227 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_5_xhdl39;
5922
                                                                                                            temp_xhdl228 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_6_xhdl40;
5923
                                                                                                            temp_xhdl229 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_7_xhdl41;
5924
                                                                                                            temp_xhdl230 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_8_xhdl42;
5925
                                                                                                            temp_xhdl231 <= "11111111" WHEN reset_mode_xhdl3 = '1' ELSE tx_data_9_xhdl43;
5926
 
5927
                                                                                                            -- End: Acceptance code register -- End: This section is for EXTENDED mode -- Reading data from registers
5928
 
5929
                                                                                                            PROCESS (addr, extended_mode_xhdl24, mode, bus_timing_0, bus_timing_1, clock_divider,
5930
                                                                                                                        acceptance_code_0_xhdl26, acceptance_code_1_xhdl28, acceptance_code_2_xhdl29,
5931
                                                                                                                        acceptance_code_3_xhdl30, acceptance_mask_0_xhdl27, acceptance_mask_1_xhdl31,
5932
                                                                                                                        acceptance_mask_2_xhdl32, acceptance_mask_3_xhdl33, status,
5933
                                                                                                                        error_warning_limit_xhdl21, rx_err_cnt, tx_err_cnt, irq_en_ext, irq_reg, mode_ext,
5934
                                                                                                                        arbitration_lost_capture, rx_message_counter, mode_basic, error_capture_code,
5935
                                                                                                                        temp_xhdl218, temp_xhdl219, temp_xhdl220, temp_xhdl221, temp_xhdl222, temp_xhdl223,
5936
                                                                                                                        temp_xhdl224, temp_xhdl225, temp_xhdl226, temp_xhdl227, temp_xhdl228, temp_xhdl229,
5937
                                                                                                                        temp_xhdl230, temp_xhdl231
5938
                                                                                                                       )
5939
                                                                                                               VARIABLE data_out_xhdl1_xhdl217  : std_logic_vector(7 DOWNTO 0);
5940
                                                                                                               VARIABLE temp_xhdl232  : std_logic_vector(5 DOWNTO 0);
5941
                                                                                                            BEGIN
5942
                                                                                                               temp_xhdl232 := extended_mode_xhdl24 & addr(4 DOWNTO 0);
5943
                                                                                                               CASE temp_xhdl232 IS
5944
                                                                                                                  WHEN "100000" =>
5945
                                                                                                                           data_out_xhdl1_xhdl217 := "0000" & mode_ext(3 DOWNTO 1) & mode;    --  extended mode
5946
                                                                                                                  WHEN "100001" =>
5947
                                                                                                                           data_out_xhdl1_xhdl217 := "00000000";    --  extended mode
5948
                                                                                                                  WHEN "100010" =>
5949
                                                                                                                           data_out_xhdl1_xhdl217 := status;    --  extended mode
5950
                                                                                                                  WHEN "100011" =>
5951
                                                                                                                           data_out_xhdl1_xhdl217 := irq_reg;    --  extended mode
5952
                                                                                                                  WHEN "100100" =>
5953
                                                                                                                           data_out_xhdl1_xhdl217 := irq_en_ext;    --  extended mode
5954
                                                                                                                  WHEN "100110" =>
5955
                                                                                                                           data_out_xhdl1_xhdl217 := bus_timing_0;    --  extended mode
5956
                                                                                                                  WHEN "100111" =>
5957
                                                                                                                           data_out_xhdl1_xhdl217 := bus_timing_1;    --  extended mode
5958
                                                                                                                  WHEN "101011" =>
5959
                                                                                                                           data_out_xhdl1_xhdl217 := "000" & arbitration_lost_capture(4 DOWNTO 0);    --  extended mode
5960
                                                                                                                  WHEN "101100" =>
5961
                                                                                                                           data_out_xhdl1_xhdl217 := error_capture_code;    --  extended mode
5962
                                                                                                                  WHEN "101101" =>
5963
                                                                                                                           data_out_xhdl1_xhdl217 := error_warning_limit_xhdl21;    --  extended mode
5964
                                                                                                                  WHEN "101110" =>
5965
                                                                                                                           data_out_xhdl1_xhdl217 := rx_err_cnt;    --  extended mode
5966
                                                                                                                  WHEN "101111" =>
5967
                                                                                                                           data_out_xhdl1_xhdl217 := tx_err_cnt;    --  extended mode
5968
                                                                                                                  WHEN "110000" =>
5969
                                                                                                                           data_out_xhdl1_xhdl217 := acceptance_code_0_xhdl26;    --  extended mode
5970
                                                                                                                  WHEN "110001" =>
5971
                                                                                                                           data_out_xhdl1_xhdl217 := acceptance_code_1_xhdl28;    --  extended mode
5972
                                                                                                                  WHEN "110010" =>
5973
                                                                                                                           data_out_xhdl1_xhdl217 := acceptance_code_2_xhdl29;    --  extended mode
5974
                                                                                                                  WHEN "110011" =>
5975
                                                                                                                           data_out_xhdl1_xhdl217 := acceptance_code_3_xhdl30;    --  extended mode
5976
                                                                                                                  WHEN "110100" =>
5977
                                                                                                                           data_out_xhdl1_xhdl217 := acceptance_mask_0_xhdl27;    --  extended mode
5978
                                                                                                                  WHEN "110101" =>
5979
                                                                                                                           data_out_xhdl1_xhdl217 := acceptance_mask_1_xhdl31;    --  extended mode
5980
                                                                                                                  WHEN "110110" =>
5981
                                                                                                                           data_out_xhdl1_xhdl217 := acceptance_mask_2_xhdl32;    --  extended mode
5982
                                                                                                                  WHEN "110111" =>
5983
                                                                                                                           data_out_xhdl1_xhdl217 := acceptance_mask_3_xhdl33;    --  extended mode
5984
                                                                                                                  WHEN "111000" =>
5985
                                                                                                                           data_out_xhdl1_xhdl217 := "00000000";    --  extended mode
5986
                                                                                                                  WHEN "111001" =>
5987
                                                                                                                           data_out_xhdl1_xhdl217 := "00000000";    --  extended mode
5988
                                                                                                                  WHEN "111010" =>
5989
                                                                                                                           data_out_xhdl1_xhdl217 := "00000000";    --  extended mode
5990
                                                                                                                  WHEN "111011" =>
5991
                                                                                                                           data_out_xhdl1_xhdl217 := "00000000";    --  extended mode
5992
                                                                                                                  WHEN "111100" =>
5993
                                                                                                                           data_out_xhdl1_xhdl217 := "00000000";    --  extended mode
5994
                                                                                                                  WHEN "111101" =>
5995
                                                                                                                           data_out_xhdl1_xhdl217 := '0' & rx_message_counter;    --  extended mode
5996
                                                                                                                  WHEN "111111" =>
5997
                                                                                                                           data_out_xhdl1_xhdl217 := clock_divider;    --  extended mode
5998
                                                                                                                  WHEN "000000" =>
5999
                                                                                                                           data_out_xhdl1_xhdl217 := "001" & mode_basic(4 DOWNTO 1) & mode;    --  basic mode
6000
                                                                                                                  WHEN "000001" =>
6001
                                                                                                                           data_out_xhdl1_xhdl217 := "11111111";    --  basic mode
6002
                                                                                                                  WHEN "000010" =>
6003
                                                                                                                           data_out_xhdl1_xhdl217 := status;    --  basic mode
6004
                                                                                                                  WHEN "000011" =>
6005
                                                                                                                           data_out_xhdl1_xhdl217 := "1110" & irq_reg(3 DOWNTO 0);    --  basic mode
6006
                                                                                                                  WHEN "000100" =>
6007
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl218;
6008
                                                                                                                  WHEN "000101" =>
6009
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl219;
6010
                                                                                                                  WHEN "000110" =>
6011
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl220;
6012
                                                                                                                  WHEN "000111" =>
6013
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl221;
6014
                                                                                                                  WHEN "001010" =>
6015
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl222;
6016
                                                                                                                  WHEN "001011" =>
6017
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl223;
6018
                                                                                                                  WHEN "001100" =>
6019
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl224;
6020
                                                                                                                  WHEN "001101" =>
6021
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl225;
6022
                                                                                                                  WHEN "001110" =>
6023
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl226;
6024
                                                                                                                  WHEN "001111" =>
6025
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl227;
6026
                                                                                                                  WHEN "010000" =>
6027
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl228;
6028
                                                                                                                  WHEN "010001" =>
6029
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl229;
6030
                                                                                                                  WHEN "010010" =>
6031
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl230;
6032
                                                                                                                  WHEN "010011" =>
6033
                                                                                                                           data_out_xhdl1_xhdl217 := temp_xhdl231;
6034
                                                                                                                  WHEN "011111" =>
6035
                                                                                                                           data_out_xhdl1_xhdl217 := clock_divider;    --  basic mode
6036
                                                                                                                  WHEN OTHERS  =>
6037
                                                                                                                           data_out_xhdl1_xhdl217 := "00000000";    --  the rest is read as 0
6038
 
6039
                                                                                                               END CASE;
6040
                                                                                                               data_out_xhdl1 <= data_out_xhdl1_xhdl217;
6041
                                                                                                            END PROCESS;
6042
                                                                                                            temp_xhdl233 <= data_overrun_irq_en_ext WHEN extended_mode_xhdl24 = '1' ELSE overrun_irq_en_basic;
6043
                                                                                                            data_overrun_irq_en <= temp_xhdl233 ;
6044
                                                                                                            temp_xhdl234 <= error_warning_irq_en_ext WHEN extended_mode_xhdl24 = '1' ELSE error_irq_en_basic;
6045
                                                                                                            error_warning_irq_en <= temp_xhdl234 ;
6046
                                                                                                            temp_xhdl235 <= transmit_irq_en_ext WHEN extended_mode_xhdl24 = '1' ELSE transmit_irq_en_basic;
6047
                                                                                                            transmit_irq_en <= temp_xhdl235 ;
6048
                                                                                                            temp_xhdl236 <= receive_irq_en_ext WHEN extended_mode_xhdl24 = '1' ELSE receive_irq_en_basic;
6049
                                                                                                            receive_irq_en <= temp_xhdl236 ;
6050
 
6051
                                                                                                            PROCESS (clk, rst)
6052
                                                                                                            BEGIN
6053
                                                                                                               IF (rst = '1') THEN
6054
                                                                                                                  data_overrun_irq <= '0';
6055
                                                                                                               ELSif clk'event and clk = '1' then
6056
                                                                                                                  IF (((overrun AND (NOT overrun_q)) AND data_overrun_irq_en) = '1') THEN
6057
                                                                                                                     data_overrun_irq <= '1' ;
6058
                                                                                                                  ELSE
6059
                                                                                                                     IF ((reset_mode_xhdl3 OR reset_irq_reg) = '1') THEN
6060
                                                                                                                        data_overrun_irq <= '0' ;
6061
                                                                                                                     END IF;
6062
                                                                                                                  END IF;
6063
                                                                                                               END IF;
6064
                                                                                                            END PROCESS;
6065
 
6066
                                                                                                            PROCESS (clk, rst)
6067
                                                                                                            BEGIN
6068
                                                                                                               IF (rst = '1') THEN
6069
                                                                                                                  transmit_irq <= '0';
6070
                                                                                                               ELSif clk'event and clk = '1' then
6071
                                                                                                                  IF ((reset_mode_xhdl3 OR reset_irq_reg) = '1') THEN
6072
                                                                                                                     transmit_irq <= '0' ;
6073
                                                                                                                  ELSE
6074
                                                                                                                     IF (((transmit_buffer_status AND (NOT transmit_buffer_status_q)) AND transmit_irq_en) = '1') THEN
6075
                                                                                                                        transmit_irq <= '1' ;
6076
                                                                                                                     END IF;
6077
                                                                                                                  END IF;
6078
                                                                                                               END IF;
6079
                                                                                                            END PROCESS;
6080
 
6081
                                                                                                            PROCESS (clk, rst)
6082
                                                                                                            BEGIN
6083
                                                                                                               IF (rst = '1') THEN
6084
                                                                                                                  receive_irq <= '0';
6085
                                                                                                               ELSif clk'event and clk = '1' then
6086
                                                                                                                  IF ((((NOT info_empty) AND (NOT receive_irq)) AND receive_irq_en) = '1') THEN
6087
                                                                                                                     receive_irq <= '1' ;
6088
                                                                                                                  ELSE
6089
                                                                                                                     IF ((reset_mode_xhdl3 OR release_buffer_xhdl8) = '1') THEN
6090
                                                                                                                        receive_irq <= '0' ;
6091
                                                                                                                     END IF;
6092
                                                                                                                  END IF;
6093
                                                                                                               END IF;
6094
                                                                                                            END PROCESS;
6095
 
6096
                                                                                                            PROCESS (clk, rst)
6097
                                                                                                            BEGIN
6098
                                                                                                               IF (rst = '1') THEN
6099
                                                                                                                  error_irq <= '0';
6100
                                                                                                               ELSif clk'event and clk = '1' then
6101
                                                                                                                  IF ((((error_status XOR error_status_q) OR (node_bus_off XOR node_bus_off_q)) AND error_warning_irq_en) = '1') THEN
6102
                                                                                                                     error_irq <= '1' ;
6103
                                                                                                                  ELSE
6104
                                                                                                                     IF (reset_irq_reg = '1') THEN
6105
                                                                                                                        error_irq <= '0' ;
6106
                                                                                                                     END IF;
6107
                                                                                                                  END IF;
6108
                                                                                                               END IF;
6109
                                                                                                            END PROCESS;
6110
 
6111
                                                                                                            PROCESS (clk, rst)
6112
                                                                                                            BEGIN
6113
                                                                                                               IF (rst = '1') THEN
6114
                                                                                                                  bus_error_irq <= '0';
6115
                                                                                                               ELSif clk'event and clk = '1' then
6116
                                                                                                                  IF ((set_bus_error_irq AND bus_error_irq_en) = '1') THEN
6117
                                                                                                                     bus_error_irq <= '1' ;
6118
                                                                                                                  ELSE
6119
                                                                                                                     IF ((reset_mode_xhdl3 OR reset_irq_reg) = '1') THEN
6120
                                                                                                                        bus_error_irq <= '0' ;
6121
                                                                                                                     END IF;
6122
                                                                                                                  END IF;
6123
                                                                                                               END IF;
6124
                                                                                                            END PROCESS;
6125
 
6126
                                                                                                            PROCESS (clk, rst)
6127
                                                                                                            BEGIN
6128
                                                                                                               IF (rst = '1') THEN
6129
                                                                                                                  arbitration_lost_irq <= '0';
6130
                                                                                                               ELSif clk'event and clk = '1' then
6131
                                                                                                                  IF ((set_arbitration_lost_irq AND arbitration_lost_irq_en) = '1') THEN
6132
                                                                                                                     arbitration_lost_irq <= '1' ;
6133
                                                                                                                  ELSE
6134
                                                                                                                     IF ((reset_mode_xhdl3 OR reset_irq_reg) = '1') THEN
6135
                                                                                                                        arbitration_lost_irq <= '0' ;
6136
                                                                                                                     END IF;
6137
                                                                                                                  END IF;
6138
                                                                                                               END IF;
6139
                                                                                                            END PROCESS;
6140
 
6141
                                                                                                            PROCESS (clk, rst)
6142
                                                                                                            BEGIN
6143
                                                                                                               IF (rst = '1') THEN
6144
                                                                                                                  error_passive_irq <= '0';
6145
                                                                                                               ELSif clk'event and clk = '1' then
6146
                                                                                                                  IF ((((node_error_passive AND (NOT node_error_passive_q)) OR (((NOT node_error_passive) AND node_error_passive_q) AND node_error_active)) AND error_passive_irq_en) = '1') THEN
6147
                                                                                                                     error_passive_irq <= '1' ;
6148
                                                                                                                  ELSE
6149
                                                                                                                     IF ((reset_mode_xhdl3 OR reset_irq_reg) = '1') THEN
6150
                                                                                                                        error_passive_irq <= '0' ;
6151
                                                                                                                     END IF;
6152
                                                                                                                  END IF;
6153
                                                                                                               END IF;
6154
                                                                                                            END PROCESS;
6155
                                                                                                            irq_reg <= bus_error_irq & arbitration_lost_irq & error_passive_irq & '0' & data_overrun_irq & error_irq & transmit_irq & receive_irq ;
6156
                                                                                                            irq <= data_overrun_irq OR transmit_irq OR receive_irq OR error_irq OR bus_error_irq OR arbitration_lost_irq OR error_passive_irq ;
6157
 
6158
--   irq_o reset change /Kristoffer 2006-02-23                                                                 PROCESS (clk, rst)
6159
--                                                                                                             BEGIN
6160
--                                                                                                                IF (rst = '1') THEN
6161
--                                                                                                                   irq_n_xhdl2 <= '1';    
6162
--                                                                                                                ELSif clk'event and clk = '1' then
6163
--                                                                                                                   IF (reset_irq_reg = '1' or release_buffer_xhdl8='1') THEN
6164
--                                                                                                                      irq_n_xhdl2 <= '1';    
6165
--                                                                                                                   ELSE
6166
--                                                                                                                      IF (irq = '1') THEN
6167
--                                                                                                                         irq_n_xhdl2 <= '0' ;    
6168
--                                                                                                                      END IF;
6169
--                                                                                                                   END IF;
6170
--                                                                                                                END IF;
6171
--                                                                                                             END PROCESS;
6172
 
6173
                                                                                                            PROCESS (clk, rst, release_buffer_xhdl8)
6174
                                                                                                            BEGIN
6175
                                                                                                               IF (rst = '1' or release_buffer_xhdl8 = '1') THEN
6176
                                                                                                                  irq_n_xhdl2 <= '1';
6177
                                                                                                               ELSif clk'event and clk = '1' then
6178
 
6179
                                                                                                                   irq_n_xhdl2 <= not irq;
6180
 
6181
                                                                                                               END IF;
6182
                                                                                                            END PROCESS;
6183
 
6184
 
6185
END ARCHITECTURE RTL;
6186
----------------------------------------------------------------------------------------------
6187
--
6188
-- VHDL file generated by X-HDL - Revision 3.2.53  Aug. 1, 2005 
6189
-- Tue Aug  9 07:33:50 2005
6190
--
6191
--      Input file         : C:/Documents and Settings/BryantI/My Documents/tmp/can_top.v
6192
--      Design name        : can_top
6193
--      Author             : 
6194
--      Company            : Actel
6195
--
6196
--      Description        : 
6197
--
6198
--
6199
----------------------------------------------------------------------------------------------
6200
--
6201
--////////////////////////////////////////////////////////////////////
6202
--//                                                              ////
6203
--//  can_top.v                                                   ////
6204
--//                                                              ////
6205
--//                                                              ////
6206
--//  This file is part of the CAN Protocol Controller            ////
6207
--//  http://www.opencores.org/projects/can/                      ////
6208
--//                                                              ////
6209
--//                                                              ////
6210
--//  Author(s):                                                  ////
6211
--//       Igor Mohor                                             ////
6212
--//       igorm@opencores.org                                    ////
6213
--//                                                              ////
6214
--//                                                              ////
6215
--//  All additional information is available in the README.txt   ////
6216
--//  file.                                                       ////
6217
--//                                                              ////
6218
--////////////////////////////////////////////////////////////////////
6219
--//                                                              ////
6220
--// Copyright (C) 2002, 2003, 2004 Authors                       ////
6221
--//                                                              ////
6222
--// This source file may be used and distributed without         ////
6223
--// restriction provided that this copyright statement is not    ////
6224
--// removed from the file and that any derivative work contains  ////
6225
--// the original copyright notice and the associated disclaimer. ////
6226
--//                                                              ////
6227
--// This source file is free software; you can redistribute it   ////
6228
--// and/or modify it under the terms of the GNU Lesser General   ////
6229
--// Public License as published by the Free Software Foundation; ////
6230
--// either version 2.1 of the License, or (at your option) any   ////
6231
--// later version.                                               ////
6232
--//                                                              ////
6233
--// This source is distributed in the hope that it will be       ////
6234
--// useful, but WITHOUT ANY WARRANTY; without even the implied   ////
6235
--// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR      ////
6236
--// PURPOSE.  See the GNU Lesser General Public License for more ////
6237
--// details.                                                     ////
6238
--//                                                              ////
6239
--// You should have received a copy of the GNU Lesser General    ////
6240
--// Public License along with this source; if not, download it   ////
6241
--// from http://www.opencores.org/lgpl.shtml                     ////
6242
--//                                                              ////
6243
--// The CAN protocol is developed by Robert Bosch GmbH and       ////
6244
--// protected by patents. Anybody who wants to implement this    ////
6245
--// CAN IP core on silicon has to obtain a CAN protocol license  ////
6246
--// from Bosch.                                                  ////
6247
--//                                                              ////
6248
--////////////////////////////////////////////////////////////////////
6249
--
6250
-- CVS Revision History
6251
--
6252
-- $Log: can_top.v,v $
6253
-- Revision 1.48  2004/10/25 11:44:47  igorm
6254
-- Interrupt is always cleared for one clock after the irq register is read.
6255
-- This fixes problems when CPU is using IRQs that are edge triggered.
6256
--
6257
-- Revision 1.47  2004/02/08 14:53:54  mohor
6258
-- Header changed. Address latched to posedge. bus_off_on signal added.
6259
--
6260
-- Revision 1.46  2003/10/17 05:55:20  markom
6261
-- mbist signals updated according to newest convention
6262
--
6263
-- Revision 1.45  2003/09/30 00:55:13  mohor
6264
-- Error counters fixed to be compatible with Bosch VHDL reference model.
6265
-- Small synchronization changes.
6266
--
6267
-- Revision 1.44  2003/09/25 18:55:49  mohor
6268
-- Synchronization changed, error counters fixed.
6269
--
6270
-- Revision 1.43  2003/08/20 09:57:39  mohor
6271
-- Tristate signal tx_o is separated to tx_o and tx_oen_o. Both signals need
6272
-- to be joined together on higher level.
6273
--
6274
-- Revision 1.42  2003/07/16 15:11:28  mohor
6275
-- Fixed according to the linter.
6276
--
6277
-- Revision 1.41  2003/07/10 15:32:27  mohor
6278
-- Unused signal removed.
6279
--
6280
-- Revision 1.40  2003/07/10 01:59:04  tadejm
6281
-- Synchronization fixed. In some strange cases it didn't work according to
6282
-- the VHDL reference model.
6283
--
6284
-- Revision 1.39  2003/07/07 11:21:37  mohor
6285
-- Little fixes (to fix warnings).
6286
--
6287
-- Revision 1.38  2003/07/03 09:32:20  mohor
6288
-- Synchronization changed.
6289
--
6290
-- Revision 1.37  2003/06/27 20:56:15  simons
6291
-- Virtual silicon ram instances added.
6292
--
6293
-- Revision 1.36  2003/06/17 14:30:30  mohor
6294
-- "chip select" signal cs_can_i is used only when not using WISHBONE
6295
-- interface.
6296
--
6297
-- Revision 1.35  2003/06/16 13:57:58  mohor
6298
-- tx_point generated one clk earlier. rx_i registered. Data corrected when
6299
-- using extended mode.
6300
--
6301
-- Revision 1.34  2003/06/13 15:02:24  mohor
6302
-- Synchronization is also needed when transmitting a message.
6303
--
6304
-- Revision 1.33  2003/06/11 14:21:35  mohor
6305
-- When switching to tx, sync stage is overjumped.
6306
--
6307
-- Revision 1.32  2003/06/09 11:32:36  mohor
6308
-- Ports added for the CAN_BIST.
6309
--
6310
-- Revision 1.31  2003/03/26 11:19:46  mohor
6311
-- CAN interrupt is active low.
6312
--
6313
-- Revision 1.30  2003/03/20 17:01:17  mohor
6314
-- unix.
6315
--
6316
-- Revision 1.28  2003/03/14 19:36:48  mohor
6317
-- can_cs signal used for generation of the cs.
6318
--
6319
-- Revision 1.27  2003/03/12 05:56:33  mohor
6320
-- Bidirectional port_0_i changed to port_0_io.
6321
-- input cs_can changed to cs_can_i.
6322
--
6323
-- Revision 1.26  2003/03/12 04:39:40  mohor
6324
-- rd_i and wr_i are active high signals. If 8051 is connected, these two signals
6325
-- need to be negated one level higher.
6326
--
6327
-- Revision 1.25  2003/03/12 04:17:36  mohor
6328
-- 8051 interface added (besides WISHBONE interface). Selection is made in
6329
-- can_defines.v file.
6330
--
6331
-- Revision 1.24  2003/03/10 17:24:40  mohor
6332
-- wire declaration added.
6333
--
6334
-- Revision 1.23  2003/03/05 15:33:13  mohor
6335
-- tx_o is now tristated signal. tx_oen and tx_o combined together.
6336
--
6337
-- Revision 1.22  2003/03/05 15:01:56  mohor
6338
-- Top level signal names changed.
6339
--
6340
-- Revision 1.21  2003/03/01 22:53:33  mohor
6341
-- Actel APA ram supported.
6342
--
6343
-- Revision 1.20  2003/02/19 15:09:02  mohor
6344
-- Incomplete sensitivity list fixed.
6345
--
6346
-- Revision 1.19  2003/02/19 15:04:14  mohor
6347
-- Typo fixed.
6348
--
6349
-- Revision 1.18  2003/02/19 14:44:03  mohor
6350
-- CAN core finished. Host interface added. Registers finished.
6351
-- Synchronization to the wishbone finished.
6352
--
6353
-- Revision 1.17  2003/02/18 00:10:15  mohor
6354
-- Most of the registers added. Registers "arbitration lost capture", "error code
6355
-- capture" + few more still need to be added.
6356
--
6357
-- Revision 1.16  2003/02/14 20:17:01  mohor
6358
-- Several registers added. Not finished, yet.
6359
--
6360
-- Revision 1.15  2003/02/12 14:25:30  mohor
6361
-- abort_tx added.
6362
--
6363
-- Revision 1.14  2003/02/11 00:56:06  mohor
6364
-- Wishbone interface added.
6365
--
6366
-- Revision 1.13  2003/02/09 18:40:29  mohor
6367
-- Overload fixed. Hard synchronization also enabled at the last bit of
6368
-- interframe.
6369
--
6370
-- Revision 1.12  2003/02/09 02:24:33  mohor
6371
-- Bosch license warning added. Error counters finished. Overload frames
6372
-- still need to be fixed.
6373
--
6374
-- Revision 1.11  2003/02/04 14:34:52  mohor
6375
-- *** empty log message ***
6376
--
6377
-- Revision 1.10  2003/01/31 01:13:38  mohor
6378
-- backup.
6379
--
6380
-- Revision 1.9  2003/01/15 13:16:48  mohor
6381
-- When a frame with "remote request" is received, no data is stored to
6382
-- fifo, just the frame information (identifier, ...). Data length that
6383
-- is stored is the received data length and not the actual data length
6384
-- that is stored to fifo.
6385
--
6386
-- Revision 1.8  2003/01/14 17:25:09  mohor
6387
-- Addresses corrected to decimal values (previously hex).
6388
--
6389
-- Revision 1.7  2003/01/10 17:51:34  mohor
6390
-- Temporary version (backup).
6391
--
6392
-- Revision 1.6  2003/01/09 21:54:45  mohor
6393
-- rx fifo added. Not 100 % verified, yet.
6394
--
6395
-- Revision 1.5  2003/01/08 02:10:56  mohor
6396
-- Acceptance filter added.
6397
--
6398
-- Revision 1.4  2002/12/28 04:13:23  mohor
6399
-- Backup version.
6400
--
6401
-- Revision 1.3  2002/12/27 00:12:52  mohor
6402
-- Header changed, testbench improved to send a frame (crc still missing).
6403
--
6404
-- Revision 1.2  2002/12/26 16:00:34  mohor
6405
-- Testbench define file added. Clock divider register added.
6406
--
6407
-- Revision 1.1.1.1  2002/12/20 16:39:21  mohor
6408
-- Initial
6409
--
6410
--
6411
--
6412
-- synopsys translate_off
6413
--`include "can_defines.v"
6414
-- synopsys translate_on
6415
 
6416
LIBRARY ieee;
6417
USE ieee.std_logic_1164.all;
6418
library grlib;
6419
use grlib.stdlib.all;
6420
 
6421
ENTITY can_top IS
6422
   PORT (
6423
--      wb_clk_i                : IN std_logic;   
6424
--      wb_rst_i                : IN std_logic;   
6425
--      wb_dat_i                : IN std_logic_vector(7 DOWNTO 0);   
6426
--      wb_dat_o                : OUT std_logic_vector(7 DOWNTO 0);   
6427
--      wb_cyc_i                : IN std_logic;   
6428
--      wb_stb_i                : IN std_logic;   
6429
--      wb_we_i                 : IN std_logic;   
6430
--      wb_adr_i                : IN std_logic_vector(7 DOWNTO 0);   
6431
--      wb_ack_o                : OUT std_logic;   
6432
      rst                     : IN std_logic;
6433
      addr                    : IN std_logic_vector(7 DOWNTO 0);
6434
      data_in                 : IN std_logic_vector(7 DOWNTO 0);
6435
      data_out                : OUT std_logic_vector(7 DOWNTO 0);
6436
      cs                      : IN std_logic;
6437
      we                      : IN std_logic;
6438
      clk_i                   : IN std_logic;
6439
      rx_i                    : IN std_logic;
6440
      tx_o                    : OUT std_logic;
6441
      bus_off_on              : OUT std_logic;
6442
      irq_on                  : OUT std_logic;
6443
      clkout_o                : OUT std_logic;
6444
      -- Bist
6445
-- port connections for Ram
6446
--64x8
6447
 
6448
      q_dp_64x8               : IN std_logic_vector(7 DOWNTO 0);
6449
      data_64x8               : OUT std_logic_vector(7 DOWNTO 0);
6450
      wren_64x8               : OUT std_logic;
6451
      rden_64x8               : OUT std_logic;
6452
      wraddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
6453
      rdaddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
6454
      --64x4
6455
 
6456
      q_dp_64x4               : IN std_logic_vector(3 DOWNTO 0);
6457
      data_64x4               : OUT std_logic_vector(3 DOWNTO 0);
6458
      wren_64x4x1             : OUT std_logic;
6459
      wraddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
6460
      rdaddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
6461
      --64x1
6462
 
6463
      q_dp_64x1               : IN std_logic;
6464
      data_64x1               : OUT std_logic);
6465
END ENTITY can_top;
6466
 
6467
ARCHITECTURE RTL OF can_top IS
6468
 
6469
   COMPONENT can_bsp
6470
      PORT (
6471
         clk                     : IN  std_logic;
6472
         rst                     : IN  std_logic;
6473
         sample_point            : IN  std_logic;
6474
         sampled_bit             : IN  std_logic;
6475
         sampled_bit_q           : IN  std_logic;
6476
         tx_point                : IN  std_logic;
6477
         hard_sync               : IN  std_logic;
6478
         addr                    : IN  std_logic_vector(7 DOWNTO 0);
6479
         data_in                 : IN  std_logic_vector(7 DOWNTO 0);
6480
         data_out                : OUT std_logic_vector(7 DOWNTO 0);
6481
         fifo_selected           : IN  std_logic;
6482
         reset_mode              : IN  std_logic;
6483
         listen_only_mode        : IN  std_logic;
6484
         acceptance_filter_mode  : IN  std_logic;
6485
         self_test_mode          : IN  std_logic;
6486
         release_buffer          : IN  std_logic;
6487
         tx_request              : IN  std_logic;
6488
         abort_tx                : IN  std_logic;
6489
         self_rx_request         : IN  std_logic;
6490
         single_shot_transmission: IN  std_logic;
6491
         tx_state                : OUT std_logic;
6492
         tx_state_q              : OUT std_logic;
6493
         overload_request        : IN  std_logic;
6494
         overload_frame          : OUT std_logic;
6495
         read_arbitration_lost_capture_reg: IN  std_logic;
6496
         read_error_code_capture_reg: IN  std_logic;
6497
         error_capture_code      : OUT std_logic_vector(7 DOWNTO 0);
6498
         error_warning_limit     : IN  std_logic_vector(7 DOWNTO 0);
6499
         we_rx_err_cnt           : IN  std_logic;
6500
         we_tx_err_cnt           : IN  std_logic;
6501
         extended_mode           : IN  std_logic;
6502
         rx_idle                 : OUT std_logic;
6503
         transmitting            : OUT std_logic;
6504
         transmitter             : OUT std_logic;
6505
         go_rx_inter             : OUT std_logic;
6506
         not_first_bit_of_inter  : OUT std_logic;
6507
         rx_inter                : OUT std_logic;
6508
         set_reset_mode          : OUT std_logic;
6509
         node_bus_off            : OUT std_logic;
6510
         error_status            : OUT std_logic;
6511
         rx_err_cnt              : OUT std_logic_vector(8 DOWNTO 0);
6512
         tx_err_cnt              : OUT std_logic_vector(8 DOWNTO 0);
6513
         transmit_status         : OUT std_logic;
6514
         receive_status          : OUT std_logic;
6515
         tx_successful           : OUT std_logic;
6516
         need_to_tx              : OUT std_logic;
6517
         overrun                 : OUT std_logic;
6518
         info_empty              : OUT std_logic;
6519
         set_bus_error_irq       : OUT std_logic;
6520
         set_arbitration_lost_irq: OUT std_logic;
6521
         arbitration_lost_capture: OUT std_logic_vector(4 DOWNTO 0);
6522
         node_error_passive      : OUT std_logic;
6523
         node_error_active       : OUT std_logic;
6524
         rx_message_counter      : OUT std_logic_vector(6 DOWNTO 0);
6525
         acceptance_code_0       : IN  std_logic_vector(7 DOWNTO 0);
6526
         acceptance_mask_0       : IN  std_logic_vector(7 DOWNTO 0);
6527
         acceptance_code_1       : IN  std_logic_vector(7 DOWNTO 0);
6528
         acceptance_code_2       : IN  std_logic_vector(7 DOWNTO 0);
6529
         acceptance_code_3       : IN  std_logic_vector(7 DOWNTO 0);
6530
         acceptance_mask_1       : IN  std_logic_vector(7 DOWNTO 0);
6531
         acceptance_mask_2       : IN  std_logic_vector(7 DOWNTO 0);
6532
         acceptance_mask_3       : IN  std_logic_vector(7 DOWNTO 0);
6533
         tx_data_0               : IN  std_logic_vector(7 DOWNTO 0);
6534
         tx_data_1               : IN  std_logic_vector(7 DOWNTO 0);
6535
         tx_data_2               : IN  std_logic_vector(7 DOWNTO 0);
6536
         tx_data_3               : IN  std_logic_vector(7 DOWNTO 0);
6537
         tx_data_4               : IN  std_logic_vector(7 DOWNTO 0);
6538
         tx_data_5               : IN  std_logic_vector(7 DOWNTO 0);
6539
         tx_data_6               : IN  std_logic_vector(7 DOWNTO 0);
6540
         tx_data_7               : IN  std_logic_vector(7 DOWNTO 0);
6541
         tx_data_8               : IN  std_logic_vector(7 DOWNTO 0);
6542
         tx_data_9               : IN  std_logic_vector(7 DOWNTO 0);
6543
         tx_data_10              : IN  std_logic_vector(7 DOWNTO 0);
6544
         tx_data_11              : IN  std_logic_vector(7 DOWNTO 0);
6545
         tx_data_12              : IN  std_logic_vector(7 DOWNTO 0);
6546
         tx                      : OUT std_logic;
6547
         tx_next                 : OUT std_logic;
6548
         bus_off_on              : OUT std_logic;
6549
         go_overload_frame       : OUT std_logic;
6550
         go_error_frame          : OUT std_logic;
6551
         go_tx                   : OUT std_logic;
6552
         send_ack                : OUT std_logic;
6553
         q_dp_64x8               : IN  std_logic_vector(7 DOWNTO 0);
6554
         data_64x8               : OUT std_logic_vector(7 DOWNTO 0);
6555
         wren_64x8               : OUT std_logic;
6556
         rden_64x8               : OUT std_logic;
6557
         wraddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
6558
         rdaddress_64x8          : OUT std_logic_vector(5 DOWNTO 0);
6559
         q_dp_64x4               : IN  std_logic_vector(3 DOWNTO 0);
6560
         data_64x4               : OUT std_logic_vector(3 DOWNTO 0);
6561
         wren_64x4x1             : OUT std_logic;
6562
         wraddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
6563
         rdaddress_64x4x1        : OUT std_logic_vector(5 DOWNTO 0);
6564
         q_dp_64x1               : IN  std_logic;
6565
         data_64x1               : OUT std_logic);
6566
   END COMPONENT;
6567
 
6568
   COMPONENT can_btl
6569
      PORT (
6570
         clk                     : IN  std_logic;
6571
         rst                     : IN  std_logic;
6572
         rx                      : IN  std_logic;
6573
         tx                      : IN  std_logic;
6574
         baud_r_presc            : IN  std_logic_vector(5 DOWNTO 0);
6575
         sync_jump_width         : IN  std_logic_vector(1 DOWNTO 0);
6576
         time_segment1           : IN  std_logic_vector(3 DOWNTO 0);
6577
         time_segment2           : IN  std_logic_vector(2 DOWNTO 0);
6578
         triple_sampling         : IN  std_logic;
6579
         sample_point            : OUT std_logic;
6580
         sampled_bit             : OUT std_logic;
6581
         sampled_bit_q           : OUT std_logic;
6582
         tx_point                : OUT std_logic;
6583
         hard_sync               : OUT std_logic;
6584
         rx_idle                 : IN  std_logic;
6585
         rx_inter                : IN  std_logic;
6586
         transmitting            : IN  std_logic;
6587
         transmitter             : IN  std_logic;
6588
         go_rx_inter             : IN  std_logic;
6589
         tx_next                 : IN  std_logic;
6590
         go_overload_frame       : IN  std_logic;
6591
         go_error_frame          : IN  std_logic;
6592
         go_tx                   : IN  std_logic;
6593
         send_ack                : IN  std_logic;
6594
         node_error_passive      : IN  std_logic);
6595
   END COMPONENT;
6596
 
6597
   COMPONENT can_registers
6598
      PORT (
6599
         clk                     : IN  std_logic;
6600
         rst                     : IN  std_logic;
6601
         cs                      : IN  std_logic;
6602
         we                      : IN  std_logic;
6603
         addr                    : IN  std_logic_vector(7 DOWNTO 0);
6604
         data_in                 : IN  std_logic_vector(7 DOWNTO 0);
6605
         data_out                : OUT std_logic_vector(7 DOWNTO 0);
6606
         irq_n                   : OUT std_logic;
6607
         sample_point            : IN  std_logic;
6608
         transmitting            : IN  std_logic;
6609
         set_reset_mode          : IN  std_logic;
6610
         node_bus_off            : IN  std_logic;
6611
         error_status            : IN  std_logic;
6612
         rx_err_cnt              : IN  std_logic_vector(7 DOWNTO 0);
6613
         tx_err_cnt              : IN  std_logic_vector(7 DOWNTO 0);
6614
         transmit_status         : IN  std_logic;
6615
         receive_status          : IN  std_logic;
6616
         tx_successful           : IN  std_logic;
6617
         need_to_tx              : IN  std_logic;
6618
         overrun                 : IN  std_logic;
6619
         info_empty              : IN  std_logic;
6620
         set_bus_error_irq       : IN  std_logic;
6621
         set_arbitration_lost_irq: IN  std_logic;
6622
         arbitration_lost_capture: IN  std_logic_vector(4 DOWNTO 0);
6623
         node_error_passive      : IN  std_logic;
6624
         node_error_active       : IN  std_logic;
6625
         rx_message_counter      : IN  std_logic_vector(6 DOWNTO 0);
6626
         reset_mode              : OUT std_logic;
6627
         listen_only_mode        : OUT std_logic;
6628
         acceptance_filter_mode  : OUT std_logic;
6629
         self_test_mode          : OUT std_logic;
6630
         clear_data_overrun      : OUT std_logic;
6631
         release_buffer          : OUT std_logic;
6632
         abort_tx                : OUT std_logic;
6633
         tx_request              : OUT std_logic;
6634
         self_rx_request         : OUT std_logic;
6635
         single_shot_transmission: OUT std_logic;
6636
         tx_state                : IN  std_logic;
6637
         tx_state_q              : IN  std_logic;
6638
         overload_request        : OUT std_logic;
6639
         overload_frame          : IN  std_logic;
6640
         read_arbitration_lost_capture_reg: OUT std_logic;
6641
         read_error_code_capture_reg: OUT std_logic;
6642
         error_capture_code      : IN  std_logic_vector(7 DOWNTO 0);
6643
         baud_r_presc            : OUT std_logic_vector(5 DOWNTO 0);
6644
         sync_jump_width         : OUT std_logic_vector(1 DOWNTO 0);
6645
         time_segment1           : OUT std_logic_vector(3 DOWNTO 0);
6646
         time_segment2           : OUT std_logic_vector(2 DOWNTO 0);
6647
         triple_sampling         : OUT std_logic;
6648
         error_warning_limit     : OUT std_logic_vector(7 DOWNTO 0);
6649
         we_rx_err_cnt           : OUT std_logic;
6650
         we_tx_err_cnt           : OUT std_logic;
6651
         extended_mode           : OUT std_logic;
6652
         clkout                  : OUT std_logic;
6653
         acceptance_code_0       : OUT std_logic_vector(7 DOWNTO 0);
6654
         acceptance_mask_0       : OUT std_logic_vector(7 DOWNTO 0);
6655
         acceptance_code_1       : OUT std_logic_vector(7 DOWNTO 0);
6656
         acceptance_code_2       : OUT std_logic_vector(7 DOWNTO 0);
6657
         acceptance_code_3       : OUT std_logic_vector(7 DOWNTO 0);
6658
         acceptance_mask_1       : OUT std_logic_vector(7 DOWNTO 0);
6659
         acceptance_mask_2       : OUT std_logic_vector(7 DOWNTO 0);
6660
         acceptance_mask_3       : OUT std_logic_vector(7 DOWNTO 0);
6661
         tx_data_0               : OUT std_logic_vector(7 DOWNTO 0);
6662
         tx_data_1               : OUT std_logic_vector(7 DOWNTO 0);
6663
         tx_data_2               : OUT std_logic_vector(7 DOWNTO 0);
6664
         tx_data_3               : OUT std_logic_vector(7 DOWNTO 0);
6665
         tx_data_4               : OUT std_logic_vector(7 DOWNTO 0);
6666
         tx_data_5               : OUT std_logic_vector(7 DOWNTO 0);
6667
         tx_data_6               : OUT std_logic_vector(7 DOWNTO 0);
6668
         tx_data_7               : OUT std_logic_vector(7 DOWNTO 0);
6669
         tx_data_8               : OUT std_logic_vector(7 DOWNTO 0);
6670
         tx_data_9               : OUT std_logic_vector(7 DOWNTO 0);
6671
         tx_data_10              : OUT std_logic_vector(7 DOWNTO 0);
6672
         tx_data_11              : OUT std_logic_vector(7 DOWNTO 0);
6673
         tx_data_12              : OUT std_logic_vector(7 DOWNTO 0));
6674
   END COMPONENT;
6675
 
6676
 
6677
--   SIGNAL cs_sync1                 :  std_logic;   
6678
--   SIGNAL cs_sync2                 :  std_logic;   
6679
--   SIGNAL cs_sync3                 :  std_logic;   
6680
--   SIGNAL cs_ack1                  :  std_logic;   
6681
--   SIGNAL cs_ack2                  :  std_logic;   
6682
--   SIGNAL cs_ack3                  :  std_logic;   
6683
--   SIGNAL cs_sync_rst1             :  std_logic;   
6684
--   SIGNAL cs_sync_rst2             :  std_logic;   
6685
--   SIGNAL cs_can_i                 :  std_logic;   
6686
   ---------------------------------
6687
   SIGNAL data_out_fifo_selected   :  std_logic;
6688
   SIGNAL data_out_fifo            :  std_logic_vector(7 DOWNTO 0);
6689
   SIGNAL data_out_regs            :  std_logic_vector(7 DOWNTO 0);
6690
   -- Mode register 
6691
   SIGNAL reset_mode               :  std_logic;
6692
   SIGNAL listen_only_mode         :  std_logic;
6693
   SIGNAL acceptance_filter_mode   :  std_logic;
6694
   SIGNAL self_test_mode           :  std_logic;
6695
   -- Command register 
6696
   SIGNAL release_buffer           :  std_logic;
6697
   SIGNAL tx_request               :  std_logic;
6698
   SIGNAL abort_tx                 :  std_logic;
6699
   SIGNAL self_rx_request          :  std_logic;
6700
   SIGNAL single_shot_transmission :  std_logic;
6701
   SIGNAL tx_state                 :  std_logic;
6702
   SIGNAL tx_state_q               :  std_logic;
6703
   SIGNAL overload_request         :  std_logic;
6704
   SIGNAL overload_frame           :  std_logic;
6705
   -- Arbitration Lost Capture Register 
6706
   SIGNAL read_arbitration_lost_capture_reg:  std_logic;
6707
   -- Error Code Capture Register 
6708
   SIGNAL read_error_code_capture_reg     :  std_logic;
6709
   SIGNAL error_capture_code       :  std_logic_vector(7 DOWNTO 0);
6710
   -- Bus Timing 0 register 
6711
   SIGNAL baud_r_presc             :  std_logic_vector(5 DOWNTO 0);
6712
   SIGNAL sync_jump_width          :  std_logic_vector(1 DOWNTO 0);
6713
   -- Bus Timing 1 register 
6714
   SIGNAL time_segment1            :  std_logic_vector(3 DOWNTO 0);
6715
   SIGNAL time_segment2            :  std_logic_vector(2 DOWNTO 0);
6716
   SIGNAL triple_sampling          :  std_logic;
6717
   -- Error Warning Limit register 
6718
   SIGNAL error_warning_limit      :  std_logic_vector(7 DOWNTO 0);
6719
   -- Rx Error Counter register 
6720
   SIGNAL we_rx_err_cnt            :  std_logic;
6721
   -- Tx Error Counter register 
6722
   SIGNAL we_tx_err_cnt            :  std_logic;
6723
   -- Clock Divider register 
6724
   SIGNAL extended_mode            :  std_logic;
6725
   -- This section is for BASIC and EXTENDED mode 
6726
   -- Acceptance code register 
6727
   SIGNAL acceptance_code_0        :  std_logic_vector(7 DOWNTO 0);
6728
   -- Acceptance mask register 
6729
   SIGNAL acceptance_mask_0        :  std_logic_vector(7 DOWNTO 0);
6730
   -- End: This section is for BASIC and EXTENDED mode 
6731
   -- This section is for EXTENDED mode 
6732
   -- Acceptance code register 
6733
   SIGNAL acceptance_code_1        :  std_logic_vector(7 DOWNTO 0);
6734
   SIGNAL acceptance_code_2        :  std_logic_vector(7 DOWNTO 0);
6735
   SIGNAL acceptance_code_3        :  std_logic_vector(7 DOWNTO 0);
6736
   -- Acceptance mask register 
6737
   SIGNAL acceptance_mask_1        :  std_logic_vector(7 DOWNTO 0);
6738
   SIGNAL acceptance_mask_2        :  std_logic_vector(7 DOWNTO 0);
6739
   SIGNAL acceptance_mask_3        :  std_logic_vector(7 DOWNTO 0);
6740
   -- End: This section is for EXTENDED mode 
6741
   -- Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data 
6742
   SIGNAL tx_data_0                :  std_logic_vector(7 DOWNTO 0);
6743
   SIGNAL tx_data_1                :  std_logic_vector(7 DOWNTO 0);
6744
   SIGNAL tx_data_2                :  std_logic_vector(7 DOWNTO 0);
6745
   SIGNAL tx_data_3                :  std_logic_vector(7 DOWNTO 0);
6746
   SIGNAL tx_data_4                :  std_logic_vector(7 DOWNTO 0);
6747
   SIGNAL tx_data_5                :  std_logic_vector(7 DOWNTO 0);
6748
   SIGNAL tx_data_6                :  std_logic_vector(7 DOWNTO 0);
6749
   SIGNAL tx_data_7                :  std_logic_vector(7 DOWNTO 0);
6750
   SIGNAL tx_data_8                :  std_logic_vector(7 DOWNTO 0);
6751
   SIGNAL tx_data_9                :  std_logic_vector(7 DOWNTO 0);
6752
   SIGNAL tx_data_10               :  std_logic_vector(7 DOWNTO 0);
6753
   SIGNAL tx_data_11               :  std_logic_vector(7 DOWNTO 0);
6754
   SIGNAL tx_data_12               :  std_logic_vector(7 DOWNTO 0);
6755
   -- End: Tx data registers 
6756
--   SIGNAL cs                       :  std_logic;   
6757
   -- Output signals from can_btl module 
6758
   SIGNAL sample_point             :  std_logic;
6759
   SIGNAL sampled_bit              :  std_logic;
6760
   SIGNAL sampled_bit_q            :  std_logic;
6761
   SIGNAL tx_point                 :  std_logic;
6762
   SIGNAL hard_sync                :  std_logic;
6763
   -- output from can_bsp module 
6764
   SIGNAL rx_idle                  :  std_logic;
6765
   SIGNAL transmitting             :  std_logic;
6766
   SIGNAL transmitter              :  std_logic;
6767
   SIGNAL go_rx_inter              :  std_logic;
6768
   SIGNAL not_first_bit_of_inter   :  std_logic;
6769
   SIGNAL set_reset_mode           :  std_logic;
6770
   SIGNAL node_bus_off             :  std_logic;
6771
   SIGNAL error_status             :  std_logic;
6772
   SIGNAL rx_err_cnt               :  std_logic_vector(7 DOWNTO 0);
6773
   SIGNAL tx_err_cnt               :  std_logic_vector(7 DOWNTO 0);
6774
   SIGNAL rx_err_cnt_dummy         :  std_logic;   --  The MSB is not displayed. It is just used for easier calculation (no counter overflow).
6775
   SIGNAL tx_err_cnt_dummy         :  std_logic;   --  The MSB is not displayed. It is just used for easier calculation (no counter overflow).
6776
   SIGNAL transmit_status          :  std_logic;
6777
   SIGNAL receive_status           :  std_logic;
6778
   SIGNAL tx_successful            :  std_logic;
6779
   SIGNAL need_to_tx               :  std_logic;
6780
   SIGNAL overrun                  :  std_logic;
6781
   SIGNAL info_empty               :  std_logic;
6782
   SIGNAL set_bus_error_irq        :  std_logic;
6783
   SIGNAL set_arbitration_lost_irq :  std_logic;
6784
   SIGNAL arbitration_lost_capture :  std_logic_vector(4 DOWNTO 0);
6785
   SIGNAL node_error_passive       :  std_logic;
6786
   SIGNAL node_error_active        :  std_logic;
6787
   SIGNAL rx_message_counter       :  std_logic_vector(6 DOWNTO 0);
6788
   SIGNAL tx_next                  :  std_logic;
6789
   SIGNAL go_overload_frame        :  std_logic;
6790
   SIGNAL go_error_frame           :  std_logic;
6791
   SIGNAL go_tx                    :  std_logic;
6792
   SIGNAL send_ack                 :  std_logic;
6793
--   SIGNAL rst                      :  std_logic;   
6794
--   SIGNAL we                       :  std_logic;   
6795
--   SIGNAL addr                     :  std_logic_vector(7 DOWNTO 0);   
6796
--   SIGNAL data_in                  :  std_logic_vector(7 DOWNTO 0);   
6797
--   SIGNAL data_out                 :  std_logic_vector(7 DOWNTO 0);   
6798
   SIGNAL rx_sync_tmp              :  std_logic;
6799
   SIGNAL rx_sync                  :  std_logic;
6800
   -- port connections for Ram
6801
   --64x8
6802
   SIGNAL w_q_dp_64x8              :  std_logic_vector(7 DOWNTO 0);
6803
   SIGNAL w_data_64x8              :  std_logic_vector(7 DOWNTO 0);
6804
   SIGNAL w_wren_64x8              :  std_logic;
6805
   SIGNAL w_rden_64x8              :  std_logic;
6806
   SIGNAL w_wraddress_64x8         :  std_logic_vector(5 DOWNTO 0);
6807
   SIGNAL w_rdaddress_64x8         :  std_logic_vector(5 DOWNTO 0);
6808
   --64x4
6809
   SIGNAL w_q_dp_64x4              :  std_logic_vector(3 DOWNTO 0);
6810
   SIGNAL w_data_64x4              :  std_logic_vector(3 DOWNTO 0);
6811
   SIGNAL w_wren_64x4x1            :  std_logic;
6812
   SIGNAL w_wraddress_64x4x1       :  std_logic_vector(5 DOWNTO 0);
6813
   SIGNAL w_rdaddress_64x4x1       :  std_logic_vector(5 DOWNTO 0);
6814
   --64x1
6815
   SIGNAL w_q_dp_64x1              :  std_logic;
6816
   SIGNAL w_data_64x1              :  std_logic;
6817
   -- From btl module 
6818
   -- Mode register 
6819
   -- Command register 
6820
   -- Arbitration Lost Capture Register 
6821
   -- Error Code Capture Register 
6822
   -- Error Warning Limit register 
6823
   -- Rx Error Counter register 
6824
   -- Tx Error Counter register 
6825
   -- Clock Divider register 
6826
   -- output from can_bsp module 
6827
   SIGNAL xhdl_148                 :  std_logic_vector(8 DOWNTO 0);
6828
   -- The MSB is not displayed. It is just used for easier calculation (no counter overflow).
6829
   SIGNAL xhdl_150                 :  std_logic_vector(8 DOWNTO 0);
6830
--   SIGNAL wb_dat_o_xhdl1           :  std_logic_vector(7 DOWNTO 0);   
6831
--   SIGNAL wb_ack_o_xhdl2           :  std_logic;   
6832
   SIGNAL tx_o_xhdl3               :  std_logic;
6833
   SIGNAL bus_off_on_xhdl4         :  std_logic;
6834
   SIGNAL irq_on_xhdl5             :  std_logic;
6835
   SIGNAL clkout_o_xhdl6           :  std_logic;
6836
   SIGNAL data_64x8_xhdl7          :  std_logic_vector(7 DOWNTO 0);
6837
   SIGNAL wren_64x8_xhdl8          :  std_logic;
6838
   SIGNAL rden_64x8_xhdl9          :  std_logic;
6839
   SIGNAL wraddress_64x8_xhdl10    :  std_logic_vector(5 DOWNTO 0);
6840
   SIGNAL rdaddress_64x8_xhdl11    :  std_logic_vector(5 DOWNTO 0);
6841
   SIGNAL data_64x4_xhdl12         :  std_logic_vector(3 DOWNTO 0);
6842
   SIGNAL wren_64x4x1_xhdl13       :  std_logic;
6843
   SIGNAL wraddress_64x4x1_xhdl14  :  std_logic_vector(5 DOWNTO 0);
6844
   SIGNAL rdaddress_64x4x1_xhdl15  :  std_logic_vector(5 DOWNTO 0);
6845
   SIGNAL data_64x1_xhdl16         :  std_logic;
6846
   SIGNAL rx_inter                 :  std_logic;
6847
 
6848
BEGIN
6849
--   wb_dat_o <= wb_dat_o_xhdl1;
6850
--   wb_ack_o <= wb_ack_o_xhdl2;
6851
   tx_o <= tx_o_xhdl3;
6852
   bus_off_on <= bus_off_on_xhdl4;
6853
   irq_on <= irq_on_xhdl5;
6854
   clkout_o <= clkout_o_xhdl6;
6855
   data_64x8 <= data_64x8_xhdl7;
6856
   wren_64x8 <= wren_64x8_xhdl8;
6857
   rden_64x8 <= rden_64x8_xhdl9;
6858
   wraddress_64x8 <= wraddress_64x8_xhdl10;
6859
   rdaddress_64x8 <= rdaddress_64x8_xhdl11;
6860
   data_64x4 <= data_64x4_xhdl12;
6861
   wren_64x4x1 <= wren_64x4x1_xhdl13;
6862
   wraddress_64x4x1 <= wraddress_64x4x1_xhdl14;
6863
   rdaddress_64x4x1 <= rdaddress_64x4x1_xhdl15;
6864
   data_64x1 <= data_64x1_xhdl16;
6865
   -- port connections for Ram
6866
   --64x8
6867
   w_q_dp_64x8 <= q_dp_64x8 ;
6868
   data_64x8_xhdl7 <= w_data_64x8 ;
6869
   wren_64x8_xhdl8 <= w_wren_64x8 ;
6870
   rden_64x8_xhdl9 <= w_rden_64x8 ;
6871
   wraddress_64x8_xhdl10 <= w_wraddress_64x8 ;
6872
   rdaddress_64x8_xhdl11 <= w_rdaddress_64x8 ;
6873
   --64x4
6874
   w_q_dp_64x4 <= q_dp_64x4 ;
6875
   data_64x4_xhdl12 <= w_data_64x4 ;
6876
   wren_64x4x1_xhdl13 <= w_wren_64x4x1 ;
6877
   wraddress_64x4x1_xhdl14 <= w_wraddress_64x4x1 ;
6878
   rdaddress_64x4x1_xhdl15 <= w_rdaddress_64x4x1 ;
6879
   --64x1
6880
   w_q_dp_64x1 <= q_dp_64x1 ;
6881
   data_64x1_xhdl16 <= w_data_64x1 ;
6882
 
6883
   -- Connecting can_registers module -- Mode register -- Command register -- Arbitration Lost Capture Register -- Error Code Capture Register -- Bus Timing 0 register -- Bus Timing 1 register -- Error Warning Limit register -- Rx Error Counter register -- Tx Error Counter register -- Clock Divider register -- This section is for BASIC and EXTENDED mode -- Acceptance code register -- Acceptance mask register -- End: This section is for BASIC and EXTENDED mode -- This section is for EXTENDED mode -- Acceptance code register -- Acceptance mask register -- End: This section is for EXTENDED mode -- Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data -- End: Tx data registers 
6884
   i_can_registers : can_registers
6885
      PORT MAP (
6886
         clk => clk_i,
6887
         rst => rst,
6888
         cs => cs,
6889
         we => we,
6890
         addr => addr,
6891
         data_in => data_in,
6892
         data_out => data_out_regs,
6893
         irq_n => irq_on_xhdl5,
6894
         sample_point => sample_point,
6895
         transmitting => transmitting,
6896
         set_reset_mode => set_reset_mode,
6897
         node_bus_off => node_bus_off,
6898
         error_status => error_status,
6899
         rx_err_cnt => rx_err_cnt,
6900
         tx_err_cnt => tx_err_cnt,
6901
         transmit_status => transmit_status,
6902
         receive_status => receive_status,
6903
         tx_successful => tx_successful,
6904
         need_to_tx => need_to_tx,
6905
         overrun => overrun,
6906
         info_empty => info_empty,
6907
         set_bus_error_irq => set_bus_error_irq,
6908
         set_arbitration_lost_irq => set_arbitration_lost_irq,
6909
         arbitration_lost_capture => arbitration_lost_capture,
6910
         node_error_passive => node_error_passive,
6911
         node_error_active => node_error_active,
6912
         rx_message_counter => rx_message_counter,
6913
         reset_mode => reset_mode,
6914
         listen_only_mode => listen_only_mode,
6915
         acceptance_filter_mode => acceptance_filter_mode,
6916
         self_test_mode => self_test_mode,
6917
         clear_data_overrun => open,
6918
         release_buffer => release_buffer,
6919
         abort_tx => abort_tx,
6920
         tx_request => tx_request,
6921
         self_rx_request => self_rx_request,
6922
         single_shot_transmission => single_shot_transmission,
6923
         tx_state => tx_state,
6924
         tx_state_q => tx_state_q,
6925
         overload_request => overload_request,
6926
         overload_frame => overload_frame,
6927
         read_arbitration_lost_capture_reg => read_arbitration_lost_capture_reg,
6928
         read_error_code_capture_reg => read_error_code_capture_reg,
6929
         error_capture_code => error_capture_code,
6930
         baud_r_presc => baud_r_presc,
6931
         sync_jump_width => sync_jump_width,
6932
         time_segment1 => time_segment1,
6933
         time_segment2 => time_segment2,
6934
         triple_sampling => triple_sampling,
6935
         error_warning_limit => error_warning_limit,
6936
         we_rx_err_cnt => we_rx_err_cnt,
6937
         we_tx_err_cnt => we_tx_err_cnt,
6938
         extended_mode => extended_mode,
6939
         clkout => clkout_o_xhdl6,
6940
         acceptance_code_0 => acceptance_code_0,
6941
         acceptance_mask_0 => acceptance_mask_0,
6942
         acceptance_code_1 => acceptance_code_1,
6943
         acceptance_code_2 => acceptance_code_2,
6944
         acceptance_code_3 => acceptance_code_3,
6945
         acceptance_mask_1 => acceptance_mask_1,
6946
         acceptance_mask_2 => acceptance_mask_2,
6947
         acceptance_mask_3 => acceptance_mask_3,
6948
         tx_data_0 => tx_data_0,
6949
         tx_data_1 => tx_data_1,
6950
         tx_data_2 => tx_data_2,
6951
         tx_data_3 => tx_data_3,
6952
         tx_data_4 => tx_data_4,
6953
         tx_data_5 => tx_data_5,
6954
         tx_data_6 => tx_data_6,
6955
         tx_data_7 => tx_data_7,
6956
         tx_data_8 => tx_data_8,
6957
         tx_data_9 => tx_data_9,
6958
         tx_data_10 => tx_data_10,
6959
         tx_data_11 => tx_data_11,
6960
         tx_data_12 => tx_data_12);
6961
 
6962
 
6963
   -- Connecting can_btl module -- Bus Timing 0 register -- Bus Timing 1 register -- Output signals from this module -- output from can_bsp module 
6964
   i_can_btl : can_btl
6965
      PORT MAP (
6966
         clk => clk_i,
6967
         rst => rst,
6968
         rx => rx_sync,
6969
         tx => tx_o_xhdl3,
6970
         baud_r_presc => baud_r_presc,
6971
         sync_jump_width => sync_jump_width,
6972
         time_segment1 => time_segment1,
6973
         time_segment2 => time_segment2,
6974
         triple_sampling => triple_sampling,
6975
         sample_point => sample_point,
6976
         sampled_bit => sampled_bit,
6977
         sampled_bit_q => sampled_bit_q,
6978
         tx_point => tx_point,
6979
         hard_sync => hard_sync,
6980
         rx_idle => rx_idle,
6981
         rx_inter => rx_inter,
6982
         transmitting => transmitting,
6983
         transmitter => transmitter,
6984
         go_rx_inter => go_rx_inter,
6985
         tx_next => tx_next,
6986
         go_overload_frame => go_overload_frame,
6987
         go_error_frame => go_error_frame,
6988
         go_tx => go_tx,
6989
         send_ack => send_ack,
6990
         node_error_passive => node_error_passive);
6991
 
6992
--   xhdl_148 <= rx_err_cnt_dummy & rx_err_cnt(7 DOWNTO 0);
6993
   rx_err_cnt_dummy <= xhdl_148(8);
6994
   rx_err_cnt(7 DOWNTO 0) <= xhdl_148(7 DOWNTO 0);
6995
--   xhdl_150 <= tx_err_cnt_dummy & tx_err_cnt(7 DOWNTO 0);
6996
   tx_err_cnt_dummy <= xhdl_150(8);
6997
   tx_err_cnt(7 DOWNTO 0) <= xhdl_150(7 DOWNTO 0);
6998
 
6999
   -- The MSB is not displayed. It is just used for easier calculation (no counter overflow).
7000
   -- This section is for BASIC and EXTENDED mode -- Acceptance code register -- Acceptance mask register -- End: This section is for BASIC and EXTENDED mode -- This section is for EXTENDED mode -- Acceptance code register -- Acceptance mask register -- End: This section is for EXTENDED mode -- Tx data registers. Holding identifier (basic mode), tx frame information (extended mode) and data -- End: Tx data registers -- Tx signal -- port connections for Ram
7001
   --64x8
7002
   --64x4
7003
   --64x1
7004
   i_can_bsp : can_bsp
7005
      PORT MAP (
7006
         clk => clk_i,
7007
         rst => rst,
7008
         sample_point => sample_point,
7009
         sampled_bit => sampled_bit,
7010
         sampled_bit_q => sampled_bit_q,
7011
         tx_point => tx_point,
7012
         hard_sync => hard_sync,
7013
         addr => addr,
7014
         data_in => data_in,
7015
         data_out => data_out_fifo,
7016
         fifo_selected => data_out_fifo_selected,
7017
         reset_mode => reset_mode,
7018
         listen_only_mode => listen_only_mode,
7019
         acceptance_filter_mode => acceptance_filter_mode,
7020
         self_test_mode => self_test_mode,
7021
         release_buffer => release_buffer,
7022
         tx_request => tx_request,
7023
         abort_tx => abort_tx,
7024
         self_rx_request => self_rx_request,
7025
         single_shot_transmission => single_shot_transmission,
7026
         tx_state => tx_state,
7027
         tx_state_q => tx_state_q,
7028
         overload_request => overload_request,
7029
         overload_frame => overload_frame,
7030
         read_arbitration_lost_capture_reg => read_arbitration_lost_capture_reg,
7031
         read_error_code_capture_reg => read_error_code_capture_reg,
7032
         error_capture_code => error_capture_code,
7033
         error_warning_limit => error_warning_limit,
7034
         we_rx_err_cnt => we_rx_err_cnt,
7035
         we_tx_err_cnt => we_tx_err_cnt,
7036
         extended_mode => extended_mode,
7037
         rx_idle => rx_idle,
7038
         transmitting => transmitting,
7039
         transmitter => transmitter,
7040
         go_rx_inter => go_rx_inter,
7041
         not_first_bit_of_inter => not_first_bit_of_inter,
7042
         rx_inter => rx_inter,
7043
         set_reset_mode => set_reset_mode,
7044
         node_bus_off => node_bus_off,
7045
         error_status => error_status,
7046
         rx_err_cnt => xhdl_148,
7047
         tx_err_cnt => xhdl_150,
7048
         transmit_status => transmit_status,
7049
         receive_status => receive_status,
7050
         tx_successful => tx_successful,
7051
         need_to_tx => need_to_tx,
7052
         overrun => overrun,
7053
         info_empty => info_empty,
7054
         set_bus_error_irq => set_bus_error_irq,
7055
         set_arbitration_lost_irq => set_arbitration_lost_irq,
7056
         arbitration_lost_capture => arbitration_lost_capture,
7057
         node_error_passive => node_error_passive,
7058
         node_error_active => node_error_active,
7059
         rx_message_counter => rx_message_counter,
7060
         acceptance_code_0 => acceptance_code_0,
7061
         acceptance_mask_0 => acceptance_mask_0,
7062
         acceptance_code_1 => acceptance_code_1,
7063
         acceptance_code_2 => acceptance_code_2,
7064
         acceptance_code_3 => acceptance_code_3,
7065
         acceptance_mask_1 => acceptance_mask_1,
7066
         acceptance_mask_2 => acceptance_mask_2,
7067
         acceptance_mask_3 => acceptance_mask_3,
7068
         tx_data_0 => tx_data_0,
7069
         tx_data_1 => tx_data_1,
7070
         tx_data_2 => tx_data_2,
7071
         tx_data_3 => tx_data_3,
7072
         tx_data_4 => tx_data_4,
7073
         tx_data_5 => tx_data_5,
7074
         tx_data_6 => tx_data_6,
7075
         tx_data_7 => tx_data_7,
7076
         tx_data_8 => tx_data_8,
7077
         tx_data_9 => tx_data_9,
7078
         tx_data_10 => tx_data_10,
7079
         tx_data_11 => tx_data_11,
7080
         tx_data_12 => tx_data_12,
7081
         tx => tx_o_xhdl3,
7082
         tx_next => tx_next,
7083
         bus_off_on => bus_off_on_xhdl4,
7084
         go_overload_frame => go_overload_frame,
7085
         go_error_frame => go_error_frame,
7086
         go_tx => go_tx,
7087
         send_ack => send_ack,
7088
         q_dp_64x8 => w_q_dp_64x8,
7089
         data_64x8 => w_data_64x8,
7090
         wren_64x8 => w_wren_64x8,
7091
         rden_64x8 => w_rden_64x8,
7092
         wraddress_64x8 => w_wraddress_64x8,
7093
         rdaddress_64x8 => w_rdaddress_64x8,
7094
         q_dp_64x4 => w_q_dp_64x4,
7095
         data_64x4 => w_data_64x4,
7096
         wren_64x4x1 => w_wren_64x4x1,
7097
         wraddress_64x4x1 => w_wraddress_64x4x1,
7098
         rdaddress_64x4x1 => w_rdaddress_64x4x1,
7099
         q_dp_64x1 => w_q_dp_64x1,
7100
         data_64x1 => w_data_64x1);
7101
 
7102
 
7103
   -- Multiplexing wb_dat_o from registers and rx fifo
7104
 
7105
   PROCESS (extended_mode, addr, reset_mode)
7106
      VARIABLE data_out_fifo_selected_xhdl203  : std_logic;
7107
   BEGIN
7108
      IF ((((extended_mode AND (NOT reset_mode)) AND CONV_STD_LOGIC((addr >= "00010000") AND (addr<="00011100"))) OR ((NOT extended_mode) AND CONV_STD_LOGIC((addr >= "00010100") AND (addr<="00011101")))) = '1') THEN
7109
         data_out_fifo_selected_xhdl203 := '1';
7110
      ELSE
7111
         data_out_fifo_selected_xhdl203 := '0';
7112
      END IF;
7113
      data_out_fifo_selected <= data_out_fifo_selected_xhdl203;
7114
   END PROCESS;
7115
 
7116
   PROCESS (clk_i)
7117
   BEGIN
7118
      IF (clk_i'EVENT AND clk_i = '1') THEN
7119
         IF ((cs AND (NOT we)) = '1') THEN
7120
            IF (data_out_fifo_selected = '1') THEN
7121
               data_out <= data_out_fifo ;
7122
            ELSE
7123
               data_out <= data_out_regs ;
7124
            END IF;
7125
         END IF;
7126
      END IF;
7127
   END PROCESS;
7128
 
7129
   PROCESS (clk_i, rst)
7130
   BEGIN
7131
      IF (rst = '1') THEN
7132
         rx_sync_tmp <= '1';
7133
         rx_sync <= '1';
7134
      ELSIF (clk_i'EVENT AND clk_i = '1') THEN
7135
         rx_sync_tmp <= rx_i ;
7136
         rx_sync <= rx_sync_tmp ;
7137
      END IF;
7138
   END PROCESS;
7139
--   cs_can_i <= '1' ;
7140
 
7141
   -- Combining wb_cyc_i and wb_stb_i signals to cs signal. Than synchronizing to clk_i clock domain. 
7142
 
7143
--   PROCESS (clk_i, rst)
7144
--   BEGIN
7145
--      IF (rst = '1') THEN
7146
--         cs_sync1 <= '0';    
7147
--         cs_sync2 <= '0';    
7148
--         cs_sync3 <= '0';    
7149
--         cs_sync_rst1 <= '0';    
7150
--         cs_sync_rst2 <= '0';    
7151
--      ELSIF (clk_i'EVENT AND clk_i = '1') THEN
7152
--         cs_sync1 <= ((wb_cyc_i AND wb_stb_i) AND (NOT cs_sync_rst2)) AND cs_can_i ;    
7153
--        cs_sync2 <= cs_sync1 AND (NOT cs_sync_rst2) ;    
7154
--        cs_sync3 <= cs_sync2 AND (NOT cs_sync_rst2) ;    
7155
--        cs_sync_rst1 <= cs_ack3 ;    
7156
--        cs_sync_rst2 <= cs_sync_rst1 ;    
7157
--     END IF;
7158
--  END PROCESS;
7159
--  cs <= cs_sync2 AND (NOT cs_sync3) ;
7160
--
7161
--   PROCESS (wb_clk_i)
7162
--   BEGIN
7163
--      IF (wb_clk_i'EVENT AND wb_clk_i = '1') THEN
7164
--         cs_ack1 <= cs_sync3 ;    
7165
--         cs_ack2 <= cs_ack1 ;    
7166
--         cs_ack3 <= cs_ack2 ;    
7167
--      END IF;
7168
--   END PROCESS;
7169
 
7170
   -- Generating acknowledge signal
7171
 
7172
--   PROCESS (wb_clk_i)
7173
--   BEGIN
7174
--      IF (wb_clk_i'EVENT AND wb_clk_i = '1') THEN
7175
--         wb_ack_o_xhdl2 <= cs_ack2 AND (NOT cs_ack3) ;    
7176
--      END IF;
7177
--   END PROCESS;
7178
--   rst <= wb_rst_i ;
7179
--   we <= wb_we_i ;
7180
--   addr <= wb_adr_i ;
7181
--   data_in <= wb_dat_i ;
7182
--   wb_dat_o_xhdl1 <= data_out ;
7183
 
7184
 
7185
 
7186
END ARCHITECTURE RTL;

powered by: WebSVN 2.1.0

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