]> jspc29.x-matter.uni-frankfurt.de Git - trb3.git/commitdiff
added temperature compensation to padiwa
authorJan Michel <j.michel@gsi.de>
Tue, 16 Jul 2013 12:13:43 +0000 (14:13 +0200)
committerJan Michel <j.michel@gsi.de>
Tue, 16 Jul 2013 12:13:43 +0000 (14:13 +0200)
wasa/compile_panda_dirc_wasa_frankfurt.pl
wasa/panda_dirc_wasa.p2t
wasa/panda_dirc_wasa.vhd
wasa/source/pwm.vhd

index a3c41a7268fa3b0a91a63877f82f8501dda85de2..766f4f923b9d178e79d0f8a75e2752ed44fe8aa1 100755 (executable)
@@ -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
index 0e70172113854799fb6e2bf40de993a0f5cbd80e..f479d4d1862d00a6579080515dc3212bde1506e1 100644 (file)
@@ -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
 #
index 2050264cbaf8f8871252bfdaa037621fe78f8245..f3d5e88c253e872fc9090b5edeff31419a5665b4 100644 (file)
@@ -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
index d167d44ab62945e116f32fab429ab4105e6a99fc..38d2383f7d1fd774485bf5d9dd2aecc106dee037 100644 (file)
@@ -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;