diff --git a/lib/radio/nco/sim/tb_mix_cordic.fdo b/lib/radio/nco/sim/tb_mix_cordic.fdo index a5caa18..e445e82 100644 --- a/lib/radio/nco/sim/tb_mix_cordic.fdo +++ b/lib/radio/nco/sim/tb_mix_cordic.fdo @@ -8,12 +8,12 @@ vcom -explicit -93 "../../cordic/src/cordic_pipe_pre.vhd" vcom -explicit -93 "../../cordic/src/cordic_pipe_post.vhd" vcom -explicit -93 "../../cordic/src/cordic_pipe_top.vhd" vcom -explicit -93 "../src/nco_pkg.vhd" -vcom -explicit -93 "../src/nco_cordic_dbg.vhd" -vcom -explicit -93 "../src/mix_cordic_dbg.vhd" +vcom -explicit -93 "../src/nco_cordic.vhd" +vcom -explicit -93 "../src/mix_cordic.vhd" vcom -explicit -93 "../src/tb_mix_cordic.vhd" vsim -t 1ps -lib work tb_mix do {tb_mix_cordic.wdo} view wave view structure view signals -run 250us +run 400us diff --git a/lib/radio/nco/src/tb_mix_cordic.vhd b/lib/radio/nco/src/tb_mix_cordic.vhd index 9fe1ba7..684af69 100644 --- a/lib/radio/nco/src/tb_mix_cordic.vhd +++ b/lib/radio/nco/src/tb_mix_cordic.vhd @@ -57,8 +57,7 @@ ARCHITECTURE behavior OF tb_mix IS wave_in_q : in sfixed; wave_out_i : out sfixed; wave_out_q : out sfixed; - out_valid : out std_logic; - debug_out : out debug_mix_out_t + out_valid : out std_logic ); END COMPONENT; @@ -82,16 +81,15 @@ ARCHITECTURE behavior OF tb_mix IS phase_out : out unsigned(nbits_phase-1 downto 0); wave_out_i : out sfixed; wave_out_q : out sfixed; - out_valid : out std_logic; - debug_out : out debug_out_t + out_valid : out std_logic ); END COMPONENT; --Constants - constant f : REAL := 9.125E6; - constant frf : REAL := 10.875E6; - constant df : REAL := 10.0E3; constant fa : REAL := 100.0E6; + constant frf : REAL := 3.333E5; + constant flo : REAL := 3.333E5; + constant df : REAL := 10.0E3; constant PERIOD : time := 10 ns; constant num_steps : integer := 1000000; @@ -99,7 +97,7 @@ ARCHITECTURE behavior OF tb_mix IS constant nbits_wave_out_frac : integer := nbits_wave_out-2; SIGNAL rfgen_freq_word : integer := integer(frf/fa*2.0**nbits_phase); - SIGNAL freq_word : integer := integer(f/fa*2.0**nbits_phase); + SIGNAL freq_word : integer := integer(flo/fa*2.0**nbits_phase); SIGNAL dfreq_word : integer := integer(df/fa*2.0**nbits_phase); --Inputs @@ -117,8 +115,7 @@ ARCHITECTURE behavior OF tb_mix IS SIGNAL wave_in_q : sfixed(shi(nbits_wave_in, nbits_wave_in_frac) downto slo(nbits_wave_in, nbits_wave_in_frac)); SIGNAL wave_out_i : sfixed(shi(nbits_wave_out, nbits_wave_out_frac) downto slo(nbits_wave_out, nbits_wave_out_frac)); SIGNAL wave_out_q : sfixed(shi(nbits_wave_out, nbits_wave_out_frac) downto slo(nbits_wave_out, nbits_wave_out_frac)); - SIGNAL out_valid : std_logic; - SIGNAL mix_debug_out : debug_mix_out_t; + SIGNAL mix_out_valid : std_logic; SIGNAL rfgen_pacc_clr : std_logic := '0'; SIGNAL rfgen_pacc_inc : std_logic := '0'; @@ -128,10 +125,9 @@ ARCHITECTURE behavior OF tb_mix IS SIGNAL rfgen_phase_in : unsigned(nbits_phase-1 downto 0); --Outputs - SIGNAL rfgen_wave_out_i : sfixed(shi(nbits_wave_in, nbits_wave_in_frac) downto slo(nbits_wave_in, nbits_wave_in_frac)); - SIGNAL rfgen_wave_out_q : sfixed(shi(nbits_wave_in, nbits_wave_in_frac) downto slo(nbits_wave_in, nbits_wave_in_frac)); + SIGNAL rfgen_out_i : sfixed(shi(nbits_wave_in, nbits_wave_in_frac) downto slo(nbits_wave_in, nbits_wave_in_frac)); + SIGNAL rfgen_out_q : sfixed(shi(nbits_wave_in, nbits_wave_in_frac) downto slo(nbits_wave_in, nbits_wave_in_frac)); SIGNAL rfgen_out_valid : std_logic; - SIGNAL rfgen_debug_out : debug_out_t; SIGNAL fileout_enable : std_logic := '0'; BEGIN @@ -160,8 +156,7 @@ BEGIN wave_in_q => wave_in_q, wave_out_i => wave_out_i, wave_out_q => wave_out_q, - out_valid => out_valid, - debug_out => mix_debug_out + out_valid => mix_out_valid ); rfgen1: nco @@ -182,10 +177,9 @@ BEGIN phase_in => rfgen_phase_in, phase_load => rfgen_phase_load, phase_out => open, - wave_out_i => rfgen_wave_out_i, - wave_out_q => rfgen_wave_out_q, - out_valid => rfgen_out_valid, - debug_out => rfgen_debug_out + wave_out_i => rfgen_out_i, + wave_out_q => rfgen_out_q, + out_valid => rfgen_out_valid ); tb_clk : PROCESS @@ -194,8 +188,8 @@ BEGIN wait for PERIOD/2; END PROCESS; --- wave_in_i <= resize(1.0*rfgen_wave_out_i, wave_in_i, false, true); - wave_in_i <= rfgen_wave_out_i; +-- wave_in_i <= resize(1.0*rfgen_out_i, wave_in_i, false, true); + wave_in_i <= rfgen_out_i; wave_in_q <= to_sfixed(0.0, wave_in_q); tb : PROCESS @@ -208,7 +202,7 @@ BEGIN wait for 4*PERIOD; srst <= '0'; - fprint(RESULT_FREQ, L,"%s\n", REAL'image(f)); + fprint(RESULT_FREQ, L,"%s\n", REAL'image(flo)); wait for 2*PERIOD; ------------------------------------------- @@ -273,7 +267,7 @@ BEGIN wait for 20*PERIOD; fileout_enable <= '1'; - wait for 20000*PERIOD; + wait for 200000*PERIOD; fileout_enable <= '0'; ------------------------------------------- @@ -359,7 +353,7 @@ BEGIN wait; END PROCESS; - tb_fo : PROCESS(clk, fileout_enable, out_valid) + tb_fo : PROCESS(clk, fileout_enable, mix_out_valid) file RESULT_Ii: text open write_mode is "i_in.txt"; file RESULT_Qi: text open write_mode is "q_in.txt"; file RESULT_Io: text open write_mode is "i_out.txt"; @@ -367,11 +361,15 @@ BEGIN variable L: line; BEGIN - if rising_edge(clk) and fileout_enable = '1' and out_valid = '1' then - fprint(RESULT_Ii, L,"%s\n", REAL'image(rfgen_debug_out.i_ud)); - fprint(RESULT_Qi, L,"%s\n", REAL'image(rfgen_debug_out.q_ud)); - fprint(RESULT_Io, L,"%s\n", REAL'image(mix_debug_out.i_out)); - fprint(RESULT_Qo, L,"%s\n", REAL'image(mix_debug_out.q_out)); + if rising_edge(clk) and fileout_enable = '1' then + if rfgen_out_valid = '1' then + fprint(RESULT_Ii, L,"%s\n", REAL'image(to_real(rfgen_out_i))); + fprint(RESULT_Qi, L,"%s\n", REAL'image(to_real(rfgen_out_q))); + end if; + if mix_out_valid = '1' then + fprint(RESULT_Io, L,"%s\n", REAL'image(to_real(wave_out_i))); + fprint(RESULT_Qo, L,"%s\n", REAL'image(to_real(wave_out_q))); + end if; end if; END PROCESS;