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

Subversion Repositories next186mp3

[/] [next186mp3/] [trunk/] [HW/] [unit186.v] - Blame information for rev 3

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

Line No. Rev Author Line
1 2 ndumitrach
//////////////////////////////////////////////////////////////////////////////////
2
//
3
// This file is part of the Next186 Soc PC project
4
// http://opencores.org/project,next186
5
//
6
// Filename: unit186.v
7
// Description: Part of the Next186 SoC PC project, 80186 unit (CPU + BIU)
8
// Version 1.0
9
// Creation date: Mar2012
10
//
11
// Author: Nicolae Dumitrache 
12
// e-mail: ndumitrache@opencores.org
13
//
14
/////////////////////////////////////////////////////////////////////////////////
15
// 
16
// Copyright (C) 2012 Nicolae Dumitrache
17
// 
18
// This source file may be used and distributed without 
19
// restriction provided that this copyright statement is not 
20
// removed from the file and that any derivative work contains 
21
// the original copyright notice and the associated disclaimer.
22
// 
23
// This source file is free software; you can redistribute it 
24
// and/or modify it under the terms of the GNU Lesser General 
25
// Public License as published by the Free Software Foundation;
26
// either version 2.1 of the License, or (at your option) any 
27
// later version. 
28
// 
29
// This source is distributed in the hope that it will be 
30
// useful, but WITHOUT ANY WARRANTY; without even the implied 
31
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 
32
// PURPOSE. See the GNU Lesser General Public License for more 
33
// details. 
34
// 
35
// You should have received a copy of the GNU Lesser General 
36
// Public License along with this source; if not, download it 
37
// from http://www.opencores.org/lgpl.shtml 
38
// 
39
///////////////////////////////////////////////////////////////////////////////////
40
// Additional Comments: 
41
//
42
//////////////////////////////////////////////////////////////////////////////////
43
 
44
`timescale 1ns / 1ps
45
 
46
module unit186(
47
                input [15:0]INPORT,
48
                input [31:0]DIN,
49
                output [15:0]CPU_DOUT,
50
                output [31:0]DOUT,
51
                output [20:0]ADDR,
52
                output [3:0]WMASK,
53
                output [15:0]PORT_ADDR,
54
 
55
                input CLK,
56
                input CE,
57
                output CPU_CE,
58
                output CE_186,
59
                input INTR,
60
                input NMI,
61
                input RST,
62
                output INTA,
63
                output LOCK,
64
                output HALT,
65
                output MREQ,
66
                output IORQ,
67
                output WR,
68
                output WORD,
69
 
70
                input PLANAR,
71
                input [3:0]VGA_WPLANE,
72
                input [1:0]VGA_RPLANE,
73
                input [7:0]VGA_BITMASK,
74
                input [2:0]VGA_RWMODE,
75
                input [3:0]VGA_SETRES,
76
                input [3:0]VGA_ENABLE_SETRES,
77
                input [1:0]VGA_LOGOP,
78
                input [3:0]VGA_COLOR_COMPARE,
79
                input [3:0]VGA_COLOR_DONT_CARE
80
    );
81
 
82
        wire [15:0] CPU_DIN;
83
        wire [20:0] CPU_IADDR;
84
        wire [20:0] CPU_ADDR;
85
        wire [47:0] CPU_INSTR;
86
        wire CPU_MREQ; // CPU memory request
87
        wire IFETCH;
88
        wire FLUSH;
89
        wire [2:0]ISIZE;
90
 
91
        wire [3:0]RAM_WMASK;
92
        wire [31:0]RAM_DOUT;
93
        wire VGAWORD;
94
        wire [7:0]N_COMPARE = ((DIN[31:24] ^ {8{VGA_COLOR_COMPARE[3]}}) & {8{VGA_COLOR_DONT_CARE[3]}}) |
95
                                                  ((DIN[23:16] ^ {8{VGA_COLOR_COMPARE[2]}}) & {8{VGA_COLOR_DONT_CARE[2]}}) |
96
                                                  ((DIN[15:8]  ^ {8{VGA_COLOR_COMPARE[1]}}) & {8{VGA_COLOR_DONT_CARE[1]}}) |
97
                                                  ((DIN[7:0]   ^ {8{VGA_COLOR_COMPARE[0]}}) & {8{VGA_COLOR_DONT_CARE[0]}});
98
        wire [7:0]SEL_RDATA = VGA_RWMODE[2] ? ~N_COMPARE : (DIN >> {VGA_RPLANE, 3'b000});
99
        reg [31:0]VGA_LATCH;
100
        wire VGA_SEL = PLANAR && (CPU_ADDR[19:16] == 4'ha);
101
        wire RAM_RD;
102
        wire RAM_WR;
103
        reg s_RAM_RD;
104
 
105
        assign ADDR[1:0] = CPU_ADDR[1:0];
106
        assign CPU_CE = CE_186 & CE;
107
        assign PORT_ADDR = CPU_ADDR[15:0];
108
        assign WMASK = (VGA_SEL & RAM_WR) ? VGA_WPLANE : RAM_WMASK;
109
        wire [7:0]VGA_BITMASK1 = VGA_SEL ? (VGA_RWMODE[1:0] == 2'b01 ? 8'h00 : VGA_RWMODE[1:0] == 2'b11 ? (VGA_BITMASK & RAM_DOUT[7:0]) : VGA_BITMASK) : 8'hff;
110
        wire [3:0]EXPAND = VGA_SEL ? VGA_RWMODE[1:0] == 2'b00 ? VGA_ENABLE_SETRES : 4'b1111 : 4'b0000;
111
        wire [3:0]EXPAND_BIT = VGA_RWMODE[1:0] == 2'b10 ? RAM_DOUT[3:0] : VGA_SETRES;
112
        wire [31:0]RAM_DOUT1 = {EXPAND[3] ? {8{EXPAND_BIT[3]}} : RAM_DOUT[31:24], EXPAND[2] ? {8{EXPAND_BIT[2]}} : RAM_DOUT[23:16],
113
                                                        EXPAND[1] ? {8{EXPAND_BIT[1]}} : RAM_DOUT[15:8],  EXPAND[0] ? {8{EXPAND_BIT[0]}} : RAM_DOUT[7:0]};
114
        reg [31:0]RAM_DOUT2;
115
        assign DOUT = ({4{VGA_BITMASK1}} & RAM_DOUT2) | ({4{~VGA_BITMASK1}} & VGA_LATCH);
116
 
117
        always @(*)
118
                if(VGA_SEL)
119
                        case(VGA_LOGOP)
120
                                2'b00: RAM_DOUT2 = RAM_DOUT1;
121
                                2'b01: RAM_DOUT2 = RAM_DOUT1 & VGA_LATCH;
122
                                2'b10: RAM_DOUT2 = RAM_DOUT1 | VGA_LATCH;
123
                                2'b11: RAM_DOUT2 = RAM_DOUT1 ^ VGA_LATCH;
124
                        endcase
125
                else RAM_DOUT2 = RAM_DOUT1;
126
 
127
 
128
        Next186_CPU cpu
129
        (
130
                 .ADDR(CPU_ADDR),
131
                 .DIN(IORQ | INTA ? INPORT : CPU_DIN),
132
                 .DOUT(CPU_DOUT),
133
                 .CLK(CLK),
134
                 .CE(CPU_CE),
135
                 .INTR(INTR),
136
                 .NMI(NMI),
137
                 .RST(RST),
138
                 .MREQ(CPU_MREQ),
139
                 .IORQ(IORQ),
140
                 .INTA(INTA),
141
                 .WR(WR),
142
                 .WORD(WORD),
143
                 .LOCK(LOCK),
144
                 .IADDR(CPU_IADDR),
145
                 .INSTR(CPU_INSTR),
146
                 .IFETCH(IFETCH),
147
                 .FLUSH(FLUSH),
148
                 .ISIZE(ISIZE),
149
                 .HALT(HALT)
150
   );
151
 
152
 
153
        BIU186_32bSync_2T_DelayRead BIU
154
        (
155
                 .CLK(CLK),
156
                 .INSTR(CPU_INSTR),
157
                 .ISIZE(ISIZE),
158
                 .IFETCH(IFETCH),
159
                 .FLUSH(FLUSH),
160
                 .MREQ(CPU_MREQ),
161
                 .WR(WR),
162
                 .WORD(WORD),
163
                 .ADDR(VGA_SEL ? {2'b11, CPU_ADDR[15], ~CPU_ADDR[15], CPU_ADDR[14:0], WORD, WORD} : CPU_ADDR),
164
                 .IADDR(CPU_IADDR),
165
                 .CE186(CE_186),
166
                 .RAM_DIN(s_RAM_RD ? {4{SEL_RDATA}} : DIN),
167
                 .RAM_DOUT(RAM_DOUT),
168
                 .RAM_ADDR(ADDR[20:2]),
169
                 .RAM_MREQ(MREQ),
170
                 .RAM_WMASK(RAM_WMASK),
171
                 .DOUT(CPU_DIN),
172
                 .DIN(CPU_DOUT),
173
                 .CE(CE),
174
                 .data_bound(VGAWORD),
175
                 .WSEL(VGA_SEL ? {VGAWORD, VGAWORD} : {~CPU_ADDR[0], CPU_ADDR[0]}),
176
                 .RAM_RD(RAM_RD),
177
                 .RAM_WR(RAM_WR)
178
        );
179
 
180
        always @(posedge CLK) if(CE) begin
181
                s_RAM_RD <= VGA_SEL & RAM_RD;
182
                if(s_RAM_RD) VGA_LATCH <= DIN;
183
        end
184
 
185
endmodule

powered by: WebSVN 2.1.0

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