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

Subversion Repositories pdp1

[/] [pdp1/] [trunk/] [rtl/] [vhdl/] [top.vhd] - Blame information for rev 3

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:    21:25:57 02/09/2009 
6
-- Design Name: 
7
-- Module Name:    top - Behavioral 
8
-- Project Name: 
9
-- Target Devices: 
10
-- Tool versions: 
11
-- Description: 
12
--
13
-- Dependencies: 
14
--
15
-- Revision: 
16
-- Revision 0.01 - File Created
17
-- Additional Comments: 
18
--
19
----------------------------------------------------------------------------------
20
library IEEE;
21
use IEEE.STD_LOGIC_1164.ALL;
22
use IEEE.STD_LOGIC_ARITH.ALL;
23
use IEEE.STD_LOGIC_UNSIGNED.ALL;
24
 
25
---- Uncomment the following library declaration if instantiating
26
---- any Xilinx primitives in this code.
27
--library UNISIM;
28
--use UNISIM.VComponents.all;
29
 
30
entity top is
31
   Port (
32
                CLK_50M : in  STD_LOGIC;
33
                CLK_AUX : in STD_LOGIC;   -- 133.33 MHz
34
                LED : out std_logic_vector(7 downto 0) := (others=>'0');
35
                SW : in std_logic_vector(3 downto 0);
36
                AWAKE : out std_logic := '0';
37
 
38
                -- SPI is in use for DAC outputs to oscilloscope
39
                SPI_MOSI : OUT std_logic := 'L';
40
                DAC_CS : OUT std_logic := '1';
41
                SPI_SCK : OUT std_logic := 'L';
42
                DAC_CLR : OUT std_logic := 'L';
43
                DAC_OUT : IN std_logic := 'L';
44
 
45
                -- VGA is (planned) for emulated vector graphics
46
                VGA_R : out  STD_LOGIC_VECTOR (3 downto 0);
47
      VGA_G : out  STD_LOGIC_VECTOR (3 downto 0);
48
      VGA_B : out  STD_LOGIC_VECTOR (3 downto 0);
49
      VGA_HSYNC : out  STD_LOGIC := '1';
50
      VGA_VSYNC : out  STD_LOGIC := '0';
51
 
52
                -- DCE serial port is used for communications with PC
53
                RS232_DCE_RXD : IN std_logic;
54
                RS232_DCE_TXD : OUT std_logic := '1';
55
 
56
                -- pushbutton to be debounced
57
                BTN_EAST : IN std_logic := '0'
58
        );
59
end top;
60
 
61
architecture Behavioral of top is
62
        subtype word is std_logic_vector(0 to 17);
63
                component vga is
64
                        Port ( VGA_R : out  STD_LOGIC_VECTOR (3 downto 0);
65
           VGA_G : out  STD_LOGIC_VECTOR (3 downto 0);
66
           VGA_B : out  STD_LOGIC_VECTOR (3 downto 0);
67
           VGA_HSYNC : out  STD_LOGIC := '1';
68
           VGA_VSYNC : out  STD_LOGIC := '0';
69
           CLK_50M : in STD_LOGIC;
70
                          CLK_133M33 : in STD_LOGIC);
71
                end component;
72
 
73
        component pdp1io is
74
          Port (
75
             CLK_50M : in  STD_LOGIC;
76
             CLK_PDP : in STD_LOGIC;
77
 
78
             IO_SET : out STD_LOGIC;
79
             IO_TO_CPU : out STD_LOGIC_VECTOR(0 to 17);
80
             AC, IO_FROM_CPU : in STD_LOGIC_VECTOR(0 to 17);
81
             IOT : in STD_LOGIC_VECTOR(0 to 63);
82
             IO_RESTART : out STD_LOGIC;
83
             IO_DORESTART : in STD_LOGIC;
84
 
85
             -- SPI is in use for DAC outputs to oscilloscope
86
             SPI_MOSI : OUT std_logic;
87
             DAC_CS : OUT std_logic;
88
             SPI_SCK : OUT std_logic;
89
             DAC_CLR : OUT std_logic;
90
             DAC_OUT : IN std_logic;
91
 
92
             -- DCE serial port is used for communications with PC
93
             RS232_DCE_RXD : IN std_logic;
94
             RS232_DCE_TXD : OUT std_logic
95
          );
96
        end component;
97
 
98
        COMPONENT flagcross
99
        generic ( width : integer := 0 );
100
        PORT(
101
                ClkA, ClkB, FastClk : IN std_logic;
102
                A : IN std_logic;
103
                B : OUT std_logic;
104
                A_reg : in STD_LOGIC_VECTOR(0 to width-1);
105
                B_reg : out STD_LOGIC_VECTOR(0 to width-1)
106
                );
107
        END COMPONENT;
108
 
109
        component coremem
110
    Port ( A : in  STD_LOGIC_VECTOR (0 to 11);
111
           CLK : in  STD_LOGIC;
112
           WE : in  STD_LOGIC;
113
           DI : in  word;
114
           DO : inout word);
115
        end component;
116
 
117
        component clockdiv
118
    Port ( CLK_50M : in  STD_LOGIC;
119
           CLK : out  STD_LOGIC;        -- 2MHz
120
                          LOCKED : out STD_LOGIC);
121
        end component;
122
 
123
        component pdp1cpu
124
    Port ( M_DO : in word;
125
           M_DI : out word;
126
           MW : inout  STD_LOGIC;
127
           MA : out  STD_LOGIC_VECTOR (0 to 11);
128
 
129
           AWAKE : out STD_LOGIC;
130
 
131
           CLK : in  STD_LOGIC;
132
 
133
           IOT : out STD_LOGIC_VECTOR(0 to 63);
134
           IODOPULSE : out STD_LOGIC;
135
           IODONE : in STD_LOGIC;
136
           IO_set : in STD_LOGIC;
137
           IO_IN : in STD_LOGIC_VECTOR(0 to 17);
138
 
139
           PC : inout unsigned(0 to 11);  -- program counter
140
           AC, IO : inout word;
141
           SW_SENSE : in STD_LOGIC_VECTOR(1 to 6);
142
 
143
           RESET : in STD_LOGIC);
144
        end component;
145
 
146
        COMPONENT debounce
147
        PORT(
148
                clk : IN std_logic;
149
                clken : IN std_logic;
150
                input : IN std_logic;
151
                output : INOUT std_logic
152
                );
153
        END COMPONENT;
154
 
155
        signal CLK, CLK_LOCKED, RESET : std_logic := '0';
156
        signal mem_we : std_logic := '0';
157
        signal mem_di, mem_do, io, ac, io_in : word := (others=>'0');
158
        signal sw_sense : std_logic_vector(1 to 6) := o"00";
159
        signal mem_a : std_logic_vector(0 to 11) := (others=>'0');
160
 
161
        signal pc : unsigned(0 to 11);
162
 
163
        signal io_dopulse, io_done, io_set : std_logic := '0';
164
        signal IOT : std_logic_vector(0 to 63) := (others=>'0');
165
        signal display_trig, display_done: std_logic;
166
 
167
        constant pdp1_enabled : boolean := true;
168
begin
169
        RESET <= (not CLK_LOCKED) or BTN_EAST;
170
 
171
        vga_out : vga port map (
172
                CLK_50M => CLK_50M,
173
                CLK_133M33 => CLK_AUX,
174
                VGA_R => VGA_R,
175
                VGA_G => VGA_G,
176
                VGA_B => VGA_B,
177
                VGA_HSYNC => VGA_HSYNC,
178
                VGA_VSYNC => VGA_VSYNC
179
        );
180
 
181
dummy: if not pdp1_enabled generate
182
begin
183
        LED <= (others => '0');
184
        SPI_SCK <= '0';
185
        RS232_DCE_TXD <= '1';
186
        SPI_MOSI <= '0';
187
        DAC_CLR <= '0';
188
        AWAKE <= '1';
189
        DAC_CS <= '1';
190
end generate;
191
 
192
disabled: if pdp1_enabled generate
193
begin
194
        clock : clockdiv
195
        port map (
196
                CLK_50M => CLK_50M,
197
                CLK => CLK,
198
                LOCKED => CLK_LOCKED
199
        );
200
 
201
        core : coremem
202
        port map (
203
                CLK => CLK,
204
                WE => mem_we,
205
                DI => mem_di,
206
                DO => mem_do,
207
                A => mem_a
208
        );
209
--        AWAKE <= '1';
210
        cpu : pdp1cpu
211
        port map (
212
                CLK => CLK,
213
                AWAKE => AWAKE,
214
 
215
                M_DO => mem_do,
216
                M_DI => mem_di,
217
                MW => mem_we,
218
                MA => mem_a,
219
 
220
                IOT => IOT,
221
                IODOPULSE => io_dopulse,
222
                IODONE => io_done,
223
                IO_IN => io_in,
224
                IO_SET => io_set,
225
 
226
                PC => pc,
227
                IO => IO,
228
                AC => AC,
229
                SW_SENSE => SW_SENSE,
230
 
231
                RESET => RESET
232
        );
233
        iodevices : pdp1io port map (
234
          CLK_50M       => CLK_50M,
235
          CLK_PDP       => CLK,
236
          IO_SET        => io_set,
237
          IO_TO_CPU     => io_in,
238
          IO_FROM_CPU   => IO,
239
          AC            => AC,
240
          IOT           => iot,
241
          IO_RESTART    => io_done,
242
          IO_DORESTART  => io_dopulse,
243
          -- display device uses DAC
244
          SPI_MOSI      => SPI_MOSI,
245
          DAC_CS        => DAC_CS,
246
          SPI_SCK       => SPI_SCK,
247
          DAC_CLR       => DAC_CLR,
248
          DAC_OUT       => DAC_OUT,
249
          -- paper tape reader uses RS232
250
          RS232_DCE_RXD => RS232_DCE_RXD,
251
          RS232_DCE_TXD => RS232_DCE_TXD);
252
 
253
        with SW select
254
          LED <=
255
          std_logic_vector(PC(11-7 to 11)) when "0000",
256
          IO(0 to 7) when others;
257
        SW_SENSE(1 to 4) <= SW(3 downto 0);
258
 
259
        Inst_debounce: debounce PORT MAP(
260
                clk => CLK,
261
                clken => '1',
262
                input => BTN_EAST,
263
                output => SW_SENSE(5)
264
        );
265
end generate;
266
 
267
end Behavioral;

powered by: WebSVN 2.1.0

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