All Classes Namespaces Files Functions Variables Groups Pages
ExamplePkg.vhd
Go to the documentation of this file.
1 -- ************************************************************************** --
2 -- ************* BittWare Incorporated ************* --
3 -- ************* 9 Hills Ave, Concord, NH 03301 ************* --
4 -- ************************************************************************** --
5 -- LEGAL NOTICE: --
6 -- Copyright (c) 2011 BittWare, Inc. --
7 -- The user is hereby granted a non-exclusive license to use and or --
8 -- modify this code provided that it runs on BittWare hardware. --
9 -- Usage of this code on non-BittWare hardware without the express --
10 -- written permission of BittWare is strictly prohibited. --
11 -- --
12 -- E-mail: support@bittware.com Tel: 603-226-0404 --
13 -- ************************************************************************** --
14 
15 --------------------------------------------------------------------------------
16 -- Libraries
17 --------------------------------------------------------------------------------
18 
19 library ieee;
20 use ieee.std_logic_1164.all;
21 use ieee.numeric_std.all;
22 
23 use work.UtilityPkg.all;
24 use work.BoardInfoPkg.all;
25 use work.AvalonPkg.all;
26 use work.DMAPkg.all;
27 
28 --------------------------------------------------------------------------------
29 -- ABSTRACT:
30 --------------------------------------------------------------------------------
33 
34 --------------------------------------------------------------------------------
35 -- DESIGN DETAILS:
36 --------------------------------------------------------------------------------
38 
39 --------------------------------------------------------------------------------
40 -- NOTES:
41 --------------------------------------------------------------------------------
43 
44 --------------------------------------------------------------------------------
45 -- TODO:
46 --------------------------------------------------------------------------------
48 
49 --------------------------------------------------------------------------------
50 -- BUGS
51 --------------------------------------------------------------------------------
53 
54 --------------------------------------------------------------------------------
55 -- RETURN LINKS:
56 --------------------------------------------------------------------------------
58 
59 --------------------------------------------------------------------------------
60 package ExamplePkg is
61 --------------------------------------------------------------------------------
62 
63  ------------------------------------------------------------------------------
64  -- ExampleComponent
65  ------------------------------------------------------------------------------
66 
67  ---------------------------
68  -- Constant Declarations
69  ---------------------------
70 
72  constant CONST_VALUE : integer := 128;
73 
76  constant MY_CONSTANT : integer := bitWidth(CONST_VALUE);
77 
78  ---------------------------
79  -- Type Declarations
80  ---------------------------
81 
83  subtype MY_DATA_RANGE is natural range 7 downto 0;
84 
86  type MyType is array (natural range <>) of std_logic;
87 
89  type MyDataArray is array (natural range <>) of std_logic_vector(CONST_VALUE-1 downto 0);
90 
93  type MyRecord is record
95  valid : std_logic;
97  data : std_logic_vector(MY_DATA_RANGE);
98  end record;
99 
101  type ArrayOfMyRecord is array(natural range <>) of MyRecord;
102 
103  ---------------------------
104  -- Function Declarations
105  ---------------------------
106 
110  function myFunction return MyType;
111 
118  function myArgFunction( x : MyType; y, z : integer ) return MyType;
119 
120  ---------------------------
121  -- Component Declaration
122  ---------------------------
123 
124  component ExampleComponent is
125  generic (
126  -- Board Specific Args
127  BOARD_INFO : BoardInfo;
128  -- Streaming Input Interface Parameters
129  DATA_IN_INFO : AvalonSTInfo;
130  -- Streaming Output Interface Parameters.
131  DATA_OUT_INFO : AvalonSTInfo
132  );
133  port (
134  -- Slave Interface
135  slaveClk : in std_logic;
136  slaveReset : in std_logic;
137  slaveIRQ : out AvalonIRQSenderIntfArray(2 downto 0);
138  slaveIn : in AvalonMMFabricToSlaveIntf;
139  slaveInRsp : out AvalonMMSlaveToFabricIntf;
140  -- Streaming Clock/Reset
141  dataClk : in std_logic;
142  dataReset : in std_logic;
143  -- Streaming Input Interface
144  dataIn : in AvalonSTSourceToSinkIntf;
145  dataInRsp : out AvalonSTSinkToSourceIntf;
146  -- Streaming Output Interface
147  dataOut : out AvalonSTSourceToSinkIntf;
148  dataOutRsp : in AvalonSTSinkToSourceIntf
149  );
150  end component;
151 
152  ------------------------------------------------------------------------------
153  -- ExampleSubSystem
154  ------------------------------------------------------------------------------
155 
158  type ExampleSubSystemInfo is record
162  NUM_DMA_ENGINES : natural range 1 to DMA_MAX_ENGINES/2;
163  end record;
164 
166  constant DEFAULT_EXAMPLE_SUB_SYSTEM_INFO : ExampleSubSystemInfo := ( NUM_DMA_ENGINES => 1 );
167 
169  type ExampleSubSystemInfoArray is array (natural range <>) of ExampleSubSystemInfo;
170 
172 . function init( num_dma : natural := DEFAULT_EXAMPLE_SUB_SYSTEM_INFONUM_DMA_ENGINES ) return ExampleSubSystemInfo;
173 
176 
177  ---------------------------
178  -- Component Declaration
179  ---------------------------
180 
181  component ExampleSubSystem is
182  generic (
183  BOARD_INFO : BoardInfo;
184  SLAVE_OUT_INFO : AvalonMMSlaveInfo;
185  DATA_IN_INFO : AvalonSTInfoArray;
186  DATA_OUT_INFO : AvalonSTInfoArray;
188  );
189  port(
190  -- Memory Mapped Slave Control/Status Interface
191  slaveInClk : in std_logic;
192  slaveInReset : in std_logic;
193  slaveInIRQ : out AvalonIRQSenderIntf;
194  slaveIn : in AvalonMMFabricToSlaveIntf;
195  slaveInRsp : out AvalonMMSlaveToFabricIntf;
196  -- Memory Mapped Slave Output Interface
197  slaveOutClk : in std_logic;
198  slaveOutReset : in std_logic;
199  slaveOut : out AvalonMMFabricToSlaveIntf;
200  slaveOutRsp : in AvalonMMSlaveToFabricIntf;
201  -- Streaming Data Clock/Reset Interface
202  dataClk : in std_logic;
203  dataReset : in std_logic;
204  -- Streaming Data Input Interface
205  dataIn : in AvalonSTSourceToSinkIntfArray;
206  dataInRsp : out AvalonSTSinkToSourceIntfArray;
207  -- Streaming Data Output Interface
208  dataOut : out AvalonSTSourceToSinkIntfArray;
209  dataOutRsp : in AvalonSTSinkToSourceIntfArray
210  );
211  end component;
212 
213 --------------------------------------------------------------------------------
214 end package;
215 --------------------------------------------------------------------------------
216 
217 --------------------------------------------------------------------------------
218 -- BRIEF DESCRIPTION:
219 --------------------------------------------------------------------------------
222 
223 --------------------------------------------------------------------------------
224 package body ExamplePkg is
225 --------------------------------------------------------------------------------
226 
227  ------------------------------------------------------------------------------
228  ------------------------------------------------------------------------------
229  function myFunction return MyType is
230  variable r : MyType(0 to 1);
231  begin
232  -- Do stuff here...
233  return r;
234  end function;
235  ------------------------------------------------------------------------------
236  ------------------------------------------------------------------------------
237  function myArgFunction( x : MyType; y, z : integer ) return MyType is
238  variable r : MyType(7 downto 0);
239  begin
240  r := x;
241  if( y <= z ) then
242  -- Do some stuff...
243  elsif( y > z ) then
244  -- Do some other stuff...
245  end if;
246  return r;
247  end function;
248  ------------------------------------------------------------------------------
249  ------------------------------------------------------------------------------
250 . function init( num_dma : natural := DEFAULT_EXAMPLE_SUB_SYSTEM_INFONUM_DMA_ENGINES )
251  return ExampleSubSystemInfo is
252  variable r : ExampleSubSystemInfo;
253  begin
254  r.NUM_DMA_ENGINES := num_dma;
255  return r;
256  end function;
257  ------------------------------------------------------------------------------
258  ------------------------------------------------------------------------------
260  num : natural := 1 ) return ExampleSubSystemInfoArray is
261  variable r : ExampleSubSystemInfoArray(0 to num-1);
262  begin
263  r := (others => info);
264  return r;
265  end function;
266  ------------------------------------------------------------------------------
267  ------------------------------------------------------------------------------
268 
269 --------------------------------------------------------------------------------
270 end package body;
271 --------------------------------------------------------------------------------