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 186

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

Line No. Rev Author Line
1 167 jshamlet
-- Copyright (c)2013 Jeremy Seth Henry
2
-- 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
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
--
24
-- VHDL Units :  o8_gpout
25
-- Description:  Provides a single 8-bit GP output register with selectable
26
--            :   tri-state control.
27
-- Notes      :  Requires 1 bit from the address bus (two locations).
28
--            :  Sequential instantiations should be separated by 2.
29
 
30
library ieee;
31
use ieee.std_logic_1164.all;
32
 
33
library work;
34
  use work.open8_pkg.all;
35
 
36
entity o8_gpout is
37
generic(
38
  Default_Out           : DATA_TYPE := x"00";
39
  Default_En            : DATA_TYPE := x"00";
40
  Disable_Tristate      : boolean   := false;
41
  Reset_Level           : std_logic;
42
  Address               : ADDRESS_TYPE
43
);
44
port(
45
  Clock                 : in  std_logic;
46
  Reset                 : in  std_logic;
47
  --
48
  Bus_Address           : in  ADDRESS_TYPE;
49
  Wr_Enable             : in  std_logic;
50
  Wr_Data               : in  DATA_TYPE;
51
  Rd_Enable             : in  std_logic;
52
  Rd_Data               : out DATA_TYPE;
53
  --
54
  GPO                   : out DATA_TYPE
55
);
56
end entity;
57
 
58
architecture behave of o8_gpout is
59
 
60
  constant User_Addr    : std_logic_vector(15 downto 1)
61
                          := Address(15 downto 1);
62
  alias  Comp_Addr      is Bus_Address(15 downto 1);
63
  alias  Reg_Addr       is Bus_Address(0);
64
  signal Reg_Sel        : std_logic;
65
  signal Addr_Match     : std_logic;
66
  signal Wr_En          : std_logic;
67
  signal Wr_Data_q      : DATA_TYPE;
68
  signal Rd_En          : std_logic;
69
 
70
  signal User_Out       : DATA_TYPE;
71
  signal User_En        : DATA_TYPE;
72
 
73
begin
74
 
75
  Addr_Match            <= '1' when Comp_Addr = User_Addr else '0';
76
 
77
  io_reg: process( Clock, Reset )
78
  begin
79
    if( Reset = Reset_Level )then
80
      Reg_Sel           <= '0';
81
      Wr_En             <= '0';
82
      Wr_Data_q         <= x"00";
83
      Rd_En             <= '0';
84
      Rd_Data           <= x"00";
85
      User_Out          <= Default_Out;
86
      if( not Disable_Tristate)then
87
        User_En         <= Default_En;
88
      end if;
89
    elsif( rising_edge( Clock ) )then
90
      Reg_Sel           <= Reg_Addr;
91
      Wr_En             <= Addr_Match and Wr_Enable;
92
      Wr_Data_q         <= Wr_Data;
93
      if( Wr_En = '1' )then
94
        if( Disable_Tristate )then
95
          User_Out      <= Wr_Data_q;
96
        else
97
          if( Reg_Sel = '0' )then
98
            User_Out    <= Wr_Data_q;
99
          else
100
            User_En     <= Wr_Data_q;
101
          end if;
102
        end if;
103
      end if;
104
 
105 172 jshamlet
      Rd_Data           <= (others => '0');
106 167 jshamlet
      Rd_En             <= Addr_Match and Rd_Enable;
107
      if( Rd_En = '1' )then
108
        Rd_Data         <= User_Out;
109
        if( (Reg_Sel = '1') and (not Disable_Tristate) )then
110
          Rd_Data       <= User_En;
111
        end if;
112
      end if;
113
    end if;
114
  end process;
115
 
116
No_Tristates: if( Disable_Tristate )generate
117
  GPO                   <= User_Out;
118
end generate;
119
 
120
Tristates: if( not Disable_Tristate )generate
121
 
122
  Output_Ctl_proc: process( User_Out, User_En )
123
  begin
124
    for i in 0 to 7 loop
125
      GPO(i)            <= 'Z';
126
      if( User_En(i) = '1' )then
127
        GPO(i)          <= User_Out(i);
128
      end if;
129
    end loop;
130
  end process;
131
 
132
end generate;
133
 
134
end architecture;

powered by: WebSVN 2.1.0

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