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

Subversion Repositories diogenes

[/] [diogenes/] [tags/] [initial/] [vhdl/] [sio.vhd] - Blame information for rev 237

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

Line No. Rev Author Line
1 188 fellnhofer
----------------------------------------------------------------------------------
2
-- Company: 
3
-- Engineer: 
4
-- 
5
-- Create Date:    12:41:22 11/11/2007 
6
-- Design Name: 
7
-- Module Name:    sio - 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
 
26
 
27
---- Uncomment the following library declaration if instantiating
28
---- any Xilinx primitives in this code.
29
library UNISIM;
30
use UNISIM.Vcomponents.ALL;
31
 
32
use work.types.ALL;
33
 
34
 
35
 
36
entity mysio is
37
    Port ( gclk : in  STD_LOGIC;
38
           reset : in  STD_LOGIC;
39
 
40
           rx : in  STD_LOGIC;
41
           tx : out  STD_LOGIC;
42
 
43
                          lcd_rs : out std_logic;
44
                          lcd_rw : out std_logic;
45
                          lcd_e  : out std_logic;
46
                          lcd_d  : out std_logic_vector(3 downto 0);
47
 
48
                          button : in std_logic_vector(7 downto 0);
49
 
50
           strataflash_oe : out std_logic;
51
           strataflash_ce : out std_logic;
52
           strataflash_we : out std_logic;
53
 
54
                          red  : out std_logic;
55
                          green  : out std_logic;
56
                          blue  : out std_logic;
57
                          vs  : out std_logic;
58
                          hs  : out std_logic;
59
 
60
                          test : out std_logic_vector(7 downto 0)
61
                          );
62
end mysio;
63
 
64
 
65
 
66
 
67
architecture Behavioral of mysio is
68
 
69
 
70
component vga is
71
  port(reset  : in std_logic;
72
                 clk50_in  : in std_logic;
73
       red_out   : out std_logic;
74
       green_out : out std_logic;
75
       blue_out  : out std_logic;
76
       hs_out    : out std_logic;
77
       vs_out    : out std_logic;
78
 
79
                 addrb     : in std_logic_VECTOR(12 downto 0);
80
                 dinb      : in std_logic_VECTOR(7 downto 0);
81
                 web       : in std_logic
82
        );
83
end component;
84
 
85
 
86
component sc_uart is
87
        generic (addr_bits : integer;
88
                clk_freq : integer;
89
                baud_rate : integer;
90
                txf_depth : integer; txf_thres : integer;
91
                rxf_depth : integer; rxf_thres : integer);
92
        port (
93
                clk             : in std_logic;
94
                reset   : in std_logic;
95
 
96
        -- SimpCon interface
97
 
98
                address         : in std_logic_vector(addr_bits-1 downto 0);
99
                wr_data         : in std_logic_vector(31 downto 0);
100
                rd, wr          : in std_logic;
101
                rd_data         : out std_logic_vector(31 downto 0);
102
        --      rdy_cnt         : out unsigned(1 downto 0);
103
 
104
                txd             : out std_logic;
105
                rxd             : in std_logic;
106
                ncts    : in std_logic;
107
                nrts    : out std_logic
108
        );
109
end component;
110
 
111
 
112
 
113
 
114
 
115
signal nreset : std_logic;
116
 
117
 
118
signal uwr_gen: std_logic;
119
signal urd_gen: std_logic;
120
signal urd_data: slv_32;
121
signal uwr_data: slv_32;
122
signal uaddr: std_logic_vector(0 downto 0);
123
 
124
signal pmem_addr_m: std_logic_VECTOR(9 downto 0);
125
signal pmem_din_m: slv_16;
126
signal pmem_we_m: std_logic;
127
 
128
signal vmem_addr_m: std_logic_VECTOR(12 downto 0);
129
signal vmem_din_m: slv_8;
130
signal vmem_we_m: std_logic;
131
 
132
signal lcd_rs_l : std_logic;
133
signal lcd_rw_l : std_logic;
134
signal lcd_e_l  : std_logic;
135
signal lcd_d_l  : std_logic_vector(3 downto 0);
136
 
137
signal test_led : std_logic_vector(7 downto 0);
138
 
139
 
140
 
141
constant LAST_ADDR: std_logic_VECTOR(9 downto 0) := "0001111111";
142
 
143
 
144
 
145
component pmem is
146
        port (
147
                addra: IN std_logic_VECTOR(9 downto 0);
148
                addrb: IN std_logic_VECTOR(9 downto 0);
149
                clka: IN std_logic;
150
                clkb: IN std_logic;
151
                dinb: IN std_logic_VECTOR(15 downto 0);
152
                douta: OUT std_logic_VECTOR(15 downto 0);
153
                web: IN std_logic
154
        );
155
end component;
156
 
157
component cpu is
158
    Port (      clk_in : in STD_LOGIC;
159
 
160
                                reset_in : in STD_LOGIC;
161
 
162
                                paddr: out std_logic_VECTOR(9 downto 0);
163
                                pdin: in std_logic_VECTOR(15 downto 0);
164
 
165
                                extrd: out std_logic;
166
                                extwr: out std_logic;
167
                                extaddr: out slv_16;
168
                                extdin: in slv_16;
169
                                extdout: out slv_16
170
                        );
171
end component;
172
 
173
 
174
 
175
signal extaddr:                                 slv_16;
176
signal extdin:                          slv_16;
177
signal extdout:                                 slv_16;
178
signal extwr:                                   std_logic;
179
signal extrd:                                   std_logic;
180
 
181
signal was_uart:                                std_logic;
182
signal was_button:                      std_logic;
183
 
184
 
185
 
186
--
187
signal mem_addr_cpu:            std_logic_VECTOR(9 downto 0);
188
signal mem_dout_cpu:            slv_16;
189
 
190
 
191
begin
192
 
193
  --
194
  --StrataFLASH must be disabled to prevent it conflicting with the LCD display 
195
  --
196
  strataflash_oe <= '1';
197
  strataflash_ce <= '1';
198
  strataflash_we <= '1';
199
 
200
 
201
nreset <= not reset;
202
 
203
 
204
vga_c: vga
205
  port map(
206
                reset    => reset,
207
                clk50_in  => gclk,
208
      red_out   => red,
209
      green_out => green,
210
      blue_out  => blue,
211
      hs_out    => hs,
212
      vs_out    => vs,
213
                addrb     => vmem_addr_m,
214
                dinb      => vmem_din_m,
215
                web       => vmem_we_m
216
    );
217
 
218
 
219
sc_uartc: sc_uart
220
  generic map (1, 50000000, 115000, 1, 1, 1, 1)
221
  port map(
222
    clk => gclk,
223
         reset => nreset,
224
         txd => tx,
225
         rxd => rx,
226
 
227
         address => uaddr,
228
         rd_data => urd_data,
229
         wr_data => uwr_data,
230
         rd => urd_gen,
231
         wr => uwr_gen,
232
 
233
         ncts => '0'
234
  );
235
 
236
 
237
pmemc: pmem
238
  port map(
239
                clka => gclk,
240
                clkb => gclk,
241
                addrb => pmem_addr_m,
242
                addra => mem_addr_cpu,
243
                dinb => pmem_din_m,
244
                douta => mem_dout_cpu,
245
                web => pmem_we_m
246
  );
247
 
248
 
249
diogenes_cpu: cpu
250
  port map(
251
                clk_in => gclk,
252
 
253
                reset_in => reset,
254
 
255
                paddr => mem_addr_cpu,
256
                pdin => mem_dout_cpu,
257
                extaddr => extaddr,
258
                extwr => extwr,
259
                extrd => extrd,
260
                extdin => extdin,
261
                extdout => extdout
262
  );
263
 
264
 
265
        lcd_rs <= lcd_rs_l;
266
        lcd_rw <= lcd_rw_l;
267
        lcd_e  <= lcd_e_l;
268
        lcd_d  <= lcd_d_l;
269
        test <= test_led;
270
 
271
 
272
        -- connect uart asynchronous
273
        process (extaddr, urd_data, uwr_data, extdout, extrd, extwr, test_led)
274
        begin
275
                uaddr <= (others => '0');
276
                uaddr(0) <= extaddr(0);
277
                uwr_data <= (others => '0');
278
                uwr_data(7 downto 0) <= extdout(7 downto 0);
279
 
280
                --urd_gen <= '0';
281
                uwr_gen <= '0';
282
           urd_gen <= extrd;
283
 
284
                if(extaddr(15)='0') then
285
                        if (extaddr(7 downto 6) = "10") then
286
                                uwr_gen <= extwr;
287
                        end if;
288
                end if;
289
 
290
      if was_uart='1' then
291
                        extdin <= urd_data(15 downto 0);
292
                elsif was_button='1' then
293
                        extdin <= "00000000" & button;
294
      end if;
295
 
296
        end process;
297
 
298
 
299
 
300
        process (reset, gclk)
301
        begin
302
 
303
                if(reset='0') then
304
                        lcd_rs_l <= '0';
305
                        lcd_rw_l <= '0';
306
                        lcd_e_l <= '0';
307
                        lcd_d_l <= (others => '0');
308
                        test_led <= (others => '0');
309
 
310
                        vmem_addr_m <= (others => '0');
311
                        vmem_din_m <= (others => '0');
312
                        vmem_we_m <= '0';
313
 
314
                        pmem_addr_m <= (others => '0');
315
                        pmem_din_m <= (others => '0');
316
                        pmem_we_m <= '0';
317
 
318
                        was_uart <= '0';
319
                elsif rising_edge(gclk) then
320
 
321
                        if (extwr='1') then
322
                                if (extaddr(15) = '0') then
323
                                        if extaddr(7 downto 6) = "11" then
324
                                                if extaddr(5 downto 4) = "00" then
325
                                                        lcd_rs_l <= extdout(0);
326
                                                elsif extaddr(5 downto 4) = "01" then
327
                                                        lcd_rw_l <= extdout(0);
328
                                                elsif extaddr(5 downto 4) = "10" then
329
                                                        lcd_e_l <= extdout(0);
330
                                                elsif extaddr(5 downto 4) = "11" then
331
                                                        lcd_d_l <= extdout(3 downto 0);
332
                                                end if;
333
                                        elsif extaddr(7 downto 6) = "00" then
334
                                                if(extwr='1') then
335
                                                        test_led(7 downto 0) <= extdout(7 downto 0);
336
                                                end if;
337
                                        end if;
338
                                elsif (extaddr(14) = '0') then
339
                                        pmem_addr_m <= extaddr(9 downto 0);
340
                                        pmem_din_m <= extdout(15 downto 0);
341
                                        pmem_we_m <= extwr;
342
                                elsif (extaddr(14) = '1') then
343
                                        vmem_addr_m <= extaddr(12 downto 0);
344
                                        vmem_din_m <= extdout(7 downto 0);
345
                                        vmem_we_m <= extwr;
346
                                end if;
347
                        elsif (extrd='1') then
348
                                        was_uart <= '0';
349
                                        was_button <= '0';
350
 
351
                                        if (extaddr(15)='0') then
352
                                                if (extaddr(7 downto 6) = "10") then
353
                                                        was_uart <= '1';
354
                                                elsif (extaddr(7 downto 6) = "00") then
355
                                                        was_button <= '1';
356
                                                end if;
357
                                        end if;
358
                        end if;
359
                end if;
360
        end process;
361
 
362
end Behavioral;
363
 

powered by: WebSVN 2.1.0

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