Rev 62 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9 | lvd | 1 | // ZXiznet project |
2 | // (c) NedoPC 2012 |
||
3 | // |
||
13 | lvd | 4 | // zx-bus functions: ports mapping/access, ROM mapping |
9 | lvd | 5 | |
6 | module zbus |
||
7 | ( |
||
13 | lvd | 8 | input wire [15:0] za, |
9 | inout wire [ 7:0] zd, |
||
10 | // |
||
25 | lvd | 11 | inout wire [ 7:0] bd, |
12 | // |
||
13 | lvd | 13 | input wire ziorq_n, |
14 | input wire zrd_n, |
||
15 | input wire zwr_n, |
||
16 | input wire zmreq_n, |
||
17 | output wire ziorqge, |
||
18 | output wire zblkrom, |
||
19 | input wire zcsrom_n, |
||
20 | input wire zrst_n, |
||
21 | |||
22 | // |
||
23 | output wire ports_wrena, |
||
24 | output wire ports_wrstb_n, |
||
25 | output wire [ 1:0] ports_addr, |
||
26 | output wire [ 7:0] ports_wrdata, |
||
27 | input wire [ 7:0] ports_rddata, |
||
28 | |||
29 | // |
||
30 | input wire [ 1:0] rommap_win, |
||
31 | input wire rommap_ena, |
||
32 | |||
33 | // |
||
34 | output wire sl811_cs_n, |
||
35 | output wire sl811_a0, |
||
36 | |||
37 | // |
||
32 | lvd | 38 | output wire w5300_cs_n, |
39 | input wire w5300_ports |
||
9 | lvd | 40 | ); |
13 | lvd | 41 | parameter BASE_ADDR = 8'hAB; |
9 | lvd | 42 | |
43 | |||
13 | lvd | 44 | |
45 | wire io_addr_ok; |
||
46 | |||
47 | wire mrd, mwr; |
||
48 | |||
25 | lvd | 49 | wire ena_dbuf; |
50 | wire ena_din; |
||
51 | wire ena_dout; |
||
13 | lvd | 52 | |
53 | |||
54 | // addr decode |
||
55 | assign io_addr_ok = (za[7:0]==BASE_ADDR); |
||
56 | |||
57 | |||
58 | // IORQGE |
||
59 | assign ziorqge = io_addr_ok ? 1'b1 : 1'bZ; |
||
60 | |||
61 | |||
62 | |||
63 | // ports write |
||
64 | assign ports_addr = za[9:8]; |
||
65 | // |
||
66 | assign ports_wrdata = zd; |
||
67 | // |
||
68 | assign ports_wrena = io_addr_ok && za[15]; |
||
69 | assign ports_wrstb_n = ziorq_n | zwr_n; |
||
70 | |||
71 | |||
59 | lvd | 72 | |
13 | lvd | 73 | // sl811 chip select and A0 |
62 | lvd | 74 | assign sl811_cs_n = !( !w5300_ports && io_addr_ok && ( !za[15] || (za[15] && za[9:8]==2'b00) ) && !ziorq_n ); |
13 | lvd | 75 | // |
76 | assign sl811_a0 = ~za[15]; |
||
77 | |||
78 | |||
79 | // w5300 chip select |
||
80 | assign mwr = !zmreq_n && !zwr_n && (za[15:14]==rommap_win) && rommap_ena; |
||
81 | assign mrd = !zmreq_n && !zrd_n && !zcsrom_n && (za[15:14]==rommap_win) && rommap_ena; |
||
82 | // |
||
32 | lvd | 83 | assign w5300_cs_n = ~(mwr || mrd || ( w5300_ports && io_addr_ok && !za[15] && !ziorq_n ) ); |
13 | lvd | 84 | |
85 | // block ROM |
||
86 | assign zblkrom = (rommap_ena && (za[15:14]==rommap_win)) ? 1'b1 : 1'bZ; |
||
87 | |||
88 | |||
89 | |||
25 | lvd | 90 | assign ena_dbuf = (~sl811_cs_n) | (~w5300_cs_n); |
91 | assign ena_din = ~zwr_n; |
||
92 | assign ena_dout = ~zrd_n; |
||
93 | |||
94 | |||
95 | // ports data read/buffering |
||
13 | lvd | 96 | assign zd = (io_addr_ok && !ziorq_n && !zrd_n && za[15] && (za[9:8]!=2'b00)) ? |
25 | lvd | 97 | ports_rddata : ( (ena_dbuf && ena_dout) ? bd : 8'bZZZZ_ZZZZ ); |
13 | lvd | 98 | |
99 | |||
25 | lvd | 100 | assign bd = (ena_dbuf && ena_din) ? zd : 8'bZZZZ_ZZZZ; |
101 | |||
9 | lvd | 102 | endmodule |
103 |