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

Subversion Repositories pdp8

[/] [pdp8/] [trunk/] [pdp8/] [kl8e/] [kl8e_rx.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
--!      KL8E UART Receiver
7
--!
8
--! \details
9
--!      This device handles KL8E Receive operations.
10
--!
11
--!      The UART Receiver is hard configured for:
12
--!      - 8 data bits
13
--!      - no parity
14
--!      - 1 stop bit
15
--!
16
--! \note
17
--!      The TTY data is transmitted with 7 bits of data and mark
18
--!      parity where the the parity is generated in the software
19
--!      and is sent as the MSB of data.
20
--!
21
--!      From the point-of-view of the UART this is just 8-bit
22
--!      data with no parity.
23
--!
24
--!      From the point-of-view of your terminal emulator, the
25
--!      data is 7 bits with mark parity (or 7 bits of data with
26
--!      two stop bits). 
27
--!
28
--!      This seemingly odd behaviour is is traceable to the
29
--!      operation of the old teletypes which were mark parity.
30
--!
31
--! \file
32
--!      kl8e_rx.vhd
33
--!
34
--! \author
35
--!      Rob Doyle - doyle (at) cox (dot) net
36
--!
37
--------------------------------------------------------------------
38
--
39
--  Copyright (C) 2009, 2010, 2011, 2012 Rob Doyle
40
--
41
-- This source file may be used and distributed without
42
-- restriction provided that this copyright statement is not
43
-- removed from the file and that any derivative work contains
44
-- the original copyright notice and the associated disclaimer.
45
--
46
-- This source file is free software; you can redistribute it
47
-- and/or modify it under the terms of the GNU Lesser General
48
-- Public License as published by the Free Software Foundation;
49
-- version 2.1 of the License.
50
--
51
-- This source is distributed in the hope that it will be
52
-- useful, but WITHOUT ANY WARRANTY; without even the implied
53
-- warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
54
-- PURPOSE. See the GNU Lesser General Public License for more
55
-- details.
56
--
57
-- You should have received a copy of the GNU Lesser General
58
-- Public License along with this source; if not, download it
59
-- from http://www.gnu.org/licenses/lgpl.txt
60
--
61
--------------------------------------------------------------------
62
--
63
-- Comments are formatted for doxygen
64
--
65
 
66
library ieee;                                   --! IEEE Library
67
use ieee.std_logic_1164.all;                    --! IEEE 1164
68
use work.uart_types.all;                        --! UART Types
69
use work.kl8e_types.all;                        --! KL8E Types
70
use work.cpu_types.all;                         --! CPU Types
71
 
72
--
73
--! KL8E UART Receiver Entity
74
--
75
 
76
entity eKL8E_RX is port (
77
    sys    : in  sys_t;                         --! Clock/Reset
78
    intEN  : out std_logic;                     --! Interrupt Enable
79
    clkBR  : in  std_logic;                     --! Clock Enable (for Baud Rate)
80
    devNUM : in  devNUM_t;                      --! IOT Device
81
    cpu    : in  cpu_t;                         --! CPU Input
82
    dev    : out dev_t;                         --! Device Output
83
    rxd    : in  std_logic                      --! Serial Data In
84
);
85
end eKL8E_RX;
86
 
87
--
88
--! KL8E UART Receiver RTL
89
--
90
 
91
architecture rtl of eKL8E_RX is
92
    signal kirCLR : std_logic;                  --! KBD Interrupt Request Clear
93
    signal kirREG : std_logic;                  --! KBD Interrupt Request
94
    signal kieMUX : std_logic;                  --! KBD Interrupt Enable MUX
95
    signal kieREG : std_logic;                  --! KBD Interrupt Enable REG
96
    signal datREG : ascii_t;                    --! KBD Received Data
97
    signal intr   : std_logic;                  --! UART Interrupt
98
    signal data   : ascii_t;                    --! UART Data
99
 
100
begin
101
 
102
    --
103
    --! Bus Interface
104
    --
105
 
106
    KL8E_BUSINTF : process(cpu.buss, kirREG, datREG, kieREG, devNUM)
107
    begin
108
 
109
        kirCLR  <= '0';
110
        kieMUX  <= kieREG;
111
        dev     <= nulldev;
112
 
113
        if cpu.buss.addr(0 to 2) = opIOT and cpu.buss.addr(3 to 8) = devNUM and cpu.buss.lxdar = '1' then
114
 
115
            case cpu.buss.addr(9 to 11) is
116
 
117
                --
118
                -- IOT 6xx0: KCF - Clear Keyboard Flag
119
                --
120
 
121
                when opKCF =>
122
                    dev.ack  <= '1';
123
                    dev.devc <= devWR;
124
                    dev.skip <= '0';
125
                    kirCLR   <= '1';
126
 
127
                --
128
                -- IOT 6xx1: KSF - Skip on Keyboard Flag
129
                --
130
 
131
                when opKSF =>
132
                    dev.ack  <= '1';
133
                    dev.devc <= devWR;
134
                    dev.skip <= kirREG;
135
                    kirCLR   <= '0';
136
 
137
                --
138
                -- IOT 6xx2: KCC - Clear Keyboard Flag, Clear AC
139
                --
140
 
141
                when opKCC =>
142
                    dev.ack  <= '1';
143
                    dev.devc <= devWRCLR;
144
                    dev.skip <= '0';
145
                    kirCLR   <= '1';
146
 
147
                --
148
                -- IOT 6xx4: KRS - Read Keyboard Buffer Status
149
                --
150
 
151
                when opKRS =>
152
                    dev.ack  <= '1';
153
                    dev.devc <= devRD;
154
                    dev.skip <= '0';
155
                    kirCLR   <= '0';
156
 
157
                --
158
                -- IOT 6xx5: KIE - Set/Clear Interrupt Enable
159
                --
160
 
161
                when opKIE =>
162
                    dev.ack  <= '1';
163
                    dev.devc <= devWR;
164
                    dev.skip <= '0';
165
                    kirCLR   <= '0';
166
                    kieMUX   <= cpu.buss.data(11);
167
 
168
                --
169
                -- IOT 6xx6: KRB - Read Keyboard Buffer Dynamic
170
                -- Clear Keyboard Flag, Clear AC, OR Keyboard Character into
171
                -- AC. This is a microprogrammed combination of KCC (6xx2) and
172
                -- KRS (6xx4).
173
                --
174
 
175
                when opKRB =>
176
                    dev.ack  <= '1';
177
                    dev.devc <= devRDCLR;
178
                    dev.skip <= '0';
179
                    kirCLR   <= '1';
180
 
181
                --
182
                -- IOT 6xx3 and 6xx7:
183
                --
184
 
185
                when others =>
186
                    null;
187
 
188
            end case;
189
        end if;
190
 
191
        dev.intr <= kirREG and kieREG;
192
        dev.data <= "0000" & datREG(0 to 7);
193
 
194
    end process KL8E_BUSINTF;
195
 
196
    --
197
    --! UART Receiver
198
    --
199
 
200
    iUART_RX : entity work.eUART_RX port map (
201
        sys   => sys,
202
        clkBR => clkBR,
203
        rxd   => rxd,
204
        intr  => intr,
205
        data  => data
206
    );
207
 
208
    --
209
    --! Keyboard Interrupt Enable Flip-Flop
210
    --!
211
    --! The CAF instruction (IOCLR) should enable interupts
212
    --!
213
 
214
    KL8E_KIE : process(sys)
215
    begin
216
        if sys.rst = '1' then
217
            kieREG <= '1';
218
        elsif rising_edge(sys.clk) then
219
            if cpu.buss.ioclr = '1' then
220
                kieREG <= '1';
221
            else
222
                kieREG <= kieMUX;
223
            end if;
224
        end if;
225
    end process KL8E_KIE;
226
 
227
    --
228
    --! Keyboard Interrupt Request Flip-Flop
229
    --!
230
    --! The CAF instruction (IOCLR) should clear the receive
231
    --! interupt flag.
232
 
233
    KL8E_KIR : process(sys)
234
    begin
235
        if sys.rst = '1' then
236
            kirREG <= '0';
237
        elsif rising_edge(sys.clk) then
238
            if cpu.buss.ioclr = '1' or kirCLR = '1' then
239
                kirREG <= '0';
240
            elsif intr = '1' then
241
                kirREG <= '1';
242
            end if;
243
        end if;
244
    end process KL8E_KIR;
245
 
246
    --
247
    --! UART Data Buffer
248
    --
249
 
250
    KL8E_BUF : process(sys)
251
    begin
252
        if sys.rst = '1' then
253
            datREG <= (others => '0');
254
        elsif rising_edge(sys.clk) then
255
            if intr = '1' then
256
                datREG <= data;
257
            end if;
258
        end if;
259
    end process KL8E_BUF;
260
 
261
    intEN <= kieREG;
262
 
263
end rtl;

powered by: WebSVN 2.1.0

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