From 01fc5edefbd34403772f034ba781396dad8b1379 Mon Sep 17 00:00:00 2001 From: Jan Michel Date: Tue, 16 Jul 2013 14:13:43 +0200 Subject: [PATCH] added temperature compensation to padiwa --- wasa/compile_panda_dirc_wasa_frankfurt.pl | 4 ++-- wasa/panda_dirc_wasa.p2t | 4 ++-- wasa/panda_dirc_wasa.vhd | 25 +++++++++++++++++++++-- wasa/source/pwm.vhd | 5 ++++- 4 files changed, 31 insertions(+), 7 deletions(-) diff --git a/wasa/compile_panda_dirc_wasa_frankfurt.pl b/wasa/compile_panda_dirc_wasa_frankfurt.pl index a3c41a7..766f4f9 100755 --- a/wasa/compile_panda_dirc_wasa_frankfurt.pl +++ b/wasa/compile_panda_dirc_wasa_frankfurt.pl @@ -117,8 +117,8 @@ execute($c); system("rm $TOPNAME.ncd"); - -$c=qq|$lattice_path/ispfpga/bin/lin/multipar -pr "$TOPNAME.prf" -o "mpar_$TOPNAME.rpt" -log "mpar_$TOPNAME.log" -p "../$TOPNAME.p2t" "$tpmap.ncd" "$TOPNAME.ncd"|; +#$c=qq|mpartrce -p "../$TOPNAME.p2t" -log "$TOPNAME.log" -o "$TOPNAME.rpt" -pr "$TOPNAME.prf" -tf "$TOPNAME.pt" "|.$TOPNAME.qq|_map.ncd" "$TOPNAME.ncd"|; + $c=qq|$lattice_path/ispfpga/bin/lin/multipar -pr "$TOPNAME.prf" -o "mpar_$TOPNAME.rpt" -log "mpar_$TOPNAME.log" -p "../$TOPNAME.p2t" "$tpmap.ncd" "$TOPNAME.ncd"|; execute($c); # IOR IO Timing Report diff --git a/wasa/panda_dirc_wasa.p2t b/wasa/panda_dirc_wasa.p2t index 0e70172..f479d4d 100644 --- a/wasa/panda_dirc_wasa.p2t +++ b/wasa/panda_dirc_wasa.p2t @@ -3,7 +3,7 @@ -l 5 -n 1 -y --s 12 +-s 1 -t 11 -c 1 -e 2 @@ -13,7 +13,7 @@ # -l 5 # -n 1 # -t 1 -# -s 1 +# -s 1 # -c 0 # -e 0 # diff --git a/wasa/panda_dirc_wasa.vhd b/wasa/panda_dirc_wasa.vhd index 2050264..f3d5e88 100644 --- a/wasa/panda_dirc_wasa.vhd +++ b/wasa/panda_dirc_wasa.vhd @@ -14,7 +14,8 @@ use machxo2.all; entity panda_dirc_wasa is generic( - PADIWA_FLAVOUR : integer := 2 + PADIWA_FLAVOUR : integer := 2; + TEMP_CORRECTION: integer := 0 ); port( CON : out std_logic_vector(16 downto 1); @@ -86,6 +87,7 @@ component pwm_generator CLK : in std_logic; DATA_IN : in std_logic_vector(15 downto 0); DATA_OUT : out std_logic_vector(15 downto 0); + COMP_IN : in signed(15 downto 0); WRITE_IN : in std_logic; ADDR_IN : in std_logic_vector(3 downto 0); PWM : out std_logic_vector(31 downto 0) @@ -197,7 +199,7 @@ signal inp_select : integer range 0 to 31 := 0; signal inp_invert : std_logic_vector(15 downto 0); signal input_enable : std_logic_vector(15 downto 0); signal inp_status : std_logic_vector(15 downto 0); -signal led_status : std_logic_vector(4 downto 0); +signal led_status : std_logic_vector(4 downto 0) := "10000"; signal timer : unsigned(18 downto 0) := (others => '0'); signal last_inp : std_logic_vector(3 downto 0) := (others => '0'); @@ -235,6 +237,11 @@ signal ram_fsm_addr_i : std_logic_vector(3 downto 0); signal ram_fsm_write_i: std_logic; signal enable_cfg_flash : std_logic; +signal comp_setting : std_logic_vector(15 downto 0); +signal compensate_i : signed(15 downto 0); +signal temp_calc_i : signed(27 downto 0); +signal temperature_i_s : std_logic_vector(11 downto 0); +signal comp_setting_s : std_logic_vector(15 downto 0); begin @@ -440,6 +447,7 @@ THE_PWM_GEN : pwm_generator CLK => clk_i, DATA_IN => pwm_data_i, DATA_OUT => pwm_data_o, + COMP_IN => compensate_i, WRITE_IN => pwm_write_i, ADDR_IN => pwm_addr_i, PWM => pwm_i @@ -523,6 +531,7 @@ THE_IO_REG_READ : process begin when x"3" => spi_reg20_i <= x"00" & "000" & std_logic_vector(to_unsigned(inp_select,5)); when x"4" => spi_reg20_i <= inp_invert; when x"5" => spi_reg20_i <= inp_stretch; + when x"6" => spi_reg20_i <= comp_setting; when others => null; end case; else @@ -545,6 +554,7 @@ THE_IO_REG_WRITE : process begin when x"3" => inp_select <= to_integer(unsigned(spi_data_i(4 downto 0))); when x"4" => inp_invert <= spi_data_i; when x"5" => inp_stretch <= spi_data_i; + when x"6" => comp_setting <= spi_data_i; when others => null; end case; end if; @@ -553,6 +563,17 @@ end process; inp_status <= INP_i when rising_edge(clk_i); last_inp <= inp_status(3 downto 0) when rising_edge(clk_i); +temperature_i_s <= temperature_i when rising_edge(clk_26); +comp_setting_s <= comp_setting when rising_edge(clk_26); +temp_calc_i <= signed(temperature_i_s) * signed(comp_setting_s) when rising_edge(clk_26); + +gen_comp: if TEMP_CORRECTION = 1 generate + compensate_i <= temp_calc_i(27 downto 12) when rising_edge(clk_26); +end generate; +gen_no_comp: if TEMP_CORRECTION = 0 generate + compensate_i <= (others => '0'); +end generate; + --------------------------------------------------------------------------- -- LED blinking when activity on inputs diff --git a/wasa/source/pwm.vhd b/wasa/source/pwm.vhd index d167d44..38d2383 100644 --- a/wasa/source/pwm.vhd +++ b/wasa/source/pwm.vhd @@ -11,6 +11,7 @@ entity pwm_generator is DATA_IN : in std_logic_vector(15 downto 0) := (others => '0'); DATA_OUT : out std_logic_vector(15 downto 0); WRITE_IN : in std_logic := '0'; + COMP_IN : in signed(15 downto 0); ADDR_IN : in std_logic_vector(3 downto 0) := (others => '0'); @@ -25,6 +26,7 @@ architecture pwm_arch of pwm_generator is type ram_t is array(0 to 15) of unsigned(16 downto 0); signal set : ram_t := (others => '0' & x"87C1"); +signal set_tmp : ram_t; type cnt_t is array(0 to 15) of unsigned(16 downto 0); signal cnt : cnt_t := (others => (others => '0')); @@ -50,7 +52,8 @@ gen_channels : for i in 0 to 15 generate flag(i) <= cnt(i)(16); last_flag(i) <= flag(i) when rising_edge(CLK); pwm_i(i) <= (last_flag(i) xor flag(i)) when rising_edge(CLK); - cnt(i) <= cnt(i) + set(i) when rising_edge(CLK); + set_tmp(i) <= unsigned(signed(set(i)) + resize(COMP_IN,17)); + cnt(i) <= cnt(i) + set_tmp(i) when rising_edge(CLK); end generate; -- 2.43.0