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

Subversion Repositories xucpu

[/] [xucpu/] [trunk/] [src/] [io/] [tty_in.vhdl] - Blame information for rev 9

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 work.system_package.ALL;
23
 
24
ENTITY tty_in IS
25
  PORT (
26
    reset    : IN  STD_LOGIC;
27
    clock    : IN  STD_LOGIC;
28
    rd       : IN  STD_LOGIC;
29
    wr       : IN  STD_LOGIC;
30
    data_in  : IN  STD_LOGIC_VECTOR(15 DOWNTO 0);
31
    data_out : OUT STD_LOGIC_VECTOR(15 DOWNTO 0);
32
    address  : IN  STD_LOGIC_VECTOR(14 DOWNTO 0);
33
    rx       : IN  STD_LOGIC);
34
END tty_in;
35
 
36
ARCHITECTURE Behavioral OF tty_in IS
37
 
38
  SIGNAL data   : STD_LOGIC_VECTOR(7 DOWNTO 0);
39
  SIGNAL status : STD_LOGIC_VECTOR(7 DOWNTO 0);
40
 
41
  SIGNAL shifter : STD_LOGIC_VECTOR(9 DOWNTO 0);
42
  SIGNAL count   : INTEGER RANGE 0 TO 9;
43
 
44
BEGIN
45
 
46
  -- purpose: Serially read in data
47
  -- type   : sequential
48
  -- inputs : clock, reset
49
  -- outputs: 
50
  serial_input : PROCESS (clock, reset)
51
  BEGIN  -- PROCESS read
52
    IF reset = '0' THEN                 -- asynchronous reset (active low)
53
      data    <= X"00";
54
      status  <= X"00";
55
      shifter <= "0000000000";
56
      count   <= 0;
57
    ELSIF rising_edge(clock) THEN       -- rising clock edge
58
 
59
      IF count = 9 THEN
60
 
61
        data    <= shifter(8 DOWNTO 1);
62
        status  <= X"01";
63
        count   <= 0;
64
        shifter <= rx & shifter(9 DOWNTO 1);
65
 
66
      ELSE
67
 
68
        IF address = "111111100000000" AND rd = '1' THEN
69
          status <= X"00";
70
        ELSE
71
          status <= status;
72
        END IF;
73
 
74
        data    <= data;
75
        count   <= count + 1;
76
        shifter <= rx & shifter(9 DOWNTO 1);
77
      END IF;
78
    END IF;
79
  END PROCESS serial_input;
80
 
81
  data_out <= status & data;
82
 
83
END Behavioral;
84
 

powered by: WebSVN 2.1.0

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