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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_gpio.vhd] - Diff between revs 224 and 244

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

Rev 224 Rev 244
Line 36... Line 36...
-- Seth Henry      12/20/13 Design Start
-- Seth Henry      12/20/13 Design Start
-- Seth Henry      04/10/20 Code cleanup and register documentation
-- Seth Henry      04/10/20 Code cleanup and register documentation
--                          Also removed "input only" generic, as there is a
--                          Also removed "input only" generic, as there is a
--                           separate module for that
--                           separate module for that
-- Seth Henry      04/16/20 Modified to make use of Open8 bus record
-- Seth Henry      04/16/20 Modified to make use of Open8 bus record
 
-- Seth Henry      05/18/20 Added write qualification input
 
 
library ieee;
library ieee;
use ieee.std_logic_1164.all;
use ieee.std_logic_1164.all;
 
 
library work;
library work;
Line 51... Line 52...
  Default_En                 : DATA_TYPE := x"00";
  Default_En                 : DATA_TYPE := x"00";
  Address                    : ADDRESS_TYPE
  Address                    : ADDRESS_TYPE
);
);
port(
port(
  Open8_Bus                  : in  OPEN8_BUS_TYPE;
  Open8_Bus                  : in  OPEN8_BUS_TYPE;
 
  Write_Qual                 : in  std_logic := '1';
  Rd_Data                    : out DATA_TYPE;
  Rd_Data                    : out DATA_TYPE;
  --
  --
  GPIO                       : inout DATA_TYPE
  GPIO                       : inout DATA_TYPE
);
);
end entity;
end entity;
Line 65... Line 67...
  alias Reset                is Open8_Bus.Reset;
  alias Reset                is Open8_Bus.Reset;
 
 
  constant User_Addr         : std_logic_vector(15 downto 2)
  constant User_Addr         : std_logic_vector(15 downto 2)
                               := Address(15 downto 2);
                               := Address(15 downto 2);
  alias  Comp_Addr           is Open8_Bus.Address(15 downto 2);
  alias  Comp_Addr           is Open8_Bus.Address(15 downto 2);
  alias  Reg_Addr            is Open8_Bus.Address(1 downto 0);
  signal Addr_Match          : std_logic;
  signal Reg_Sel             : std_logic_vector(1 downto 0) := "00";
 
  signal Addr_Match          : std_logic := '0';
  alias  Reg_Sel_d           is Open8_Bus.Address(1 downto 0);
  signal Wr_En               : std_logic := '0';
  signal Reg_Sel_q           : std_logic_vector(1 downto 0) := "00";
 
  signal Wr_En_d             : std_logic := '0';
 
  signal Wr_En_q             : std_logic := '0';
 
  alias  Wr_Data_d           is Open8_Bus.Wr_Data;
  signal Wr_Data_q           : DATA_TYPE := x"00";
  signal Wr_Data_q           : DATA_TYPE := x"00";
  signal Rd_En               : std_logic := '0';
  signal Rd_En_d             : std_logic := '0';
 
  signal Rd_En_q             : std_logic := '0';
 
 
  signal User_Out            : DATA_TYPE := x"00";
  signal User_Out            : DATA_TYPE := x"00";
  signal User_En             : DATA_TYPE := x"00";
  signal User_En             : DATA_TYPE := x"00";
  signal User_In             : DATA_TYPE := x"00";
  signal User_In             : DATA_TYPE := x"00";
 
 
begin
begin
 
 
  Addr_Match                 <= '1' when Comp_Addr = User_Addr else '0';
  Addr_Match                 <= '1' when Comp_Addr = User_Addr else '0';
 
  Wr_En_d                    <= Addr_Match and Open8_Bus.Wr_En and Write_Qual;
 
  Rd_En_d                    <= Addr_Match and Open8_Bus.Rd_En;
 
 
  io_reg: process( Clock, Reset )
  io_reg: process( Clock, Reset )
  begin
  begin
    if( Reset = Reset_Level )then
    if( Reset = Reset_Level )then
      Reg_Sel                <= "00";
      Reg_Sel_q              <= "00";
      Rd_En                  <= '0';
      Wr_En_q                <= '0';
      Rd_Data                <= OPEN8_NULLBUS;
 
      Wr_En                  <= '0';
 
      Wr_Data_q              <= x"00";
      Wr_Data_q              <= x"00";
 
      Rd_En_q                <= '0';
 
      Rd_Data                <= OPEN8_NULLBUS;
 
 
      User_Out               <= Default_Out;
      User_Out               <= Default_Out;
      User_En                <= Default_En;
      User_En                <= Default_En;
    elsif( rising_edge( Clock ) )then
    elsif( rising_edge( Clock ) )then
      Reg_Sel                <= Reg_Addr;
      Reg_Sel_q              <= Reg_Sel_d;
 
 
      Wr_En                  <= Addr_Match and Open8_Bus.Wr_En;
      Wr_En_q                <= Wr_En_d;
      Wr_Data_q              <= Open8_Bus.Wr_Data;
      Wr_Data_q              <= Wr_Data_d;
      if( Wr_En = '1' )then
      if( Wr_En_q = '1' )then
        case( Reg_Sel )is
        case( Reg_Sel_q )is
          when "00" =>
          when "00" =>
            User_Out         <= Wr_Data_q;
            User_Out         <= Wr_Data_q;
          when "01" =>
          when "01" =>
            User_En          <= Wr_Data_q;
            User_En          <= Wr_Data_q;
          when others => null;
          when others => null;
        end case;
        end case;
      end if;
      end if;
 
 
      User_In                <= GPIO;
      User_In                <= GPIO;
 
 
 
      Rd_En_q                <= Rd_En_d;
      Rd_Data                <= OPEN8_NULLBUS;
      Rd_Data                <= OPEN8_NULLBUS;
      Rd_En                  <= Addr_Match and Open8_Bus.Rd_En;
      if( Rd_En_q = '1' )then
      if( Rd_En = '1' )then
        case( Reg_Sel_q )is
        Rd_Data              <= User_In;
 
        case( Reg_Sel )is
 
          when "00" =>
          when "00" =>
            Rd_Data          <= User_Out;
            Rd_Data          <= User_Out;
          when "01" =>
          when "01" =>
            Rd_Data          <= User_En;
            Rd_Data          <= User_En;
          when "10" =>
          when "10" =>

powered by: WebSVN 2.1.0

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