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

Subversion Repositories pdp1

[/] [pdp1/] [trunk/] [rtl/] [vhdl/] [testtop.vhd] - Blame information for rev 10

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

Line No. Rev Author Line
1 3 yannv
--------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer:
4
--
5
-- Create Date:   00:00:04 08/14/2009
6
-- Design Name:   
7
-- Module Name:   /home/yann/fpga/work/pdp1-3/testtop.vhd
8
-- Project Name:  pdp1-3
9
-- Target Device:  
10
-- Tool versions:  
11
-- Description:   
12
-- 
13
-- VHDL Test Bench Created by ISE for module: top
14
-- 
15
-- Dependencies:
16
-- 
17
-- Revision:
18
-- Revision 0.01 - File Created
19
-- Additional Comments:
20
--
21
-- Notes: 
22
-- This testbench has been automatically generated using types std_logic and
23
-- std_logic_vector for the ports of the unit under test.  Xilinx recommends
24
-- that these types always be used for the top-level I/O of a design in order
25
-- to guarantee that the testbench will bind correctly to the post-implementation 
26
-- simulation model.
27
--------------------------------------------------------------------------------
28
LIBRARY ieee;
29
USE ieee.std_logic_1164.ALL;
30
USE ieee.numeric_std.ALL;
31 10 yannv
 
32
--USE ieee.textio.ALL;
33 3 yannv
 
34
ENTITY testtop IS
35
END testtop;
36
 
37
ARCHITECTURE behavior OF testtop IS
38
 
39
    -- Component Declaration for the Unit Under Test (UUT)
40
 
41
    COMPONENT top
42
    PORT(
43
         CLK_50M : IN  std_logic;
44 10 yannv
         CLK_AUX : IN  std_logic;
45 3 yannv
         LED : OUT  std_logic_vector(7 downto 0);
46
         SW : IN  std_logic_vector(3 downto 0);
47
         AWAKE : OUT  std_logic;
48
         SPI_MOSI : OUT  std_logic;
49
         DAC_CS : OUT  std_logic;
50
         SPI_SCK : OUT  std_logic;
51
         DAC_CLR : OUT  std_logic;
52
         DAC_OUT : IN  std_logic;
53
                        RS232_DCE_RXD : IN std_logic;
54
                        RS232_DCE_TXD : OUT std_logic
55
        );
56
    END COMPONENT;
57
 
58
 
59
   --Inputs
60
   signal CLK_50M : std_logic := '0';
61 10 yannv
   signal CLK_AUX : std_logic := '0';
62 3 yannv
   signal SW : std_logic_vector(3 downto 0) := (others => '0');
63
   signal DAC_OUT : std_logic := '0';
64
 
65
        --Outputs
66
   signal LED : std_logic_vector(7 downto 0);
67
   signal AWAKE : std_logic;
68
   signal SPI_MOSI : std_logic;
69
   signal DAC_CS : std_logic;
70
   signal SPI_SCK : std_logic;
71
   signal DAC_CLR : std_logic;
72
        signal TXD, RXD : std_logic;
73 10 yannv
 
74
        -- UART interface
75
        COMPONENT Minimal_UART_CORE
76
        PORT(
77
                CLOCK : IN std_logic;
78
                RXD : IN std_logic;
79
                INP : IN std_logic_vector(7 downto 0);
80
                WR : IN std_logic;
81
                OUTP : INOUT std_logic_vector(7 downto 0);
82
                EOC : OUT std_logic;
83
                TXD : OUT std_logic;
84
                EOT : OUT std_logic;
85
                READY : OUT std_logic
86
                );
87
        END COMPONENT;
88
        signal received_byte, old_received_byte, tx_ready, wrote, byte_request,
89
                eot : std_logic := '0';
90
        signal read_byte, write_byte: std_logic_vector(7 downto 0);
91
 
92
 
93 3 yannv
   constant CLK_50M_period : time := 20ns;
94 10 yannv
   constant CLK_AUX_period : time := 7.5ns;
95
 
96 3 yannv
        constant bittime : time := 8.680555us; --1s/115200;
97 10 yannv
        constant waittime : time := 20*bittime;
98
 
99
   procedure send_byte (bytetosend : in std_logic_vector(7 downto 0);
100
                                                                signal tx_ready : in std_logic;
101
                                                                signal eot : in std_logic;
102
                                                                signal write_byte : out std_logic_vector(7 downto 0);
103
                                                                signal wrote : out std_logic)
104
        is
105
      -- subprogram_declarative_items (constant declarations, variable declarations, etc.)
106
   begin
107
--              wait for 100ns;
108
                wait until rising_edge(CLK_50M) and tx_ready = '1' and eot='0';
109
                write_byte <= bytetosend;
110
                wrote <= '1';
111
                wait until rising_edge(CLK_50M);
112
                wrote <= '0';
113
--              wait until eot='0' and tx_ready='1';
114
 
115
                -- Without UART, it was something like:
116
--              RXD <= '0'; wait for bittime;
117
--              RXD <= bytetosend(0); wait for bittime;
118
--              RXD <= bytetosend(1); wait for bittime;
119
--              RXD <= bytetosend(2); wait for bittime;
120
--              RXD <= bytetosend(3); wait for bittime;
121
--              RXD <= bytetosend(4); wait for bittime;
122
--              RXD <= bytetosend(5); wait for bittime;
123
--              RXD <= bytetosend(6); wait for bittime;
124
--              RXD <= bytetosend(7); wait for bittime;
125
--              RXD <= '1'; wait for bittime;           -- first sixbit 000101
126
--              wait for waittime;
127
   end send_byte;
128
 
129 3 yannv
 
130
BEGIN
131
 
132
        -- Instantiate the Unit Under Test (UUT)
133
   uut: top PORT MAP (
134
          CLK_50M => CLK_50M,
135 10 yannv
                         CLK_AUX => CLK_AUX,
136 3 yannv
          LED => LED,
137
          SW => SW,
138
          AWAKE => AWAKE,
139
          SPI_MOSI => SPI_MOSI,
140
          DAC_CS => DAC_CS,
141
          SPI_SCK => SPI_SCK,
142
          DAC_CLR => DAC_CLR,
143
          DAC_OUT => DAC_OUT,
144
                        RS232_DCE_RXD => RXD,
145
                        RS232_DCE_TXD => TXD
146
        );
147
 
148
   -- No clocks detected in port list. Replace CLK_50M below with 
149
   -- appropriate port name 
150
 
151
   CLK_50M_process :process
152
   begin
153
                CLK_50M <= '0';
154
                wait for CLK_50M_period/2;
155
                CLK_50M <= '1';
156
                wait for CLK_50M_period/2;
157
   end process;
158
 
159 10 yannv
   CLK_AUX_process :process
160
   begin
161
                CLK_AUX <= '0';
162
                wait for CLK_AUX_period/2;
163
                CLK_AUX <= '1';
164
                wait for CLK_AUX_period/2;
165
   end process;
166
 
167
        -- UART for talking to UUT
168
        Inst_Minimal_UART_CORE: Minimal_UART_CORE PORT MAP(
169
                CLOCK => CLK_50M,
170
 
171
                EOC => received_byte,   -- end of character; rising edge indicates valid data in OUTP
172
                OUTP => read_byte,
173
 
174
                RXD => TXD,
175
                TXD => RXD,
176 3 yannv
 
177 10 yannv
                EOT => eot,     -- end of transmit; indicates a character has been sent
178
                INP => write_byte,
179
                READY => tx_ready,      -- indicates that we may write
180
                WR => wrote
181
        );
182
 
183 3 yannv
   -- Stimulus process
184
   stim_proc: process
185
   begin
186 10 yannv
                wait for 1ms;
187
                send_byte("10000101", tx_ready, eot, write_byte, wrote);
188
                send_byte("00111111", tx_ready, eot, write_byte, wrote);  -- ignored, as bit 7 is not set
189
                send_byte("10000110", tx_ready, eot, write_byte, wrote);
190
                send_byte("10111000", tx_ready, eot, write_byte, wrote);  -- Together 050670
191 3 yannv
                -- TODO: show reply data
192
 
193
      wait for CLK_50M_period*10;
194
 
195
      -- insert stimulus here 
196
 
197
      wait;
198
   end process;
199
 
200
END;

powered by: WebSVN 2.1.0

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