1 |
2 |
dimamali |
------------------------------------------------------------------------------
|
2 |
|
|
-- This file is a part of the GRLIB VHDL IP LIBRARY
|
3 |
|
|
-- Copyright (C) 2003, Gaisler Research
|
4 |
|
|
--
|
5 |
|
|
-- This program is free software; you can redistribute it and/or modify
|
6 |
|
|
-- it under the terms of the GNU General Public License as published by
|
7 |
|
|
-- the Free Software Foundation; either version 2 of the License, or
|
8 |
|
|
-- (at your option) any later version.
|
9 |
|
|
--
|
10 |
|
|
-- This program is distributed in the hope that it will be useful,
|
11 |
|
|
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
|
|
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
|
|
-- GNU General Public License for more details.
|
14 |
|
|
--
|
15 |
|
|
-- You should have received a copy of the GNU General Public License
|
16 |
|
|
-- along with this program; if not, write to the Free Software
|
17 |
|
|
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
18 |
|
|
-----------------------------------------------------------------------------
|
19 |
|
|
-- Package: can
|
20 |
|
|
-- File: can.vhd
|
21 |
|
|
-- Author: Jiri Gaisler - Gaisler Research
|
22 |
|
|
-- Description: CAN component declartions
|
23 |
|
|
------------------------------------------------------------------------------
|
24 |
|
|
|
25 |
|
|
library ieee;
|
26 |
|
|
use ieee.std_logic_1164.all;
|
27 |
|
|
|
28 |
|
|
library grlib;
|
29 |
|
|
use grlib.amba.all;
|
30 |
|
|
library techmap;
|
31 |
|
|
use techmap.gencomp.all;
|
32 |
|
|
|
33 |
|
|
package can is
|
34 |
|
|
|
35 |
|
|
component can_mod
|
36 |
|
|
generic (memtech : integer := DEFMEMTECH; syncrst : integer := 0;
|
37 |
|
|
ft : integer := 0);
|
38 |
|
|
port (
|
39 |
|
|
reset : in std_logic;
|
40 |
|
|
clk : in std_logic;
|
41 |
|
|
cs : in std_logic;
|
42 |
|
|
we : in std_logic;
|
43 |
|
|
addr : in std_logic_vector(7 downto 0);
|
44 |
|
|
data_in : in std_logic_vector(7 downto 0);
|
45 |
|
|
data_out: out std_logic_vector(7 downto 0);
|
46 |
|
|
irq : out std_logic;
|
47 |
|
|
rxi : in std_logic;
|
48 |
|
|
txo : out std_logic;
|
49 |
|
|
testen : in std_logic);
|
50 |
|
|
end component;
|
51 |
|
|
|
52 |
|
|
component can_oc
|
53 |
|
|
generic (
|
54 |
|
|
slvndx : integer := 0;
|
55 |
|
|
ioaddr : integer := 16#000#;
|
56 |
|
|
iomask : integer := 16#FF0#;
|
57 |
|
|
irq : integer := 0;
|
58 |
|
|
memtech : integer := DEFMEMTECH;
|
59 |
|
|
syncrst : integer := 0;
|
60 |
|
|
ft : integer := 0);
|
61 |
|
|
port (
|
62 |
|
|
resetn : in std_logic;
|
63 |
|
|
clk : in std_logic;
|
64 |
|
|
ahbsi : in ahb_slv_in_type;
|
65 |
|
|
ahbso : out ahb_slv_out_type;
|
66 |
|
|
can_rxi : in std_logic;
|
67 |
|
|
can_txo : out std_logic
|
68 |
|
|
);
|
69 |
|
|
end component;
|
70 |
|
|
|
71 |
|
|
component can_mc
|
72 |
|
|
generic (
|
73 |
|
|
slvndx : integer := 0;
|
74 |
|
|
ioaddr : integer := 16#000#;
|
75 |
|
|
iomask : integer := 16#FF0#;
|
76 |
|
|
irq : integer := 0;
|
77 |
|
|
memtech : integer := DEFMEMTECH;
|
78 |
|
|
ncores : integer range 1 to 8 := 1;
|
79 |
|
|
sepirq : integer range 0 to 1 := 0;
|
80 |
|
|
syncrst : integer range 0 to 1 := 0;
|
81 |
|
|
ft : integer range 0 to 1 := 0);
|
82 |
|
|
port (
|
83 |
|
|
resetn : in std_logic;
|
84 |
|
|
clk : in std_logic;
|
85 |
|
|
ahbsi : in ahb_slv_in_type;
|
86 |
|
|
ahbso : out ahb_slv_out_type;
|
87 |
|
|
can_rxi : in std_logic_vector(0 to 7);
|
88 |
|
|
can_txo : out std_logic_vector(0 to 7)
|
89 |
|
|
);
|
90 |
|
|
end component;
|
91 |
|
|
|
92 |
|
|
component can_rd
|
93 |
|
|
generic (
|
94 |
|
|
slvndx : integer := 0;
|
95 |
|
|
ioaddr : integer := 16#000#;
|
96 |
|
|
iomask : integer := 16#FF0#;
|
97 |
|
|
irq : integer := 0;
|
98 |
|
|
memtech : integer := DEFMEMTECH;
|
99 |
|
|
syncrst : integer := 0;
|
100 |
|
|
dmap : integer := 0);
|
101 |
|
|
port (
|
102 |
|
|
resetn : in std_logic;
|
103 |
|
|
clk : in std_logic;
|
104 |
|
|
ahbsi : in ahb_slv_in_type;
|
105 |
|
|
ahbso : out ahb_slv_out_type;
|
106 |
|
|
can_rxi : in std_logic_vector(1 downto 0);
|
107 |
|
|
can_txo : out std_logic_vector(1 downto 0)
|
108 |
|
|
);
|
109 |
|
|
end component;
|
110 |
|
|
|
111 |
|
|
component canmux
|
112 |
|
|
port(
|
113 |
|
|
sel : in std_logic;
|
114 |
|
|
canrx : out std_logic;
|
115 |
|
|
cantx : in std_logic;
|
116 |
|
|
canrxv : in std_logic_vector(0 to 1);
|
117 |
|
|
cantxv : out std_logic_vector(0 to 1)
|
118 |
|
|
);
|
119 |
|
|
end component;
|
120 |
|
|
|
121 |
|
|
-----------------------------------------------------------------------------
|
122 |
|
|
-- interface type declarations for can controller
|
123 |
|
|
-----------------------------------------------------------------------------
|
124 |
|
|
type can_in_type is record
|
125 |
|
|
rx: std_logic_vector(1 downto 0); -- receive lines
|
126 |
|
|
end record;
|
127 |
|
|
|
128 |
|
|
type can_out_type is record
|
129 |
|
|
tx: std_logic_vector(1 downto 0); -- transmit lines
|
130 |
|
|
en: std_logic_vector(1 downto 0); -- transmit enables
|
131 |
|
|
end record;
|
132 |
|
|
|
133 |
|
|
-----------------------------------------------------------------------------
|
134 |
|
|
-- component declaration for grcan controller
|
135 |
|
|
-----------------------------------------------------------------------------
|
136 |
|
|
component grcan is
|
137 |
|
|
generic (
|
138 |
|
|
hindex: integer := 0;
|
139 |
|
|
pindex: integer := 0;
|
140 |
|
|
paddr: integer := 0;
|
141 |
|
|
pmask: integer := 16#ffc#;
|
142 |
|
|
pirq: integer := 1; -- index of first irq
|
143 |
|
|
singleirq: integer := 0; -- single irq output
|
144 |
|
|
txchannels: integer range 1 to 16 := 1; -- 1 to 16 channels
|
145 |
|
|
rxchannels: integer range 1 to 16 := 1; -- 1 to 16 channels
|
146 |
|
|
ptrwidth: integer range 4 to 16 := 16); -- 16 to 64k messages
|
147 |
|
|
-- 2k to 8M bits
|
148 |
|
|
port (
|
149 |
|
|
rstn: in std_ulogic;
|
150 |
|
|
clk: in std_ulogic;
|
151 |
|
|
apbi: in apb_slv_in_type;
|
152 |
|
|
apbo: out apb_slv_out_type;
|
153 |
|
|
ahbi: in ahb_mst_in_type;
|
154 |
|
|
ahbo: out ahb_mst_out_type;
|
155 |
|
|
cani: in can_in_type;
|
156 |
|
|
cano: out can_out_type);
|
157 |
|
|
end component;
|
158 |
|
|
|
159 |
|
|
end;
|