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

Subversion Repositories pdp8

[/] [pdp8/] [trunk/] [nexys2/] [nexys2_testbench.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
--!      NEXYS2 Wrapper: Test Bench
7
--!
8
--! \details
9
--!      Test Bench.
10
--!
11
--! \file
12
--!      nexys2_testbench.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.std_logic_textio.all;                                  --! IEEE Std Logic TextIO
50
use std.textio.all;                                             --! TEXTIO
51
use work.uart_types.all;                                        --! UART Types
52
use work.dk8e_types.all;                                        --! DK8E Types
53
use work.kc8e_types.all;                                        --! KC8E Types
54
use work.cpu_types.all;                                         --! CPU Types
55
use work.nexys2_types.all;                                      --! Nexys2 Types
56
 
57
--
58
--! NEXYS2 Test Bench Entity
59
--
60
 
61
entity NEXYS2_TESTBENCH is
62
end NEXYS2_TESTBENCH;
63
 
64
--
65
--! NEXYS2 Test Bench Behav
66
--
67
 
68
architecture behav of NEXYS2_TESTBENCH is
69
 
70
    --
71
    -- PDP8 Pins
72
    --
73
 
74
    signal clk            : std_logic           := '0';
75
    signal rst            : std_logic           := '0';
76
    signal sw             : sw_t                := ('0', '0', '0', '0', '0', '0', '0', '0');
77
    signal led            : led_t;
78
    -- TTY1 Interfaces
79
    signal tty1RXD        : std_logic           := '1';
80
    signal tty1TXD        : std_logic           := '1';
81
    -- TTY2 Interfaces
82
    signal tty2RXD        : std_logic           := '1';
83
    signal tty2TXD        : std_logic           := '1';
84
    -- LPR Interfaces
85
    signal lprDTR         : std_logic           := '1';
86
    signal lprDSR         : std_logic           := '1';
87
    signal lprRXD         : std_logic           := '1';
88
    signal lprTXD         : std_logic           := '1';
89
    -- PTR Interfaces
90
    signal ptrRXD         : std_logic           := '1';
91
    signal ptrTXD         : std_logic           := '1';
92
    -- SD Interface
93
    signal sdCD           : std_logic           := '0';         --! SD Card Detect
94
    signal sdWP           : std_logic           := '0';         --! SD Write Protect
95
    signal sdMISO         : std_logic;                          --! SD Data In
96
    signal sdMOSI         : std_logic;                          --! SD Data Out
97
    signal sdSCLK         : std_logic;                          --! SD Clock
98
    signal sdCS           : std_logic;                          --! SD Chip Select
99
    -- IO Interface
100
    signal ioDATA         : iodata_t;
101
    signal inOEA_L        : std_logic;
102
    signal inOEB_L        : std_logic;
103
    signal outLEA         : std_logic;
104
    signal outLEB         : std_logic;
105
    --
106
    signal inDATAa        : iodata_t;
107
    signal inDATAb        : iodata_t;
108
    signal outDATA        : iodata_t;
109
    signal swCNTL         : swCNTL_t;
110
    signal swDATA         : data_t;
111
    signal ledRUN         : std_logic;
112
    signal ledADDR        : xaddr_t;
113
    signal ledDATA        : data_t;
114
    signal dispSeg_L      : dispSeg_t;
115
    signal dispDig_L      : dispDig_t;
116
    signal ttyBR          : uartBR_t;
117
    signal swCPU          : swCPU_t;
118
    signal swOPT          : swOPT_t;
119
    signal swROT          : swROT_t;
120
    signal swRTC          : swRTC_t;
121
 
122
    --
123
    -- UART
124
    --
125
 
126
    constant bitTIME      : time := 8680.5 ns;
127
    --constant bitTIME      : time := 1.0 / 115200.0;
128
 
129
begin
130
 
131
    UUT : entity work.eNEXYS2_PDP8 (rtl) port map (
132
        clk        => clk,
133
        rstIN      => rst,
134
        sw         => sw,
135
        led        => led,
136
        -- TTY1 Interfaces
137
        tty1RXD     => tty1RXD,
138
        tty1TXD     => tty1TXD,
139
        -- TTY2 Interfaces
140
        tty2RXD     => tty2RXD,
141
        tty2TXD     => tty2TXD,
142
        -- LPR Interfaces
143
        lprRXD      => lprRXD,
144
        lprTXD      => lprTXD,
145
        -- PTR Interfaces
146
        ptrRXD      => ptrRXD,
147
        ptrTXD      => ptrTXD,
148
        -- SD Interface
149
        sdCD       => sdCD,
150
        sdWP       => sdWP,
151
        sdMISO     => sdMISO,
152
        sdMOSI     => sdMOSI,
153
        sdSCLK     => sdSCLK,
154
        sdCS       => sdCS,
155
        -- IO Interface
156
        ioDATA     => ioDATA,
157
        inOEA_L    => inOEA_L,
158
        inOEB_L    => inOEB_L,
159
        outLEA     => outLEA,
160
        outLEB     => outLEB,
161
        -- Seven Segment Display
162
        dispSeg_L  => dispSeg_L,
163
        dispDig_L  => dispDig_L
164
    );
165
 
166
    --
167
    -- SD Card Simulator
168
    --
169
 
170
    iSDSIM : entity work.eSDSIM (behav) port map (
171
        clk    => clk,
172
        rst    => rst,
173
        sdCD   => sdCD,
174
        sdWP   => sdWP,
175
        sdMISO => sdMISO,
176
        sdMOSI => sdMOSI,
177
        sdSCLK => sdSCLK,
178
        sdCS   => sdCS
179
    );
180
 
181
    --
182
    -- UART Simulator
183
    --
184
 
185
    eUARTSIM : entity work.eUARTSIM  (behav) port map (
186
        rst     => rst,
187
        bitTIME => bitTIME,
188
        TXD     => tty1RXD
189
    );
190
 
191
    --
192
    -- Reset Signal
193
    --
194
 
195
    rst <= '1', '0' after 80 ns;
196
 
197
    --
198
    --! Clock Generator
199
    --
200
 
201
    CLKGEN : process
202
    begin
203
        wait for 10 ns;
204
        clk <= not(clk);
205
    end process CLKGEN;
206
 
207
    --
208
    -- Switches
209
    --
210
 
211
    ttyBR            <= uartBR115200;
212
    swCPU            <= swPDP8A;
213
    swOPT.KE8        <= '1';
214
    swOPT.KM8E       <= '1';
215
    swOPT.TSD        <= '0';
216
    swOPT.SP0        <= '0';
217
    swOPT.SP1        <= '0';
218
    swOPT.SP2        <= '0';
219
    swOPT.SP3        <= '0';
220
    swOPT.STARTUP    <= '1';
221
    swROT            <= dispAC;
222
    swRTC            <= clkDK8EA1;
223
 
224
    swCNTL.boot      <= '0';
225
    swCNTL.lock      <= '0';
226
    swCNTL.loadADDR  <= '0';
227
    swCNTL.loadEXTD  <= '0';
228
    swCNTL.clear     <= '0';
229
    swCNTL.cont      <= '0';   -- not(ledRUN) after 200 nS;
230
    swCNTL.exam      <= '0';
231
    swCNTL.halt      <= '0';
232
    swCNTL.step      <= '0';
233
    swDATA           <= o"0000";
234
    swCNTL.dep       <= '0';
235
 
236
 
237
    --
238
    -- Input Mux
239
    --
240
 
241
    inDATAa <= ttyBR(0)     & ttyBR(1)     & ttyBR(2)          & ttyBR(3)              & swCPU(0)              & swCPU(1)          &
242
               swCPU(2)     & swCPU(3)     & swOPT.KE8         & swOPT.KM8E            & swOPT.TSD             & swOPT.SP0         &
243
               swOPT.SP1    & swOPT.SP2    & swOPT.SP3         & swOPT.STARTUP         & swRTC(0)              & swRTC(1)          &
244
               swRTC(2)     & '0'          & '0'               & '0'                   & '0'                   & swCNTL.lock;
245
 
246
    inDATAb <= swROT(0)     & swROT(1)     & swROT(2)          & SWCNTL.dep            & swCNTL.step           & swCNTL.halt       &
247
               swCNTL.exam  & swCNTL.cont  & not(swCNTL.clear) & swDATA(11)            & swDATA(10)            & swDATA(9)         &
248
               swDATA(8)    & swDATA(7)    & swDATA(6)         & swDATA(5)             & swDATA(4)             & swDATA(3)         &
249
               swDATA(2)    & swDATA(1)    & swDATA(0)         & not(swCNTL.loadEXTD)  & not(swCNTL.loadADDR)  & not(swCNTL.boot);
250
 
251
    outDATA <= ioDATA;
252
 
253
    ioDATA  <= not(inDATAa) when inOEA_L = '0' else
254
               not(inDATAb) when inOEB_L = '0' else
255
               (others => 'Z');
256
 
257
    --
258
    --! Output IO Latches
259
    --
260
 
261
    IOSIM : process(clk, rst)
262
    begin
263
        if rst = '1' then
264
            ledRUN  <= '0';
265
            ledADDR <= (others => '0');
266
            ledDATA <= (others => '0');
267
        elsif rising_edge(clk) then
268
            if outLEA = '1' then
269
                ledDATA(11) <= outDATA( 0);
270
                ledDATA(10) <= outDATA( 1);
271
                ledDATA( 9) <= outDATA( 2);
272
                ledDATA( 8) <= outDATA( 3);
273
                ledDATA( 7) <= outDATA( 4);
274
                ledDATA( 6) <= outDATA( 5);
275
                ledDATA( 5) <= outDATA( 6);
276
                ledDATA( 4) <= outDATA( 7);
277
                ledDATA( 3) <= outDATA( 8);
278
                ledDATA( 2) <= outDATA( 9);
279
                ledDATA( 1) <= outDATA(10);
280
                ledDATA( 0) <= outDATA(11);
281
            elsif outLEB = '1' then
282
                ledRUN      <= outDATA( 0);
283
                ledADDR(14) <= outDATA( 1);
284
                ledADDR(13) <= outDATA( 2);
285
                ledADDR(12) <= outDATA( 3);
286
                ledADDR(11) <= outDATA( 4);
287
                ledADDR(10) <= outDATA( 5);
288
                ledADDR( 9) <= outDATA( 6);
289
                ledADDR( 8) <= outDATA( 7);
290
                ledADDR( 7) <= outDATA( 8);
291
                ledADDR( 6) <= outDATA( 9);
292
                ledADDR( 5) <= outDATA(10);
293
                ledADDR( 4) <= outDATA(11);
294
                ledADDR( 3) <= outDATA(12);
295
                ledADDR( 2) <= outDATA(13);
296
                ledADDR( 1) <= outDATA(14);
297
                ledADDR( 0) <= outDATA(15);
298
            end if;
299
            if outLEA = '1' and outLEB = '1' then
300
                assert false report "Both outLEA and outLEB asserted at the same time" severity failure;
301
            end if;
302
            if inOEA_L = '0' and inOEB_L = '0' then
303
                assert false report "Both inOEA_L and inOEB_L asserted at the same time" severity failure;
304
            end if;
305
        end if;
306
    end process IOSIM;
307
 
308
end behav;

powered by: WebSVN 2.1.0

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