diff --git a/Documentation/DeveloperInfo/FPGA_protocol.tex b/Documentation/DeveloperInfo/FPGA_protocol.tex index 9660519..40acb96 100644 --- a/Documentation/DeveloperInfo/FPGA_protocol.tex +++ b/Documentation/DeveloperInfo/FPGA_protocol.tex @@ -386,7 +386,7 @@ Setting & Window type\\ \begin{itemize} \item \textbf{Presc[7:0]:} Amount of FPGA clock cycles between ADC samples. $$ SR_{ADC} = \frac{\SI{102.4}{\mega\hertz}}{Presc} $$ -The minimum value for this register is 111, which results in a samplerate of roughly \SI{922.5}{\kilo\hertz}. If Presc is set to a lower value, the data acquisition from the ADC is not done when the next sample starts and samples will be skipped. +The minimum value for this register is 112, which results in a samplerate of roughly \SI{914.3}{\kilo\hertz}. If Presc is set to a lower value, the data acquisition from the ADC is not done when the next sample starts and samples will be skipped. \end{itemize} \subsection{Phase Increment: 0x05} @@ -446,7 +446,7 @@ See datasheet of MAX2871 for bit descriptions. Bits for the fields N, FRAC, M, V \label{dft} In addition to the single bin DFT configured through the ADC prescaler and phase increment registers (see \ref{reg:ADC} and \ref{reg:phaseinc}), the FPGA also includes a multiple point DFT. This DFT only operates on the port 1 and port 2 receivers and is intended to speed up spectrum analyzer measurements. If enabled, the DFT runs in parallel to all other calculations. -The DFT has a fixed number of bins (64), but the frequencies these bins correspond to can be changed. +The DFT has a fixed number of bins (96), but the frequencies these bins correspond to can be changed. \subsubsection{DFT\_FIRST\_BIN: 0x12} \begin{center} diff --git a/FPGA/VNA/DFT.vhd b/FPGA/VNA/DFT.vhd index 9a90d40..8975b9b 100644 --- a/FPGA/VNA/DFT.vhd +++ b/FPGA/VNA/DFT.vhd @@ -33,8 +33,8 @@ entity DFT is Generic (BINS : integer); Port ( CLK : in STD_LOGIC; RESET : in STD_LOGIC; - PORT1 : in STD_LOGIC_VECTOR (15 downto 0); - PORT2 : in STD_LOGIC_VECTOR (15 downto 0); + PORT1 : in STD_LOGIC_VECTOR (17 downto 0); + PORT2 : in STD_LOGIC_VECTOR (17 downto 0); NEW_SAMPLE : in STD_LOGIC; NSAMPLES : in STD_LOGIC_VECTOR (12 downto 0); BIN1_PHASEINC : in STD_LOGIC_VECTOR (15 downto 0); @@ -45,25 +45,14 @@ entity DFT is end DFT; architecture Behavioral of DFT is -COMPONENT dft_result -GENERIC(depth : integer); -PORT( - CLK : IN std_logic; - READ_ADDRESS : in integer range 0 to depth-1; - WRITE_ADDRESS : in integer range 0 to depth-1; - DATA_IN : IN std_logic_vector(191 downto 0); - WE : IN std_logic; - DATA_OUT : OUT std_logic_vector(191 downto 0) - ); -END COMPONENT; COMPONENT result_bram PORT ( clka : IN STD_LOGIC; wea : IN STD_LOGIC_VECTOR(0 DOWNTO 0); - addra : IN STD_LOGIC_VECTOR(5 DOWNTO 0); + addra : IN STD_LOGIC_VECTOR(7 DOWNTO 0); dina : IN STD_LOGIC_VECTOR(191 DOWNTO 0); clkb : IN STD_LOGIC; - addrb : IN STD_LOGIC_VECTOR(5 DOWNTO 0); + addrb : IN STD_LOGIC_VECTOR(7 DOWNTO 0); doutb : OUT STD_LOGIC_VECTOR(191 DOWNTO 0) ); END COMPONENT; @@ -75,14 +64,6 @@ COMPONENT SinCos sine : OUT STD_LOGIC_VECTOR(15 DOWNTO 0) ); END COMPONENT; -COMPONENT SinCosMult - PORT ( - clk : IN STD_LOGIC; - a : IN STD_LOGIC_VECTOR(15 DOWNTO 0); - b : IN STD_LOGIC_VECTOR(15 DOWNTO 0); - p : OUT STD_LOGIC_VECTOR(31 DOWNTO 0) - ); -END COMPONENT; COMPONENT DSP_SLICE PORT ( clk : IN STD_LOGIC; @@ -120,16 +101,16 @@ END COMPONENT; signal read_address : integer range 0 to BINS-1; signal write_address : integer range 0 to BINS-1; - signal read_address_vector : std_logic_vector(5 downto 0); - signal write_address_vector : std_logic_vector(5 downto 0); + signal read_address_vector : std_logic_vector(7 downto 0); + signal write_address_vector : std_logic_vector(7 downto 0); signal we : std_logic_vector(0 downto 0); signal ram_in : std_logic_vector(191 downto 0); signal ram_out : std_logic_vector(191 downto 0); type States is (WaitingForSample, WaitMult, WaitSinCos, Busy, Ready); signal state : States; - signal port1_latch : std_logic_vector(15 downto 0); - signal port2_latch : std_logic_vector(15 downto 0); + signal port1_latch : std_logic_vector(17 downto 0); + signal port2_latch : std_logic_vector(17 downto 0); signal phase : std_logic_vector(31 downto 0); signal phase_inc : std_logic_vector(31 downto 0); @@ -219,8 +200,8 @@ begin doutb => ram_out ); - read_address_vector <= std_logic_vector(to_unsigned(read_address, 6)); - write_address_vector <= std_logic_vector(to_unsigned(write_address, 6)); + read_address_vector <= std_logic_vector(to_unsigned(read_address, 8)); + write_address_vector <= std_logic_vector(to_unsigned(write_address, 8)); OUTPUT <= ram_out; mult1_c <= ram_out(191 downto 144); @@ -294,13 +275,13 @@ begin mult_enable <= '1'; read_address <= 1; -- sign extended multiplication - mult1_a <= port1_latch(15) & port1_latch(15) & port1_latch; + mult1_a <= port1_latch; mult1_b <= sine(15) & sine(15) & sine; - mult2_a <= port1_latch(15) & port1_latch(15) & port1_latch; + mult2_a <= port1_latch; mult2_b <= cosine(15) & cosine(15) & cosine; - mult3_a <= port2_latch(15) & port2_latch(15) & port2_latch; + mult3_a <= port2_latch; mult3_b <= sine(15) & sine(15) & sine; - mult4_a <= port2_latch(15) & port2_latch(15) & port2_latch; + mult4_a <= port2_latch; mult4_b <= cosine(15) & cosine(15) & cosine; state <= BUSY; if sample_cnt = 0 then @@ -319,13 +300,13 @@ begin RESULT_READY <= '0'; phase <= std_logic_vector(unsigned(phase)+unsigned(phase_inc)); -- sign extended multiplication - mult1_a <= port1_latch(15) & port1_latch(15) & port1_latch; + mult1_a <= port1_latch; mult1_b <= sine(15) & sine(15) & sine; - mult2_a <= port1_latch(15) & port1_latch(15) & port1_latch; + mult2_a <= port1_latch; mult2_b <= cosine(15) & cosine(15) & cosine; - mult3_a <= port2_latch(15) & port2_latch(15) & port2_latch; + mult3_a <= port2_latch; mult3_b <= sine(15) & sine(15) & sine; - mult4_a <= port2_latch(15) & port2_latch(15) & port2_latch; + mult4_a <= port2_latch; mult4_b <= cosine(15) & cosine(15) & cosine; if bin_cnt >= 3 then -- multiplier result is available, advance write address diff --git a/FPGA/VNA/Sampling.vhd b/FPGA/VNA/Sampling.vhd index f1b2287..0c752e2 100644 --- a/FPGA/VNA/Sampling.vhd +++ b/FPGA/VNA/Sampling.vhd @@ -35,9 +35,9 @@ entity Sampling is RESET : in STD_LOGIC; ADC_PRESCALER : in STD_LOGIC_VECTOR(7 downto 0); PHASEINC : in STD_LOGIC_VECTOR(11 downto 0); - PORT1 : in STD_LOGIC_VECTOR (15 downto 0); - PORT2 : in STD_LOGIC_VECTOR (15 downto 0); - REF : in STD_LOGIC_VECTOR (15 downto 0); + PORT1 : in STD_LOGIC_VECTOR (17 downto 0); + PORT2 : in STD_LOGIC_VECTOR (17 downto 0); + REF : in STD_LOGIC_VECTOR (17 downto 0); ADC_START : out STD_LOGIC; NEW_SAMPLE : in STD_LOGIC; DONE : out STD_LOGIC; @@ -62,13 +62,16 @@ COMPONENT SinCos sine : OUT STD_LOGIC_VECTOR(15 DOWNTO 0) ); END COMPONENT; -COMPONENT SinCosMult - PORT ( - clk : IN STD_LOGIC; - a : IN STD_LOGIC_VECTOR(15 DOWNTO 0); - b : IN STD_LOGIC_VECTOR(15 DOWNTO 0); - p : OUT STD_LOGIC_VECTOR(31 DOWNTO 0) - ); +COMPONENT DSP_SLICE + PORT ( + clk : IN STD_LOGIC; + ce : IN STD_LOGIC; + sel : IN STD_LOGIC_VECTOR(0 DOWNTO 0); + a : IN STD_LOGIC_VECTOR(17 DOWNTO 0); + b : IN STD_LOGIC_VECTOR(17 DOWNTO 0); + c : IN STD_LOGIC_VECTOR(47 DOWNTO 0); + p : OUT STD_LOGIC_VECTOR(47 DOWNTO 0) + ); END COMPONENT; COMPONENT window PORT( @@ -79,12 +82,12 @@ PORT( ); END COMPONENT; - signal p1_I : signed(47 downto 0); - signal p1_Q : signed(47 downto 0); - signal p2_I : signed(47 downto 0); - signal p2_Q : signed(47 downto 0); - signal r_I : signed(47 downto 0); - signal r_Q : signed(47 downto 0); + signal p1_I : std_logic_vector(47 downto 0); + signal p1_Q : std_logic_vector(47 downto 0); + signal p2_I : std_logic_vector(47 downto 0); + signal p2_Q : std_logic_vector(47 downto 0); + signal r_I : std_logic_vector(47 downto 0); + signal r_Q : std_logic_vector(47 downto 0); signal clk_cnt : integer range 0 to 255; signal sample_cnt : integer range 0 to 131071; signal samples_to_take : integer range 0 to 131071; @@ -93,16 +96,15 @@ END COMPONENT; signal sine : std_logic_vector(15 downto 0); signal cosine : std_logic_vector(15 downto 0); - signal mult1_I : std_logic_vector(31 downto 0); - signal mult1_Q : std_logic_vector(31 downto 0); - signal mult2_I : std_logic_vector(31 downto 0); - signal mult2_Q : std_logic_vector(31 downto 0); - signal multR_I : std_logic_vector(31 downto 0); - signal multR_Q : std_logic_vector(31 downto 0); + signal mult_a : std_logic_vector(17 downto 0); + signal mult_b : std_logic_vector(17 downto 0); + signal mult_c : std_logic_vector(47 downto 0); + signal mult_p : std_logic_vector(47 downto 0); - signal last_sample : std_logic; + signal mult_enable : std_logic; + signal mult_accumulate : std_logic_vector(0 downto 0); - type States is (Idle, Sampling, WaitForMult, Accumulating, Ready); + type States is (Idle, Sampling, P1Q, P2I, P2Q, RI, RQ, SaveP1Q, SaveP2I, SaveP2Q, SaveRI, SaveRQ, Ready); signal state : States; begin -- Always fails for simulation, comment out @@ -117,49 +119,21 @@ begin cosine => cosine, sine => sine ); - Port1_I_Mult : SinCosMult + + Mult : DSP_SLICE PORT MAP ( clk => CLK, - a => PORT1, - b => cosine, - p => mult1_I - ); - Port1_Q_Mult : SinCosMult - PORT MAP ( - clk => CLK, - a => PORT1, - b => sine, - p => mult1_Q - ); - Port2_I_Mult : SinCosMult - PORT MAP ( - clk => CLK, - a => PORT2, - b => cosine, - p => mult2_I - ); - Port2_Q_Mult : SinCosMult - PORT MAP ( - clk => CLK, - a => PORT2, - b => sine, - p => mult2_Q - ); - Ref_I_Mult : SinCosMult - PORT MAP ( - clk => CLK, - a => REF, - b => cosine, - p => multR_I - ); - Ref_Q_Mult : SinCosMult - PORT MAP ( - clk => CLK, - a => REF, - b => sine, - p => multR_Q + ce => mult_enable, + sel => mult_accumulate, + a => mult_a, + b => mult_b, + c => mult_c, + p => mult_p ); + -- sign extend b input of multiplier (sin/cos) + mult_b(17 downto 16) <= mult_b(15) & mult_b(15); + process(CLK, RESET) begin if rising_edge(CLK) then @@ -172,15 +146,14 @@ begin clk_cnt <= 0; sample_cnt <= 0; phase <= (others => '0'); + mult_enable <= '0'; + mult_accumulate <= "0"; else -- when not idle, generate pulses for ADCs if state /= Idle then - if clk_cnt = unsigned(ADC_PRESCALER) - 1 and last_sample = '0' then - ADC_START <= '1'; + if clk_cnt = unsigned(ADC_PRESCALER) - 1 then if sample_cnt < samples_to_take then - sample_cnt <= sample_cnt + 1; - else - last_sample <= '1'; + ADC_START <= '1'; end if; clk_cnt <= 0; else @@ -193,50 +166,116 @@ begin -- handle state transitions case state is when Idle => - last_sample <= '0'; sample_cnt <= 0; DONE <= '0'; PRE_DONE <= '0'; ACTIVE <= '0'; clk_cnt <= 0; phase <= (others => '0'); - p1_I <= (others => '0'); - p1_Q <= (others => '0'); - p2_I <= (others => '0'); - p2_Q <= (others => '0'); - r_I <= (others => '0'); - r_Q <= (others => '0'); - phase <= (others => '0'); + mult_enable <= '0'; + mult_accumulate <= "0"; if START = '1' then state <= Sampling; - samples_to_take <= to_integer(unsigned(SAMPLES & "0000") - 1); + samples_to_take <= to_integer(unsigned(SAMPLES & "0000")); end if; when Sampling => DONE <= '0'; PRE_DONE <= '0'; ACTIVE <= '1'; + mult_enable <= '0'; if NEW_SAMPLE = '1' then - state <= WaitForMult; + sample_cnt <= sample_cnt + 1; + mult_enable <= '1'; + mult_a <= PORT1; + mult_b(15 downto 0) <= cosine; + mult_c <= p1_I; + state <= P1Q; end if; - when WaitForMult => - DONE <= '0'; - PRE_DONE <= '0'; - ACTIVE <= '1'; - state <= Accumulating; - when Accumulating => - -- multipliers are finished with the sample - p1_I <= p1_I + signed(mult1_I); - p1_Q <= p1_Q + signed(mult1_Q); - p2_I <= p2_I + signed(mult2_I); - p2_Q <= p2_Q + signed(mult2_Q); - r_I <= r_I + signed(multR_I); - r_Q <= r_Q + signed(multR_Q); - -- advance phase + when P1Q => ACTIVE <= '1'; DONE <= '0'; PRE_DONE <= '0'; + mult_enable <= '1'; + mult_a <= PORT1; + mult_b(15 downto 0) <= sine; + mult_c <= p1_Q; + state <= P2I; + when P2I => + ACTIVE <= '1'; + DONE <= '0'; + PRE_DONE <= '0'; + mult_enable <= '1'; + mult_a <= PORT2; + mult_b(15 downto 0) <= cosine; + mult_c <= p2_I; + state <= P2Q; + when P2Q => + ACTIVE <= '1'; + DONE <= '0'; + PRE_DONE <= '0'; + mult_enable <= '1'; + mult_a <= PORT2; + mult_b(15 downto 0) <= sine; + mult_c <= p2_Q; + state <= RI; + when RI => + ACTIVE <= '1'; + DONE <= '0'; + PRE_DONE <= '0'; + mult_enable <= '1'; + mult_a <= REF; + mult_b(15 downto 0) <= cosine; + mult_c <= r_I; + state <= RQ; + when RQ => + ACTIVE <= '1'; + DONE <= '0'; + PRE_DONE <= '0'; + mult_enable <= '1'; + mult_a <= REF; + mult_b(15 downto 0) <= sine; + mult_c <= r_Q; + -- first result is available + p1_I <= mult_p; + state <= SaveP1Q; + when SaveP1Q => + ACTIVE <= '1'; + DONE <= '0'; + PRE_DONE <= '0'; + mult_enable <= '1'; + p1_Q <= mult_p; + state <= SaveP2I; + when SaveP2I => + ACTIVE <= '1'; + DONE <= '0'; + PRE_DONE <= '0'; + mult_enable <= '1'; + p2_I <= mult_p; + state <= SaveP2Q; + when SaveP2Q => + ACTIVE <= '1'; + DONE <= '0'; + PRE_DONE <= '0'; + mult_enable <= '1'; + p2_Q <= mult_p; + state <= SaveRI; + when SaveRI => + ACTIVE <= '1'; + DONE <= '0'; + PRE_DONE <= '0'; + mult_enable <= '1'; + r_I <= mult_p; + state <= SaveRQ; + when SaveRQ => + ACTIVE <= '1'; + DONE <= '0'; + PRE_DONE <= '0'; + mult_enable <= '0'; + r_Q <= mult_p; + -- from now on accumulate results + mult_accumulate <= "1"; phase <= std_logic_vector(unsigned(phase) + unsigned(PHASEINC)); - if last_sample = '0' then + if sample_cnt < samples_to_take then state <= Sampling; else state <= Ready; @@ -245,12 +284,13 @@ begin ACTIVE <= '1'; DONE <= '1'; PRE_DONE <= '1'; - PORT1_I <= std_logic_vector(p1_I); - PORT1_Q <= std_logic_vector(p1_Q); - PORT2_I <= std_logic_vector(p2_I); - PORT2_Q <= std_logic_vector(p2_Q); - REF_I <= std_logic_vector(r_I); - REF_Q <= std_logic_vector(r_Q); + mult_enable <= '0'; + PORT1_I <= p1_I; + PORT1_Q <= p1_Q; + PORT2_I <= p2_I; + PORT2_Q <= p2_Q; + REF_I <= r_I; + REF_Q <= r_Q; state <= Idle; end case; end if; diff --git a/FPGA/VNA/Test_DFT.vhd b/FPGA/VNA/Test_DFT.vhd index 2bd28ad..85ecc36 100644 --- a/FPGA/VNA/Test_DFT.vhd +++ b/FPGA/VNA/Test_DFT.vhd @@ -44,8 +44,8 @@ ARCHITECTURE behavior OF Test_DFT IS PORT( CLK : IN std_logic; RESET : IN std_logic; - PORT1 : IN std_logic_vector(15 downto 0); - PORT2 : IN std_logic_vector(15 downto 0); + PORT1 : IN std_logic_vector(17 downto 0); + PORT2 : IN std_logic_vector(17 downto 0); NEW_SAMPLE : IN std_logic; NSAMPLES : in STD_LOGIC_VECTOR (12 downto 0); BIN1_PHASEINC : IN std_logic_vector(15 downto 0); @@ -60,8 +60,8 @@ ARCHITECTURE behavior OF Test_DFT IS --Inputs signal CLK : std_logic := '0'; signal RESET : std_logic := '0'; - signal PORT1 : std_logic_vector(15 downto 0) := (others => '0'); - signal PORT2 : std_logic_vector(15 downto 0) := (others => '0'); + signal PORT1 : std_logic_vector(17 downto 0) := (others => '0'); + signal PORT2 : std_logic_vector(17 downto 0) := (others => '0'); signal NEW_SAMPLE : std_logic := '0'; signal BIN1_PHASEINC : std_logic_vector(15 downto 0) := (others => '0'); signal DIFFBIN_PHASEINC : std_logic_vector(15 downto 0) := (others => '0'); @@ -109,11 +109,11 @@ BEGIN begin -- hold reset state for 100 ns. RESET <= '1'; - PORT1 <= "1000000000000000"; - PORT2 <= "0100000000000000"; + PORT1 <= "100000000000000000"; + PORT2 <= "010000000000000000"; BIN1_PHASEINC <= "0100000000000000"; DIFFBIN_PHASEINC <= "0010000000000000"; - NSAMPLES <= "0000000000000011"; + NSAMPLES <= "0000000000011"; wait for 100 ns; RESET <= '0'; wait for CLK_period*10; diff --git a/FPGA/VNA/Test_SPICommands.vhd b/FPGA/VNA/Test_SPICommands.vhd index 3bdc1da..957a524 100644 --- a/FPGA/VNA/Test_SPICommands.vhd +++ b/FPGA/VNA/Test_SPICommands.vhd @@ -48,19 +48,18 @@ ARCHITECTURE behavior OF Test_SPICommands IS MISO : OUT std_logic; NSS : IN std_logic; NEW_SAMPLING_DATA : IN std_logic; - SAMPLING_RESULT : IN std_logic_vector(287 downto 0); + SAMPLING_RESULT : IN std_logic_vector(303 downto 0); SOURCE_UNLOCKED : IN std_logic; LO_UNLOCKED : IN std_logic; MAX2871_DEF_4 : OUT std_logic_vector(31 downto 0); MAX2871_DEF_3 : OUT std_logic_vector(31 downto 0); MAX2871_DEF_1 : OUT std_logic_vector(31 downto 0); MAX2871_DEF_0 : OUT std_logic_vector(31 downto 0); - SWEEP_DATA : OUT std_logic_vector(111 downto 0); + SWEEP_DATA : OUT std_logic_vector(95 downto 0); SWEEP_ADDRESS : OUT std_logic_vector(12 downto 0); SWEEP_WRITE : OUT std_logic_vector(0 downto 0); SWEEP_POINTS : OUT std_logic_vector(12 downto 0); - NSAMPLES : OUT std_logic_vector(16 downto 0); - SETTLING_TIME : OUT std_logic_vector(15 downto 0); + NSAMPLES : OUT std_logic_vector(12 downto 0); PORT1_EN : OUT std_logic; PORT2_EN : OUT std_logic; REF_EN : OUT std_logic; @@ -80,7 +79,7 @@ ARCHITECTURE behavior OF Test_SPICommands IS signal MOSI : std_logic := '0'; signal NSS : std_logic := '0'; signal NEW_SAMPLING_DATA : std_logic := '0'; - signal SAMPLING_RESULT : std_logic_vector(287 downto 0) := (others => '0'); + signal SAMPLING_RESULT : std_logic_vector(303 downto 0) := (others => '0'); signal SOURCE_UNLOCKED : std_logic := '1'; signal LO_UNLOCKED : std_logic := '1'; @@ -90,12 +89,11 @@ ARCHITECTURE behavior OF Test_SPICommands IS signal MAX2871_DEF_3 : std_logic_vector(31 downto 0); signal MAX2871_DEF_1 : std_logic_vector(31 downto 0); signal MAX2871_DEF_0 : std_logic_vector(31 downto 0); - signal SWEEP_DATA : std_logic_vector(111 downto 0); + signal SWEEP_DATA : std_logic_vector(95 downto 0); signal SWEEP_ADDRESS : std_logic_vector(12 downto 0); signal SWEEP_WRITE : std_logic_vector(0 downto 0); signal SWEEP_POINTS : std_logic_vector(12 downto 0); - signal NSAMPLES : std_logic_vector(16 downto 0); - signal SETTLING_TIME : std_logic_vector(15 downto 0); + signal NSAMPLES : std_logic_vector(12 downto 0); signal PORT1_EN : std_logic; signal PORT2_EN : std_logic; signal REF_EN : std_logic; @@ -133,7 +131,6 @@ BEGIN SWEEP_WRITE => SWEEP_WRITE, SWEEP_POINTS => SWEEP_POINTS, NSAMPLES => NSAMPLES, - SETTLING_TIME => SETTLING_TIME, PORT1_EN => PORT1_EN, PORT2_EN => PORT2_EN, REF_EN => REF_EN, diff --git a/FPGA/VNA/Test_Sampling.vhd b/FPGA/VNA/Test_Sampling.vhd index a964baa..b56f330 100644 --- a/FPGA/VNA/Test_Sampling.vhd +++ b/FPGA/VNA/Test_Sampling.vhd @@ -46,13 +46,12 @@ ARCHITECTURE behavior OF Test_Sampling IS RESET : IN std_logic; ADC_PRESCALER : IN std_logic_vector(7 downto 0); PHASEINC : IN std_logic_vector(11 downto 0); - PORT1 : IN std_logic_vector(15 downto 0); - PORT2 : IN std_logic_vector(15 downto 0); - REF : IN std_logic_vector(15 downto 0); + PORT1 : IN std_logic_vector(17 downto 0); + PORT2 : IN std_logic_vector(17 downto 0); + REF : IN std_logic_vector(17 downto 0); NEW_SAMPLE : IN std_logic; START : IN std_logic; - SAMPLES : IN std_logic_vector(12 downto 0); - WINDOW_TYPE : IN std_logic_vector(1 downto 0); + SAMPLES : IN std_logic_vector(12 downto 0); ADC_START : OUT std_logic; DONE : OUT std_logic; PRE_DONE : OUT std_logic; @@ -70,9 +69,9 @@ ARCHITECTURE behavior OF Test_Sampling IS --Inputs signal CLK : std_logic := '0'; signal RESET : std_logic := '0'; - signal PORT1 : std_logic_vector(15 downto 0) := (others => '0'); - signal PORT2 : std_logic_vector(15 downto 0) := (others => '0'); - signal REF : std_logic_vector(15 downto 0) := (others => '0'); + signal PORT1 : std_logic_vector(17 downto 0) := (others => '0'); + signal PORT2 : std_logic_vector(17 downto 0) := (others => '0'); + signal REF : std_logic_vector(17 downto 0) := (others => '0'); signal NEW_SAMPLE : std_logic := '0'; signal START : std_logic := '0'; signal SAMPLES : std_logic_vector(12 downto 0) := (others => '0'); @@ -107,8 +106,7 @@ BEGIN REF => REF, NEW_SAMPLE => NEW_SAMPLE, START => START, - SAMPLES => SAMPLES, - WINDOW_TYPE => "00", + SAMPLES => SAMPLES, ADC_START => ADC_START, DONE => DONE, PRE_DONE => PRE_DONE, @@ -117,7 +115,7 @@ BEGIN PORT2_I => PORT2_I, PORT2_Q => PORT2_Q, REF_I => REF_I, - REF_Q => REF_I, + REF_Q => REF_Q, ACTIVE => open ); @@ -141,11 +139,11 @@ BEGIN wait for CLK_period*10; -- insert stimulus here - ADC_PRESCALER <= "01110000"; + ADC_PRESCALER <= "011110000"; PHASEINC <= "010001100000"; - PORT1 <= "0111111111111111"; - PORT2 <= "0111111111111111"; - REF <= "0111111111111111"; + PORT1 <= "000001111111111111"; + PORT2 <= "000011111111111111"; + REF <= "000111111111111111"; SAMPLES <= "0000000000001"; START <= '1'; while True loop diff --git a/FPGA/VNA/Test_Sync.vhd b/FPGA/VNA/Test_Sync.vhd deleted file mode 100644 index 2e75fef..0000000 --- a/FPGA/VNA/Test_Sync.vhd +++ /dev/null @@ -1,117 +0,0 @@ --------------------------------------------------------------------------------- --- Company: --- Engineer: --- --- Create Date: 14:55:06 05/10/2020 --- Design Name: --- Module Name: /home/jan/Projekte/VNA/FPGA/VNA/Test_Sync.vhd --- Project Name: VNA --- Target Device: --- Tool versions: --- Description: --- --- VHDL Test Bench Created by ISE for module: SwitchingSync --- --- Dependencies: --- --- Revision: --- Revision 0.01 - File Created --- Additional Comments: --- --- Notes: --- This testbench has been automatically generated using types std_logic and --- std_logic_vector for the ports of the unit under test. Xilinx recommends --- that these types always be used for the top-level I/O of a design in order --- to guarantee that the testbench will bind correctly to the post-implementation --- simulation model. --------------------------------------------------------------------------------- -LIBRARY ieee; -USE ieee.std_logic_1164.ALL; - --- Uncomment the following library declaration if using --- arithmetic functions with Signed or Unsigned values ---USE ieee.numeric_std.ALL; - -ENTITY Test_Sync IS -END Test_Sync; - -ARCHITECTURE behavior OF Test_Sync IS - - -- Component Declaration for the Unit Under Test (UUT) - - COMPONENT SwitchingSync - Generic (CLK_DIV : integer); - PORT( - CLK : IN std_logic; - RESET : IN std_logic; - SETTING : IN std_logic_vector(1 downto 0); - SYNC_OUT : OUT std_logic; - SYNC_PULSE_IN : IN std_logic - ); - END COMPONENT; - - - --Inputs - signal CLK : std_logic := '0'; - signal RESET : std_logic := '0'; - signal SETTING : std_logic_vector(1 downto 0) := (others => '0'); - signal SYNC_PULSE_IN : std_logic := '0'; - - --Outputs - signal SYNC_OUT : std_logic; - - -- Clock period definitions - constant CLK_period : time := 6.25 ns; - constant SYNC_PULSE_period : time := 1031.25 ns; - -BEGIN - - -- Instantiate the Unit Under Test (UUT) - uut: SwitchingSync - GENERIC MAP (CLK_DIV => 160) - PORT MAP ( - CLK => CLK, - RESET => RESET, - SETTING => SETTING, - SYNC_OUT => SYNC_OUT, - SYNC_PULSE_IN => SYNC_PULSE_IN - ); - - -- Clock process definitions - CLK_process :process - begin - CLK <= '0'; - wait for CLK_period/2; - CLK <= '1'; - wait for CLK_period/2; - end process; - - SYNC_process :process - begin - SYNC_PULSE_IN <= '1'; - wait for CLK_period; - SYNC_PULSE_IN <= '0'; - wait for SYNC_PULSE_period - CLK_period; - end process; - - - -- Stimulus process - stim_proc: process - begin - -- hold reset state for 100 ns. - RESET <= '1'; - wait for 100 ns; - RESET <= '0'; - wait for CLK_period*10; - - -- insert stimulus here - SETTING <= "00"; - wait for CLK_period*1600; - SETTING <= "01"; - wait for CLK_period*1600; - SETTING <= "10"; - wait for CLK_period*1600; - wait; - end process; - -END; diff --git a/FPGA/VNA/Test_Window.vhd b/FPGA/VNA/Test_Window.vhd index 5da84dc..fc53c7f 100644 --- a/FPGA/VNA/Test_Window.vhd +++ b/FPGA/VNA/Test_Window.vhd @@ -43,7 +43,7 @@ ARCHITECTURE behavior OF Test_Window IS PORT( CLK : IN std_logic; INDEX : IN std_logic_vector(6 downto 0); - WINDOW : IN std_logic_vector(1 downto 0); + WINDOW_TYPE : IN std_logic_vector(1 downto 0); VALUE : OUT std_logic_vector(15 downto 0) ); END COMPONENT; @@ -52,7 +52,7 @@ ARCHITECTURE behavior OF Test_Window IS --Inputs signal CLK : std_logic := '0'; signal INDEX : std_logic_vector(6 downto 0) := (others => '0'); - signal WINDOW2 : std_logic_vector(1 downto 0) := (others => '0'); + signal WINDOW_TYPE : std_logic_vector(1 downto 0) := (others => '0'); --Outputs signal VALUE : std_logic_vector(15 downto 0); @@ -66,7 +66,7 @@ BEGIN uut: window PORT MAP ( CLK => CLK, INDEX => INDEX, - WINDOW => WINDOW2, + WINDOW_TYPE => WINDOW_TYPE, VALUE => VALUE ); @@ -85,11 +85,11 @@ BEGIN begin -- hold reset state for 100 ns. wait for 100 ns; - WINDOW2 <= "00"; + WINDOW_TYPE <= "00"; INDEX <= "0000000"; wait for CLK_period*10; - WINDOW2 <= "10"; + WINDOW_TYPE <= "10"; -- insert stimulus here wait for CLK_period*10; INDEX <= "0000001"; diff --git a/FPGA/VNA/Test_Windowing.vhd b/FPGA/VNA/Test_Windowing.vhd index 58517e4..398db59 100644 --- a/FPGA/VNA/Test_Windowing.vhd +++ b/FPGA/VNA/Test_Windowing.vhd @@ -48,9 +48,9 @@ ARCHITECTURE behavior OF Test_Windowing IS PORT2_RAW : IN std_logic_vector(15 downto 0); REF_RAW : IN std_logic_vector(15 downto 0); ADC_READY : IN std_logic; - PORT1_WINDOWED : OUT std_logic_vector(15 downto 0); - PORT2_WINDOWED : OUT std_logic_vector(15 downto 0); - REF_WINDOWED : OUT std_logic_vector(15 downto 0); + PORT1_WINDOWED : OUT std_logic_vector(17 downto 0); + PORT2_WINDOWED : OUT std_logic_vector(17 downto 0); + REF_WINDOWED : OUT std_logic_vector(17 downto 0); WINDOWING_DONE : OUT std_logic; NSAMPLES : IN std_logic_vector(12 downto 0) ); @@ -68,9 +68,9 @@ ARCHITECTURE behavior OF Test_Windowing IS signal NSAMPLES : std_logic_vector(12 downto 0) := (others => '0'); --Outputs - signal PORT1_WINDOWED : std_logic_vector(15 downto 0); - signal PORT2_WINDOWED : std_logic_vector(15 downto 0); - signal REF_WINDOWED : std_logic_vector(15 downto 0); + signal PORT1_WINDOWED : std_logic_vector(17 downto 0); + signal PORT2_WINDOWED : std_logic_vector(17 downto 0); + signal REF_WINDOWED : std_logic_vector(17 downto 0); signal WINDOWING_DONE : std_logic; -- Clock period definitions diff --git a/FPGA/VNA/VNA.gise b/FPGA/VNA/VNA.gise index 955d340..f25e55f 100644 --- a/FPGA/VNA/VNA.gise +++ b/FPGA/VNA/VNA.gise @@ -47,11 +47,11 @@ + + - - @@ -71,6 +71,7 @@ + @@ -121,6 +122,9 @@ + + + @@ -131,7 +135,7 @@ - + @@ -154,7 +158,6 @@ - @@ -162,89 +165,56 @@ - + - + - + - - - - - - - - - - - + + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + + + + - - - - - + - + + + + - - + @@ -254,7 +224,7 @@ - + @@ -262,8 +232,6 @@ - - @@ -285,7 +253,7 @@ - + @@ -307,7 +275,7 @@ - + @@ -316,10 +284,12 @@ - + + + @@ -330,7 +300,7 @@ - + @@ -344,7 +314,7 @@ - + @@ -398,7 +368,7 @@ - + diff --git a/FPGA/VNA/VNA.xise b/FPGA/VNA/VNA.xise index 1327387..7f1807b 100644 --- a/FPGA/VNA/VNA.xise +++ b/FPGA/VNA/VNA.xise @@ -17,14 +17,14 @@ - + - + @@ -34,21 +34,17 @@ - + - + - + - - - - @@ -64,15 +60,15 @@ - + - + - + @@ -92,19 +88,15 @@ - - - - - - - + - + + + @@ -114,7 +106,7 @@ - + @@ -128,7 +120,7 @@ - + @@ -138,18 +130,18 @@ - + - - + + - - + + - + @@ -160,9 +152,6 @@ - - - @@ -358,7 +347,7 @@ - + @@ -416,8 +405,8 @@ - - + + @@ -435,7 +424,7 @@ - + @@ -487,7 +476,7 @@ - + diff --git a/FPGA/VNA/Windowing.vhd b/FPGA/VNA/Windowing.vhd index 8271d3f..3750645 100644 --- a/FPGA/VNA/Windowing.vhd +++ b/FPGA/VNA/Windowing.vhd @@ -37,9 +37,9 @@ entity Windowing is PORT2_RAW : in STD_LOGIC_VECTOR (15 downto 0); REF_RAW : in STD_LOGIC_VECTOR (15 downto 0); ADC_READY : in STD_LOGIC; - PORT1_WINDOWED : out STD_LOGIC_VECTOR (15 downto 0); - PORT2_WINDOWED : out STD_LOGIC_VECTOR (15 downto 0); - REF_WINDOWED : out STD_LOGIC_VECTOR (15 downto 0); + PORT1_WINDOWED : out STD_LOGIC_VECTOR (17 downto 0); + PORT2_WINDOWED : out STD_LOGIC_VECTOR (17 downto 0); + REF_WINDOWED : out STD_LOGIC_VECTOR (17 downto 0); WINDOWING_DONE : out STD_LOGIC; NSAMPLES : in STD_LOGIC_VECTOR (12 downto 0)); end Windowing; @@ -171,19 +171,19 @@ begin WINDOWING_DONE <= '0'; mult_enable <= '1'; mult_b(15 downto 0) <= (others => '0'); - PORT1_WINDOWED <= mult_p(30 downto 15); + PORT1_WINDOWED <= mult_p(30 downto 13); state <= StorePort2; when StorePort2 => WINDOWING_DONE <= '0'; mult_enable <= '1'; mult_b(15 downto 0) <= (others => '0'); - PORT2_WINDOWED <= mult_p(30 downto 15); + PORT2_WINDOWED <= mult_p(30 downto 13); state <= StoreRef; when StoreRef => WINDOWING_DONE <= '1'; mult_enable <= '0'; mult_b(15 downto 0) <= (others => '0'); - REF_WINDOWED <= mult_p(30 downto 15); + REF_WINDOWED <= mult_p(30 downto 13); -- update window increment if window_sample_cnt + window_sample_cnt_inc < window_sample_compare then window_sample_cnt <= window_sample_cnt + window_sample_cnt_inc; diff --git a/FPGA/VNA/ipcore_dir/SinCosMult.xco b/FPGA/VNA/ipcore_dir/SinCosMult.xco deleted file mode 100644 index bae637f..0000000 --- a/FPGA/VNA/ipcore_dir/SinCosMult.xco +++ /dev/null @@ -1,68 +0,0 @@ -############################################################## -# -# Xilinx Core Generator version 14.6 -# Date: Tue May 5 15:41:30 2020 -# -############################################################## -# -# This file contains the customisation parameters for a -# Xilinx CORE Generator IP GUI. It is strongly recommended -# that you do not manually alter this file as it may cause -# unexpected and unsupported behavior. -# -############################################################## -# -# Generated from component: xilinx.com:ip:mult_gen:11.2 -# -############################################################## -# -# BEGIN Project Options -SET addpads = false -SET asysymbol = true -SET busformat = BusFormatAngleBracketNotRipped -SET createndf = false -SET designentry = VHDL -SET device = xc6slx9 -SET devicefamily = spartan6 -SET flowvendor = Other -SET formalverification = false -SET foundationsym = false -SET implementationfiletype = Ngc -SET package = tqg144 -SET removerpms = false -SET simulationfiles = Behavioral -SET speedgrade = -2 -SET verilogsim = false -SET vhdlsim = true -# END Project Options -# BEGIN Select -SELECT Multiplier xilinx.com:ip:mult_gen:11.2 -# END Select -# BEGIN Parameters -CSET ccmimp=Distributed_Memory -CSET clockenable=false -CSET component_name=SinCosMult -CSET constvalue=129 -CSET internaluser=0 -CSET multiplier_construction=Use_Mults -CSET multtype=Parallel_Multiplier -CSET optgoal=Speed -CSET outputwidthhigh=31 -CSET outputwidthlow=0 -CSET pipestages=2 -CSET portatype=Signed -CSET portawidth=16 -CSET portbtype=Signed -CSET portbwidth=16 -CSET roundpoint=0 -CSET sclrcepriority=SCLR_Overrides_CE -CSET syncclear=false -CSET use_custom_output_width=false -CSET userounding=false -CSET zerodetect=false -# END Parameters -# BEGIN Extra information -MISC pkg_timestamp=2012-11-05T14:23:07Z -# END Extra information -GENERATE -# CRC: 7fa795cb diff --git a/FPGA/VNA/ipcore_dir/SinCosMult.xise b/FPGA/VNA/ipcore_dir/SinCosMult.xise deleted file mode 100644 index a9f8a31..0000000 --- a/FPGA/VNA/ipcore_dir/SinCosMult.xise +++ /dev/null @@ -1,73 +0,0 @@ - - - -
- - - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
diff --git a/FPGA/VNA/ipcore_dir/result_bram.xco b/FPGA/VNA/ipcore_dir/result_bram.xco index 3baf072..5a73570 100644 --- a/FPGA/VNA/ipcore_dir/result_bram.xco +++ b/FPGA/VNA/ipcore_dir/result_bram.xco @@ -1,7 +1,7 @@ ############################################################## # # Xilinx Core Generator version 14.6 -# Date: Tue Nov 3 21:55:11 2020 +# Date: Sat Nov 7 15:56:38 2020 # ############################################################## # @@ -97,7 +97,7 @@ CSET use_regcea_pin=false CSET use_regceb_pin=false CSET use_rsta_pin=false CSET use_rstb_pin=false -CSET write_depth_a=64 +CSET write_depth_a=256 CSET write_width_a=192 CSET write_width_b=192 # END Parameters @@ -105,4 +105,4 @@ CSET write_width_b=192 MISC pkg_timestamp=2012-11-19T16:22:25Z # END Extra information GENERATE -# CRC: 64af2239 +# CRC: 14273b86 diff --git a/FPGA/VNA/ipcore_dir/result_bram.xise b/FPGA/VNA/ipcore_dir/result_bram.xise index cb2b34c..0abc844 100644 --- a/FPGA/VNA/ipcore_dir/result_bram.xise +++ b/FPGA/VNA/ipcore_dir/result_bram.xise @@ -17,11 +17,11 @@ - + - - + + @@ -29,30 +29,359 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - + + + + + + + + diff --git a/FPGA/VNA/top.bin b/FPGA/VNA/top.bin index 6ad41ec..1a6d8e3 100644 Binary files a/FPGA/VNA/top.bin and b/FPGA/VNA/top.bin differ diff --git a/FPGA/VNA/top.vhd b/FPGA/VNA/top.vhd index 41b0f72..391a933 100644 --- a/FPGA/VNA/top.vhd +++ b/FPGA/VNA/top.vhd @@ -156,9 +156,9 @@ architecture Behavioral of top is REF_RAW : IN std_logic_vector(15 downto 0); ADC_READY : IN std_logic; NSAMPLES : IN std_logic_vector(12 downto 0); - PORT1_WINDOWED : OUT std_logic_vector(15 downto 0); - PORT2_WINDOWED : OUT std_logic_vector(15 downto 0); - REF_WINDOWED : OUT std_logic_vector(15 downto 0); + PORT1_WINDOWED : OUT std_logic_vector(17 downto 0); + PORT2_WINDOWED : OUT std_logic_vector(17 downto 0); + REF_WINDOWED : OUT std_logic_vector(17 downto 0); WINDOWING_DONE : OUT std_logic ); END COMPONENT; @@ -170,9 +170,9 @@ architecture Behavioral of top is RESET : IN std_logic; ADC_PRESCALER : in STD_LOGIC_VECTOR(7 downto 0); PHASEINC : in STD_LOGIC_VECTOR(11 downto 0); - PORT1 : IN std_logic_vector(15 downto 0); - PORT2 : IN std_logic_vector(15 downto 0); - REF : IN std_logic_vector(15 downto 0); + PORT1 : IN std_logic_vector(17 downto 0); + PORT2 : IN std_logic_vector(17 downto 0); + REF : IN std_logic_vector(17 downto 0); NEW_SAMPLE : IN std_logic; START : IN std_logic; SAMPLES : IN std_logic_vector(12 downto 0); @@ -277,8 +277,8 @@ architecture Behavioral of top is PORT( CLK : IN std_logic; RESET : IN std_logic; - PORT1 : IN std_logic_vector(15 downto 0); - PORT2 : IN std_logic_vector(15 downto 0); + PORT1 : IN std_logic_vector(17 downto 0); + PORT2 : IN std_logic_vector(17 downto 0); NEW_SAMPLE : IN std_logic; NSAMPLES : IN std_logic_vector(12 downto 0); BIN1_PHASEINC : IN std_logic_vector(15 downto 0); @@ -342,9 +342,9 @@ architecture Behavioral of top is signal adc_minmax : std_logic_vector(95 downto 0); signal adc_reset_minmax : std_logic; - signal port1_windowed : std_logic_vector(15 downto 0); - signal port2_windowed : std_logic_vector(15 downto 0); - signal ref_windowed : std_logic_vector(15 downto 0); + signal port1_windowed : std_logic_vector(17 downto 0); + signal port2_windowed : std_logic_vector(17 downto 0); + signal ref_windowed : std_logic_vector(17 downto 0); signal windowing_ready : std_logic; -- Sampling signals @@ -753,7 +753,7 @@ begin dft_reset <= not dft_enable; - SA_DFT: DFT GENERIC MAP(BINS => 64) + SA_DFT: DFT GENERIC MAP(BINS => 96) PORT MAP( CLK => clk160, RESET => dft_reset, diff --git a/Software/PC_Application/Device/device.cpp b/Software/PC_Application/Device/device.cpp index 88c598d..439cfe7 100644 --- a/Software/PC_Application/Device/device.cpp +++ b/Software/PC_Application/Device/device.cpp @@ -129,12 +129,12 @@ static constexpr Protocol::DeviceInfo defaultInfo = { .limits_minFreq = 0, .limits_maxFreq = 6000000000, .limits_minIFBW = 10, - .limits_maxIFBW = 50000, - .limits_maxPoints = 4501, - .limits_cdbm_min = -4000, - .limits_cdbm_max = 0, - .limits_minRBW = 15, - .limits_maxRBW = 100000, + .limits_maxIFBW = 1000000, + .limits_maxPoints = 10000, + .limits_cdbm_min = -10000, + .limits_cdbm_max = 1000, + .limits_minRBW = 1, + .limits_maxRBW = 1000000, }; Protocol::DeviceInfo Device::lastInfo = defaultInfo; diff --git a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp index 252cffc..a1c612e 100644 --- a/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp +++ b/Software/PC_Application/SpectrumAnalyzer/spectrumanalyzer.cpp @@ -232,8 +232,8 @@ using namespace std; void SpectrumAnalyzer::NewDatapoint(Protocol::SpectrumAnalyzerResult d) { // TODO level adjustment in device - d.port1 /= pow(10.0, 7.5); - d.port2 /= pow(10.0, 7.5); + d.port1 /= 126500000.0; + d.port2 /= 126500000.0; d = average.process(d); traceModel.addSAData(d); emit dataChanged(); diff --git a/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.hpp b/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.hpp index cae5e3e..b6624ad 100644 --- a/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.hpp +++ b/Software/VNA_embedded/Application/Drivers/FPGA/FPGA.hpp @@ -6,7 +6,7 @@ namespace FPGA { static constexpr uint16_t MaxPoints = 4501; -static constexpr uint16_t DFTbins = 64; +static constexpr uint16_t DFTbins = 96; static constexpr uint32_t Clockrate = 102400000UL; enum class Reg {