From 8f8733aefb530048c074726438270afff99a4cd0 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Mon, 17 Feb 2020 22:22:50 +0100 Subject: [PATCH 01/16] wip --- hdl/top.vhd | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hdl/top.vhd b/hdl/top.vhd index e8b54f5..2cc8822 100644 --- a/hdl/top.vhd +++ b/hdl/top.vhd @@ -19,6 +19,9 @@ PORT( HEX4 : out std_logic_vector(6 downto 0); HEX5 : out std_logic_vector(6 downto 0); + -- //////////// Infrared Interface ////////// + IRDA_RXD : in std_logic; + IRDA_TXD : in std_logic; ---------HPS Connections--------------- HPS_CONV_USB_N : inout std_logic; From 57d0885373c46a92a8bcc9eb4c46ec789c86510b Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 14:17:26 +0100 Subject: [PATCH 02/16] add hdl units --- hdl/components/infrared/counter.vhd | 91 +++++++++++++++++++ hdl/components/infrared/infrared.vhd | 116 ++++++++++++++++++++++++ hdl/components/infrared/strobe_gen.vhd | 119 +++++++++++++++++++++++++ hdl/components/infrared/sync.vhd | 101 +++++++++++++++++++++ 4 files changed, 427 insertions(+) create mode 100644 hdl/components/infrared/counter.vhd create mode 100644 hdl/components/infrared/infrared.vhd create mode 100644 hdl/components/infrared/strobe_gen.vhd create mode 100644 hdl/components/infrared/sync.vhd diff --git a/hdl/components/infrared/counter.vhd b/hdl/components/infrared/counter.vhd new file mode 100644 index 0000000..d129025 --- /dev/null +++ b/hdl/components/infrared/counter.vhd @@ -0,0 +1,91 @@ +------------------------------------------------------------------------------- +--! @file counter.vhd +--! @author Michael Wurm +--! @copyright 2020 Michael Wurm +--! @brief Entity implementation of counter. +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +--! @brief Entity declaration of counter +--! @details +--! Provides a counter value of clock ticks of clk_i. +--! The counter is free-running, and thus overflows at its maximum. + +entity counter is + port ( + --! @name Clocks and resets + --! @{ + + --! System clock + clk_i : in std_logic; + --! Asynchronous reset + rst_n_i : in std_logic; + + --! @} + --! @name Control signals + --! @{ + + --! Enable + enable_i : in std_ulogic; + --! Generated strobe + count_o : out std_ulogic_vector(31 downto 0)); + + --! @} + +end entity counter; + +--! RTL implementation of counter +architecture rtl of counter is + ----------------------------------------------------------------------------- + --! @name Internal Registers + ----------------------------------------------------------------------------- + --! @{ + + signal count : unsigned(count_o'range); + + --! @} + ----------------------------------------------------------------------------- + --! @name Internal Wires + ----------------------------------------------------------------------------- + --! @{ + + + --! @} + +begin -- architecture rtl + + ------------------------------------------------------------------------------ + -- Outputs + ------------------------------------------------------------------------------ + + count_o <= count; + + ----------------------------------------------------------------------------- + -- Signal Assignments + ----------------------------------------------------------------------------- + + ------------------------------------------------------------------------------ + -- Registers + ------------------------------------------------------------------------------ + + regs : process (clk_i, rst_n_i) is + procedure reset is + begin + count <= to_unsigned(0, count'length); + end procedure reset; + begin -- process strobe + if rst_n_i = '0' then + reset; + elsif rising_edge(clk_i) then + if enable_i = '0' then + reset; + else + count <= count + 1; + end if; + end if; + end process regs; + +end architecture rtl; diff --git a/hdl/components/infrared/infrared.vhd b/hdl/components/infrared/infrared.vhd new file mode 100644 index 0000000..e31e345 --- /dev/null +++ b/hdl/components/infrared/infrared.vhd @@ -0,0 +1,116 @@ +------------------------------------------------------------------------------- +--! @file infrared.vhd +--! @author Michael Wurm +--! @copyright 2020 Michael Wurm +--! @brief Entity implementation of infrared. +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +--! @brief Entity declaration of infrared +--! @details +--! TODO + +entity infrared is + generic ( + --! System clock frequency + clk_freq_g : natural := clk_freq_c; + --! Period between two strobes + period_g : time := 100 us); + port ( + --! @name Clocks and resets + --! @{ + + --! System clock + clk_i : in std_logic; + --! Asynchronous reset + rst_n_i : in std_logic; + + --! @} + --! @name Strobe signals + --! @{ + + --! Enable + enable_i : in std_ulogic; + --! Generated strobe + strobe_o : out std_ulogic); + + --! @} + +begin + + -- pragma translate_off + assert ((1 sec / clk_freq_g) <= period_g) + report "infrared: The Clk frequency is to low to generate such a short strobe cycle." + severity error; + -- pragma translate_on + +end entity infrared; + +--! RTL implementation of infrared +architecture rtl of infrared is + ----------------------------------------------------------------------------- + --! @name Types and Constants + ----------------------------------------------------------------------------- + --! @{ + + constant clks_per_strobe_c : natural := clk_freq_g / (1 sec / period_g); + + --! @} + ----------------------------------------------------------------------------- + --! @name Internal Registers + ----------------------------------------------------------------------------- + --! @{ + + signal count : unsigned(log_dualis(clks_per_strobe_c) downto 0); + + --! @} + ----------------------------------------------------------------------------- + --! @name Internal Wires + ----------------------------------------------------------------------------- + --! @{ + + signal strobe : std_ulogic; + + --! @} + +begin -- architecture rtl + + ------------------------------------------------------------------------------ + -- Outputs + ------------------------------------------------------------------------------ + + strobe_o <= strobe; + + ------------------------------------------------------------------------------ + -- Registers + ------------------------------------------------------------------------------ + + -- Count the number of clk_i cycles from strobe pulse to strobe pulse. + regs : process (clk_i, rst_n_i) is + procedure reset is + begin + count <= to_unsigned(0, count'length); + strobe <= '0'; + end procedure reset; + begin -- process strobe + if rst_n_i = '0' then + reset; + elsif rising_edge(clk_i) then + if enable_i = '0' then + reset; + else + if count = clks_per_strobe_c-1 then + count <= (others => '0'); + strobe <= '1'; + else + count <= count + 1; + strobe <= '0'; + end if; + end if; + end if; + end process regs; + +end architecture rtl; diff --git a/hdl/components/infrared/strobe_gen.vhd b/hdl/components/infrared/strobe_gen.vhd new file mode 100644 index 0000000..8c26822 --- /dev/null +++ b/hdl/components/infrared/strobe_gen.vhd @@ -0,0 +1,119 @@ +------------------------------------------------------------------------------- +--! @file strobe_gen.vhd +--! @author Michael Wurm +--! @copyright 2020 Michael Wurm +--! @brief Entity implementation of strobe_gen. +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +--! @brief Entity declaration of strobe_gen +--! @details +--! Generates a strobe signal that will be '1' for one clock cycle +--! of clk_i. The strobe comes every period_g. If this cycle time +--! cannot be generated exactly it will be truncated with the +--! accuracy of one clk_i cycle. + +entity strobe_gen is + generic ( + --! System clock frequency + clk_freq_g : natural := clk_freq_c; + --! Period between two strobes + period_g : time := 100 us); + port ( + --! @name Clocks and resets + --! @{ + + --! System clock + clk_i : in std_logic; + --! Asynchronous reset + rst_n_i : in std_logic; + + --! @} + --! @name Strobe signals + --! @{ + + --! Enable + enable_i : in std_ulogic; + --! Generated strobe + strobe_o : out std_ulogic); + + --! @} + +begin + + -- pragma translate_off + assert ((1 sec / clk_freq_g) <= period_g) + report "strobe_gen: The Clk frequency is to low to generate such a short strobe cycle." + severity error; + -- pragma translate_on + +end entity strobe_gen; + +--! RTL implementation of strobe_gen +architecture rtl of strobe_gen is + ----------------------------------------------------------------------------- + --! @name Types and Constants + ----------------------------------------------------------------------------- + --! @{ + + constant clks_per_strobe_c : natural := clk_freq_g / (1 sec / period_g); + + --! @} + ----------------------------------------------------------------------------- + --! @name Internal Registers + ----------------------------------------------------------------------------- + --! @{ + + signal count : unsigned(log_dualis(clks_per_strobe_c) downto 0); + + --! @} + ----------------------------------------------------------------------------- + --! @name Internal Wires + ----------------------------------------------------------------------------- + --! @{ + + signal strobe : std_ulogic; + + --! @} + +begin -- architecture rtl + + ------------------------------------------------------------------------------ + -- Outputs + ------------------------------------------------------------------------------ + + strobe_o <= strobe; + + ------------------------------------------------------------------------------ + -- Registers + ------------------------------------------------------------------------------ + + -- Count the number of clk_i cycles from strobe pulse to strobe pulse. + regs : process (clk_i, rst_n_i) is + procedure reset is + begin + count <= to_unsigned(0, count'length); + strobe <= '0'; + end procedure reset; + begin -- process strobe + if rst_n_i = '0' then + reset; + elsif rising_edge(clk_i) then + if enable_i = '0' then + reset; + else + if count = clks_per_strobe_c-1 then + count <= (others => '0'); + strobe <= '1'; + else + count <= count + 1; + strobe <= '0'; + end if; + end if; + end if; + end process regs; + +end architecture rtl; diff --git a/hdl/components/infrared/sync.vhd b/hdl/components/infrared/sync.vhd new file mode 100644 index 0000000..2caec00 --- /dev/null +++ b/hdl/components/infrared/sync.vhd @@ -0,0 +1,101 @@ +------------------------------------------------------------------------------- +--! @file sync.vhd +--! @author Michael Wurm +--! @copyright 2020 Michael Wurm +--! @brief Implementation of sync. +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; + +--! @brief Entity declaration of sync +--! @details +--! The sync implementation. + +entity sync is + generic ( + init_value_g : std_ulogic := '0'; + num_delays_g : natural := 2; + sig_width_g : natural := 1); + port ( + --! @name Clocks and resets + --! @{ + + --! System clock + clk_i : in std_logic; + --! Asynchronous reset + rst_n_i : in std_logic; + + --! @} + --! @name Sync signals + --! @{ + + --! Asynchronous input + async_i : in std_ulogic_vector(sig_width_g-1 downto 0); + --! Synchronous output + sync_o : out std_ulogic_vector(sig_width_g-1 downto 0)); + + --! @} + +end entity sync; + +--! RTL implementation of sync +architecture rtl of sync is + ----------------------------------------------------------------------------- + --! @name Types and Constants + ----------------------------------------------------------------------------- + --! @{ + + type delay_t is array(num_delays_g-1 downto 0) of + std_ulogic_vector(sig_width_g-1 downto 0); + + --! @} + ----------------------------------------------------------------------------- + --! @name Internal Registers + ----------------------------------------------------------------------------- + --! @{ + + signal delay : delay_t := (others => (others => init_value_g)); + + --! @} + ----------------------------------------------------------------------------- + --! @name Internal Wires + ----------------------------------------------------------------------------- + --! @{ + + signal next_delay : delay_t := (others => (others => init_value_g)); + + --! @} + +begin -- architecture rtl + + ------------------------------------------------------------------------------ + -- Outputs + ------------------------------------------------------------------------------ + + sync_o <= delay(delay'high); + + ----------------------------------------------------------------------------- + -- Signal Assignments + ----------------------------------------------------------------------------- + + next_delay <= delay(delay'high-1 downto delay'low) & async_i; + + ------------------------------------------------------------------------------ + -- Registers + ------------------------------------------------------------------------------ + + regs : process(clk_i, rst_n_i) + procedure reset is + begin + delay <= (others => (others => init_value_g)); + end procedure reset; + begin -- process regs + if rst_n_i = '0' then + reset; + elsif rising_edge(clk_i) then + delay <= next_delay; + end if; + end process regs; + +end architecture rtl; From 19e4f6a83b713423308b443e1aef0cac1b05c244 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 15:20:53 +0100 Subject: [PATCH 03/16] implement infrared entity --- hdl/components/infrared/infrared.vhd | 118 +++++++++++++++++++-------- 1 file changed, 84 insertions(+), 34 deletions(-) diff --git a/hdl/components/infrared/infrared.vhd b/hdl/components/infrared/infrared.vhd index e31e345..9358e15 100644 --- a/hdl/components/infrared/infrared.vhd +++ b/hdl/components/infrared/infrared.vhd @@ -14,11 +14,6 @@ use ieee.numeric_std.all; --! TODO entity infrared is - generic ( - --! System clock frequency - clk_freq_g : natural := clk_freq_c; - --! Period between two strobes - period_g : time := 100 us); port ( --! @name Clocks and resets --! @{ @@ -29,23 +24,32 @@ entity infrared is rst_n_i : in std_logic; --! @} - --! @name Strobe signals + --! @name Avalon MM Bus --! @{ + avs_s0_address : in std_logic_vector(7 downto 0); + avs_s0_read : in std_logic; + avs_s0_readdata : out std_logic_vector(31 downto 0); + avs_s0_write : in std_logic; + avs_s0_writedata : in std_logic_vector(31 downto 0); + avs_s0_waitrequest : out std_logic; - --! Enable - enable_i : in std_ulogic; - --! Generated strobe - strobe_o : out std_ulogic); + --! @} + --! @name Infrared transceiver signals + --! @{ - --! @} + --! IR Receive + ir_rx_i : in std_ulogic; + --! IR Transmit + ir_tx_o : out std_ulogic; + + --! @} + --! @name Status signals + --! @{ -begin + --! IR Receive Mirror + ir_rx_o : out std_ulogic); - -- pragma translate_off - assert ((1 sec / clk_freq_g) <= period_g) - report "infrared: The Clk frequency is to low to generate such a short strobe cycle." - severity error; - -- pragma translate_on + --! @} end entity infrared; @@ -56,15 +60,18 @@ architecture rtl of infrared is ----------------------------------------------------------------------------- --! @{ - constant clks_per_strobe_c : natural := clk_freq_g / (1 sec / period_g); - --! @} ----------------------------------------------------------------------------- --! @name Internal Registers ----------------------------------------------------------------------------- --! @{ - signal count : unsigned(log_dualis(clks_per_strobe_c) downto 0); + type ram_t is array(0 to 255) of std_ulogic_vector(31 downto 0); + signal ram : ram_t := (others => (others => '0')); + + signal addr : unsigned(7 downto 0) := (others => '0'); + signal ir_rx : std_ulogic_vector(1 downto 0); + signal store_timestamp : std_ulogic; --! @} ----------------------------------------------------------------------------- @@ -72,7 +79,10 @@ architecture rtl of infrared is ----------------------------------------------------------------------------- --! @{ - signal strobe : std_ulogic; + signal ir_rx_sync : std_ulogic; + signal rising : std_ulogic; + signal falling : std_ulogic; + signal timestamp : std_ulogic_vector(31 downto 0); --! @} @@ -82,35 +92,75 @@ begin -- architecture rtl -- Outputs ------------------------------------------------------------------------------ - strobe_o <= strobe; + ir_rx_o <= ir_rx(ir_rx'high); + avs_s0_readdata <= ram_readdata; + + ----------------------------------------------------------------------------- + -- Signal Assignments + ----------------------------------------------------------------------------- + + next_ir_rx <= ir_rx(ir_rx'high-1 downto ir_rx'low) & ir_rx_sync; + rising <= '1' when ir_rx(1)='0' and ir_rx(0)='1' else '0'; + falling <= not rising; + + ----------------------------------------------------------------------------- + -- Instantiations + ----------------------------------------------------------------------------- + + sync_inst : entity work.sync + generic map ( + init_value_g => '0', + num_delays_g => 2, + sig_width_g => 1) + port map ( + clk_i => clk_i, + rst_n_i => rst_n_i, + async_i => ir_rx_i, + sync_o => ir_rx_sync); + + counter_inst : entity work.counter + port map ( + clk_i => clk_i, + rst_n_i => rst_n_i, + enable_i => '1', + count_o => timestamp); ------------------------------------------------------------------------------ -- Registers ------------------------------------------------------------------------------ - -- Count the number of clk_i cycles from strobe pulse to strobe pulse. regs : process (clk_i, rst_n_i) is procedure reset is begin - count <= to_unsigned(0, count'length); + addr <= to_unsigned(0, count'length); strobe <= '0'; end procedure reset; begin -- process strobe if rst_n_i = '0' then reset; elsif rising_edge(clk_i) then - if enable_i = '0' then - reset; - else - if count = clks_per_strobe_c-1 then - count <= (others => '0'); - strobe <= '1'; - else - count <= count + 1; - strobe <= '0'; - end if; + -- Defaults + ir_rx <= next_ir_rx; + store_timestamp <= '0'; + + if rising = '1' or falling = '1' then + addr <= addr + 1; + store_timestamp <= '1'; end if; end if; end process regs; + ram : process (clk_i) is + begin + if rising_edge(clk_i) then + if store_timestamp = '1' then + ram(to_integer(addr)) <= timestamp; + end if; + + if avs_s0_read = '1' then + ram_readdata <= ram(to_integer(to_unsigned(avs_s0_address, addr'length))); + end if; + end if; + end process ram; + end architecture rtl; From d22ef9b687d51edb931aec9ced8ddc2a6cd82281 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 16:20:40 +0100 Subject: [PATCH 04/16] instantiate counters --- hdl/components/infrared/comp.do | 18 ++++++++++++++ hdl/components/infrared/counter.vhd | 21 ++++++++++++---- hdl/components/infrared/infrared.vhd | 36 +++++++++++++++++++++------- 3 files changed, 63 insertions(+), 12 deletions(-) create mode 100644 hdl/components/infrared/comp.do diff --git a/hdl/components/infrared/comp.do b/hdl/components/infrared/comp.do new file mode 100644 index 0000000..dca8e74 --- /dev/null +++ b/hdl/components/infrared/comp.do @@ -0,0 +1,18 @@ + +#----------------------------------*-tcl-*- + +#------------------------------------------- +proc myvcom {filename} { + if {[file exists ${filename}] == 1} { + puts "## vcom $filename" + vcom -93 -novopt -quiet ${filename} -work work + } else { + puts "## WARNING: File not found: ${filename}" + } +} + +#------------------------------------------- +vlib work +myvcom counter.vhd +myvcom sync.vhd +myvcom infrared.vhd diff --git a/hdl/components/infrared/counter.vhd b/hdl/components/infrared/counter.vhd index d129025..7df6422 100644 --- a/hdl/components/infrared/counter.vhd +++ b/hdl/components/infrared/counter.vhd @@ -15,6 +15,8 @@ use ieee.numeric_std.all; --! The counter is free-running, and thus overflows at its maximum. entity counter is + generic ( + counter_width_g : natural := 31); port ( --! @name Clocks and resets --! @{ @@ -25,13 +27,15 @@ entity counter is rst_n_i : in std_logic; --! @} - --! @name Control signals + --! @name Control and status signals --! @{ --! Enable enable_i : in std_ulogic; + --! Overflow + overflow_o : out std_ulogic; --! Generated strobe - count_o : out std_ulogic_vector(31 downto 0)); + count_o : out std_ulogic_vector(counter_width_g-1 downto 0)); --! @} @@ -45,6 +49,7 @@ architecture rtl of counter is --! @{ signal count : unsigned(count_o'range); + signal overflow : std_ulogic := '0'; --! @} ----------------------------------------------------------------------------- @@ -61,7 +66,8 @@ begin -- architecture rtl -- Outputs ------------------------------------------------------------------------------ - count_o <= count; + count_o <= count; + overflow_o <= overflow; ----------------------------------------------------------------------------- -- Signal Assignments @@ -75,15 +81,22 @@ begin -- architecture rtl procedure reset is begin count <= to_unsigned(0, count'length); + overflow <= '0'; end procedure reset; - begin -- process strobe + begin -- process regs if rst_n_i = '0' then reset; elsif rising_edge(clk_i) then + -- Defaults + overflow <= '0'; + if enable_i = '0' then reset; else count <= count + 1; + if count = 2**count'length-1 then + overflow <= '1'; + end if; end if; end if; end process regs; diff --git a/hdl/components/infrared/infrared.vhd b/hdl/components/infrared/infrared.vhd index 9358e15..c86c191 100644 --- a/hdl/components/infrared/infrared.vhd +++ b/hdl/components/infrared/infrared.vhd @@ -11,7 +11,8 @@ use ieee.numeric_std.all; --! @brief Entity declaration of infrared --! @details ---! TODO +--! Stores timestamps on every change of the IR LED input. +--! In that way, a sequence can be recorded and reproduced afterwards. entity infrared is port ( @@ -46,6 +47,8 @@ entity infrared is --! @name Status signals --! @{ + --! Done recording interrupt + done_recording_irq_o : out std_ulogic; --! IR Receive Mirror ir_rx_o : out std_ulogic); @@ -82,6 +85,7 @@ architecture rtl of infrared is signal ir_rx_sync : std_ulogic; signal rising : std_ulogic; signal falling : std_ulogic; + signal recording_stopped : std_ulogic; signal timestamp : std_ulogic_vector(31 downto 0); --! @} @@ -94,6 +98,7 @@ begin -- architecture rtl ir_rx_o <= ir_rx(ir_rx'high); avs_s0_readdata <= ram_readdata; + done_recording_irq_o <= recording_stopped; ----------------------------------------------------------------------------- -- Signal Assignments @@ -101,7 +106,7 @@ begin -- architecture rtl next_ir_rx <= ir_rx(ir_rx'high-1 downto ir_rx'low) & ir_rx_sync; rising <= '1' when ir_rx(1)='0' and ir_rx(0)='1' else '0'; - falling <= not rising; + falling <= '1' when ir_rx(1)='1' and ir_rx(0)='0' else '0'; ----------------------------------------------------------------------------- -- Instantiations @@ -118,12 +123,25 @@ begin -- architecture rtl async_i => ir_rx_i, sync_o => ir_rx_sync); - counter_inst : entity work.counter - port map ( - clk_i => clk_i, - rst_n_i => rst_n_i, - enable_i => '1', - count_o => timestamp); + timestamp_counter_inst : entity work.counter + generic map ( + counter_width_g => 31) + port map ( + clk_i => clk_i, + rst_n_i => rst_n_i, + enable_i => '1', + overflow_o => open, + count_o => timestamp); + + stop_counter_inst : entity work.counter + generic map ( + counter_width_g => 25) -- 2^25 steps @ 100MHz => 0.3355 sec + port map ( + clk_i => clk_i, + rst_n_i => rst_n_i, + enable_i => falling, + overflow_o => recording_stopped, + count_o => timestamp); ------------------------------------------------------------------------------ -- Registers @@ -146,6 +164,8 @@ begin -- architecture rtl if rising = '1' or falling = '1' then addr <= addr + 1; store_timestamp <= '1'; + elsif recording_stopped = '1' then + addr <= (others => '0'); end if; end if; end process regs; From 9c8555d0861e8fcbc02235bd6d3e40b2e097ca7d Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 16:37:56 +0100 Subject: [PATCH 05/16] fix errors --- hdl/components/infrared/comp.do | 3 + hdl/components/infrared/counter.vhd | 2 +- hdl/components/infrared/infrared.vhd | 24 ++++--- hdl/components/infrared/sync_single.vhd | 91 +++++++++++++++++++++++++ 4 files changed, 108 insertions(+), 12 deletions(-) create mode 100644 hdl/components/infrared/sync_single.vhd diff --git a/hdl/components/infrared/comp.do b/hdl/components/infrared/comp.do index dca8e74..41abef2 100644 --- a/hdl/components/infrared/comp.do +++ b/hdl/components/infrared/comp.do @@ -15,4 +15,7 @@ proc myvcom {filename} { vlib work myvcom counter.vhd myvcom sync.vhd +myvcom sync_single.vhd myvcom infrared.vhd + +quit diff --git a/hdl/components/infrared/counter.vhd b/hdl/components/infrared/counter.vhd index 7df6422..c2d6677 100644 --- a/hdl/components/infrared/counter.vhd +++ b/hdl/components/infrared/counter.vhd @@ -35,7 +35,7 @@ entity counter is --! Overflow overflow_o : out std_ulogic; --! Generated strobe - count_o : out std_ulogic_vector(counter_width_g-1 downto 0)); + count_o : out unsigned(counter_width_g-1 downto 0)); --! @} diff --git a/hdl/components/infrared/infrared.vhd b/hdl/components/infrared/infrared.vhd index c86c191..9da7054 100644 --- a/hdl/components/infrared/infrared.vhd +++ b/hdl/components/infrared/infrared.vhd @@ -69,8 +69,10 @@ architecture rtl of infrared is ----------------------------------------------------------------------------- --! @{ - type ram_t is array(0 to 255) of std_ulogic_vector(31 downto 0); - signal ram : ram_t := (others => (others => '0')); + subtype timestamp_t is unsigned(31 downto 0); + type ram_t is array(0 to 255) of timestamp_t; + signal ram_data : ram_t := (others => (others => '0')); + signal ram_readdata : timestamp_t := (others => '0'); signal addr : unsigned(7 downto 0) := (others => '0'); signal ir_rx : std_ulogic_vector(1 downto 0); @@ -83,10 +85,11 @@ architecture rtl of infrared is --! @{ signal ir_rx_sync : std_ulogic; + signal next_ir_rx : std_ulogic_vector(1 downto 0); signal rising : std_ulogic; signal falling : std_ulogic; signal recording_stopped : std_ulogic; - signal timestamp : std_ulogic_vector(31 downto 0); + signal timestamp : timestamp_t; --! @} @@ -97,7 +100,7 @@ begin -- architecture rtl ------------------------------------------------------------------------------ ir_rx_o <= ir_rx(ir_rx'high); - avs_s0_readdata <= ram_readdata; + avs_s0_readdata <= std_logic_vector(ram_readdata); done_recording_irq_o <= recording_stopped; ----------------------------------------------------------------------------- @@ -112,11 +115,10 @@ begin -- architecture rtl -- Instantiations ----------------------------------------------------------------------------- - sync_inst : entity work.sync + sync_inst : entity work.sync_single generic map ( init_value_g => '0', - num_delays_g => 2, - sig_width_g => 1) + num_delays_g => 2) port map ( clk_i => clk_i, rst_n_i => rst_n_i, @@ -150,8 +152,8 @@ begin -- architecture rtl regs : process (clk_i, rst_n_i) is procedure reset is begin - addr <= to_unsigned(0, count'length); - strobe <= '0'; + addr <= to_unsigned(0, addr'length); + store_timestamp <= '0'; end procedure reset; begin -- process strobe if rst_n_i = '0' then @@ -174,11 +176,11 @@ begin -- architecture rtl begin if rising_edge(clk_i) then if store_timestamp = '1' then - ram(to_integer(addr)) <= timestamp; + ram_data(to_integer(addr)) <= timestamp; end if; if avs_s0_read = '1' then - ram_readdata <= ram(to_integer(to_unsigned(avs_s0_address, addr'length))); + ram_readdata <= ram_data(to_integer(unsigned(avs_s0_address))); end if; end if; end process ram; diff --git a/hdl/components/infrared/sync_single.vhd b/hdl/components/infrared/sync_single.vhd new file mode 100644 index 0000000..d43a07a --- /dev/null +++ b/hdl/components/infrared/sync_single.vhd @@ -0,0 +1,91 @@ +------------------------------------------------------------------------------- +--! @file sync_single.vhd +--! @author Michael Wurm +--! @copyright 2020 Michael Wurm +--! @brief Implementation of sync_single. +------------------------------------------------------------------------------- + +library ieee; +use ieee.std_logic_1164.all; + +--! @brief Entity declaration of sync_single +--! @details +--! The sync_single implementation. + +entity sync_single is + generic ( + init_value_g : std_ulogic := '0'; + num_delays_g : natural := 2); + port ( + --! @name Clocks and resets + --! @{ + + --! System clock + clk_i : in std_logic; + --! Asynchronous reset + rst_n_i : in std_logic; + + --! @} + --! @name Sync signals + --! @{ + + --! Asynchronous input + async_i : in std_ulogic; + --! Synchronous output + sync_o : out std_ulogic); + + --! @} + +end entity sync_single; + +--! RTL implementation of sync_single +architecture rtl of sync_single is + ----------------------------------------------------------------------------- + --! @name Internal Registers + ----------------------------------------------------------------------------- + --! @{ + + signal delay : std_ulogic_vector(num_delays_g-1 downto 0) := (others => '0'); + + --! @} + ----------------------------------------------------------------------------- + --! @name Internal Wires + ----------------------------------------------------------------------------- + --! @{ + + signal next_delay : std_ulogic_vector(delay'range); + + --! @} + +begin -- architecture rtl + + ------------------------------------------------------------------------------ + -- Outputs + ------------------------------------------------------------------------------ + + sync_o <= delay(delay'high); + + ----------------------------------------------------------------------------- + -- Signal Assignments + ----------------------------------------------------------------------------- + + next_delay <= delay(delay'high-1 downto delay'low) & async_i; + + ------------------------------------------------------------------------------ + -- Registers + ------------------------------------------------------------------------------ + + regs : process(clk_i, rst_n_i) + procedure reset is + begin + delay <= (others => init_value_g); + end procedure reset; + begin -- process regs + if rst_n_i = '0' then + reset; + elsif rising_edge(clk_i) then + delay <= next_delay; + end if; + end process regs; + +end architecture rtl; From 5134bd3841020918d7da7c0e2309394163ec56b6 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 16:43:45 +0100 Subject: [PATCH 06/16] create infrared_hw.tcl --- hdl/components/infrared/infrared_hw.tcl | 122 ++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 hdl/components/infrared/infrared_hw.tcl diff --git a/hdl/components/infrared/infrared_hw.tcl b/hdl/components/infrared/infrared_hw.tcl new file mode 100644 index 0000000..370220c --- /dev/null +++ b/hdl/components/infrared/infrared_hw.tcl @@ -0,0 +1,122 @@ +# TCL File Generated by Component Editor 19.1 +# Tue Feb 18 16:43:18 CET 2020 +# DO NOT MODIFY + + +# +# infrared "infrared" v1.0 +# Michael Wurm 2020.02.18.16:43:18 +# Infrared Recorder/Transmitter +# + +# +# request TCL package from ACDS 16.1 +# +package require -exact qsys 16.1 + + +# +# module infrared +# +set_module_property DESCRIPTION "Infrared Recorder/Transmitter" +set_module_property NAME infrared +set_module_property VERSION 1.0 +set_module_property INTERNAL false +set_module_property OPAQUE_ADDRESS_MAP true +set_module_property AUTHOR "Michael Wurm" +set_module_property DISPLAY_NAME infrared +set_module_property INSTANTIATE_IN_SYSTEM_MODULE true +set_module_property EDITABLE true +set_module_property REPORT_TO_TALKBACK false +set_module_property ALLOW_GREYBOX_GENERATION false +set_module_property REPORT_HIERARCHY false + + +# +# file sets +# +add_fileset QUARTUS_SYNTH QUARTUS_SYNTH "" "" +set_fileset_property QUARTUS_SYNTH TOP_LEVEL infrared +set_fileset_property QUARTUS_SYNTH ENABLE_RELATIVE_INCLUDE_PATHS false +set_fileset_property QUARTUS_SYNTH ENABLE_FILE_OVERWRITE_MODE false +add_fileset_file counter.vhd VHDL PATH components/infrared/counter.vhd +add_fileset_file infrared.vhd VHDL PATH components/infrared/infrared.vhd TOP_LEVEL_FILE +add_fileset_file sync_single.vhd VHDL PATH components/infrared/sync_single.vhd + + +# +# parameters +# + + +# +# display items +# + + +# +# connection point s0 +# +add_interface s0 avalon end +set_interface_property s0 addressUnits WORDS +set_interface_property s0 associatedClock clk_i +set_interface_property s0 associatedReset rst_n_i +set_interface_property s0 bitsPerSymbol 8 +set_interface_property s0 burstOnBurstBoundariesOnly false +set_interface_property s0 burstcountUnits WORDS +set_interface_property s0 explicitAddressSpan 0 +set_interface_property s0 holdTime 0 +set_interface_property s0 linewrapBursts false +set_interface_property s0 maximumPendingReadTransactions 0 +set_interface_property s0 maximumPendingWriteTransactions 0 +set_interface_property s0 readLatency 0 +set_interface_property s0 readWaitTime 1 +set_interface_property s0 setupTime 0 +set_interface_property s0 timingUnits Cycles +set_interface_property s0 writeWaitTime 0 +set_interface_property s0 ENABLED true +set_interface_property s0 EXPORT_OF "" +set_interface_property s0 PORT_NAME_MAP "" +set_interface_property s0 CMSIS_SVD_VARIABLES "" +set_interface_property s0 SVD_ADDRESS_GROUP "" + +add_interface_port s0 avs_s0_address address Input 8 +add_interface_port s0 avs_s0_read read Input 1 +add_interface_port s0 avs_s0_readdata readdata Output 32 +add_interface_port s0 avs_s0_write write Input 1 +add_interface_port s0 avs_s0_writedata writedata Input 32 +add_interface_port s0 avs_s0_waitrequest waitrequest Output 1 +set_interface_assignment s0 embeddedsw.configuration.isFlash 0 +set_interface_assignment s0 embeddedsw.configuration.isMemoryDevice 0 +set_interface_assignment s0 embeddedsw.configuration.isNonVolatileStorage 0 +set_interface_assignment s0 embeddedsw.configuration.isPrintableDevice 0 + + +# +# connection point clk_i +# +add_interface clk_i clock end +set_interface_property clk_i clockRate 0 +set_interface_property clk_i ENABLED true +set_interface_property clk_i EXPORT_OF "" +set_interface_property clk_i PORT_NAME_MAP "" +set_interface_property clk_i CMSIS_SVD_VARIABLES "" +set_interface_property clk_i SVD_ADDRESS_GROUP "" + +add_interface_port clk_i clk_i clk Input 1 + + +# +# connection point rst_n_i +# +add_interface rst_n_i reset end +set_interface_property rst_n_i associatedClock clk_i +set_interface_property rst_n_i synchronousEdges DEASSERT +set_interface_property rst_n_i ENABLED true +set_interface_property rst_n_i EXPORT_OF "" +set_interface_property rst_n_i PORT_NAME_MAP "" +set_interface_property rst_n_i CMSIS_SVD_VARIABLES "" +set_interface_property rst_n_i SVD_ADDRESS_GROUP "" + +add_interface_port rst_n_i rst_n_i reset_n Input 1 + From 713f3b8d573510a125e6f09ca8a5a826835f5d35 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 16:46:00 +0100 Subject: [PATCH 07/16] qsys with version 19.1 --- hdl/HPSPlatform.qsys | 50 ++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/hdl/HPSPlatform.qsys b/hdl/HPSPlatform.qsys index 0643f77..e1e9222 100644 --- a/hdl/HPSPlatform.qsys +++ b/hdl/HPSPlatform.qsys @@ -367,7 +367,7 @@ internal="hmi.switches_external_connection" type="conduit" dir="end" /> - + @@ -398,9 +398,9 @@ - + - + @@ -932,7 +932,7 @@ @@ -941,7 +941,7 @@ @@ -950,7 +950,7 @@ @@ -959,7 +959,7 @@ @@ -968,7 +968,7 @@ @@ -977,7 +977,7 @@ @@ -986,76 +986,76 @@ - + - + From 048e60c434d04b49c8ba4ea6625271fd6c76f0f7 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 17:10:03 +0100 Subject: [PATCH 08/16] add ip component into qsys --- .gitignore | 1 + hdl/HPSPlatform.qsys | 35 ++++++++ hdl/components/infrared/infrared.vhd | 8 +- hdl/components/infrared/infrared_hw.tcl | 108 +++++++++++++++++++----- hdl/ip/subsystemHMI.qsys | 62 +++++++++++--- 5 files changed, 176 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index 0f214e3..4cbbc17 100644 --- a/.gitignore +++ b/.gitignore @@ -23,6 +23,7 @@ transcript # Quartus temporary files .qsys_edit/ +subsystemHMI/ db/ HPSPlatform/ incremental_db/ diff --git a/hdl/HPSPlatform.qsys b/hdl/HPSPlatform.qsys index e1e9222..fe4a393 100644 --- a/hdl/HPSPlatform.qsys +++ b/hdl/HPSPlatform.qsys @@ -177,6 +177,19 @@ type = "int"; } } + element hmi.infrared_s0 + { + datum _lockedAddress + { + value = "1"; + type = "boolean"; + } + datum baseAddress + { + value = "2048"; + type = "String"; + } + } element hmi.leds_s1 { datum _lockedAddress @@ -378,6 +391,9 @@ + + + @@ -930,6 +946,15 @@ + + + + + + + + + + + + + + - + + @@ -219,45 +259,45 @@ version="1.0" enabled="1"> - + - + - $${FILENAME}_subsystemApds9301 + subsystemHMI_subsystemApds9301 - + - + - $${FILENAME}_subsystemHdc1000 + subsystemHMI_subsystemHdc1000 - + - + - $${FILENAME}_subsystemMpu9250 + subsystemHMI_subsystemMpu9250 - + From 4deb429470b88e8f1fac8904217a0f1ecb1ee1c0 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 17:32:34 +0100 Subject: [PATCH 09/16] update instantiatation --- hdl/HPSPlatform.qsys | 27 +- hdl/top.vhd | 814 ++++++++++++++++++++++--------------------- 2 files changed, 438 insertions(+), 403 deletions(-) diff --git a/hdl/HPSPlatform.qsys b/hdl/HPSPlatform.qsys index fe4a393..6454af1 100644 --- a/hdl/HPSPlatform.qsys +++ b/hdl/HPSPlatform.qsys @@ -197,6 +197,11 @@ value = "1"; type = "boolean"; } + datum _tags + { + value = ""; + type = "String"; + } datum baseAddress { value = "1040"; @@ -292,6 +297,26 @@ + + + + - + diff --git a/hdl/top.vhd b/hdl/top.vhd index 2cc8822..6923cbe 100644 --- a/hdl/top.vhd +++ b/hdl/top.vhd @@ -1,402 +1,412 @@ -library ieee; -use ieee.std_logic_1164.all; -use ieee.numeric_std.all; - -ENTITY top IS - -PORT( - ---------FPGA Connections------------- - CLOCK_50 : in std_logic; - SW : in std_logic_vector(9 downto 0); - LEDR : out std_logic_vector(9 downto 0); - - - -- //////////// SEG7 ////////// - HEX0 : out std_logic_vector(6 downto 0); - HEX1 : out std_logic_vector(6 downto 0); - HEX2 : out std_logic_vector(6 downto 0); - HEX3 : out std_logic_vector(6 downto 0); - HEX4 : out std_logic_vector(6 downto 0); - HEX5 : out std_logic_vector(6 downto 0); - - -- //////////// Infrared Interface ////////// - IRDA_RXD : in std_logic; - IRDA_TXD : in std_logic; - - ---------HPS Connections--------------- - HPS_CONV_USB_N : inout std_logic; - HPS_DDR3_ADDR : out std_logic_vector(14 downto 0); - HPS_DDR3_BA : out std_logic_vector(2 downto 0); - HPS_DDR3_CAS_N : out std_logic; - HPS_DDR3_CKE : out std_logic; - HPS_DDR3_CK_N : out std_logic; - HPS_DDR3_CK_P : out std_logic; - HPS_DDR3_CS_N : out std_logic; - HPS_DDR3_DM : out std_logic_vector(3 downto 0); - HPS_DDR3_DQ : inout std_logic_vector(31 downto 0); - HPS_DDR3_DQS_N : inout std_logic_vector(3 downto 0); - HPS_DDR3_DQS_P : inout std_logic_vector(3 downto 0); - HPS_DDR3_ODT : out std_logic; - HPS_DDR3_RAS_N : out std_logic; - HPS_DDR3_RESET_N : out std_logic; - HPS_DDR3_RZQ : in std_logic; - HPS_DDR3_WE_N : out std_logic; - - HPS_ENET_GTX_CLK : out std_logic; - HPS_ENET_INT_N : inout std_logic; - HPS_ENET_MDC : out std_logic; - HPS_ENET_MDIO : inout std_logic; - HPS_ENET_RX_CLK : in std_logic; - HPS_ENET_RX_DATA : in std_logic_vector(3 downto 0); - HPS_ENET_RX_DV : in std_logic; - HPS_ENET_TX_DATA : out std_logic_vector(3 downto 0); - HPS_ENET_TX_EN : out std_logic; - - HPS_KEY : inout std_logic; - HPS_LED : inout std_logic; - - HPS_SD_CLK : out std_logic; - HPS_SD_CMD : inout std_logic; - HPS_SD_DATA : inout std_logic_vector(3 downto 0); - - HPS_UART_RX : in std_logic; - HPS_UART_TX : out std_logic; - - HPS_USB_CLKOUT : in std_logic; - HPS_USB_DATA : inout std_logic_vector(7 downto 0); - HPS_USB_DIR : in std_logic; - HPS_USB_NXT : in std_logic; - HPS_USB_STP : out std_logic; - - HPS_I2C1_SCLK : inout std_logic; - HPS_I2C1_SDAT : inout std_logic; - HPS_I2C2_SCLK : inout std_logic; - HPS_I2C2_SDAT : inout std_logic; - HPS_I2C_CONTROL : inout std_logic; - - HPS_LTC_GPIO : inout std_logic; - HPS_GSENSOR_INT : inout std_logic; - - HPS_SPIM_CLK : out std_logic; - HPS_SPIM_MISO : in std_logic; - HPS_SPIM_MOSI : out std_logic; - HPS_SPIM_SS : inout std_logic; - - --////////// GPIO, GPIO connect to RFS - RF and Sensor ////////// - --BT_KEY : inout std_logic; - --BT_UART_RX : in std_logic; - --BT_UART_TX : out std_logic; - LSENSOR_INT : in std_logic; - LSENSOR_SCL : inout std_logic; - LSENSOR_SDA : inout std_logic; - MPU_AD0_SDO : in std_logic; - MPU_CS_n : inout std_logic; - MPU_FSYNC : out std_logic; - MPU_INT : in std_logic; - MPU_SCL_SCLK : inout std_logic; - MPU_SDA_SDI : inout std_logic; - RH_TEMP_DRDY_n : in std_ulogic; - RH_TEMP_I2C_SCL : inout std_logic; - RH_TEMP_I2C_SDA : inout std_logic; - TMD_D : out std_logic_vector(7 downto 0); - --UART2USB_CTS : in std_logic; - --UART2USB_RTS : out std_logic; - --UART2USB_RX : in std_logic; - --UART2USB_TX : out std_logic; - --WIFI_EN : out std_logic; - --WIFI_RST_n : out std_logic; - --WIFI_UART0_CTS : in std_logic; - --WIFI_UART0_RTS : out std_logic; - --WIFI_UART0_RX : in std_logic; - --WIFI_UART0_TX : out std_logic; - --WIFI_UART1_RX : in std_logic - GPIO_0 : out std_logic_vector(35 downto 0) -); - -END ENTITY; - -ARCHITECTURE MAIN OF top IS - component HPSPlatform is - port ( - clk_clk : in std_logic := 'X'; -- clk - hps_0_h2f_reset_reset_n : out std_logic; -- reset_n - hps_0_f2h_cold_reset_req_reset_n : in std_logic := 'X'; -- reset_n - hps_0_f2h_debug_reset_req_reset_n : in std_logic := 'X'; -- reset_n - hps_0_f2h_stm_hw_events_stm_hwevents : in std_logic_vector(27 downto 0) := (others => 'X'); -- stm_hwevents - hps_0_f2h_warm_reset_req_reset_n : in std_logic := 'X'; -- reset_n - hps_io_hps_io_emac1_inst_TX_CLK : out std_logic; -- hps_io_emac1_inst_TX_CLK - hps_io_hps_io_emac1_inst_TXD0 : out std_logic; -- hps_io_emac1_inst_TXD0 - hps_io_hps_io_emac1_inst_TXD1 : out std_logic; -- hps_io_emac1_inst_TXD1 - hps_io_hps_io_emac1_inst_TXD2 : out std_logic; -- hps_io_emac1_inst_TXD2 - hps_io_hps_io_emac1_inst_TXD3 : out std_logic; -- hps_io_emac1_inst_TXD3 - hps_io_hps_io_emac1_inst_RXD0 : in std_logic := 'X'; -- hps_io_emac1_inst_RXD0 - hps_io_hps_io_emac1_inst_MDIO : inout std_logic := 'X'; -- hps_io_emac1_inst_MDIO - hps_io_hps_io_emac1_inst_MDC : out std_logic; -- hps_io_emac1_inst_MDC - hps_io_hps_io_emac1_inst_RX_CTL : in std_logic := 'X'; -- hps_io_emac1_inst_RX_CTL - hps_io_hps_io_emac1_inst_TX_CTL : out std_logic; -- hps_io_emac1_inst_TX_CTL - hps_io_hps_io_emac1_inst_RX_CLK : in std_logic := 'X'; -- hps_io_emac1_inst_RX_CLK - hps_io_hps_io_emac1_inst_RXD1 : in std_logic := 'X'; -- hps_io_emac1_inst_RXD1 - hps_io_hps_io_emac1_inst_RXD2 : in std_logic := 'X'; -- hps_io_emac1_inst_RXD2 - hps_io_hps_io_emac1_inst_RXD3 : in std_logic := 'X'; -- hps_io_emac1_inst_RXD3 - hps_io_hps_io_sdio_inst_CMD : inout std_logic := 'X'; -- hps_io_sdio_inst_CMD - hps_io_hps_io_sdio_inst_D0 : inout std_logic := 'X'; -- hps_io_sdio_inst_D0 - hps_io_hps_io_sdio_inst_D1 : inout std_logic := 'X'; -- hps_io_sdio_inst_D1 - hps_io_hps_io_sdio_inst_CLK : out std_logic; -- hps_io_sdio_inst_CLK - hps_io_hps_io_sdio_inst_D2 : inout std_logic := 'X'; -- hps_io_sdio_inst_D2 - hps_io_hps_io_sdio_inst_D3 : inout std_logic := 'X'; -- hps_io_sdio_inst_D3 - hps_io_hps_io_usb1_inst_D0 : inout std_logic := 'X'; -- hps_io_usb1_inst_D0 - hps_io_hps_io_usb1_inst_D1 : inout std_logic := 'X'; -- hps_io_usb1_inst_D1 - hps_io_hps_io_usb1_inst_D2 : inout std_logic := 'X'; -- hps_io_usb1_inst_D2 - hps_io_hps_io_usb1_inst_D3 : inout std_logic := 'X'; -- hps_io_usb1_inst_D3 - hps_io_hps_io_usb1_inst_D4 : inout std_logic := 'X'; -- hps_io_usb1_inst_D4 - hps_io_hps_io_usb1_inst_D5 : inout std_logic := 'X'; -- hps_io_usb1_inst_D5 - hps_io_hps_io_usb1_inst_D6 : inout std_logic := 'X'; -- hps_io_usb1_inst_D6 - hps_io_hps_io_usb1_inst_D7 : inout std_logic := 'X'; -- hps_io_usb1_inst_D7 - hps_io_hps_io_usb1_inst_CLK : in std_logic := 'X'; -- hps_io_usb1_inst_CLK - hps_io_hps_io_usb1_inst_STP : out std_logic; -- hps_io_usb1_inst_STP - hps_io_hps_io_usb1_inst_DIR : in std_logic := 'X'; -- hps_io_usb1_inst_DIR - hps_io_hps_io_usb1_inst_NXT : in std_logic := 'X'; -- hps_io_usb1_inst_NXT - hps_io_hps_io_spim1_inst_CLK : out std_logic; -- hps_io_spim1_inst_CLK - hps_io_hps_io_spim1_inst_MOSI : out std_logic; -- hps_io_spim1_inst_MOSI - hps_io_hps_io_spim1_inst_MISO : in std_logic := 'X'; -- hps_io_spim1_inst_MISO - hps_io_hps_io_spim1_inst_SS0 : out std_logic; -- hps_io_spim1_inst_SS0 - hps_io_hps_io_uart0_inst_RX : in std_logic := 'X'; -- hps_io_uart0_inst_RX - hps_io_hps_io_uart0_inst_TX : out std_logic; -- hps_io_uart0_inst_TX - hps_io_hps_io_i2c0_inst_SDA : inout std_logic := 'X'; -- hps_io_i2c0_inst_SDA - hps_io_hps_io_i2c0_inst_SCL : inout std_logic := 'X'; -- hps_io_i2c0_inst_SCL - hps_io_hps_io_i2c1_inst_SDA : inout std_logic := 'X'; -- hps_io_i2c1_inst_SDA - hps_io_hps_io_i2c1_inst_SCL : inout std_logic := 'X'; -- hps_io_i2c1_inst_SCL - hps_io_hps_io_gpio_inst_GPIO09 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO09 - hps_io_hps_io_gpio_inst_GPIO35 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO35 - hps_io_hps_io_gpio_inst_GPIO40 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO40 - hps_io_hps_io_gpio_inst_GPIO48 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO48 - hps_io_hps_io_gpio_inst_GPIO53 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO53 - hps_io_hps_io_gpio_inst_GPIO54 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO54 - hps_io_hps_io_gpio_inst_GPIO61 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO61 - memory_mem_a : out std_logic_vector(14 downto 0); -- mem_a - memory_mem_ba : out std_logic_vector(2 downto 0); -- mem_ba - memory_mem_ck : out std_logic; -- mem_ck - memory_mem_ck_n : out std_logic; -- mem_ck_n - memory_mem_cke : out std_logic; -- mem_cke - memory_mem_cs_n : out std_logic; -- mem_cs_n - memory_mem_ras_n : out std_logic; -- mem_ras_n - memory_mem_cas_n : out std_logic; -- mem_cas_n - memory_mem_we_n : out std_logic; -- mem_we_n - memory_mem_reset_n : out std_logic; -- mem_reset_n - memory_mem_dq : inout std_logic_vector(31 downto 0) := (others => 'X'); -- mem_dq - memory_mem_dqs : inout std_logic_vector(3 downto 0) := (others => 'X'); -- mem_dqs - memory_mem_dqs_n : inout std_logic_vector(3 downto 0) := (others => 'X'); -- mem_dqs_n - memory_mem_odt : out std_logic; -- mem_odt - memory_mem_dm : out std_logic_vector(3 downto 0); -- mem_dm - memory_oct_rzqin : in std_logic := 'X'; -- oct_rzqin - reset_reset_n : in std_logic := 'X'; -- reset_n - leds_external_connection_export : out std_logic_vector(9 downto 0); -- export - seven_segment_conduit_end_export : out std_logic_vector(41 downto 0); -- export - switches_external_connection_export : in std_logic_vector(9 downto 0) := (others => 'X'); -- export - hmi_subsystemapds9301_apdsinterrupt_irq_n : in std_logic := 'X'; -- irq_n - hmi_subsystemapds9301_i2c_scl_in : in std_logic := 'X'; -- scl_in - hmi_subsystemapds9301_i2c_scl_oe : out std_logic; -- scl_oe - hmi_subsystemapds9301_i2c_sda_in : in std_logic := 'X'; -- sda_in - hmi_subsystemapds9301_i2c_sda_oe : out std_logic; -- sda_oe - hmi_subsystemhdc1000_hdcrdy_interrupt : in std_logic := 'X'; -- interrupt - hmi_subsystemhdc1000_i2c_0_i2c_serial_sda_in : in std_logic := 'X'; -- sda_in - hmi_subsystemhdc1000_i2c_0_i2c_serial_scl_in : in std_logic := 'X'; -- scl_in - hmi_subsystemhdc1000_i2c_0_i2c_serial_sda_oe : out std_logic; -- sda_oe - hmi_subsystemhdc1000_i2c_0_i2c_serial_scl_oe : out std_logic; -- scl_oe - hmi_subsystemmpu9250_spi_MISO : in std_logic := 'X'; -- MISO - hmi_subsystemmpu9250_spi_MOSI : out std_logic; -- MOSI - hmi_subsystemmpu9250_spi_SCLK : out std_logic; -- SCLK - hmi_subsystemmpu9250_spi_SS_n : out std_logic; -- SS_n - hmi_subsystemmpu9250_mpuint_irq_n : in std_logic := 'X' -- irq_n - ); - end component HPSPlatform; - - component i2c_io_buf - PORT - ( - datain : IN STD_LOGIC_VECTOR (1 DOWNTO 0); - oe : IN STD_LOGIC_VECTOR (1 DOWNTO 0); - dataio : INOUT STD_LOGIC_VECTOR (1 DOWNTO 0); - dataout : OUT STD_LOGIC_VECTOR (1 DOWNTO 0) - ); - end component; - - - signal HPS_H2F_RST : std_logic; - - constant hps_cold_reset : std_logic := '0'; - constant hps_warm_reset : std_logic := '0'; - constant hps_debug_reset : std_logic := '0'; - constant sync_levels : natural := 100; - - signal stm_hw_events : std_logic_vector(27 downto 0); - signal test : std_logic; - signal key_reset_sync : std_logic_vector(sync_levels downto 0); - - signal hdc1000_i2c_serial_sda_in : std_logic; - signal hdc1000_i2c_serial_scl_in : std_logic; - signal hdc1000_i2c_serial_sda_oe : std_logic; - signal hdc1000_i2c_serial_scl_oe : std_logic; - - signal apds9301_i2c_serial_sda_in : std_logic; - signal apds9301_i2c_serial_scl_in : std_logic; - signal apds9301_i2c_serial_sda_oe : std_logic; - signal apds9301_i2c_serial_scl_oe : std_logic; - -BEGIN - - -u0 : component HPSPlatform - port map ( - clk_clk => CLOCK_50, -- clk.clk - reset_reset_n => key_reset_sync(0), -- reset.reset_n - memory_mem_a => HPS_DDR3_ADDR, -- memory.mem_a - memory_mem_ba => HPS_DDR3_BA, -- .mem_ba - memory_mem_ck => HPS_DDR3_CK_P, -- .mem_ck - memory_mem_ck_n => HPS_DDR3_CK_N, -- .mem_ck_n - memory_mem_cke => HPS_DDR3_CKE, -- .mem_cke - memory_mem_cs_n => HPS_DDR3_CS_N, -- .mem_cs_n - memory_mem_ras_n => HPS_DDR3_RAS_N, -- .mem_ras_n - memory_mem_cas_n => HPS_DDR3_CAS_N, -- .mem_cas_n - memory_mem_we_n => HPS_DDR3_WE_N, -- .mem_we_n - memory_mem_reset_n => HPS_DDR3_RESET_N, -- .mem_reset_n - memory_mem_dq => HPS_DDR3_DQ, -- .mem_dq - memory_mem_dqs => HPS_DDR3_DQS_P, -- .mem_dqs - memory_mem_dqs_n => HPS_DDR3_DQS_N, -- .mem_dqs_n - memory_mem_odt => HPS_DDR3_ODT, -- .mem_odt - memory_mem_dm => HPS_DDR3_DM, -- .mem_dm - memory_oct_rzqin => HPS_DDR3_RZQ, -- .oct_rzqin - hps_0_h2f_reset_reset_n => HPS_H2F_RST, -- hps_0_h2f_reset.reset_n - hps_0_f2h_cold_reset_req_reset_n => not(hps_cold_reset), -- hps_0_f2h_cold_reset_req.reset_n - hps_0_f2h_debug_reset_req_reset_n => not(hps_debug_reset), -- hps_0_f2h_debug_reset_req.reset_n - hps_0_f2h_stm_hw_events_stm_hwevents => stm_hw_events, -- hps_0_f2h_stm_hw_events.stm_hwevents - hps_0_f2h_warm_reset_req_reset_n => not(hps_warm_reset), -- hps_0_f2h_warm_reset_req.reset_n - hps_io_hps_io_emac1_inst_TX_CLK => HPS_ENET_GTX_CLK, -- hps_io.hps_io_emac1_inst_TX_CLK - hps_io_hps_io_emac1_inst_TXD0 => HPS_ENET_TX_DATA(0), -- .hps_io_emac1_inst_TXD0 - hps_io_hps_io_emac1_inst_TXD1 => HPS_ENET_TX_DATA(1), -- .hps_io_emac1_inst_TXD1 - hps_io_hps_io_emac1_inst_TXD2 => HPS_ENET_TX_DATA(2), -- .hps_io_emac1_inst_TXD2 - hps_io_hps_io_emac1_inst_TXD3 => HPS_ENET_TX_DATA(3), -- .hps_io_emac1_inst_TXD3 - hps_io_hps_io_emac1_inst_RXD0 => HPS_ENET_RX_DATA(0), -- .hps_io_emac1_inst_RXD0 - hps_io_hps_io_emac1_inst_MDIO => HPS_ENET_MDIO, -- .hps_io_emac1_inst_MDIO - hps_io_hps_io_emac1_inst_MDC => HPS_ENET_MDC, -- .hps_io_emac1_inst_MDC - hps_io_hps_io_emac1_inst_RX_CTL => HPS_ENET_RX_DV, -- .hps_io_emac1_inst_RX_CTL - hps_io_hps_io_emac1_inst_TX_CTL => HPS_ENET_TX_EN, -- .hps_io_emac1_inst_TX_CTL - hps_io_hps_io_emac1_inst_RX_CLK => HPS_ENET_RX_CLK, -- .hps_io_emac1_inst_RX_CLK - hps_io_hps_io_emac1_inst_RXD1 => HPS_ENET_RX_DATA(1), -- .hps_io_emac1_inst_RXD1 - hps_io_hps_io_emac1_inst_RXD2 => HPS_ENET_RX_DATA(2), -- .hps_io_emac1_inst_RXD2 - hps_io_hps_io_emac1_inst_RXD3 => HPS_ENET_RX_DATA(3), -- .hps_io_emac1_inst_RXD3 - hps_io_hps_io_sdio_inst_CMD => HPS_SD_CMD, -- .hps_io_sdio_inst_CMD - hps_io_hps_io_sdio_inst_D0 => HPS_SD_DATA(0), -- .hps_io_sdio_inst_D0 - hps_io_hps_io_sdio_inst_D1 => HPS_SD_DATA(1), -- .hps_io_sdio_inst_D1 - hps_io_hps_io_sdio_inst_CLK => HPS_SD_CLK, -- .hps_io_sdio_inst_CLK - hps_io_hps_io_sdio_inst_D2 => HPS_SD_DATA(2), -- .hps_io_sdio_inst_D2 - hps_io_hps_io_sdio_inst_D3 => HPS_SD_DATA(3), -- .hps_io_sdio_inst_D3 - hps_io_hps_io_usb1_inst_D0 => HPS_USB_DATA(0), -- .hps_io_usb1_inst_D0 - hps_io_hps_io_usb1_inst_D1 => HPS_USB_DATA(1), -- .hps_io_usb1_inst_D1 - hps_io_hps_io_usb1_inst_D2 => HPS_USB_DATA(2), -- .hps_io_usb1_inst_D2 - hps_io_hps_io_usb1_inst_D3 => HPS_USB_DATA(3), -- .hps_io_usb1_inst_D3 - hps_io_hps_io_usb1_inst_D4 => HPS_USB_DATA(4), -- .hps_io_usb1_inst_D4 - hps_io_hps_io_usb1_inst_D5 => HPS_USB_DATA(5), -- .hps_io_usb1_inst_D5 - hps_io_hps_io_usb1_inst_D6 => HPS_USB_DATA(6), -- .hps_io_usb1_inst_D6 - hps_io_hps_io_usb1_inst_D7 => HPS_USB_DATA(7), -- .hps_io_usb1_inst_D7 - hps_io_hps_io_usb1_inst_CLK => HPS_USB_CLKOUT, -- .hps_io_usb1_inst_CLK - hps_io_hps_io_usb1_inst_STP => HPS_USB_STP, -- .hps_io_usb1_inst_STP - hps_io_hps_io_usb1_inst_DIR => HPS_USB_DIR, -- .hps_io_usb1_inst_DIR - hps_io_hps_io_usb1_inst_NXT => HPS_USB_NXT, -- .hps_io_usb1_inst_NXT - hps_io_hps_io_spim1_inst_CLK => HPS_SPIM_CLK, -- .hps_io_spim1_inst_CLK - hps_io_hps_io_spim1_inst_MOSI => HPS_SPIM_MOSI, -- .hps_io_spim1_inst_MOSI - hps_io_hps_io_spim1_inst_MISO => HPS_SPIM_MISO, -- .hps_io_spim1_inst_MISO - hps_io_hps_io_spim1_inst_SS0 => HPS_SPIM_SS, -- .hps_io_spim1_inst_SS0 - hps_io_hps_io_uart0_inst_RX => HPS_UART_RX, -- .hps_io_uart0_inst_RX - hps_io_hps_io_uart0_inst_TX => HPS_UART_TX, -- .hps_io_uart0_inst_TX - hps_io_hps_io_i2c0_inst_SDA => HPS_I2C1_SDAT, -- .hps_io_i2c0_inst_SDA - hps_io_hps_io_i2c0_inst_SCL => HPS_I2C1_SCLK, -- .hps_io_i2c0_inst_SCL - hps_io_hps_io_i2c1_inst_SDA => HPS_I2C2_SDAT, -- .hps_io_i2c1_inst_SDA - hps_io_hps_io_i2c1_inst_SCL => HPS_I2C2_SCLK, -- .hps_io_i2c1_inst_SCL - hps_io_hps_io_gpio_inst_GPIO09 => HPS_CONV_USB_N, -- hps_io_gpio_inst_GPIO09 - hps_io_hps_io_gpio_inst_GPIO35 => HPS_ENET_INT_N, -- .hps_io_gpio_inst_GPIO35 - hps_io_hps_io_gpio_inst_GPIO40 => HPS_LTC_GPIO, -- .hps_io_gpio_inst_GPIO40 - hps_io_hps_io_gpio_inst_GPIO48 => HPS_I2C_CONTROL, -- .hps_io_gpio_inst_GPIO48 - hps_io_hps_io_gpio_inst_GPIO53 => HPS_LED, -- hps_io_gpio_inst_GPIO53 - hps_io_hps_io_gpio_inst_GPIO54 => HPS_KEY, -- hps_io_gpio_inst_GPIO54 - hps_io_hps_io_gpio_inst_GPIO61 => HPS_GSENSOR_INT, -- .hps_io_gpio_inst_GPIO61 - - - -- periph --- leds_external_connection_export => LEDR, -- led_external_connection.export - switches_external_connection_export => SW, -- sw_external_connection.export - - seven_segment_conduit_end_export(6+7*0 downto 7*0) => HEX0, - seven_segment_conduit_end_export(6+7*1 downto 7*1) => HEX1, - seven_segment_conduit_end_export(6+7*2 downto 7*2) => HEX2, - seven_segment_conduit_end_export(6+7*3 downto 7*3) => HEX3, - seven_segment_conduit_end_export(6+7*4 downto 7*4) => HEX4, - seven_segment_conduit_end_export(6+7*5 downto 7*5) => HEX5, - - hmi_subsystemhdc1000_hdcrdy_interrupt => RH_TEMP_DRDY_n, -- hdc1000_0_hdcrdy.interrupt - hmi_subsystemhdc1000_i2c_0_i2c_serial_sda_in => hdc1000_i2c_serial_sda_in, -- hdc1000_i2c_0_i2c_serial.sda_in - hmi_subsystemhdc1000_i2c_0_i2c_serial_scl_in => hdc1000_i2c_serial_scl_in, -- .scl_in - hmi_subsystemhdc1000_i2c_0_i2c_serial_sda_oe => hdc1000_i2c_serial_sda_oe, -- .sda_oe - hmi_subsystemhdc1000_i2c_0_i2c_serial_scl_oe => hdc1000_i2c_serial_scl_oe, -- .scl_oe - - hmi_subsystemapds9301_apdsinterrupt_irq_n => LSENSOR_INT, -- hmi_subsystemapds9301_apdsinterrupt.irq_n - hmi_subsystemapds9301_i2c_sda_in => apds9301_i2c_serial_sda_in, -- hmi_subsystemapds9301_i2c_0_i2c_serial.scl_in - hmi_subsystemapds9301_i2c_scl_in => apds9301_i2c_serial_scl_in, -- .scl_oe - hmi_subsystemapds9301_i2c_sda_oe => apds9301_i2c_serial_sda_oe, -- .sda_in - hmi_subsystemapds9301_i2c_scl_oe => apds9301_i2c_serial_scl_oe, - - hmi_subsystemmpu9250_spi_MISO => MPU_AD0_SDO, -- hmi_subsystemmpu9250_spi_0_external.MISO - hmi_subsystemmpu9250_spi_MOSI => MPU_SDA_SDI, -- .MOSI - hmi_subsystemmpu9250_spi_SCLK => MPU_SCL_SCLK, -- .SCLK - hmi_subsystemmpu9250_spi_SS_n => MPU_CS_n, -- .SS_n - hmi_subsystemmpu9250_mpuint_irq_n => MPU_INT -- hmi_subsystemmpu9250_mpuint.irq_n - ); - - key_sync : process( CLOCK_50, HPS_H2F_RST, SW(0) ) - begin - if (HPS_H2F_RST AND SW(0)) = '0' then - key_reset_sync <= (others => '0'); - elsif rising_edge(CLOCK_50) then - key_reset_sync(sync_levels) <= '1'; - key_reset_sync(sync_levels-1 downto 0) <= key_reset_sync(sync_levels downto 1); - end if; - end process; -- key_sync - - hdc1000_i2c_io : component i2c_io_buf - port map ( - datain => (others => '0'), - oe(1) => hdc1000_i2c_serial_scl_oe, - oe(0) => hdc1000_i2c_serial_sda_oe, - dataout(1) => hdc1000_i2c_serial_scl_in, - dataout(0) => hdc1000_i2c_serial_sda_in, - dataio(1) => RH_TEMP_I2C_SCL, - dataio(0) => RH_TEMP_I2C_SDA); - - apds9301_i2c_io : component i2c_io_buf - port map ( - datain => (others => '0'), - oe(1) => apds9301_i2c_serial_scl_oe, - oe(0) => apds9301_i2c_serial_sda_oe, - dataout(1) => apds9301_i2c_serial_scl_in, - dataout(0) => apds9301_i2c_serial_sda_in, - dataio(1) => LSENSOR_SCL, - dataio(0) => LSENSOR_SDA); - - LEDR(0) <= HPS_H2F_RST AND key_reset_sync(0); - LEDR(LEDR'high downto 1) <= (others => '0'); - - GPIO_0( 0) <= RH_TEMP_DRDY_n; - GPIO_0( 1) <= RH_TEMP_I2C_SCL; - GPIO_0( 2) <= RH_TEMP_I2C_SDA; - - GPIO_0( 4) <= LSENSOR_INT; - GPIO_0( 5) <= LSENSOR_SCL; - GPIO_0( 6) <= LSENSOR_SDA; - - GPIO_0(10) <= MPU_SCL_SCLK; - GPIO_0(11) <= MPU_CS_n; - GPIO_0(12) <= MPU_INT; - GPIO_0(14) <= MPU_AD0_SDO; - GPIO_0(15) <= MPU_SDA_SDI; - -END ARCHITECTURE; +library ieee; +use ieee.std_logic_1164.all; +use ieee.numeric_std.all; + +ENTITY top IS + +PORT( + ---------FPGA Connections------------- + CLOCK_50 : in std_logic; + SW : in std_logic_vector(9 downto 0); + LEDR : out std_logic_vector(9 downto 0); + + + -- //////////// SEG7 ////////// + HEX0 : out std_logic_vector(6 downto 0); + HEX1 : out std_logic_vector(6 downto 0); + HEX2 : out std_logic_vector(6 downto 0); + HEX3 : out std_logic_vector(6 downto 0); + HEX4 : out std_logic_vector(6 downto 0); + HEX5 : out std_logic_vector(6 downto 0); + + -- //////////// Infrared Interface ////////// + IRDA_RXD : in std_logic; + IRDA_TXD : in std_logic; + + ---------HPS Connections--------------- + HPS_CONV_USB_N : inout std_logic; + HPS_DDR3_ADDR : out std_logic_vector(14 downto 0); + HPS_DDR3_BA : out std_logic_vector(2 downto 0); + HPS_DDR3_CAS_N : out std_logic; + HPS_DDR3_CKE : out std_logic; + HPS_DDR3_CK_N : out std_logic; + HPS_DDR3_CK_P : out std_logic; + HPS_DDR3_CS_N : out std_logic; + HPS_DDR3_DM : out std_logic_vector(3 downto 0); + HPS_DDR3_DQ : inout std_logic_vector(31 downto 0); + HPS_DDR3_DQS_N : inout std_logic_vector(3 downto 0); + HPS_DDR3_DQS_P : inout std_logic_vector(3 downto 0); + HPS_DDR3_ODT : out std_logic; + HPS_DDR3_RAS_N : out std_logic; + HPS_DDR3_RESET_N : out std_logic; + HPS_DDR3_RZQ : in std_logic; + HPS_DDR3_WE_N : out std_logic; + + HPS_ENET_GTX_CLK : out std_logic; + HPS_ENET_INT_N : inout std_logic; + HPS_ENET_MDC : out std_logic; + HPS_ENET_MDIO : inout std_logic; + HPS_ENET_RX_CLK : in std_logic; + HPS_ENET_RX_DATA : in std_logic_vector(3 downto 0); + HPS_ENET_RX_DV : in std_logic; + HPS_ENET_TX_DATA : out std_logic_vector(3 downto 0); + HPS_ENET_TX_EN : out std_logic; + + HPS_KEY : inout std_logic; + HPS_LED : inout std_logic; + + HPS_SD_CLK : out std_logic; + HPS_SD_CMD : inout std_logic; + HPS_SD_DATA : inout std_logic_vector(3 downto 0); + + HPS_UART_RX : in std_logic; + HPS_UART_TX : out std_logic; + + HPS_USB_CLKOUT : in std_logic; + HPS_USB_DATA : inout std_logic_vector(7 downto 0); + HPS_USB_DIR : in std_logic; + HPS_USB_NXT : in std_logic; + HPS_USB_STP : out std_logic; + + HPS_I2C1_SCLK : inout std_logic; + HPS_I2C1_SDAT : inout std_logic; + HPS_I2C2_SCLK : inout std_logic; + HPS_I2C2_SDAT : inout std_logic; + HPS_I2C_CONTROL : inout std_logic; + + HPS_LTC_GPIO : inout std_logic; + HPS_GSENSOR_INT : inout std_logic; + + HPS_SPIM_CLK : out std_logic; + HPS_SPIM_MISO : in std_logic; + HPS_SPIM_MOSI : out std_logic; + HPS_SPIM_SS : inout std_logic; + + --////////// GPIO, GPIO connect to RFS - RF and Sensor ////////// + --BT_KEY : inout std_logic; + --BT_UART_RX : in std_logic; + --BT_UART_TX : out std_logic; + LSENSOR_INT : in std_logic; + LSENSOR_SCL : inout std_logic; + LSENSOR_SDA : inout std_logic; + MPU_AD0_SDO : in std_logic; + MPU_CS_n : inout std_logic; + MPU_FSYNC : out std_logic; + MPU_INT : in std_logic; + MPU_SCL_SCLK : inout std_logic; + MPU_SDA_SDI : inout std_logic; + RH_TEMP_DRDY_n : in std_ulogic; + RH_TEMP_I2C_SCL : inout std_logic; + RH_TEMP_I2C_SDA : inout std_logic; + TMD_D : out std_logic_vector(7 downto 0); + --UART2USB_CTS : in std_logic; + --UART2USB_RTS : out std_logic; + --UART2USB_RX : in std_logic; + --UART2USB_TX : out std_logic; + --WIFI_EN : out std_logic; + --WIFI_RST_n : out std_logic; + --WIFI_UART0_CTS : in std_logic; + --WIFI_UART0_RTS : out std_logic; + --WIFI_UART0_RX : in std_logic; + --WIFI_UART0_TX : out std_logic; + --WIFI_UART1_RX : in std_logic + GPIO_0 : out std_logic_vector(35 downto 0) +); + +END ENTITY; + +ARCHITECTURE MAIN OF top IS + component HPSPlatform is + port ( + clk_clk : in std_logic := 'X'; -- clk + hmi_subsystemapds9301_apdsinterrupt_irq_n : in std_logic := 'X'; -- irq_n + hmi_subsystemapds9301_i2c_sda_in : in std_logic := 'X'; -- sda_in + hmi_subsystemapds9301_i2c_scl_in : in std_logic := 'X'; -- scl_in + hmi_subsystemapds9301_i2c_sda_oe : out std_logic; -- sda_oe + hmi_subsystemapds9301_i2c_scl_oe : out std_logic; -- scl_oe + hmi_subsystemhdc1000_hdcrdy_interrupt : in std_logic := 'X'; -- interrupt + hmi_subsystemhdc1000_i2c_0_i2c_serial_sda_in : in std_logic := 'X'; -- sda_in + hmi_subsystemhdc1000_i2c_0_i2c_serial_scl_in : in std_logic := 'X'; -- scl_in + hmi_subsystemhdc1000_i2c_0_i2c_serial_sda_oe : out std_logic; -- sda_oe + hmi_subsystemhdc1000_i2c_0_i2c_serial_scl_oe : out std_logic; -- scl_oe + hmi_subsystemmpu9250_mpuint_irq_n : in std_logic := 'X'; -- irq_n + hmi_subsystemmpu9250_spi_sclk : out std_logic; -- sclk + hmi_subsystemmpu9250_spi_mosi : out std_logic; -- mosi + hmi_subsystemmpu9250_spi_miso : in std_logic := 'X'; -- miso + hmi_subsystemmpu9250_spi_ss_n : out std_logic; -- ss_n + hps_0_f2h_cold_reset_req_reset_n : in std_logic := 'X'; -- reset_n + hps_0_f2h_debug_reset_req_reset_n : in std_logic := 'X'; -- reset_n + hps_0_f2h_stm_hw_events_stm_hwevents : in std_logic_vector(27 downto 0) := (others => 'X'); -- stm_hwevents + hps_0_f2h_warm_reset_req_reset_n : in std_logic := 'X'; -- reset_n + hps_0_h2f_reset_reset_n : out std_logic; -- reset_n + hps_io_hps_io_emac1_inst_TX_CLK : out std_logic; -- hps_io_emac1_inst_TX_CLK + hps_io_hps_io_emac1_inst_TXD0 : out std_logic; -- hps_io_emac1_inst_TXD0 + hps_io_hps_io_emac1_inst_TXD1 : out std_logic; -- hps_io_emac1_inst_TXD1 + hps_io_hps_io_emac1_inst_TXD2 : out std_logic; -- hps_io_emac1_inst_TXD2 + hps_io_hps_io_emac1_inst_TXD3 : out std_logic; -- hps_io_emac1_inst_TXD3 + hps_io_hps_io_emac1_inst_RXD0 : in std_logic := 'X'; -- hps_io_emac1_inst_RXD0 + hps_io_hps_io_emac1_inst_MDIO : inout std_logic := 'X'; -- hps_io_emac1_inst_MDIO + hps_io_hps_io_emac1_inst_MDC : out std_logic; -- hps_io_emac1_inst_MDC + hps_io_hps_io_emac1_inst_RX_CTL : in std_logic := 'X'; -- hps_io_emac1_inst_RX_CTL + hps_io_hps_io_emac1_inst_TX_CTL : out std_logic; -- hps_io_emac1_inst_TX_CTL + hps_io_hps_io_emac1_inst_RX_CLK : in std_logic := 'X'; -- hps_io_emac1_inst_RX_CLK + hps_io_hps_io_emac1_inst_RXD1 : in std_logic := 'X'; -- hps_io_emac1_inst_RXD1 + hps_io_hps_io_emac1_inst_RXD2 : in std_logic := 'X'; -- hps_io_emac1_inst_RXD2 + hps_io_hps_io_emac1_inst_RXD3 : in std_logic := 'X'; -- hps_io_emac1_inst_RXD3 + hps_io_hps_io_sdio_inst_CMD : inout std_logic := 'X'; -- hps_io_sdio_inst_CMD + hps_io_hps_io_sdio_inst_D0 : inout std_logic := 'X'; -- hps_io_sdio_inst_D0 + hps_io_hps_io_sdio_inst_D1 : inout std_logic := 'X'; -- hps_io_sdio_inst_D1 + hps_io_hps_io_sdio_inst_CLK : out std_logic; -- hps_io_sdio_inst_CLK + hps_io_hps_io_sdio_inst_D2 : inout std_logic := 'X'; -- hps_io_sdio_inst_D2 + hps_io_hps_io_sdio_inst_D3 : inout std_logic := 'X'; -- hps_io_sdio_inst_D3 + hps_io_hps_io_usb1_inst_D0 : inout std_logic := 'X'; -- hps_io_usb1_inst_D0 + hps_io_hps_io_usb1_inst_D1 : inout std_logic := 'X'; -- hps_io_usb1_inst_D1 + hps_io_hps_io_usb1_inst_D2 : inout std_logic := 'X'; -- hps_io_usb1_inst_D2 + hps_io_hps_io_usb1_inst_D3 : inout std_logic := 'X'; -- hps_io_usb1_inst_D3 + hps_io_hps_io_usb1_inst_D4 : inout std_logic := 'X'; -- hps_io_usb1_inst_D4 + hps_io_hps_io_usb1_inst_D5 : inout std_logic := 'X'; -- hps_io_usb1_inst_D5 + hps_io_hps_io_usb1_inst_D6 : inout std_logic := 'X'; -- hps_io_usb1_inst_D6 + hps_io_hps_io_usb1_inst_D7 : inout std_logic := 'X'; -- hps_io_usb1_inst_D7 + hps_io_hps_io_usb1_inst_CLK : in std_logic := 'X'; -- hps_io_usb1_inst_CLK + hps_io_hps_io_usb1_inst_STP : out std_logic; -- hps_io_usb1_inst_STP + hps_io_hps_io_usb1_inst_DIR : in std_logic := 'X'; -- hps_io_usb1_inst_DIR + hps_io_hps_io_usb1_inst_NXT : in std_logic := 'X'; -- hps_io_usb1_inst_NXT + hps_io_hps_io_spim1_inst_CLK : out std_logic; -- hps_io_spim1_inst_CLK + hps_io_hps_io_spim1_inst_MOSI : out std_logic; -- hps_io_spim1_inst_MOSI + hps_io_hps_io_spim1_inst_MISO : in std_logic := 'X'; -- hps_io_spim1_inst_MISO + hps_io_hps_io_spim1_inst_SS0 : out std_logic; -- hps_io_spim1_inst_SS0 + hps_io_hps_io_uart0_inst_RX : in std_logic := 'X'; -- hps_io_uart0_inst_RX + hps_io_hps_io_uart0_inst_TX : out std_logic; -- hps_io_uart0_inst_TX + hps_io_hps_io_i2c0_inst_SDA : inout std_logic := 'X'; -- hps_io_i2c0_inst_SDA + hps_io_hps_io_i2c0_inst_SCL : inout std_logic := 'X'; -- hps_io_i2c0_inst_SCL + hps_io_hps_io_i2c1_inst_SDA : inout std_logic := 'X'; -- hps_io_i2c1_inst_SDA + hps_io_hps_io_i2c1_inst_SCL : inout std_logic := 'X'; -- hps_io_i2c1_inst_SCL + hps_io_hps_io_gpio_inst_GPIO09 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO09 + hps_io_hps_io_gpio_inst_GPIO35 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO35 + hps_io_hps_io_gpio_inst_GPIO40 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO40 + hps_io_hps_io_gpio_inst_GPIO48 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO48 + hps_io_hps_io_gpio_inst_GPIO53 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO53 + hps_io_hps_io_gpio_inst_GPIO54 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO54 + hps_io_hps_io_gpio_inst_GPIO61 : inout std_logic := 'X'; -- hps_io_gpio_inst_GPIO61 + leds_external_connection_export : out std_logic_vector(9 downto 0); -- export + memory_mem_a : out std_logic_vector(14 downto 0); -- mem_a + memory_mem_ba : out std_logic_vector(2 downto 0); -- mem_ba + memory_mem_ck : out std_logic; -- mem_ck + memory_mem_ck_n : out std_logic; -- mem_ck_n + memory_mem_cke : out std_logic; -- mem_cke + memory_mem_cs_n : out std_logic; -- mem_cs_n + memory_mem_ras_n : out std_logic; -- mem_ras_n + memory_mem_cas_n : out std_logic; -- mem_cas_n + memory_mem_we_n : out std_logic; -- mem_we_n + memory_mem_reset_n : out std_logic; -- mem_reset_n + memory_mem_dq : inout std_logic_vector(31 downto 0) := (others => 'X'); -- mem_dq + memory_mem_dqs : inout std_logic_vector(3 downto 0) := (others => 'X'); -- mem_dqs + memory_mem_dqs_n : inout std_logic_vector(3 downto 0) := (others => 'X'); -- mem_dqs_n + memory_mem_odt : out std_logic; -- mem_odt + memory_mem_dm : out std_logic_vector(3 downto 0); -- mem_dm + memory_oct_rzqin : in std_logic := 'X'; -- oct_rzqin + reset_reset_n : in std_logic := 'X'; -- reset_n + seven_segment_conduit_end_export : out std_logic_vector(41 downto 0); -- export + switches_external_connection_export : in std_logic_vector(9 downto 0) := (others => 'X'); -- export + hmi_infrared_ir_tx_o_conduit : out std_logic; -- conduit + hmi_infrared_ir_rx_o_conduit : out std_logic; -- conduit + hmi_infrared_ir_rx_i_conduit : in std_logic := 'X' -- conduit + ); + end component HPSPlatform; + + component i2c_io_buf + PORT + ( + datain : IN STD_LOGIC_VECTOR (1 DOWNTO 0); + oe : IN STD_LOGIC_VECTOR (1 DOWNTO 0); + dataio : INOUT STD_LOGIC_VECTOR (1 DOWNTO 0); + dataout : OUT STD_LOGIC_VECTOR (1 DOWNTO 0) + ); + end component; + + + signal HPS_H2F_RST : std_logic; + + constant hps_cold_reset : std_logic := '0'; + constant hps_warm_reset : std_logic := '0'; + constant hps_debug_reset : std_logic := '0'; + constant sync_levels : natural := 100; + + signal stm_hw_events : std_logic_vector(27 downto 0); + signal test : std_logic; + signal key_reset_sync : std_logic_vector(sync_levels downto 0); + + signal hdc1000_i2c_serial_sda_in : std_logic; + signal hdc1000_i2c_serial_scl_in : std_logic; + signal hdc1000_i2c_serial_sda_oe : std_logic; + signal hdc1000_i2c_serial_scl_oe : std_logic; + + signal apds9301_i2c_serial_sda_in : std_logic; + signal apds9301_i2c_serial_scl_in : std_logic; + signal apds9301_i2c_serial_sda_oe : std_logic; + signal apds9301_i2c_serial_scl_oe : std_logic; + + signal ir_rx_mirror : std_logic; + +BEGIN + + +u0 : component HPSPlatform + port map ( + clk_clk => CLOCK_50, -- clk.clk + reset_reset_n => key_reset_sync(0), -- reset.reset_n + memory_mem_a => HPS_DDR3_ADDR, -- memory.mem_a + memory_mem_ba => HPS_DDR3_BA, -- .mem_ba + memory_mem_ck => HPS_DDR3_CK_P, -- .mem_ck + memory_mem_ck_n => HPS_DDR3_CK_N, -- .mem_ck_n + memory_mem_cke => HPS_DDR3_CKE, -- .mem_cke + memory_mem_cs_n => HPS_DDR3_CS_N, -- .mem_cs_n + memory_mem_ras_n => HPS_DDR3_RAS_N, -- .mem_ras_n + memory_mem_cas_n => HPS_DDR3_CAS_N, -- .mem_cas_n + memory_mem_we_n => HPS_DDR3_WE_N, -- .mem_we_n + memory_mem_reset_n => HPS_DDR3_RESET_N, -- .mem_reset_n + memory_mem_dq => HPS_DDR3_DQ, -- .mem_dq + memory_mem_dqs => HPS_DDR3_DQS_P, -- .mem_dqs + memory_mem_dqs_n => HPS_DDR3_DQS_N, -- .mem_dqs_n + memory_mem_odt => HPS_DDR3_ODT, -- .mem_odt + memory_mem_dm => HPS_DDR3_DM, -- .mem_dm + memory_oct_rzqin => HPS_DDR3_RZQ, -- .oct_rzqin + hps_0_h2f_reset_reset_n => HPS_H2F_RST, -- hps_0_h2f_reset.reset_n + hps_0_f2h_cold_reset_req_reset_n => not(hps_cold_reset), -- hps_0_f2h_cold_reset_req.reset_n + hps_0_f2h_debug_reset_req_reset_n => not(hps_debug_reset), -- hps_0_f2h_debug_reset_req.reset_n + hps_0_f2h_stm_hw_events_stm_hwevents => stm_hw_events, -- hps_0_f2h_stm_hw_events.stm_hwevents + hps_0_f2h_warm_reset_req_reset_n => not(hps_warm_reset), -- hps_0_f2h_warm_reset_req.reset_n + hps_io_hps_io_emac1_inst_TX_CLK => HPS_ENET_GTX_CLK, -- hps_io.hps_io_emac1_inst_TX_CLK + hps_io_hps_io_emac1_inst_TXD0 => HPS_ENET_TX_DATA(0), -- .hps_io_emac1_inst_TXD0 + hps_io_hps_io_emac1_inst_TXD1 => HPS_ENET_TX_DATA(1), -- .hps_io_emac1_inst_TXD1 + hps_io_hps_io_emac1_inst_TXD2 => HPS_ENET_TX_DATA(2), -- .hps_io_emac1_inst_TXD2 + hps_io_hps_io_emac1_inst_TXD3 => HPS_ENET_TX_DATA(3), -- .hps_io_emac1_inst_TXD3 + hps_io_hps_io_emac1_inst_RXD0 => HPS_ENET_RX_DATA(0), -- .hps_io_emac1_inst_RXD0 + hps_io_hps_io_emac1_inst_MDIO => HPS_ENET_MDIO, -- .hps_io_emac1_inst_MDIO + hps_io_hps_io_emac1_inst_MDC => HPS_ENET_MDC, -- .hps_io_emac1_inst_MDC + hps_io_hps_io_emac1_inst_RX_CTL => HPS_ENET_RX_DV, -- .hps_io_emac1_inst_RX_CTL + hps_io_hps_io_emac1_inst_TX_CTL => HPS_ENET_TX_EN, -- .hps_io_emac1_inst_TX_CTL + hps_io_hps_io_emac1_inst_RX_CLK => HPS_ENET_RX_CLK, -- .hps_io_emac1_inst_RX_CLK + hps_io_hps_io_emac1_inst_RXD1 => HPS_ENET_RX_DATA(1), -- .hps_io_emac1_inst_RXD1 + hps_io_hps_io_emac1_inst_RXD2 => HPS_ENET_RX_DATA(2), -- .hps_io_emac1_inst_RXD2 + hps_io_hps_io_emac1_inst_RXD3 => HPS_ENET_RX_DATA(3), -- .hps_io_emac1_inst_RXD3 + hps_io_hps_io_sdio_inst_CMD => HPS_SD_CMD, -- .hps_io_sdio_inst_CMD + hps_io_hps_io_sdio_inst_D0 => HPS_SD_DATA(0), -- .hps_io_sdio_inst_D0 + hps_io_hps_io_sdio_inst_D1 => HPS_SD_DATA(1), -- .hps_io_sdio_inst_D1 + hps_io_hps_io_sdio_inst_CLK => HPS_SD_CLK, -- .hps_io_sdio_inst_CLK + hps_io_hps_io_sdio_inst_D2 => HPS_SD_DATA(2), -- .hps_io_sdio_inst_D2 + hps_io_hps_io_sdio_inst_D3 => HPS_SD_DATA(3), -- .hps_io_sdio_inst_D3 + hps_io_hps_io_usb1_inst_D0 => HPS_USB_DATA(0), -- .hps_io_usb1_inst_D0 + hps_io_hps_io_usb1_inst_D1 => HPS_USB_DATA(1), -- .hps_io_usb1_inst_D1 + hps_io_hps_io_usb1_inst_D2 => HPS_USB_DATA(2), -- .hps_io_usb1_inst_D2 + hps_io_hps_io_usb1_inst_D3 => HPS_USB_DATA(3), -- .hps_io_usb1_inst_D3 + hps_io_hps_io_usb1_inst_D4 => HPS_USB_DATA(4), -- .hps_io_usb1_inst_D4 + hps_io_hps_io_usb1_inst_D5 => HPS_USB_DATA(5), -- .hps_io_usb1_inst_D5 + hps_io_hps_io_usb1_inst_D6 => HPS_USB_DATA(6), -- .hps_io_usb1_inst_D6 + hps_io_hps_io_usb1_inst_D7 => HPS_USB_DATA(7), -- .hps_io_usb1_inst_D7 + hps_io_hps_io_usb1_inst_CLK => HPS_USB_CLKOUT, -- .hps_io_usb1_inst_CLK + hps_io_hps_io_usb1_inst_STP => HPS_USB_STP, -- .hps_io_usb1_inst_STP + hps_io_hps_io_usb1_inst_DIR => HPS_USB_DIR, -- .hps_io_usb1_inst_DIR + hps_io_hps_io_usb1_inst_NXT => HPS_USB_NXT, -- .hps_io_usb1_inst_NXT + hps_io_hps_io_spim1_inst_CLK => HPS_SPIM_CLK, -- .hps_io_spim1_inst_CLK + hps_io_hps_io_spim1_inst_MOSI => HPS_SPIM_MOSI, -- .hps_io_spim1_inst_MOSI + hps_io_hps_io_spim1_inst_MISO => HPS_SPIM_MISO, -- .hps_io_spim1_inst_MISO + hps_io_hps_io_spim1_inst_SS0 => HPS_SPIM_SS, -- .hps_io_spim1_inst_SS0 + hps_io_hps_io_uart0_inst_RX => HPS_UART_RX, -- .hps_io_uart0_inst_RX + hps_io_hps_io_uart0_inst_TX => HPS_UART_TX, -- .hps_io_uart0_inst_TX + hps_io_hps_io_i2c0_inst_SDA => HPS_I2C1_SDAT, -- .hps_io_i2c0_inst_SDA + hps_io_hps_io_i2c0_inst_SCL => HPS_I2C1_SCLK, -- .hps_io_i2c0_inst_SCL + hps_io_hps_io_i2c1_inst_SDA => HPS_I2C2_SDAT, -- .hps_io_i2c1_inst_SDA + hps_io_hps_io_i2c1_inst_SCL => HPS_I2C2_SCLK, -- .hps_io_i2c1_inst_SCL + hps_io_hps_io_gpio_inst_GPIO09 => HPS_CONV_USB_N, -- hps_io_gpio_inst_GPIO09 + hps_io_hps_io_gpio_inst_GPIO35 => HPS_ENET_INT_N, -- .hps_io_gpio_inst_GPIO35 + hps_io_hps_io_gpio_inst_GPIO40 => HPS_LTC_GPIO, -- .hps_io_gpio_inst_GPIO40 + hps_io_hps_io_gpio_inst_GPIO48 => HPS_I2C_CONTROL, -- .hps_io_gpio_inst_GPIO48 + hps_io_hps_io_gpio_inst_GPIO53 => HPS_LED, -- hps_io_gpio_inst_GPIO53 + hps_io_hps_io_gpio_inst_GPIO54 => HPS_KEY, -- hps_io_gpio_inst_GPIO54 + hps_io_hps_io_gpio_inst_GPIO61 => HPS_GSENSOR_INT, -- .hps_io_gpio_inst_GPIO61 + + + -- periph +-- leds_external_connection_export => LEDR, -- led_external_connection.export + switches_external_connection_export => SW, -- sw_external_connection.export + + seven_segment_conduit_end_export(6+7*0 downto 7*0) => HEX0, + seven_segment_conduit_end_export(6+7*1 downto 7*1) => HEX1, + seven_segment_conduit_end_export(6+7*2 downto 7*2) => HEX2, + seven_segment_conduit_end_export(6+7*3 downto 7*3) => HEX3, + seven_segment_conduit_end_export(6+7*4 downto 7*4) => HEX4, + seven_segment_conduit_end_export(6+7*5 downto 7*5) => HEX5, + + hmi_subsystemhdc1000_hdcrdy_interrupt => RH_TEMP_DRDY_n, -- hdc1000_0_hdcrdy.interrupt + hmi_subsystemhdc1000_i2c_0_i2c_serial_sda_in => hdc1000_i2c_serial_sda_in, -- hdc1000_i2c_0_i2c_serial.sda_in + hmi_subsystemhdc1000_i2c_0_i2c_serial_scl_in => hdc1000_i2c_serial_scl_in, -- .scl_in + hmi_subsystemhdc1000_i2c_0_i2c_serial_sda_oe => hdc1000_i2c_serial_sda_oe, -- .sda_oe + hmi_subsystemhdc1000_i2c_0_i2c_serial_scl_oe => hdc1000_i2c_serial_scl_oe, -- .scl_oe + + hmi_subsystemapds9301_apdsinterrupt_irq_n => LSENSOR_INT, -- hmi_subsystemapds9301_apdsinterrupt.irq_n + hmi_subsystemapds9301_i2c_sda_in => apds9301_i2c_serial_sda_in, -- hmi_subsystemapds9301_i2c_0_i2c_serial.scl_in + hmi_subsystemapds9301_i2c_scl_in => apds9301_i2c_serial_scl_in, -- .scl_oe + hmi_subsystemapds9301_i2c_sda_oe => apds9301_i2c_serial_sda_oe, -- .sda_in + hmi_subsystemapds9301_i2c_scl_oe => apds9301_i2c_serial_scl_oe, + + hmi_subsystemmpu9250_spi_miso => MPU_AD0_SDO, -- hmi_subsystemmpu9250_spi_0_external.MISO + hmi_subsystemmpu9250_spi_mosi => MPU_SDA_SDI, -- .MOSI + hmi_subsystemmpu9250_spi_sclk => MPU_SCL_SCLK, -- .SCLK + hmi_subsystemmpu9250_spi_ss_n => MPU_CS_n, -- .SS_n + hmi_subsystemmpu9250_mpuint_irq_n => MPU_INT, -- hmi_subsystemmpu9250_mpuint.irq_n + + hmi_infrared_ir_tx_o_conduit => IRDA_TXD, + hmi_infrared_ir_rx_o_conduit => ir_rx_mirror, + hmi_infrared_ir_rx_i_conduit => IRDA_RXD + ); + + key_sync : process( CLOCK_50, HPS_H2F_RST, SW(0) ) + begin + if (HPS_H2F_RST AND SW(0)) = '0' then + key_reset_sync <= (others => '0'); + elsif rising_edge(CLOCK_50) then + key_reset_sync(sync_levels) <= '1'; + key_reset_sync(sync_levels-1 downto 0) <= key_reset_sync(sync_levels downto 1); + end if; + end process; -- key_sync + + hdc1000_i2c_io : component i2c_io_buf + port map ( + datain => (others => '0'), + oe(1) => hdc1000_i2c_serial_scl_oe, + oe(0) => hdc1000_i2c_serial_sda_oe, + dataout(1) => hdc1000_i2c_serial_scl_in, + dataout(0) => hdc1000_i2c_serial_sda_in, + dataio(1) => RH_TEMP_I2C_SCL, + dataio(0) => RH_TEMP_I2C_SDA); + + apds9301_i2c_io : component i2c_io_buf + port map ( + datain => (others => '0'), + oe(1) => apds9301_i2c_serial_scl_oe, + oe(0) => apds9301_i2c_serial_sda_oe, + dataout(1) => apds9301_i2c_serial_scl_in, + dataout(0) => apds9301_i2c_serial_sda_in, + dataio(1) => LSENSOR_SCL, + dataio(0) => LSENSOR_SDA); + + LEDR(0) <= HPS_H2F_RST AND key_reset_sync(0); + LEDR(1) <= ir_rx_mirror; + LEDR(LEDR'high downto 2) <= (others => '0'); + + GPIO_0( 0) <= RH_TEMP_DRDY_n; + GPIO_0( 1) <= RH_TEMP_I2C_SCL; + GPIO_0( 2) <= RH_TEMP_I2C_SDA; + + GPIO_0( 4) <= LSENSOR_INT; + GPIO_0( 5) <= LSENSOR_SCL; + GPIO_0( 6) <= LSENSOR_SDA; + + GPIO_0(10) <= MPU_SCL_SCLK; + GPIO_0(11) <= MPU_CS_n; + GPIO_0(12) <= MPU_INT; + GPIO_0(14) <= MPU_AD0_SDO; + GPIO_0(15) <= MPU_SDA_SDI; + +END ARCHITECTURE; From f79ebf7bedc99ef6ef4ba3f4644a04782e06adf4 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 21:06:48 +0100 Subject: [PATCH 10/16] fix minor synthesis errors --- hdl/components/infrared/infrared.vhd | 5 +++-- hdl/top.vhd | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/hdl/components/infrared/infrared.vhd b/hdl/components/infrared/infrared.vhd index 846564e..6a90d3e 100644 --- a/hdl/components/infrared/infrared.vhd +++ b/hdl/components/infrared/infrared.vhd @@ -99,7 +99,8 @@ begin -- architecture rtl -- Outputs ------------------------------------------------------------------------------ - ir_rx_o <= ir_rx(ir_rx'high); + ir_rx_o <= ir_rx(ir_rx'high); -- mirror rx signal (for debug only) + ir_tx_o <= ir_rx(ir_rx'high); -- mirror rx signal (until tx is implemented) avs_s0_readdata <= std_logic_vector(ram_readdata); done_recording_irq_o <= recording_stopped; @@ -143,7 +144,7 @@ begin -- architecture rtl rst_n_i => rst_n_i, enable_i => falling, overflow_o => recording_stopped, - count_o => timestamp); + count_o => open); ------------------------------------------------------------------------------ -- Registers diff --git a/hdl/top.vhd b/hdl/top.vhd index 6923cbe..98848be 100644 --- a/hdl/top.vhd +++ b/hdl/top.vhd @@ -21,7 +21,7 @@ PORT( -- //////////// Infrared Interface ////////// IRDA_RXD : in std_logic; - IRDA_TXD : in std_logic; + IRDA_TXD : out std_logic; ---------HPS Connections--------------- HPS_CONV_USB_N : inout std_logic; From 08a0f4818ef70425e37e2bd8718678b525c45c5a Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 21:07:03 +0100 Subject: [PATCH 11/16] add vhdltool-config.yaml file --- hdl/vhdltool-config.yaml | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 hdl/vhdltool-config.yaml diff --git a/hdl/vhdltool-config.yaml b/hdl/vhdltool-config.yaml new file mode 100644 index 0000000..fc7a391 --- /dev/null +++ b/hdl/vhdltool-config.yaml @@ -0,0 +1,57 @@ +#Define your project's libraries and source files here. +#This section is compulsory. +Libraries: + #The name of the library. + - name: work + #The paths where the source files for this library can be found. Use "**" to match arbitrarily nested directories. + paths: + - ".vhd" + + + - name: hardware_lib2 + paths: + - "hardware_lib2/**/*.vhd" + - "hardware_lib2/**/*.vhdl" + + + #Point to the IEEE standard libraries + - name: ieee + paths: + - "/home/awesome-vhdl-dev/ieee/*.vhd" + - "/home/awesome-vhdl-dev/ieee/*.vhdl" + +#Enable/disable typechecking +TypeCheck: True + +#Enable/disable check-as-you-type +CheckOnChange: True + +#Linter rule configuration. +#Rules can be enabled or disabled. +#Rules also have a severity. It may be one of Info, Warning, Critical or Error. +Lint: + #Threshold, below which messages are not displayed. + Threshold: Warning + + #Long form rule configuration. Both enabled/disabled status and severity can be configured this way. + DeclaredNotAssigned: + enabled: True + severity: Warning #Default severity Warning + + #Short form. Only enabled/disabled status can be specified. Severity is the default for the rule. + DeclaredNotRead: True #Default severity Warning + ReadNotAssigned: True #Default severity Critical + SensitivityListCheck: True #Default severity Warning + ExtraSensitivityListCheck: True #Default severity Warning + DuplicateSensitivity: True #Default severity Warning + LatchCheck: True #Default severity Critical + VariableNotRead: True #Default severity Warning + VariableNotWritten: True #Default severity Warning + PortNotRead: True #Default severity Warning + PortNotWritten: True #Default severity Critical + NoPrimaryUnit: True #Default severity Warning + DuplicateLibraryImport: True #Default severity Warning + DuplicatePackageUsage: True #Default severity Warning + DeprecatedPackages: True #Default severity Warning + ImplicitLibraries: True #Default severity Warning + DisconnectedPorts: True #Default severity Critical From b7553268fde8130297528326eb94f467b7b4be47 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Tue, 18 Feb 2020 21:12:09 +0100 Subject: [PATCH 12/16] move the yaml file --- hdl/vhdltool-config.yaml => vhdltool-config.yaml | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) rename hdl/vhdltool-config.yaml => vhdltool-config.yaml (86%) diff --git a/hdl/vhdltool-config.yaml b/vhdltool-config.yaml similarity index 86% rename from hdl/vhdltool-config.yaml rename to vhdltool-config.yaml index fc7a391..8f4db44 100644 --- a/hdl/vhdltool-config.yaml +++ b/vhdltool-config.yaml @@ -5,20 +5,7 @@ Libraries: - name: work #The paths where the source files for this library can be found. Use "**" to match arbitrarily nested directories. paths: - - ".vhd" - - - - name: hardware_lib2 - paths: - - "hardware_lib2/**/*.vhd" - - "hardware_lib2/**/*.vhdl" - - - #Point to the IEEE standard libraries - - name: ieee - paths: - - "/home/awesome-vhdl-dev/ieee/*.vhd" - - "/home/awesome-vhdl-dev/ieee/*.vhdl" + - "**/infrared/*.vhd" #Enable/disable typechecking TypeCheck: True From 916d588d55aca0cf414ff50c729d63766a921ec1 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Wed, 19 Feb 2020 11:32:43 +0100 Subject: [PATCH 13/16] fix width error --- hdl/components/infrared/infrared.vhd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hdl/components/infrared/infrared.vhd b/hdl/components/infrared/infrared.vhd index 6a90d3e..c9fdcb8 100644 --- a/hdl/components/infrared/infrared.vhd +++ b/hdl/components/infrared/infrared.vhd @@ -128,7 +128,7 @@ begin -- architecture rtl timestamp_counter_inst : entity work.counter generic map ( - counter_width_g => 31) + counter_width_g => 32) port map ( clk_i => clk_i, rst_n_i => rst_n_i, From b771e30cfd60f831fb0dacc058106912d3af9e55 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Wed, 19 Feb 2020 12:28:37 +0100 Subject: [PATCH 14/16] hook up irq to shared irq line --- hdl/HPSPlatform.qsys | 15 ++++++---- hdl/components/infrared/infrared_hw.tcl | 38 ++++++++++++++++--------- hdl/ip/subsystemHMI.qsys | 11 +++---- 3 files changed, 39 insertions(+), 25 deletions(-) diff --git a/hdl/HPSPlatform.qsys b/hdl/HPSPlatform.qsys index 6454af1..3237d7e 100644 --- a/hdl/HPSPlatform.qsys +++ b/hdl/HPSPlatform.qsys @@ -312,11 +312,7 @@ internal="hmi.infrared_ir_tx_o" type="conduit" dir="end" /> - + - + @@ -1076,6 +1072,13 @@ start="clk_0.clk" end="hmi.subsystemmpu9250_clk" /> + + + + - + Date: Wed, 19 Feb 2020 14:27:56 +0100 Subject: [PATCH 15/16] implement a control register interface --- hdl/components/infrared/infrared.vhd | 34 ++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/hdl/components/infrared/infrared.vhd b/hdl/components/infrared/infrared.vhd index c9fdcb8..c5c9228 100644 --- a/hdl/components/infrared/infrared.vhd +++ b/hdl/components/infrared/infrared.vhd @@ -73,6 +73,7 @@ architecture rtl of infrared is type ram_t is array(0 to 255) of timestamp_t; signal ram_data : ram_t := (others => (others => '0')); signal ram_readdata : timestamp_t := (others => '0'); + signal ctrl_readdata : timestamp_t := (others => '0'); signal addr : unsigned(7 downto 0) := (others => '0'); signal ir_rx : std_ulogic_vector(1 downto 0); @@ -90,6 +91,8 @@ architecture rtl of infrared is signal falling : std_ulogic; signal recording_stopped : std_ulogic; signal timestamp : timestamp_t; + signal ctrl_access : std_ulogic; + signal irq_active : std_ulogic; --! @} @@ -101,7 +104,8 @@ begin -- architecture rtl ir_rx_o <= ir_rx(ir_rx'high); -- mirror rx signal (for debug only) ir_tx_o <= ir_rx(ir_rx'high); -- mirror rx signal (until tx is implemented) - avs_s0_readdata <= std_logic_vector(ram_readdata); + avs_s0_readdata <= std_logic_vector(ram_readdata) when ctrl_access = '0' + else ctrl_readdata; done_recording_irq_o <= recording_stopped; ----------------------------------------------------------------------------- @@ -111,6 +115,7 @@ begin -- architecture rtl next_ir_rx <= ir_rx(ir_rx'high-1 downto ir_rx'low) & ir_rx_sync; rising <= '1' when ir_rx(1)='0' and ir_rx(0)='1' else '0'; falling <= '1' when ir_rx(1)='1' and ir_rx(0)='0' else '0'; + ctrl_access <= '1' when avs_s0_address > ram_t'length-1 else '0'; ----------------------------------------------------------------------------- -- Instantiations @@ -155,6 +160,7 @@ begin -- architecture rtl begin addr <= to_unsigned(0, addr'length); store_timestamp <= '0'; + irq_active <= '0'; end procedure reset; begin -- process strobe if rst_n_i = '0' then @@ -168,6 +174,7 @@ begin -- architecture rtl addr <= addr + 1; store_timestamp <= '1'; elsif recording_stopped = '1' then + irq_active <= '1'; addr <= (others => '0'); end if; end if; @@ -181,9 +188,32 @@ begin -- architecture rtl end if; if avs_s0_read = '1' then - ram_readdata <= ram_data(to_integer(unsigned(avs_s0_address))); + ram_readdata <= ram_data(to_integer(unsigned(avs_s0_address(addr'range)))); end if; end if; end process ram; + ctrl_interface : process (clk_i) is + procedure reset is + begin + end procedure reset; + begin -- process ctrl_interface + if rst_n_i = '0' then + reset; + elsif rising_edge(clk_i) then + if avs_s0_read = '1' then + -- addresses higher 255 + case (to_integer(unsigned(avs_s0_address(avs_s0_address'high downto addr'high+1)))) is + when 0 => -- magic number + ctrl_readdata <= x"ABCD1234"; + when 1 => -- read and clear irq status + ctrl_readdata <= irq_active; + irq_active <= '0'; + when others => + ctrl_readdata <= x"DEADBEEF"; + end case; + end if; + end if; + end process ctrl_interface; + end architecture rtl; From 3a76deb523ac2622ea99fc8113b9aefbd05a62d8 Mon Sep 17 00:00:00 2001 From: Michael Wurm Date: Wed, 19 Feb 2020 15:13:17 +0100 Subject: [PATCH 16/16] more magic number regs --- hdl/components/infrared/infrared.vhd | 35 +++++++++++++++------ hdl/components/infrared/modelsim_compile.sh | 3 ++ 2 files changed, 29 insertions(+), 9 deletions(-) create mode 100755 hdl/components/infrared/modelsim_compile.sh diff --git a/hdl/components/infrared/infrared.vhd b/hdl/components/infrared/infrared.vhd index c5c9228..59f566c 100644 --- a/hdl/components/infrared/infrared.vhd +++ b/hdl/components/infrared/infrared.vhd @@ -27,7 +27,7 @@ entity infrared is --! @} --! @name Avalon MM Bus --! @{ - avs_s0_address : in std_logic_vector(7 downto 0); + avs_s0_address : in std_logic_vector(10 downto 0); avs_s0_read : in std_logic; avs_s0_readdata : out std_logic_vector(31 downto 0); avs_s0_write : in std_logic; @@ -71,13 +71,16 @@ architecture rtl of infrared is subtype timestamp_t is unsigned(31 downto 0); type ram_t is array(0 to 255) of timestamp_t; + signal ram_data : ram_t := (others => (others => '0')); signal ram_readdata : timestamp_t := (others => '0'); signal ctrl_readdata : timestamp_t := (others => '0'); signal addr : unsigned(7 downto 0) := (others => '0'); - signal ir_rx : std_ulogic_vector(1 downto 0); - signal store_timestamp : std_ulogic; + signal ir_rx : std_ulogic_vector(1 downto 0) := (others => '0'); + signal store_timestamp : std_ulogic := '0'; + signal irq_active : std_ulogic := '0'; + signal irq_reset : std_ulogic := '0'; --! @} ----------------------------------------------------------------------------- @@ -92,7 +95,6 @@ architecture rtl of infrared is signal recording_stopped : std_ulogic; signal timestamp : timestamp_t; signal ctrl_access : std_ulogic; - signal irq_active : std_ulogic; --! @} @@ -105,7 +107,7 @@ begin -- architecture rtl ir_rx_o <= ir_rx(ir_rx'high); -- mirror rx signal (for debug only) ir_tx_o <= ir_rx(ir_rx'high); -- mirror rx signal (until tx is implemented) avs_s0_readdata <= std_logic_vector(ram_readdata) when ctrl_access = '0' - else ctrl_readdata; + else std_logic_vector(ctrl_readdata); done_recording_irq_o <= recording_stopped; ----------------------------------------------------------------------------- @@ -115,7 +117,7 @@ begin -- architecture rtl next_ir_rx <= ir_rx(ir_rx'high-1 downto ir_rx'low) & ir_rx_sync; rising <= '1' when ir_rx(1)='0' and ir_rx(0)='1' else '0'; falling <= '1' when ir_rx(1)='1' and ir_rx(0)='0' else '0'; - ctrl_access <= '1' when avs_s0_address > ram_t'length-1 else '0'; + ctrl_access <= '1' when to_integer(unsigned(avs_s0_address)) > ram_t'length-1 else '0'; ----------------------------------------------------------------------------- -- Instantiations @@ -177,6 +179,9 @@ begin -- architecture rtl irq_active <= '1'; addr <= (others => '0'); end if; + if irq_reset = '1' then + irq_active <= '0'; + end if; end if; end process regs; @@ -196,19 +201,31 @@ begin -- architecture rtl ctrl_interface : process (clk_i) is procedure reset is begin + ctrl_readdata <= (others => '0'); + irq_reset <= '0'; end procedure reset; begin -- process ctrl_interface if rst_n_i = '0' then reset; elsif rising_edge(clk_i) then if avs_s0_read = '1' then + -- Defaults + ctrl_readdata <= (others => '0'); + irq_reset <= '0'; + -- addresses higher 255 case (to_integer(unsigned(avs_s0_address(avs_s0_address'high downto addr'high+1)))) is when 0 => -- magic number ctrl_readdata <= x"ABCD1234"; - when 1 => -- read and clear irq status - ctrl_readdata <= irq_active; - irq_active <= '0'; + when 1 => -- magic number + ctrl_readdata <= x"11111111"; + when 2 => -- magic number + ctrl_readdata <= x"22222222"; + when 3 => -- magic number + ctrl_readdata <= x"33333333"; + when 4 => -- read and clear irq status + ctrl_readdata(0) <= irq_active; + irq_reset <= '1'; when others => ctrl_readdata <= x"DEADBEEF"; end case; diff --git a/hdl/components/infrared/modelsim_compile.sh b/hdl/components/infrared/modelsim_compile.sh new file mode 100755 index 0000000..9be7554 --- /dev/null +++ b/hdl/components/infrared/modelsim_compile.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +vsim -do comp.do -c