]> jspc29.x-matter.uni-frankfurt.de Git - logicbox.git/commitdiff
SED seems to work in MachXO3 according to SEI tool
authorJan Michel <j.michel@gsi.de>
Tue, 29 Mar 2016 12:21:36 +0000 (14:21 +0200)
committerJan Michel <j.michel@gsi.de>
Tue, 29 Mar 2016 12:21:36 +0000 (14:21 +0200)
code/sedcheck.vhd [new file with mode: 0644]
default/diamond/LogicBox.ldf
default/logicbox.prj
default/logicbox.vhd

diff --git a/code/sedcheck.vhd b/code/sedcheck.vhd
new file mode 100644 (file)
index 0000000..0c67d6f
--- /dev/null
@@ -0,0 +1,198 @@
+library ieee;
+use ieee.std_logic_1164.all;
+use ieee.numeric_std.all;
+
+library work;
+use work.trb_net_std.all;
+
+library ecp5um;
+use ecp5um.components.all;
+
+entity sedcheck is
+  port(
+    CLK        : in std_logic;
+    ERROR_OUT  : out std_logic;
+    
+    CONTROL_IN : in std_logic_vector(3 downto 0);
+    DEBUG      : out std_logic_vector(31 downto 0)
+    );
+end entity;
+
+
+architecture sed_arch of sedcheck is
+  component SEDFA
+    generic (
+      CHECKALWAYS : string :="DISABLED";
+      SED_CLK_FREQ : string :="3.5" ;
+      DEV_DENSITY : string :="2100L" 
+      );
+    port (
+      SEDSTDBY  : in std_logic;
+      SEDENABLE : in std_logic;
+      SEDSTART : in std_logic;
+      SEDFRCERR : in std_logic;
+      SEDERR : out std_logic;
+      SEDDONE : out std_logic;
+      SEDINPROG : out std_logic;
+      SEDCLKOUT : out std_logic
+      );
+  end component;  
+  type state_t is (IDLE, INIT_1, INIT_2, INIT_3, START_1, START_2, WAITACTIVE, WAITDONE);
+  signal state          : state_t;
+  signal state_bits     : std_logic_vector(3 downto 0);
+
+  signal sed_edge       : std_logic;
+  signal sed_clock_last : std_logic;
+
+  signal sed_clock      : std_logic;
+  signal sed_done       : std_logic;
+  signal sed_enable     : std_logic;
+  signal sed_error      : std_logic;
+  signal sed_inprogress : std_logic;
+  signal sed_start      : std_logic;
+
+  signal sed_clock_q      : std_logic;
+  signal sed_done_q       : std_logic;
+  signal sed_error_q      : std_logic;
+  signal sed_inprogress_q : std_logic;
+
+  signal status_i       : std_logic_vector(31 downto 0);
+  
+  signal run_counter    : unsigned(7 downto 0) := (others => '0');
+  signal error_counter  : unsigned(7 downto 0) := (others => '0');
+  signal timer          : unsigned(22 downto 0);
+  
+begin
+
+sed_clock_last <= sed_clock_q when rising_edge(CLK);
+sed_edge       <= sed_clock_q and not sed_clock_last when rising_edge(CLK);
+
+sed_clock_q      <= sed_clock when rising_edge(CLK);
+sed_done_q       <= sed_done when rising_edge(CLK);
+sed_inprogress_q <= sed_inprogress when rising_edge(CLK);
+sed_error_q      <= sed_error when rising_edge(CLK);
+
+
+---------------------------------------------------------------------------
+-- SED control state machine
+---------------------------------------------------------------------------
+proc_ctrl : process begin
+  wait until rising_edge(CLK);
+  timer <= timer + 1;
+  case state is
+    when IDLE =>
+      sed_enable   <= '0';
+      sed_start    <= '0';
+      if CONTROL_IN(0) = '1' then
+        state      <= INIT_1;
+        timer      <= (0 => '1', others => '0');
+      end if;
+    when INIT_1 =>
+      sed_enable   <= '0';
+      sed_start    <= '0';
+      if timer(5 downto 0) = 0 then
+        state      <= INIT_2;
+      end if;
+    when INIT_2 =>
+      sed_enable   <= '1';
+      sed_start    <= '0';
+      if timer(5 downto 0) = 0 then
+        state      <= INIT_3;
+      end if;
+    when INIT_3 =>
+      sed_enable   <= '1';
+      sed_start    <= '0';
+      if timer(5 downto 0) = 0 then
+        state      <= START_1;
+      end if;
+    when START_1 =>
+      sed_enable   <= '1';
+      sed_start    <= '0';
+      if sed_edge = '1' then
+        state      <= START_2;
+      end if;
+    when START_2 =>      
+      sed_enable   <= '1';
+      sed_start    <= '1';
+      if sed_edge = '1' and sed_inprogress_q = '1' then
+        state      <= WAITACTIVE;
+      end if;
+    when WAITACTIVE =>
+      sed_enable   <= '1';
+      sed_start    <= '1';
+      if sed_edge = '1' and sed_done_q = '0' then
+        state      <= WAITDONE;
+      end if;
+    when WAITDONE =>
+      sed_enable   <= '1';
+      sed_start    <= '1';
+      if (sed_edge = '1' and sed_inprogress_q = '0' and sed_done_q = '1') then
+        state       <= INIT_1;\r
+               timer       <= (0 => '1', others => '0');
+        run_counter <= run_counter + 1;
+        if sed_error_q = '1' then
+          error_counter <= error_counter + 1;
+        end if;
+      end if;
+  end case;
+  
+  if CONTROL_IN(0) = '0' or (timer = 0 and state /= IDLE) then
+    sed_enable <= '0';
+    state      <= IDLE;
+  end if;
+  
+end process;
+
+---------------------------------------------------------------------------
+-- Status Information
+---------------------------------------------------------------------------
+state_bits <= x"8" when state = IDLE else
+              x"1" when state = INIT_1 else
+              x"2" when state = INIT_2 else
+              x"3" when state = INIT_3 else
+              x"4" when state = START_1 else
+              x"5" when state = START_2 else
+              x"6" when state = WAITACTIVE else
+              x"7" when state = WAITDONE else
+--               x"9" when state = RESULT else
+              x"F";
+
+status_i(3 downto 0) <= state_bits;
+status_i(4)          <= sed_clock_q;
+status_i(5)          <= sed_enable;
+status_i(6)          <= sed_start;
+status_i(7)          <= sed_done_q;
+status_i(8)          <= sed_inprogress_q;
+status_i(9)          <= sed_error_q;
+status_i(10)         <= not sed_edge;
+status_i(15 downto 11) <= (others => '0');
+status_i(23 downto 16) <= std_logic_vector(run_counter)(7 downto 0);
+status_i(31 downto 24) <= std_logic_vector(error_counter)(7 downto 0);
+              
+ERROR_OUT <= sed_error;              
+DEBUG     <= status_i when rising_edge(CLK);
+
+---------------------------------------------------------------------------
+-- SED
+---------------------------------------------------------------------------
+THE_SED : SEDFA
+  generic map(
+      CHECKALWAYS  => "DISABLED",
+      SED_CLK_FREQ   => "3.5",
+      DEV_DENSITY  => "2100L" 
+      )
+  port map(
+    SEDSTDBY  => '0',
+    SEDENABLE => sed_enable,
+    SEDSTART  => sed_start,
+    SEDFRCERR => '0',
+    SEDERR    => sed_error,
+    SEDDONE   => sed_done,
+    SEDINPROG => sed_inprogress,
+    SEDCLKOUT => sed_clock
+    );
+    
+    
+end architecture; 
index 8e00e2031f4310085226b041fce46aa014fe8498..f7226b8ed0e264349a6f6418ce47c046886ebb93 100644 (file)
@@ -2,13 +2,10 @@
 <BaliProject version="3.2" title="L" device="LCMXO3LF-2100E-5UWG49CTR" default_implementation="L">
     <Options/>
     <Implementation title="L" dir="L" description="L" synthesis="synplify" default_strategy="Strategy1">
-        <Options  top="logicbox"/>
+        <Options def_top="uart_sctrl" top="logicbox"/>
         <Source name="../logicbox.vhd" type="VHDL" type_short="VHDL">
             <Options top_module="logicbox"/>
         </Source>
-        <Source name="../../../padiwa/source/uart_sctrl.vhd" type="VHDL" type_short="VHDL">
-            <Options/>
-        </Source>
         <Source name="../../../trbnet/special/uart_rec.vhd" type="VHDL" type_short="VHDL">
             <Options/>
         </Source>
         <Source name="../../../trbnet/trb_net_std.vhd" type="VHDL" type_short="VHDL">
             <Options/>
         </Source>
+        <Source name="../../code/sedcheck.vhd" type="VHDL" type_short="VHDL">
+            <Options/>
+        </Source>
+        <Source name="../../code/uart_sctrl.vhd" type="VHDL" type_short="VHDL">
+            <Options/>
+        </Source>
+        <Source name="L/L.xcf" type="Programming Project File" type_short="Programming">
+            <Options/>
+        </Source>
+        <Source name="Test/Test.spf" type="Simulation Project File" type_short="SPF">
+            <Options/>
+        </Source>
+        <Source name="sei.xcf" type="Programming Project File" type_short="Programming" excluded="TRUE">
+            <Options/>
+        </Source>
         <Source name="../../pinout/logicbox.lpf" type="Logic Preference" type_short="LPF">
             <Options/>
         </Source>
+        <Source name="../../../trb3/trb3_gbe/projectfrankfurt/powertest.pcf" type="Power Calculator" type_short="PCF" excluded="TRUE">
+            <Options/>
+        </Source>
     </Implementation>
     <Strategy name="Strategy1" file="LogicBox1.sty"/>
 </BaliProject>
index d0b8b95f621de30acf4c86db5884aa5939b015c3..657a0cb1cba76624283e5ebb5dcb8fa3457b35b8 100644 (file)
@@ -7,7 +7,9 @@
 add_file -vhdl -lib work "/d/jspc29/lattice/diamond/3.6_x64/cae_library/synthesis/vhdl/machxo3lf.vhd"
 
 #add_file -vhdl -lib work "../../trbnet/lattice/machxo3/fifo_9x2k_oreg.vhd"
+add_file -vhdl -lib work "../../trbnet/trb_net_std.vhd"
 add_file -vhdl -lib work "../code/uart_sctrl.vhd"
+add_file -vhdl -lib work "../code/sedcheck.vhd"
 add_file -vhdl -lib work "../../trbnet/special/uart_rec.vhd"
 add_file -vhdl -lib work "../../trbnet/special/uart_trans.vhd"
 add_file -vhdl -lib work "logicbox.vhd"
index 1e5296b8966e77e664f289701d900a363872db6a..216128969a80fb1b11b2eb0eb1271ce8be844f50 100644 (file)
@@ -5,6 +5,8 @@ use ieee.numeric_std.all;
 library machxo3lf;\r
 use machxo3lf.all;\r
 \r
+library work;\r
+use work.trb_net_std.all;\r
 \r
 entity logicbox is\r
   port(\r
@@ -54,6 +56,10 @@ architecture arch of logicbox is
   signal reg         : std_logic_vector(31 downto 0);\r
   signal last_config : std_logic_vector(3 downto 0);\r
  \r
+  signal sed_error : std_logic;\r
+  signal sed_debug : std_logic_vector(31 downto 0);\r
+  signal controlsed_i : std_logic_vector(3 downto 0);\r
\r
   component OSCH\r
     generic (NOM_FREQ: string := "133.00");\r
     port (\r
@@ -214,6 +220,7 @@ process begin
 end process;  \r
 \r
 LED <= led_i when led_highz = '0' else "ZZZZ";\r
+-- LED <= sed_debug(3 downto 0);\r
 \r
 ---------------------------------------------------------------------------\r
 -- UART\r
@@ -247,15 +254,26 @@ PROC_REGS : process begin
     case uart_addr is\r
       when x"00" => uart_tx_data <= x"0000000" & config;\r
       when x"10" => uart_tx_data <= reg;\r
+      when x"ee" => uart_tx_data <= sed_debug;\r
     end case;\r
   elsif bus_write = '1' then\r
     case uart_addr is\r
       when x"10" => reg <= uart_rx_data;\r
+         when x"ee" => controlsed_i <= uart_rx_data(3 downto 0);\r
     end case;\r
   end if;\r
 end process;\r
 \r
 \r
+THE_SED : entity work.sedcheck\r
+  port map(\r
+    CLK        => clk_i,\r
+    ERROR_OUT  => sed_error,\r
+    \r
+    CONTROL_IN => controlsed_i,\r
+    DEBUG      => sed_debug\r
+    );\r
+    \r
 \r
 end architecture;\r
 \r