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

Subversion Repositories neorv32

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

Show entire file | Details | Blame | View Log

Rev 66 Rev 70
Line 1... Line 1...
-- #################################################################################################
-- #################################################################################################
-- # << NEORV32 - General Purpose Parallel Input/Output Port (GPIO) >>                             #
-- # << NEORV32 - General Purpose Parallel Input/Output Port (GPIO) >>                             #
-- # ********************************************************************************************* #
-- # ********************************************************************************************* #
-- # 64-bit general purpose parallel input & output port unit.                                     #
-- # 64-bit general purpose parallel input & output port unit. Input/outputs are split into two    #
 
-- # 32-bit memory-mapped registers each.                                                          #
-- # ********************************************************************************************* #
-- # ********************************************************************************************* #
-- # BSD 3-Clause License                                                                          #
-- # BSD 3-Clause License                                                                          #
-- #                                                                                               #
-- #                                                                                               #
-- # Copyright (c) 2021, Stephan Nolting. All rights reserved.                                     #
-- # Copyright (c) 2022, Stephan Nolting. All rights reserved.                                     #
-- #                                                                                               #
-- #                                                                                               #
-- # Redistribution and use in source and binary forms, with or without modification, are          #
-- # Redistribution and use in source and binary forms, with or without modification, are          #
-- # permitted provided that the following conditions are met:                                     #
-- # permitted provided that the following conditions are met:                                     #
-- #                                                                                               #
-- #                                                                                               #
-- # 1. Redistributions of source code must retain the above copyright notice, this list of        #
-- # 1. Redistributions of source code must retain the above copyright notice, this list of        #
Line 49... Line 50...
    rden_i : in  std_ulogic; -- read enable
    rden_i : in  std_ulogic; -- read enable
    wren_i : in  std_ulogic; -- write enable
    wren_i : in  std_ulogic; -- write enable
    data_i : in  std_ulogic_vector(31 downto 0); -- data in
    data_i : in  std_ulogic_vector(31 downto 0); -- data in
    data_o : out std_ulogic_vector(31 downto 0); -- data out
    data_o : out std_ulogic_vector(31 downto 0); -- data out
    ack_o  : out std_ulogic; -- transfer acknowledge
    ack_o  : out std_ulogic; -- transfer acknowledge
 
    err_o  : out std_ulogic; -- transfer error
    -- parallel io --
    -- parallel io --
    gpio_o : out std_ulogic_vector(63 downto 0);
    gpio_o : out std_ulogic_vector(63 downto 0);
    gpio_i : in  std_ulogic_vector(63 downto 0)
    gpio_i : in  std_ulogic_vector(63 downto 0)
  );
  );
end neorv32_gpio;
end neorv32_gpio;
Line 68... Line 70...
  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 wren   : std_ulogic; -- word write enable
  signal rden   : std_ulogic; -- read 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_hi,  din_lo  : std_ulogic_vector(31 downto 0); -- r/-: parallel input hi/lo
  signal dout_lo, dout_hi : std_ulogic_vector(31 downto 0); -- r/w
  signal dout_hi, dout_lo : std_ulogic_vector(31 downto 0); -- r/w: parallel output hi/lo
 
 
begin
begin
 
 
  -- Access Control -------------------------------------------------------------------------
  -- Access Control -------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
Line 87... Line 89...
  -- -------------------------------------------------------------------------------------------
  -- -------------------------------------------------------------------------------------------
  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 <= wren or rden;
      ack_o <= (wren and addr(3)) or rden;
 
      err_o <= wren and (not addr(3)); -- INPUT registers are read only!
 
 
      -- write access --
      -- write access --
      if (wren = '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;
Line 99... Line 102...
        if (addr = gpio_out_hi_addr_c) then
        if (addr = gpio_out_hi_addr_c) then
          dout_hi <= data_i;
          dout_hi <= data_i;
        end if;
        end if;
      end if;
      end if;
 
 
      -- input buffer --
      -- input buffer (prevent metastability) --
      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');

powered by: WebSVN 2.1.0

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