我想为我的I2S多路复用器模块生成一个测试激励。刺激包含来自ADC测量的值。 I2S标准提供两个时钟:LRCLOCK和BITCLOCK。在我的情况下,LRCLOCK的频率为48kHz(这也是采样率),而BITCLOCK为64 * LRCLOCK,这将产生3.072MHz的时钟。
在测试平台中创建时钟时,LRCLOCK和BITLCOCK之间始终存在偏移。而且我无法解释此偏移量的来源。
我尝试根据以下信息创建时钟生成过程:VHDL - How should I create a clock in a testbench?
两个建议的解决方案都表现出相同的行为。 我使用VIVADO 2016.4,模拟器的分辨率为1ps
程序:
procedure clk_gen(signal clk : out std_logic; constant FREQ : real) is
constant PERIOD : time := 1 sec / FREQ; -- Full period
constant HIGH_TIME : time := PERIOD / 2; -- High time
constant LOW_TIME : time := PERIOD - HIGH_TIME; -- Low time; always >= HIGH_TIME
begin
-- Check the arguments
assert (HIGH_TIME /= 0 fs) report "clk_plain: High time is zero; time resolution to large for frequency" severity FAILURE;
-- Generate a clock cycle
loop
clk <= '1';
wait for HIGH_TIME;
clk <= '0';
wait for LOW_TIME;
end loop;
end procedure;
时钟分配:
process
begin
i2s_lrclock <= '1';
wait until reset /= '1';
clk_gen(i2s_lrclock,48.0e3);
end process;
process
begin
i2s_bitclock <= '1';
wait until reset /= '1';
clk_gen(i2s_bitclock,48.0e3*64);
end process;
我希望两个时钟的边沿都是同步的,但是从i2s_bitclock到i2s_lrclock有26ps的偏移量。
答案 0 :(得分:0)
3.072MHz时钟的周期为325.5208333 ... ns,模拟器必须将周期中继到某个地方,并且其他时钟可能不在同一数字上。
尝试类似的事情:
signal i2s_lrclock : std_logic := '0';
signal i2s_bitclock : std_logic := '0';
begin
i2s_lrclock <= not(i2s_lrclock) after 10416640 ps; -- 64 * 325.520 ns / 2
i2s_bitclock <= not(i2s_bitclock) after 162760 ps ; -- 325.520 ns / 2
仿真中时钟的实际值不是很重要。它们之间的比例是。