分析insert_main_stream_attrbutes_one_channel.vhd
顾名思义,改代码是在原始数据流的基础上插入MSA。MSA的内容只能在每帧发送完成后的BS和BE间插入。(我读协议时好像看到是一帧结束后才能插入MSA,后来没仔细核对,但是代码也确实是这么做的)
---------------------------------------------
-- Is the BS in the channel 0's data0 symbol?
---------------------------------------------
if in_data(8 downto 0) = BS then
---------------------------------
-- This time in_data(17 downto 9) = VB-ID
-- First, see if this is a line in
-- the VSYNC
---------------------------------
if in_data(9) = '1' then
if armed = '1' then
count <= "00001";
armed <= '0';
end if;
else
-- Not in the Vblank. so arm the trigger to send the MSA
-- when the next BS with Vblank asserted occurs
armed <= '1';
end if;
end if;
这段的意思是检测到BS及VB-ID的最后一个bit为1时,count置为1,然后count会从1计数到27后保持为0,利用这个计数器将MSA的内容逐字插入到数据流中替换原始无效数据。里面有个armed,意义就是原始发送数据流中600~627行同样满足BS及VB-ID的最后一个bit为1,但此时我们不插入MSA,MSA仅在传完第599行(从0计数)有效数据的Blanding期间插入
---------------------------------------------
-- Is the BS in the channel 0's data1 symbol?
---------------------------------------------
if in_data(17 downto 9) = BS then
last_was_bs <= '1';
else
last_was_bs <= '0';
end if;
---------------------------------------------
-- Was the BS in the channel 0's data1 symbol
-- during the last cycle?
---------------------------------------------
if last_was_bs = '1' then
---------------------------------
-- This time in_ch0_data0 = VB-ID
-- First, see if this is a line in
-- the VSYNC
---------------------------------
if in_data(0) = '1' then
if armed = '1' then
count <= "00001";
armed <= '0';
end if;
else
-- Not in the Vblank. so arm the trigger to send the MSA
-- when the next BS with Vblank asserted occurs
armed <= active;
end if;
end if;
这两段是处理BS和VB-ID不在同一个字时的情况。在使用自己产生的数据时,没有设计这种情况