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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [VHDL/] [o8_gpout.vhd] - Blame information for rev 327

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 213 jshamlet
-- Copyright (c)2011, 20219, 2020 Jeremy Seth Henry
2 167 jshamlet
-- All rights reserved.
3
--
4
-- Redistribution and use in source and binary forms, with or without
5
-- modification, are permitted provided that the following conditions are met:
6
--     * Redistributions of source code must retain the above copyright
7
--       notice, this list of conditions and the following disclaimer.
8
--     * Redistributions in binary form must reproduce the above copyright
9
--       notice, this list of conditions and the following disclaimer in the
10
--       documentation and/or other materials provided with the distribution,
11
--       where applicable (as part of a user interface, debugging port, etc.)
12
--
13
-- THIS SOFTWARE IS PROVIDED BY JEREMY SETH HENRY ``AS IS'' AND ANY
14
-- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15
-- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16
-- DISCLAIMED. IN NO EVENT SHALL JEREMY SETH HENRY BE LIABLE FOR ANY
17
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
20
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 194 jshamlet
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
22
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 167 jshamlet
--
24
-- VHDL Units :  o8_gpout
25
-- Description:  Provides a single 8-bit GP output register with selectable
26
--            :   tri-state control.
27 213 jshamlet
--
28
-- Register Map:
29
-- Offset  Bitfield Description                        Read/Write
30
--   0x00  AAAAAAAA Output Register                       (RW)
31
--   0x01  AAAAAAAA Enable/Tri-State Register             (RW)
32
--
33
-- Note that setting a bit to '1' will enable the pin for output, while
34
--  setting it to a '0' will tri-state the pin.
35
--
36
-- Revision History
37
-- Author          Date     Change
38
------------------ -------- ---------------------------------------------------
39
-- Seth Henry      07/28/11 Design Start
40
-- Seth Henry      12/19/19 Renamed to "o8_gpout" to fit "theme"
41
-- Seth Henry      04/10/20 Code Cleanup and comments
42 224 jshamlet
-- Seth Henry      04/16/20 Modified to make use of Open8 bus record
43 244 jshamlet
-- Seth Henry      05/18/20 Added write qualification input
44 167 jshamlet
 
45
library ieee;
46
use ieee.std_logic_1164.all;
47
 
48
library work;
49
  use work.open8_pkg.all;
50
 
51
entity o8_gpout is
52
generic(
53 224 jshamlet
  Default_Out                : DATA_TYPE := x"00";
54
  Default_En                 : DATA_TYPE := x"00";
55
  Disable_Tristate           : boolean   := false;
56
  Address                    : ADDRESS_TYPE
57 167 jshamlet
);
58
port(
59 224 jshamlet
  Open8_Bus                  : in  OPEN8_BUS_TYPE;
60 244 jshamlet
  Write_Qual                 : in  std_logic := '1';
61 224 jshamlet
  Rd_Data                    : out DATA_TYPE;
62 167 jshamlet
  --
63 224 jshamlet
  GPO                        : out DATA_TYPE
64 167 jshamlet
);
65
end entity;
66
 
67
architecture behave of o8_gpout is
68
 
69 224 jshamlet
  alias Clock                is Open8_Bus.Clock;
70
  alias Reset                is Open8_Bus.Reset;
71 167 jshamlet
 
72 224 jshamlet
  constant User_Addr         : std_logic_vector(15 downto 1)
73
                               := Address(15 downto 1);
74
  alias  Comp_Addr           is Open8_Bus.Address(15 downto 1);
75
  signal Addr_Match          : std_logic := '0';
76 244 jshamlet
  alias  Reg_Sel_d           is Open8_Bus.Address(0);
77
  signal Reg_Sel_q           : std_logic := '0';
78
  signal Wr_En_d             : std_logic := '0';
79
  signal Wr_En_q             : std_logic := '0';
80
  alias  Wr_Data_d           is Open8_Bus.Wr_Data;
81 224 jshamlet
  signal Wr_Data_q           : DATA_TYPE := x"00";
82 244 jshamlet
  signal Rd_En_d             : std_logic := '0';
83
  signal Rd_En_q             : std_logic := '0';
84 167 jshamlet
 
85 224 jshamlet
  signal User_Out            : DATA_TYPE := x"00";
86
  signal User_En             : DATA_TYPE := x"00";
87
 
88 167 jshamlet
begin
89
 
90 224 jshamlet
  Addr_Match                 <= '1' when Comp_Addr = User_Addr else '0';
91 167 jshamlet
 
92
  io_reg: process( Clock, Reset )
93
  begin
94
    if( Reset = Reset_Level )then
95 244 jshamlet
      Reg_Sel_q              <= '0';
96
      Wr_En_q                <= '0';
97 224 jshamlet
      Wr_Data_q              <= x"00";
98 244 jshamlet
      Rd_En_q                <= '0';
99 224 jshamlet
      Rd_Data                <= OPEN8_NULLBUS;
100
      User_Out               <= Default_Out;
101 167 jshamlet
      if( not Disable_Tristate)then
102 224 jshamlet
        User_En              <= Default_En;
103 167 jshamlet
      end if;
104
    elsif( rising_edge( Clock ) )then
105 244 jshamlet
      Reg_Sel_q              <= Reg_Sel_d;
106
 
107
      Wr_En_q                <= Wr_En_d;
108
      Wr_Data_q              <= Wr_Data_d;
109
      if( Wr_En_q = '1' )then
110 167 jshamlet
        if( Disable_Tristate )then
111 224 jshamlet
          User_Out           <= Wr_Data_q;
112 167 jshamlet
        else
113 244 jshamlet
          if( Reg_Sel_q = '0' )then
114 224 jshamlet
            User_Out         <= Wr_Data_q;
115 167 jshamlet
          else
116 224 jshamlet
            User_En          <= Wr_Data_q;
117 167 jshamlet
          end if;
118
        end if;
119
      end if;
120
 
121 244 jshamlet
      Rd_En_q                <= Rd_En_d;
122 224 jshamlet
      Rd_Data                <= OPEN8_NULLBUS;
123 244 jshamlet
      if( Rd_En_q = '1' )then
124 224 jshamlet
        Rd_Data              <= User_Out;
125 244 jshamlet
        if( (Reg_Sel_q = '1') and (not Disable_Tristate) )then
126 224 jshamlet
          Rd_Data            <= User_En;
127 167 jshamlet
        end if;
128
      end if;
129
    end if;
130
  end process;
131
 
132
No_Tristates: if( Disable_Tristate )generate
133 224 jshamlet
  GPO                        <= User_Out;
134 167 jshamlet
end generate;
135
 
136
Tristates: if( not Disable_Tristate )generate
137
 
138
  Output_Ctl_proc: process( User_Out, User_En )
139
  begin
140
    for i in 0 to 7 loop
141 224 jshamlet
      GPO(i)                 <= 'Z';
142 167 jshamlet
      if( User_En(i) = '1' )then
143 224 jshamlet
        GPO(i)               <= User_Out(i);
144 167 jshamlet
      end if;
145
    end loop;
146
  end process;
147
 
148
end generate;
149
 
150
end architecture;

powered by: WebSVN 2.1.0

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