OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [rtl/] [core/] [neorv32_gpio.vhd] - Diff between revs 61 and 66

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 61 Rev 66
Line 64... Line 64...
  constant lo_abb_c : natural := index_size_f(gpio_size_c); -- low address boundary bit
  constant lo_abb_c : natural := index_size_f(gpio_size_c); -- low address boundary bit
 
 
  -- access control --
  -- access control --
  signal acc_en : std_ulogic; -- module access enable
  signal acc_en : std_ulogic; -- module access enable
  signal addr   : std_ulogic_vector(31 downto 0); -- access address
  signal addr   : std_ulogic_vector(31 downto 0); -- access address
 
  signal wren   : std_ulogic; -- word write enable
 
  signal rden   : std_ulogic; -- read enable
 
 
  -- accessible regs --
  -- accessible regs --
  signal din_lo,  din_hi  : std_ulogic_vector(31 downto 0); -- r/-
  signal din_lo,  din_hi  : std_ulogic_vector(31 downto 0); -- r/-
  signal dout_lo, dout_hi : std_ulogic_vector(31 downto 0); -- r/w
  signal dout_lo, dout_hi : std_ulogic_vector(31 downto 0); -- r/w
 
 
Line 75... Line 77...
 
 
  -- Access Control -------------------------------------------------------------------------
  -- Access Control -------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  acc_en <= '1' when (addr_i(hi_abb_c downto lo_abb_c) = gpio_base_c(hi_abb_c downto lo_abb_c)) else '0';
  acc_en <= '1' when (addr_i(hi_abb_c downto lo_abb_c) = gpio_base_c(hi_abb_c downto lo_abb_c)) else '0';
  addr   <= gpio_base_c(31 downto lo_abb_c) & addr_i(lo_abb_c-1 downto 2) & "00"; -- word aligned
  addr   <= gpio_base_c(31 downto lo_abb_c) & addr_i(lo_abb_c-1 downto 2) & "00"; -- word aligned
 
  wren   <= acc_en and wren_i;
 
  rden   <= acc_en and rden_i;
 
 
 
 
  -- Read/Write Access ----------------------------------------------------------------------
  -- Read/Write Access ----------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  rw_access: process(clk_i)
  rw_access: process(clk_i)
  begin
  begin
    if rising_edge(clk_i) then
    if rising_edge(clk_i) then
      -- bus handshake --
      -- bus handshake --
      ack_o <= acc_en and (rden_i or wren_i);
      ack_o <= wren or rden;
 
 
      -- write access --
      -- write access --
      if ((acc_en and wren_i) = '1') then
      if (wren = '1') then
        if (addr = gpio_out_lo_addr_c) then
        if (addr = gpio_out_lo_addr_c) then
          dout_lo <= data_i;
          dout_lo <= data_i;
        end if;
        end if;
        if (addr = gpio_out_hi_addr_c) then
        if (addr = gpio_out_hi_addr_c) then
          dout_hi <= data_i;
          dout_hi <= data_i;
Line 101... Line 105...
      din_lo <= gpio_i(31 downto 00);
      din_lo <= gpio_i(31 downto 00);
      din_hi <= gpio_i(63 downto 32);
      din_hi <= gpio_i(63 downto 32);
 
 
      -- read access --
      -- read access --
      data_o <= (others => '0');
      data_o <= (others => '0');
      if ((acc_en and rden_i) = '1') then
      if (rden = '1') then
        case addr is
        case addr(3 downto 2) is
          when gpio_in_lo_addr_c  => data_o <= din_lo;
          when "00"   => data_o <= din_lo;
          when gpio_in_hi_addr_c  => data_o <= din_hi;
          when "01"   => data_o <= din_hi;
          when gpio_out_lo_addr_c => data_o <= dout_lo;
          when "10"   => data_o <= dout_lo;
          when gpio_out_hi_addr_c => data_o <= dout_hi;
          when others => data_o <= dout_hi;
          when others             => data_o <= (others => '0');
 
        end case;
        end case;
      end if;
      end if;
 
 
    end if;
    end if;
  end process rw_access;
  end process rw_access;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.