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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [src/] [io/] [gpio_out.vhdl] - Blame information for rev 25

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

Line No. Rev Author Line
1 2 lcdsgmtr
-- Copyright 2015, Jürgen Defurne
2
--
3
-- This file is part of the Experimental Unstable CPU System.
4
--
5
-- The Experimental Unstable CPU System Is free software: you can redistribute
6
-- it and/or modify it under the terms of the GNU Lesser General Public License
7
-- as published by the Free Software Foundation, either version 3 of the
8
-- License, or (at your option) any later version.
9
--
10
-- The Experimental Unstable CPU System is distributed in the hope that it will
11
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
12
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser
13
-- General Public License for more details.
14
--
15
-- You should have received a copy of the GNU Lesser General Public License
16
-- along with Experimental Unstable CPU System. If not, see
17
-- http://www.gnu.org/licenses/lgpl.txt.
18
 
19
 
20
LIBRARY ieee;
21
USE ieee.std_logic_1164.ALL;
22
USE ieee.numeric_std.ALL;
23
 
24
ENTITY gpio_out IS
25
  GENERIC(
26
    w_data : NATURAL RANGE 1 TO 32 := 16;
27
    w_port : NATURAL RANGE 1 TO 32 := 16);
28
  PORT (rst      : IN  STD_LOGIC;
29
        clk      : IN  STD_LOGIC;
30
        ena      : IN  STD_LOGIC;
31
        we       : IN  STD_LOGIC;
32
        D        : IN  STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
33
        Q        : OUT STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0);
34
        port_out : OUT STD_LOGIC_VECTOR(w_port - 1 DOWNTO 0));
35
END ENTITY gpio_out;
36
 
37
ARCHITECTURE Behavioral OF gpio_out IS
38
 
39
  SIGNAL output : STD_LOGIC_VECTOR(w_data - 1 DOWNTO 0)
40
    := STD_LOGIC_VECTOR(to_unsigned(0, w_data));
41
 
42
BEGIN  -- ARCHITECTURE Behavioral
43
 
44
  -- purpose: Simple input GPIO
45
  -- type   : sequential
46
  -- inputs : clk, rst, ena, port_in
47
  -- outputs: D
48
  WRITE_PORT : PROCESS (clk) IS
49
  BEGIN  -- PROCESS PORT_IN
50
    IF rising_edge(clk) THEN
51
      IF rst = '1' THEN
52
        output <= STD_LOGIC_VECTOR(to_unsigned(16#7FFFFFFF#, w_data));
53
      ELSIF ena = '1' AND we = '1' THEN
54
        output <= D;
55
      END IF;
56
    END IF;
57
  END PROCESS WRITE_PORT;
58
 
59
  port_out <= output(w_port - 1 DOWNTO 0);
60
  Q        <= output;
61
 
62
END ARCHITECTURE Behavioral;

powered by: WebSVN 2.1.0

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