-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathdvb_ts.vhd
231 lines (206 loc) · 5.31 KB
/
dvb_ts.vhd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
-- NetUP Universal Dual DVB-CI FPGA firmware
-- http://www.netup.tv
--
-- Copyright (c) 2014 NetUP Inc, AVB Labs
-- License: GPLv3
-- altera vhdl_input_version vhdl_2008
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use work.avblabs_common_pkg.all;
entity dvb_ts is
port (
rst : in std_logic;
clk : in std_logic;
-- control
address : in std_logic_vector(8 downto 0);
byteenable : in std_logic_vector(3 downto 0);
writedata : in std_logic_vector(31 downto 0);
write : in std_logic;
readdata : out std_logic_vector(31 downto 0);
read : in std_logic;
waitrequest : out std_logic;
--
interrupt : out std_logic;
cam_bypass : in std_logic;
-- input port 1
dvb_in0_dsop : in std_logic;
dvb_in0_data : in std_logic_vector(7 downto 0);
dvb_in0_dval : in std_logic;
-- input port 2
dvb_in1_dsop : in std_logic;
dvb_in1_data : in std_logic_vector(7 downto 0);
dvb_in1_dval : in std_logic;
-- input port 3
dvb_in2_dsop : in std_logic;
dvb_in2_data : in std_logic_vector(7 downto 0);
dvb_in2_dval : in std_logic;
-- CAM port
cam_baseclk : in std_logic;
cam_mclki : out std_logic;
cam_mdi : out std_logic_vector(7 downto 0);
cam_mival : out std_logic;
cam_mistrt : out std_logic;
cam_mclko : in std_logic;
cam_mdo : in std_logic_vector(7 downto 0);
cam_moval : in std_logic;
cam_mostrt : in std_logic;
-- output port (DMA)
dvb_out_dsop : out std_logic;
dvb_out_data : out std_logic_vector(7 downto 0);
dvb_out_dval : out std_logic
);
end entity;
architecture rtl of dvb_ts is
constant REG_CLKDIV : natural := 0;
constant REG_SRCSEL : natural := 1;
signal clkdiv : std_logic_vector(3 downto 0);
signal srcsel : std_logic_vector(1 downto 0);
signal cam_dsop : std_logic;
signal cam_data : std_logic_vector(7 downto 0);
signal cam_dval : std_logic;
signal swts_dsop : std_logic;
signal swts_data : std_logic_vector(7 downto 0);
signal swts_dval : std_logic;
signal mux_dsop : std_logic;
signal mux_data : std_logic_vector(7 downto 0);
signal mux_dval : std_logic;
signal filter_dsop : std_logic;
signal filter_data : std_logic_vector(7 downto 0);
signal filter_dval : std_logic;
signal pid_tbl_read : std_logic;
signal pid_tbl_write : std_logic;
signal pid_tbl_rddata : std_logic_vector(31 downto 0);
signal pid_tbl_waitreq : std_logic;
begin
-- control
pid_tbl_write <= write and address(8);
pid_tbl_read <= read and address(8);
waitrequest <= pid_tbl_waitreq;
readdata <= pid_tbl_rddata when address(8) else
X"0000000" & clkdiv when not address(0) else
X"0000000" & "00" & srcsel;
interrupt <= '0';
process (rst, clk)
begin
if rising_edge(clk) then
if write and byteenable(0) then
if not address(0) and not address(8) then
clkdiv <= writedata(clkdiv'range);
end if;
if address(0) and not address(8) then
srcsel <= writedata(srcsel'range);
end if;
end if;
end if;
if rst then
clkdiv <= (others => '0');
srcsel <= (others => '0');
end if;
end process;
-- input demux
process (rst, clk)
begin
if rising_edge(clk) then
case srcsel is
when "00" =>
mux_dsop <= dvb_in0_dsop;
mux_data <= dvb_in0_data;
mux_dval <= dvb_in0_dval;
when "01" =>
mux_dsop <= dvb_in1_dsop;
mux_data <= dvb_in1_data;
mux_dval <= dvb_in1_dval;
when "10" =>
mux_dsop <= dvb_in2_dsop;
mux_data <= dvb_in2_data;
mux_dval <= dvb_in2_dval;
when others =>
mux_dsop <= swts_dsop;
mux_data <= swts_data;
mux_dval <= swts_dval;
end case;
end if;
if rst then
mux_dsop <= '0';
mux_data <= (others => '0');
mux_dval <= '0';
end if;
end process;
FILTER_0 : entity work.dvb_ts_filter
port map (
rst => rst,
clk => clk,
--
pid_tbl_addr => address(7 downto 0),
pid_tbl_be => byteenable,
pid_tbl_wrdata => writedata,
pid_tbl_write => pid_tbl_write,
pid_tbl_rddata => pid_tbl_rddata,
pid_tbl_read => pid_tbl_read,
pid_tbl_waitreq => pid_tbl_waitreq,
--
dvb_in_dsop => mux_dsop,
dvb_in_data => mux_data,
dvb_in_dval => mux_dval,
--
dvb_out_dsop => filter_dsop,
dvb_out_data => filter_data,
dvb_out_dval => filter_dval
);
CAM_OUT_0 : entity work.dvb_ts_shaper
port map (
rst => rst,
clk => clk,
--
bypass_test => cam_bypass,
--
clkdiv => X"2",
--
dvb_indrdy => open,
dvb_indata => filter_data,
dvb_indsop => filter_dsop,
dvb_indval => filter_dval,
-- stream domain
dvb_clk => cam_baseclk,
--
dvb_out_clk => cam_mclki,
dvb_out_data => cam_mdi,
dvb_out_dval => cam_mival,
dvb_out_dsop => cam_mistrt
);
CAM_IN_0 : entity work.dvb_ts_sync
port map (
ts_clk => cam_mclko,
ts_strt => cam_mostrt,
ts_dval => cam_moval,
ts_data => cam_mdo,
--
rst => rst,
clk => clk,
--
strt => cam_dsop,
data => cam_data,
dval => cam_dval
);
-- CAM bypass cotrol
process (rst, clk)
begin
if rising_edge(clk) then
if cam_bypass then
dvb_out_dsop <= filter_dsop;
dvb_out_data <= filter_data;
dvb_out_dval <= filter_dval;
else
dvb_out_dsop <= cam_dsop;
dvb_out_data <= cam_data;
dvb_out_dval <= cam_dval;
end if;
end if;
if rst then
dvb_out_dsop <= '0';
dvb_out_data <= (others => '0');
dvb_out_dval <= '0';
end if;
end process;
end architecture;