Skip to content
Snippets Groups Projects
Commit cf4316f9 authored by Daniel van der Schuur's avatar Daniel van der Schuur
Browse files

-Cleaned code.

parent 4fdb66a5
No related branches found
No related tags found
1 merge request!137st_histogram updates. Ready for integration in LOFAR2.
......@@ -80,10 +80,9 @@ ARCHITECTURE tb OF tb_st_histogram IS
-- Constants derived from generics
---------------------------------------------------------------------------
CONSTANT c_expected_ram_content_counter : NATURAL := g_nof_data_per_sync/g_nof_bins;
CONSTANT c_nof_levels_per_bin : NATURAL := (2**g_data_w)/g_nof_bins; --e.g. 2 values per bin if g_data_w=9 (512 levels) and g_nof_bins=256
CONSTANT c_ram_dat_w : NATURAL := ceil_log2(g_nof_data_per_sync)+1;
CONSTANT c_ram_adr_w : NATURAL := ceil_log2(g_nof_bins);
CONSTANT c_nof_levels_per_bin : NATURAL := (2**g_data_w)/g_nof_bins; --e.g. 2 values per bin if g_data_w=9 (512 levels) and g_nof_bins=256
CONSTANT c_ram_dat_w : NATURAL := ceil_log2(g_nof_data_per_sync)+1;
CONSTANT c_ram_adr_w : NATURAL := ceil_log2(g_nof_bins);
---------------------------------------------------------------------------
-- Clocks and resets
......@@ -98,21 +97,20 @@ ARCHITECTURE tb OF tb_st_histogram IS
----------------------------------------------------------------------------
-- stimuli
----------------------------------------------------------------------------
CONSTANT c_sine_amplitude : REAL := real((2**g_data_w)/2-1);
CONSTANT c_sine_amplitude : REAL := real((2**g_data_w)/2-1);
CONSTANT c_sine_nof_periods : REAL := 1.0;
CONSTANT c_sine_nof_samples_per_period : REAL := real(g_nof_data_per_sync)/c_sine_nof_periods;
CONSTANT c_sine_time_step_denom : REAL := sel_a_b(g_lock_sine, MATH_2_PI, 5.0); -- Use 5 instead of 2 pi to create unlocked, drifting sine wave
CONSTANT c_sine_time_step : REAL := c_sine_time_step_denom / c_sine_nof_samples_per_period;
SIGNAL stimuli_en : STD_LOGIC := '1';
SIGNAL stimuli_src_out : t_dp_sosi;
SIGNAL stimuli_en : STD_LOGIC := '1';
SIGNAL stimuli_src_out : t_dp_sosi;
SIGNAL nxt_stimuli_src_out : t_dp_sosi;
SIGNAL stimuli_src_in : t_dp_siso;
SIGNAL stimuli_count : REAL;
SIGNAL stimuli_data : STD_LOGIC_VECTOR(g_data_w-1 DOWNTO 0); --NOTE This is undefined in the wave window
SIGNAL stimuli_done : STD_LOGIC;
SIGNAL stimuli_src_in : t_dp_siso;
SIGNAL stimuli_count : REAL;
SIGNAL stimuli_data : STD_LOGIC_VECTOR(g_data_w-1 DOWNTO 0); -- QuestaSim: Format->Analog, Radix->Decimal
SIGNAL random_data : STD_LOGIC_VECTOR(g_data_w-1 DOWNTO 0);
SIGNAL stimuli_done : STD_LOGIC;
----------------------------------------------------------------------------
-- st_histogram
......@@ -131,8 +129,8 @@ ARCHITECTURE tb OF tb_st_histogram IS
SIGNAL histogram_bin_signed : INTEGER; -- QuestaSim: Radix->Decimal
SIGNAL histogram_valid : STD_LOGIC;
SIGNAL sum_of_bins : NATURAL;
SIGNAL verification_done : STD_LOGIC;
SIGNAL sum_of_bins : NATURAL;
SIGNAL verification_done : STD_LOGIC;
BEGIN
......@@ -188,13 +186,10 @@ BEGIN
nxt_stimuli_src_out.valid <= '1';
stimuli_count <= 0.0;
FOR I IN 0 TO g_nof_sync-1 LOOP
-- nxt_stimuli_src_out.data <= (OTHERS=>'0');
-- stimuli_data <= (OTHERS=>'0');
nxt_stimuli_src_out.sync <= '1'; -- cycle 0
WAIT FOR 5 ns;
FOR j IN 1 TO g_nof_data_per_sync-1 LOOP --cycles 1..g_nof_data_per_sync-1
nxt_stimuli_src_out.sync <= '0';
-- stimuli_data <= TO_SVEC( integer(round( c_sine_amplitude * sin(stimuli_count) )), g_data_w);
nxt_stimuli_src_out.data(g_data_w-1 DOWNTO 0) <= TO_SVEC( integer(round( c_sine_amplitude * sin(stimuli_count) )), g_data_w);
stimuli_count<=stimuli_count+c_sine_time_step;
WAIT FOR 5 ns;
......@@ -206,13 +201,13 @@ BEGIN
IF g_stimuli_mode="random" THEN
nxt_stimuli_src_out.valid <= '1';
FOR I IN 0 TO g_nof_sync-1 LOOP
stimuli_data <= (OTHERS=>'0');
random_data <= (OTHERS=>'0');
nxt_stimuli_src_out.sync <= '1'; -- cycle 0
WAIT FOR 5 ns;
FOR j IN 1 TO g_nof_data_per_sync-1 LOOP
nxt_stimuli_src_out.sync <= '0';
stimuli_data <= func_common_random(stimuli_data);
nxt_stimuli_src_out.data(g_data_w-1 DOWNTO 0) <= stimuli_data; --all g_nof_data_per_sync cycles
random_data <= func_common_random(random_data);
nxt_stimuli_src_out.data(g_data_w-1 DOWNTO 0) <= random_data; --all g_nof_data_per_sync cycles
WAIT FOR 5 ns;
END LOOP;
END LOOP;
......@@ -232,8 +227,10 @@ BEGIN
stimuli_src_out <= nxt_stimuli_src_out;
END IF;
END PROCESS;
-- nxt_stimuli_src_out.data(g_data_w-1 DOWNTO 0) <= stimuli_data;
-- signal to verify histogram by eye in the wave window
stimuli_data <= stimuli_src_out.data(g_data_w-1 DOWNTO 0);
----------------------------------------------------------------------------
-- st_histogram
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment