1 ------------------------------------------------------------------------------- 2 -- File : JesdTestStreamTx.vhd 3 -- Company : SLAC National Accelerator Laboratory 4 -- Created : 2015-04-15 5 -- Last update: 2015-04-15 6 ------------------------------------------------------------------------------- 7 -- Description: Test Data Stream Generator 8 -- Outputs a saw, ramp, or square wave test signal data stream for testing 9 -- Saw signal increment (type_i = 00): Ramp step is determined by rampStep_i. 10 -- Saw signal decrement (type_i = 01): Ramp step is determined by rampStep_i. 11 -- Square wave(type_i = 10): Period is squarePeriod_i. Duty cycle is 50%. 12 -- Amplitude is determined by posAmplitude_i and negAmplitude_i. 13 -- pulse_o is a binary equivalent of the analogue square wave. 14 ------------------------------------------------------------------------------- 15 -- This file is part of 'SLAC Firmware Standard Library'. 16 -- It is subject to the license terms in the LICENSE.txt file found in the 17 -- top-level directory of this distribution and at: 18 -- https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. 19 -- No part of 'SLAC Firmware Standard Library', including this file, 20 -- may be copied, modified, propagated, or distributed except according to 21 -- the terms contained in the LICENSE.txt file. 22 ------------------------------------------------------------------------------- 25 use ieee.std_logic_1164.
all;
26 use ieee.std_logic_unsigned.
all;
31 use work.jesd204bpkg.
all;
34 --! @ingroup protocols_jesd204b 44 -- Enable signal generation 45 -- when switching between signal types the module has to be 46 -- disabled and re-enabled in order to align signals 50 type_i : in slv(1 downto 0);
52 -- Increase counter by the step 56 -- Positive and negative amplitude square wave 60 -- Sample data containing test signal 62 -- Digital out pulse for latency debug 65 end entity JesdTestStreamTx;
69 constant SAM_IN_WORD_C : positive := (GT_WORD_SIZE_C/F_G);
71 type RegType is record 72 squareCnt : slv(PER_STEP_WIDTH_C-1 downto 0);
73 rampCnt : (F_G*8-1 downto 0);
79 constant REG_INIT_C : RegType := ( 80 squareCnt => (others => '0'), 81 rampCnt => (others => '0'), 82 testData => (others => '0'), 87 signal r : RegType := REG_INIT_C;
98 ------------------------------------------------------------- 101 -- Saw tooth increment 106 -- Saw tooth decrement 111 -- Ramp up or down counter 112 if (v.inc = '1') then 113 -- Increment sample base 114 v.rampCnt := r.rampCnt + slvToInt(rampStep_i)*SAM_IN_WORD_C;
116 -- Increment samples within the word 117 for I in (SAM_IN_WORD_C-1) downto 0 loop 118 v.testData((F_G*8*I)+(F_G*8-1) downto F_G*8*I) := (r.rampCnt(F_G*8-1 downto 0)+((SAM_IN_WORD_C-1)-I)*slvToInt(rampStep_i));
121 -- Decrement sample base 122 v.rampCnt := r.rampCnt - slvToInt(rampStep_i)*SAM_IN_WORD_C;
124 -- Decrement samples within the word 125 for I in (SAM_IN_WORD_C-1) downto 0 loop 126 v.testData((F_G*8*I)+(F_G*8-1) downto F_G*8*I) := (r.rampCnt(F_G*8-1 downto 0)-((SAM_IN_WORD_C-1)-I)*slvToInt(rampStep_i));
130 -- Initialize square parameters 131 v.squareCnt := (others=>'0');
133 elsif (type_i = "10") then 134 v.squareCnt := r.squareCnt+1;
136 v.squareCnt := (others=>'0');
137 v.sign := not r.sign;
138 if (r.sign = '0') then 139 for I in (SAM_IN_WORD_C-1) downto 0 loop 142 elsif (r.sign = '1') then 143 for I in (SAM_IN_WORD_C-1) downto 0 loop 149 -- Initialize ramp parameters 150 v.rampCnt := (others=>'0');
153 v.testData := (others=>'0');
155 -- Initialize square parameters 156 v.squareCnt := (others=>'0');
159 -- Initialize ramp parameters 160 v.rampCnt := (others=>'0');
176 seq :
process (
clk)
is 178 if (rising_edge(clk)) then 179 r <= rin after TPD_G;
183 -- Digital square waveform out 185 -- Output data assignment 187 --------------------------------------- 188 end architecture rtl;
in squarePeriod_islv( PER_STEP_WIDTH_C- 1 downto 0)
out sampleData_oslv( GT_WORD_SIZE_C* 8- 1 downto 0)
in negAmplitude_islv( F_G* 8- 1 downto 0)
in type_islv( 1 downto 0)
in posAmplitude_islv( F_G* 8- 1 downto 0)
in rampStep_islv( PER_STEP_WIDTH_C- 1 downto 0)