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

Subversion Repositories plasma

[/] [plasma/] [trunk/] [vhdl/] [uart.vhd] - Blame information for rev 47

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

Line No. Rev Author Line
1 47 rhoads
---------------------------------------------------------------------
2
-- TITLE: UART
3
-- AUTHOR: Steve Rhoads (rhoadss@yahoo.com)
4
-- DATE CREATED: 5/29/02
5
-- FILENAME: uart.vhd
6
-- PROJECT: Plasma CPU core
7
-- COPYRIGHT: Software placed into the public domain by the author.
8
--    Software 'as is' without warranty.  Author liable for nothing.
9
-- DESCRIPTION:
10
--    Implements the UART.
11
---------------------------------------------------------------------
12
library ieee;
13
use ieee.std_logic_1164.all;
14
use ieee.std_logic_misc.all;
15
use ieee.std_logic_arith.all;
16
use ieee.std_logic_textio.all;
17
use std.textio.all;
18
 
19
use ieee.std_logic_unsigned.all;
20
use work.mlite_pack.all;
21
 
22
entity uart is
23
   generic(save_file_name : string);
24
   port(clk       : in std_logic;
25
        reset     : in std_logic;
26
        uart_sel  : in std_logic;
27
        data      : in std_logic_vector(7 downto 0);
28
        read_pin  : in std_logic;
29
        write_pin : out std_logic;
30
        pause     : out std_logic);
31
end; --entity ram
32
 
33
architecture logic of uart is
34
   signal uart_data_reg : std_logic_vector(8 downto 0);
35
   signal uart_bits_reg : std_logic_vector(3 downto 0);
36
   signal uart_div_reg  : std_logic_vector(7 downto 0);
37
 
38
begin
39
uart_proc: process(clk, reset, uart_sel, data,
40
      uart_data_reg, uart_bits_reg, uart_div_reg)
41
   file store_file : text is out save_file_name;
42
   variable hex_file_line : line;
43
   variable c : character;
44
   variable index : natural;
45
   variable line_length : natural := 0;
46
   variable uart_data_next : std_logic_vector(8 downto 0);
47
   variable uart_bits_next : std_logic_vector(3 downto 0);
48
   variable uart_div_next  : std_logic_vector(7 downto 0);
49
begin
50
   uart_data_next := uart_data_reg;
51
   uart_bits_next := uart_bits_reg;
52
   uart_div_next  := uart_div_reg;
53
 
54
   if uart_bits_reg = "0000" and uart_sel = '1' then
55
      uart_data_next := '1' & data;
56
      uart_bits_next := "1001";
57
      uart_div_next := ZERO(7 downto 0);
58
--"10001100"
59
   elsif uart_bits_reg /= "0000" and uart_div_reg = "00000100" then
60
      uart_data_next := uart_data_reg(7 downto 0) & '0';
61
      uart_bits_next := uart_bits_reg - 1;
62
      uart_div_next := ZERO(7 downto 0);
63
   else
64
      uart_div_next := uart_div_reg + 1;
65
   end if;
66
 
67
   if reset = '1' then
68
      uart_data_next := ZERO(8 downto 0);
69
      uart_bits_next := "0000";
70
      uart_div_next := ZERO(7 downto 0);
71
   end if;
72
 
73
   if rising_edge(clk) then
74
      if uart_sel = '1' then
75
         -- Debug log file
76
         index := conv_integer(data(6 downto 0));
77
         if index /= 10 then
78
            c := character'val(index);
79
            write(hex_file_line, c);
80
            line_length := line_length + 1;
81
         end if;
82
         if index = 10 or line_length >= 72 then
83
            writeline(store_file, hex_file_line);
84
            line_length := 0;
85
         end if;
86
      end if;
87
 
88
      uart_data_reg <= uart_data_next;
89
      uart_bits_reg <= uart_bits_next;
90
      uart_div_reg <= uart_div_next;
91
   end if;
92
 
93
   write_pin <= uart_data_reg(8);
94
   if uart_bits_reg = ZERO(7 downto 0) or uart_sel = '1' then
95
--      pause <= '0';
96
   else
97
--      pause <= '1';
98
   end if;
99
   pause <= '0';
100
end process;
101
 
102
end; --architecture logic
103
 
104
 

powered by: WebSVN 2.1.0

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