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

Subversion Repositories pdp8

[/] [pdp8/] [trunk/] [testbench/] [uartsim.vhd] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 trurl
------------------------------------------------------------------
2
--!
3
--! PDP-8 Processor
4
--!
5
--! \brief
6
--!      UART Sim Testbench
7
--!
8
--! \details
9
--!      Test Bench.
10
--!
11
--! \file
12
--!      uartsim.vhd
13
--!
14
--! \author
15
--!      Rob Doyle - doyle (at) cox (dot) net
16
--!
17
--------------------------------------------------------------------
18
--
19
--  Copyright (C) 2012 Rob Doyle
20
--
21
-- This source file may be used and distributed without
22
-- restriction provided that this copyright statement is not
23
-- removed from the file and that any derivative work contains
24
-- the original copyright notice and the associated disclaimer.
25
--
26
-- This source file is free software; you can redistribute it
27
-- and/or modify it under the terms of the GNU Lesser General
28
-- Public License as published by the Free Software Foundation;
29
-- version 2.1 of the License.
30
--
31
-- This source is distributed in the hope that it will be
32
-- useful, but WITHOUT ANY WARRANTY; without even the implied
33
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
34
-- PURPOSE. See the GNU Lesser General Public License for more
35
-- details.
36
--
37
-- You should have received a copy of the GNU Lesser General
38
-- Public License along with this source; if not, download it
39
-- from http://www.gnu.org/licenses/lgpl.txt
40
--
41
--------------------------------------------------------------------
42
--
43
-- Comments are formatted for doxygen
44
--
45
 
46
 
47
library ieee;                                   --! IEEE Library
48
use ieee.std_logic_1164.all;                    --! IEEE 1164
49
use ieee.numeric_std.all;                     --! IEEE Numeric Standard
50
use std.textio.all;                             --! TEXTIO
51
use ieee.std_logic_textio.all;                  --! IEEE Std Logic TextIO
52
 
53
--
54
--! UARTSIM Test Entity
55
--
56
 
57
entity eUARTSIM is port (
58
    rst      : in  std_logic;                   --! Reset
59
    bitTIME  : in  time;                        --! baud rate
60
    TXD      : out std_logic                    --! TXD
61
);
62
end eUARTSIM;
63
 
64
--
65
--! UARTSIM Test Bench Behav
66
--
67
 
68
architecture behav of eUARTSIM is
69
 
70
  --constant msg  : string := "EX RKA0:ADVENT.LD";
71
    constant msg  : string := "RUN RKA0:K12MIT.SV";
72
    constant quit : string := "EXIT";
73
 
74
    --
75
    --! This procedure simulates a UART transmitter
76
    --
77
 
78
    procedure tx(constant s : in string; signal TXD : out std_logic) is
79
        variable cmd    : string(msg'left to msg'right+1);
80
        variable txDATA : std_logic_vector(0 to 7);
81
        variable val    : integer range 0 to 255;
82
 
83
    begin
84
 
85
        cmd := s & CR;
86
 
87
        for i in 1 to cmd'right loop
88
 
89
            val := character'pos(cmd(i));
90
            txDATA := std_logic_vector(to_unsigned( val, 8 ));
91
 
92
            TXD <= '0';
93
            wait for bitTIME;
94
            TXD <= txDATA(7);
95
            wait for bitTIME;
96
            TXD <= txDATA(6);
97
            wait for bitTIME;
98
            TXD <= txDATA(5);
99
            wait for bitTIME;
100
            TXD <= txDATA(4);
101
            wait for bitTIME;
102
            TXD <= txDATA(3);
103
            wait for bitTIME;
104
            TXD <= txDATA(2);
105
            wait for bitTIME;
106
            TXD <= txDATA(1);
107
            wait for bitTIME;
108
            TXD <= txDATA(0);
109
            wait for bitTIME;
110
            TXD <= '1';
111
            wait for bitTIME*5;
112
        end loop;
113
    end tx;
114
 
115
    --
116
    --! Send UART Data to PDP8
117
    --
118
 
119
begin
120
 
121
    process
122
    begin
123
        TXD <= '1';
124
        wait for 5000 us;
125
        tx(msg, TXD);
126
        wait for 37000 us;
127
        tx(quit, TXD);
128
        wait for 100000 ms;
129
    end process;
130
 
131
end behav;

powered by: WebSVN 2.1.0

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