Debian Codegraph @

hdl/fpga/ip/nuand/synthesis/fifo_readwrite_p.vhd

raw
1 -- Copyright (c) 2017 Nuand LLC
2 --
3 -- Permission is hereby granted, free of charge, to any person obtaining a copy
4 -- of this software and associated documentation files (the "Software"), to deal
5 -- in the Software without restriction, including without limitation the rights
6 -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 -- copies of the Software, and to permit persons to whom the Software is
8 -- furnished to do so, subject to the following conditions:
9 --
10 -- The above copyright notice and this permission notice shall be included in
11 -- all copies or substantial portions of the Software.
12 --
13 -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 -- THE SOFTWARE.
20
21 library ieee;
22 use ieee.std_logic_1164.all;
23 use ieee.numeric_std.all;
24
25 package fifo_readwrite_p is
26
27 type sample_control_t is record
28 enable : std_logic;
29 data_req : std_logic;
30 end record;
31
32 type sample_controls_t is array( natural range <> ) of sample_control_t;
33
34 type sample_stream_t is record
35 data_i : signed(15 downto 0);
36 data_q : signed(15 downto 0);
37 data_v : std_logic;
38 end record;
39
40 type sample_streams_t is array( natural range <> ) of sample_stream_t;
41
42 type packet_control_t is record
43 pkt_core_id : std_logic_vector(7 downto 0);
44 pkt_flags : std_logic_vector(7 downto 0);
45 pkt_sop : std_logic;
46 pkt_eop : std_logic;
47 data : std_logic_vector(31 downto 0);
48 data_valid : std_logic;
49 end record;
50
51 type packet_controls_t is array( natural range <> ) of packet_control_t;
52
53 constant SAMPLE_CONTROL_ENABLE : sample_control_t;
54 constant SAMPLE_CONTROL_DISABLE : sample_control_t;
55
56 constant PACKET_CONTROL_DEFAULT : packet_control_t;
57
58 constant ZERO_SAMPLE : sample_stream_t;
59
60 -- Count how many channels are enabled
61 function count_enabled_channels( x : sample_controls_t ) return natural;
62
63 end package;
64
65 package body fifo_readwrite_p is
66
67 constant SAMPLE_CONTROL_ENABLE : sample_control_t := (
68 enable => '1',
69 data_req => '1'
70 );
71
72 constant SAMPLE_CONTROL_DISABLE : sample_control_t := (
73 enable => '0',
74 data_req => '0'
75 );
76
77 constant PACKET_CONTROL_DEFAULT : packet_control_t := (
78 pkt_core_id => (others => '0'),
79 pkt_flags => (others => '0'),
80 pkt_sop => '0',
81 pkt_eop => '0',
82 data => (others => '0'),
83 data_valid => '0'
84 );
85
86
87 constant ZERO_SAMPLE : sample_stream_t := (
88 data_i => (others => '0'),
89 data_q => (others => '0'),
90 data_v => '0'
91 );
92
93 -- Count how many channels are enabled
94 function count_enabled_channels( x : sample_controls_t ) return natural is
95 variable rv : natural := 0;
96 begin
97 rv := 0;
98 for i in x'range loop
99 if( x(i).enable = '1' ) then
100 rv := rv + 1;
101 end if;
102 end loop;
103 return rv;
104 end function;
105
106 end package body;