1 |
47 |
gedra |
----------------------------------------------------------------------
|
2 |
|
|
---- ----
|
3 |
|
|
---- WISHBONE SPDIF IP Core ----
|
4 |
|
|
---- ----
|
5 |
|
|
---- This file is part of the SPDIF project ----
|
6 |
|
|
---- http://www.opencores.org/cores/spdif_interface/ ----
|
7 |
|
|
---- ----
|
8 |
|
|
---- Description ----
|
9 |
|
|
---- Bit buffer holding 2x192 bits of either channel status or ----
|
10 |
|
|
---- user data for the transmitter. ----
|
11 |
|
|
---- ----
|
12 |
|
|
---- To Do: ----
|
13 |
|
|
---- - ----
|
14 |
|
|
---- ----
|
15 |
|
|
---- Author(s): ----
|
16 |
|
|
---- - Geir Drange, gedra@opencores.org ----
|
17 |
|
|
---- ----
|
18 |
|
|
----------------------------------------------------------------------
|
19 |
|
|
---- ----
|
20 |
|
|
---- Copyright (C) 2004 Authors and OPENCORES.ORG ----
|
21 |
|
|
---- ----
|
22 |
|
|
---- This source file may be used and distributed without ----
|
23 |
|
|
---- restriction provided that this copyright statement is not ----
|
24 |
|
|
---- removed from the file and that any derivative work contains ----
|
25 |
|
|
---- the original copyright notice and the associated disclaimer. ----
|
26 |
|
|
---- ----
|
27 |
|
|
---- This source file is free software; you can redistribute it ----
|
28 |
|
|
---- and/or modify it under the terms of the GNU Lesser General ----
|
29 |
|
|
---- Public License as published by the Free Software Foundation; ----
|
30 |
|
|
---- either version 2.1 of the License, or (at your option) any ----
|
31 |
|
|
---- later version. ----
|
32 |
|
|
---- ----
|
33 |
|
|
---- This source is distributed in the hope that it will be ----
|
34 |
|
|
---- useful, but WITHOUT ANY WARRANTY; without even the implied ----
|
35 |
|
|
---- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR ----
|
36 |
|
|
---- PURPOSE. See the GNU Lesser General Public License for more ----
|
37 |
|
|
---- details. ----
|
38 |
|
|
---- ----
|
39 |
|
|
---- You should have received a copy of the GNU Lesser General ----
|
40 |
|
|
---- Public License along with this source; if not, download it ----
|
41 |
|
|
---- from http://www.opencores.org/lgpl.shtml ----
|
42 |
|
|
---- ----
|
43 |
|
|
----------------------------------------------------------------------
|
44 |
|
|
--
|
45 |
|
|
-- CVS Revision History
|
46 |
|
|
--
|
47 |
|
|
-- $Log: not supported by cvs2svn $
|
48 |
72 |
gedra |
-- Revision 1.3 2004/07/19 16:59:43 gedra
|
49 |
|
|
-- Fixed bug.
|
50 |
|
|
--
|
51 |
58 |
gedra |
-- Revision 1.2 2004/07/17 17:21:11 gedra
|
52 |
|
|
-- Fixed bug.
|
53 |
|
|
--
|
54 |
53 |
gedra |
-- Revision 1.1 2004/07/14 17:58:19 gedra
|
55 |
|
|
-- Transmitter channel status buffer.
|
56 |
47 |
gedra |
--
|
57 |
|
|
--
|
58 |
53 |
gedra |
--
|
59 |
47 |
gedra |
|
60 |
|
|
library ieee;
|
61 |
72 |
gedra |
use ieee.std_logic_1164.all;
|
62 |
47 |
gedra |
use ieee.numeric_std.all;
|
63 |
|
|
|
64 |
72 |
gedra |
entity tx_bitbuf is
|
65 |
|
|
generic (ENABLE_BUFFER : integer range 0 to 1);
|
66 |
|
|
port (
|
67 |
|
|
wb_clk_i : in std_logic; -- clock
|
68 |
|
|
wb_rst_i : in std_logic; -- reset
|
69 |
|
|
buf_wr : in std_logic; -- buffer write strobe
|
70 |
|
|
wb_adr_i : in std_logic_vector(4 downto 0); -- address
|
71 |
|
|
wb_dat_i : in std_logic_vector(15 downto 0); -- data
|
72 |
|
|
buf_data_a : out std_logic_vector(191 downto 0);
|
73 |
|
|
buf_data_b : out std_logic_vector(191 downto 0));
|
74 |
47 |
gedra |
end tx_bitbuf;
|
75 |
|
|
|
76 |
|
|
architecture rtl of tx_bitbuf is
|
77 |
|
|
|
78 |
72 |
gedra |
type buf_type is array (0 to 23) of std_logic_vector(7 downto 0);
|
79 |
|
|
signal buffer_a, buffer_b : buf_type;
|
80 |
|
|
|
81 |
47 |
gedra |
begin
|
82 |
|
|
|
83 |
72 |
gedra |
-- the byte buffer is 192 bits (24 bytes) for each channel
|
84 |
|
|
EB : if ENABLE_BUFFER = 1 generate
|
85 |
|
|
WBUF : process (wb_clk_i, wb_rst_i)
|
86 |
|
|
begin
|
87 |
|
|
if wb_rst_i = '1' then
|
88 |
|
|
for i in 0 to 23 loop
|
89 |
|
|
buffer_a(i) <= (others => '0');
|
90 |
|
|
buffer_b(i) <= (others => '0');
|
91 |
|
|
end loop;
|
92 |
|
|
elsif rising_edge(wb_clk_i) then
|
93 |
|
|
if buf_wr = '1' and to_integer(unsigned(wb_adr_i)) < 24 then
|
94 |
|
|
buffer_a(to_integer(unsigned(wb_adr_i))) <= wb_dat_i(7 downto 0);
|
95 |
|
|
buffer_b(to_integer(unsigned(wb_adr_i))) <= wb_dat_i(15 downto 8);
|
96 |
|
|
end if;
|
97 |
|
|
end if;
|
98 |
|
|
end process WBUF;
|
99 |
|
|
VGEN : for k in 0 to 23 generate
|
100 |
|
|
buf_data_a(8 * k + 7 downto 8 * k) <= buffer_a(k);
|
101 |
|
|
buf_data_b(8 * k + 7 downto 8 * k) <= buffer_b(k);
|
102 |
|
|
end generate VGEN;
|
103 |
|
|
end generate EB;
|
104 |
|
|
|
105 |
|
|
-- if the byte buffer is not enabled, set all bits to zero
|
106 |
|
|
NEB : if ENABLE_BUFFER = 0 generate
|
107 |
|
|
buf_data_a(191 downto 0) <= (others => '0');
|
108 |
|
|
buf_data_b(191 downto 0) <= (others => '0');
|
109 |
|
|
end generate NEB;
|
110 |
|
|
|
111 |
47 |
gedra |
end rtl;
|