1717-------------------------------------------------------------------------------
1818library ieee;
1919use ieee.std_logic_1164.all ;
20+ use ieee.numeric_std.all ;
2021
2122use work.wishbone_pkg.all ;
2223
@@ -27,13 +28,23 @@ package rtm_lamp_pkg is
2728 constant c_MAX_ADC_CHANNELS : natural := 12 ;
2829 constant c_MAX_DAC_CHANNELS : natural := 12 ;
2930
31+ -- Number of bits for PI coeficients. Must match register map!
32+ constant c_PI_COEFF_BITS : natural := 26 ;
33+ -- Number of bits for PI setpoint. Must match register map!
34+ constant c_PI_SP_BITS : natural := 16 ;
35+
3036 --------------------------------------------------------------------
3137 -- Types
3238 --------------------------------------------------------------------
3339 subtype t_16b_word is std_logic_vector (15 downto 0 );
34-
3540 type t_16b_word_array is array (natural range <> ) of t_16b_word;
3641
42+ subtype t_pi_coeff_word is std_logic_vector (c_PI_COEFF_BITS- 1 downto 0 );
43+ type t_pi_coeff_word_array is array (natural range <> ) of t_pi_coeff_word;
44+
45+ subtype t_pi_sp_word is std_logic_vector (c_PI_SP_BITS- 1 downto 0 );
46+ type t_pi_sp_word_array is array (natural range <> ) of t_pi_sp_word;
47+
3748 --------------------------------------------------------------------
3849 -- Components
3950 --------------------------------------------------------------------
@@ -112,6 +123,7 @@ package rtm_lamp_pkg is
112123 sck_ret_i : in std_logic ;
113124 ready_o : out std_logic := '0' ;
114125 done_pp_o : out std_logic ;
126+ done_cnv_pp_ref_sys_o : out std_logic ;
115127 sdo1a_i : in std_logic ;
116128 sdo2_i : in std_logic := '0' ;
117129 sdo3b_i : in std_logic := '0' ;
@@ -237,7 +249,15 @@ package rtm_lamp_pkg is
237249 -- Serial registers clock frequency [Hz]
238250 g_SERIAL_REG_SCLK_FREQ : natural := 100000 ;
239251 -- Number of AMP channels
240- g_SERIAL_REGS_AMP_CHANNELS : natural := 12
252+ g_SERIAL_REGS_AMP_CHANNELS : natural := 12 ;
253+ -- Number of for PI coeficients
254+ g_PI_COEFF_BITS : natural := 26 ;
255+ -- Number od ADC bits
256+ g_ADC_BITS : natural := 16 ;
257+ -- Use Chipscope or not
258+ g_WITH_CHIPSCOPE : boolean := false ;
259+ -- Use VIO or not
260+ g_WITH_VIO : boolean := false
241261 );
242262 port (
243263 ---------------------------------------------------------------------------
@@ -318,6 +338,42 @@ package rtm_lamp_pkg is
318338 dac_ready_o : out std_logic ;
319339 dac_done_pp_o : out std_logic ;
320340
341+ dbg_dac_start_o : out std_logic ;
342+ dbg_dac_data_o : out t_16b_word_array(g_DAC_CHANNELS- 1 downto 0 );
343+
344+ ---------------------------------------------------------------------------
345+ -- PI parameters
346+ ---------------------------------------------------------------------------
347+ -- Kp parameter
348+ pi_kp_i : in t_pi_coeff_word_array(g_DAC_CHANNELS- 1 downto 0 );
349+ -- Ti parameter
350+ pi_ti_i : in t_pi_coeff_word_array(g_DAC_CHANNELS- 1 downto 0 );
351+ -- Setpoint parameter
352+ pi_sp_i : in t_pi_sp_word_array(g_DAC_CHANNELS- 1 downto 0 );
353+
354+ -- select if we want a triangular wave directly at the DAC inputs. Limits defined by
355+ -- pi_sp_i and pi_sp_lim_inf_i
356+ pi_ol_mode_triang_enable_i : in std_logic_vector (g_DAC_CHANNELS- 1 downto 0 );
357+ -- select if we want a square wave directly at the DAC inputs. Limits defined by
358+ -- pi_sp_i and pi_sp_lim_inf_i
359+ pi_ol_mode_square_enable_i : in std_logic_vector (g_DAC_CHANNELS- 1 downto 0 );
360+ -- defines the period of both triang/square modes in ADC clock ticks
361+ pi_ol_dac_mode_counter_max_i : in unsigned (21 downto 0 );
362+ -- defines the other limit for triang/square modes. pi_sp_i being one and
363+ -- pi_sp_lim_inf_i the other
364+ pi_sp_lim_inf_i : in std_logic_vector (g_ADC_BITS- 1 downto 0 );
365+
366+ -- select if we want a square wave at the PI inputs
367+ pi_sp_mode_square_enable_i : in std_logic_vector (g_DAC_CHANNELS- 1 downto 0 );
368+
369+ -- enagble or disable PI controller. if pi_enable_i = 0, then dac_data_i/dac_start_i
370+ -- takes effect and the RTM board can be controller in open_loop. Otherwise, pi_ol modes
371+ -- take effect and lastly, if everything = 0, pi_sp_i takes effect to set PI setpoint
372+ pi_enable_i : in std_logic_vector (g_DAC_CHANNELS- 1 downto 0 );
373+
374+ -- debug output to monitor PI Setpoint
375+ dbg_pi_ctrl_sp_o : out t_pi_sp_word_array(g_DAC_CHANNELS- 1 downto 0 );
376+
321377 ---------------------------------------------------------------------------
322378 -- AMP parallel interface
323379 ---------------------------------------------------------------------------
@@ -363,7 +419,15 @@ package rtm_lamp_pkg is
363419 -- Serial registers clock frequency [Hz]
364420 g_SERIAL_REG_SCLK_FREQ : natural := 100000 ;
365421 -- Number of AMP channels
366- g_SERIAL_REGS_AMP_CHANNELS : natural := 12
422+ g_SERIAL_REGS_AMP_CHANNELS : natural := 12 ;
423+ -- Number of for PI coeficients
424+ g_PI_COEFF_BITS : natural := 26 ;
425+ -- Number od ADC bits
426+ g_ADC_BITS : natural := 16 ;
427+ -- Use Chipscope or not
428+ g_WITH_CHIPSCOPE : boolean := false ;
429+ -- Use VIO or not
430+ g_WITH_VIO : boolean := false
367431 );
368432 port (
369433 ---------------------------------------------------------------------------
@@ -457,7 +521,16 @@ package rtm_lamp_pkg is
457521 dac_start_i : in std_logic ;
458522 dac_data_i : in std_logic_vector (16 * g_DAC_CHANNELS- 1 downto 0 );
459523 dac_ready_o : out std_logic ;
460- dac_done_pp_o : out std_logic
524+ dac_done_pp_o : out std_logic ;
525+
526+ dbg_dac_start_o : out std_logic ;
527+ dbg_dac_data_o : out std_logic_vector (16 * g_DAC_CHANNELS- 1 downto 0 );
528+
529+ ---------------------------------------------------------------------------
530+ -- PI parameters
531+ ---------------------------------------------------------------------------
532+ -- debug output to monitor PI Setpoint
533+ dbg_pi_ctrl_sp_o : out std_logic_vector (16 * g_DAC_CHANNELS- 1 downto 0 )
461534 );
462535 end component ;
463536
@@ -491,7 +564,15 @@ package rtm_lamp_pkg is
491564 -- Serial registers clock frequency [Hz]
492565 g_SERIAL_REG_SCLK_FREQ : natural := 100000 ;
493566 -- Number of AMP channels
494- g_SERIAL_REGS_AMP_CHANNELS : natural := 12
567+ g_SERIAL_REGS_AMP_CHANNELS : natural := 12 ;
568+ -- Number of for PI coeficients
569+ g_PI_COEFF_BITS : natural := 26 ;
570+ -- Number od ADC bits
571+ g_ADC_BITS : natural := 16 ;
572+ -- Use Chipscope or not
573+ g_WITH_CHIPSCOPE : boolean := false ;
574+ -- Use VIO or not
575+ g_WITH_VIO : boolean := false
495576 );
496577 port (
497578 ---------------------------------------------------------------------------
@@ -576,7 +657,17 @@ package rtm_lamp_pkg is
576657 dac_start_i : in std_logic ;
577658 dac_data_i : in t_16b_word_array(g_DAC_CHANNELS- 1 downto 0 );
578659 dac_ready_o : out std_logic ;
579- dac_done_pp_o : out std_logic
660+ dac_done_pp_o : out std_logic ;
661+
662+ dbg_dac_start_o : out std_logic ;
663+ dbg_dac_data_o : out t_16b_word_array(g_DAC_CHANNELS- 1 downto 0 );
664+
665+ ---------------------------------------------------------------------------
666+ -- PI parameters
667+ ---------------------------------------------------------------------------
668+
669+ -- debug output to monitor PI Setpoint
670+ dbg_pi_ctrl_sp_o : out t_pi_sp_word_array(g_DAC_CHANNELS- 1 downto 0 )
580671 );
581672 end component ;
582673
0 commit comments