1 |
2 |
robfinch |
// ============================================================================
|
2 |
|
|
// 8088 to WISHBONE bus bridge
|
3 |
|
|
//
|
4 |
|
|
//
|
5 |
|
|
// 2009 Robert T Finch
|
6 |
|
|
// robfinch<remove>@opencores.org
|
7 |
|
|
//
|
8 |
|
|
//
|
9 |
|
|
// This source code is available for evaluation and validation purposes
|
10 |
|
|
// only. This copyright statement and disclaimer must remain present in
|
11 |
|
|
// the file.
|
12 |
|
|
//
|
13 |
|
|
// NO WARRANTY.
|
14 |
|
|
// THIS Work, IS PROVIDEDED "AS IS" WITH NO WARRANTIES OF ANY KIND, WHETHER
|
15 |
|
|
// EXPRESS OR IMPLIED. The user must assume the entire risk of using the
|
16 |
|
|
// Work.
|
17 |
|
|
//
|
18 |
|
|
// IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE FOR ANY
|
19 |
|
|
// INCIDENTAL, CONSEQUENTIAL, OR PUNITIVE DAMAGES WHATSOEVER RELATING TO
|
20 |
|
|
// THE USE OF THIS WORK, OR YOUR RELATIONSHIP WITH THE AUTHOR.
|
21 |
|
|
//
|
22 |
|
|
// IN ADDITION, IN NO EVENT DOES THE AUTHOR AUTHORIZE YOU TO USE THE WORK
|
23 |
|
|
// IN APPLICATIONS OR SYSTEMS WHERE THE WORK'S FAILURE TO PERFORM CAN
|
24 |
|
|
// REASONABLY BE EXPECTED TO RESULT IN A SIGNIFICANT PHYSICAL INJURY, OR IN
|
25 |
|
|
// LOSS OF LIFE. ANY SUCH USE BY YOU IS ENTIRELY AT YOUR OWN RISK, AND YOU
|
26 |
|
|
// AGREE TO HOLD THE AUTHOR AND CONTRIBUTORS HARMLESS FROM ANY CLAIMS OR
|
27 |
|
|
// LOSSES RELATING TO SUCH UNAUTHORIZED USE.
|
28 |
|
|
//
|
29 |
|
|
//
|
30 |
|
|
// Verilog
|
31 |
|
|
//
|
32 |
|
|
// Connects an internal WISHBONE bus to the regular 8088 bus.
|
33 |
|
|
// If there is a hold acknowledge, a number of line have to be tri-stated.
|
34 |
|
|
//
|
35 |
|
|
// Slice 16 / LUTs 30 / FF's 5 / 307.977 MHz
|
36 |
|
|
// ============================================================================
|
37 |
|
|
//
|
38 |
|
|
`ifndef CT_INTA
|
39 |
|
|
`include "cycle_types.v"
|
40 |
|
|
`endif
|
41 |
|
|
|
42 |
|
|
module wb8088_bridge(
|
43 |
|
|
rst_i, clk_i,
|
44 |
|
|
nmi_i, irq_i, busy_i, inta_o,
|
45 |
|
|
stb_o, ack_i, we_o, adr_o, dat_i, dat_o,
|
46 |
|
|
ie, cyc_type, S43,
|
47 |
|
|
RESET, CLK, NMI, INTR, INTA_n, ALE, DEN_n, DT_R, IO_M, RD_n, WR_n, READY, A, AD, SSO,
|
48 |
|
|
TEST_n, HOLD, HLDA
|
49 |
|
|
);
|
50 |
|
|
parameter T0 = 3'd0;
|
51 |
|
|
parameter T1 = 3'd1;
|
52 |
|
|
parameter T2 = 3'd2;
|
53 |
|
|
parameter T3 = 3'd3;
|
54 |
|
|
parameter T4 = 3'd4;
|
55 |
|
|
|
56 |
|
|
output rst_i;
|
57 |
|
|
output clk_i;
|
58 |
|
|
output nmi_i;
|
59 |
|
|
output irq_i;
|
60 |
|
|
output busy_i;
|
61 |
|
|
input inta_o;
|
62 |
|
|
input stb_o;
|
63 |
|
|
output ack_i;
|
64 |
|
|
input we_o;
|
65 |
|
|
input [19:0] adr_o;
|
66 |
|
|
input [7:0] dat_o;
|
67 |
|
|
output [7:0] dat_i;
|
68 |
|
|
|
69 |
|
|
input ie;
|
70 |
|
|
input [2:0] cyc_type;
|
71 |
|
|
input [1:0] S43;
|
72 |
|
|
|
73 |
|
|
input RESET;
|
74 |
|
|
input CLK;
|
75 |
|
|
input NMI;
|
76 |
|
|
input INTR;
|
77 |
|
|
output INTA_n;
|
78 |
|
|
output ALE;
|
79 |
|
|
output DEN_n;
|
80 |
|
|
output DT_R;
|
81 |
|
|
output IO_M;
|
82 |
|
|
output RD_n;
|
83 |
|
|
output WR_n;
|
84 |
|
|
input READY;
|
85 |
|
|
output [19:8] A;
|
86 |
|
|
tri [19:8] A;
|
87 |
|
|
inout [7:0] AD;
|
88 |
|
|
tri [7:0] AD;
|
89 |
|
|
output SSO;
|
90 |
|
|
input TEST_n;
|
91 |
|
|
input HOLD;
|
92 |
|
|
output HLDA;
|
93 |
|
|
|
94 |
|
|
reg HLDA;
|
95 |
|
|
reg [2:0] Tcyc; // "T" cycle
|
96 |
|
|
wire IsT1 = Tcyc==T1;
|
97 |
|
|
wire IsT2 = Tcyc==T2;
|
98 |
|
|
wire IsT3 = Tcyc==T3;
|
99 |
|
|
wire IsT4 = Tcyc==T4;
|
100 |
|
|
wire IsT23 = (Tcyc==T2) || (Tcyc==T3);
|
101 |
|
|
|
102 |
|
|
assign rst_i = RESET;
|
103 |
|
|
assign clk_i = CLK;
|
104 |
|
|
assign irq_i = INTR;
|
105 |
|
|
assign nmi_i = NMI;
|
106 |
|
|
assign busy_i = TEST_n;
|
107 |
|
|
// Will not get to T4 unless READY is active
|
108 |
|
|
assign ack_i = IsT3 & READY;
|
109 |
|
|
assign ALE = IsT1 && !CLK; // high pulse during clock low
|
110 |
|
|
assign RD_n = HLDA ? 1'bz : !(stb_o && !we_o && IsT23);
|
111 |
|
|
assign WR_n = HLDA ? 1'bz : !(stb_o && we_o && IsT23);
|
112 |
|
|
assign INTA_n = !(inta_o & IsT23);
|
113 |
|
|
assign dat_i = AD[7:0];
|
114 |
|
|
|
115 |
|
|
assign AD[7:0] = HLDA ? 8'bz : IsT1 ? (inta_o ? 8'bz : adr_o[7:0]) : // address cycle
|
116 |
|
|
(we_o ? dat_o : 8'bz); // data cycle
|
117 |
|
|
assign A[15:8] = (HLDA | inta_o) ? 8'bz : adr_o[15:8];
|
118 |
|
|
assign A[19:16] = HLDA ? 4'bz : IsT1 ? adr_o[19:16] : {1'b0,ie,S43};
|
119 |
|
|
|
120 |
|
|
|
121 |
|
|
assign DEN_n = HLDA ? 1'bz : !(we_o ? IsT23 || (IsT4 && !CLK) :
|
122 |
|
|
(CLK && IsT2) || IsT3 || (IsT4 && !CLK));
|
123 |
|
|
assign DT_R = HLDA ? 1'bz : we_o;
|
124 |
|
|
assign IO_M = cyc_type==`CT_RDIO || cyc_type==`CT_WRIO || cyc_type==`CT_HALT || cyc_type==`CT_INTA;
|
125 |
|
|
assign SSO = cyc_type==`CT_RDIO || cyc_type==`CT_HALT || cyc_type==`CT_RDMEM || cyc_type==`CT_PASSIVE;
|
126 |
|
|
|
127 |
|
|
// T State generator
|
128 |
|
|
// Tcyc:
|
129 |
|
|
// - bus cycle state machine
|
130 |
|
|
// The machine sits in state T0 until a bus request is present, then transitions to state T1.
|
131 |
|
|
// The machine sits in state T1 if there is a HOLD present
|
132 |
|
|
// State T2 always moves to state T3
|
133 |
|
|
// The machine sits in state T3 until the bus transfer is acknowledged
|
134 |
|
|
// State T4 waits for the WISHBONE bus to acknowledge bus cycle completion.
|
135 |
|
|
|
136 |
|
|
always @(negedge CLK)
|
137 |
|
|
if (RESET)
|
138 |
|
|
Tcyc <= T4;
|
139 |
|
|
else begin
|
140 |
|
|
case(Tcyc)
|
141 |
|
|
T0: if (stb_o) Tcyc <= T1; // If there is a request for a bus cycle
|
142 |
|
|
T1: Tcyc <= HOLD ? T1 : T2; // HOLD in the T1 state
|
143 |
|
|
T2: Tcyc <= T3; // always move to next
|
144 |
|
|
T3: if (READY) Tcyc <= T4; // wait for READY signal
|
145 |
|
|
T4: if (!stb_o) Tcyc <= T0; // wait for end of bus cycle
|
146 |
|
|
default: Tcyc <= T4;
|
147 |
|
|
endcase
|
148 |
|
|
end
|
149 |
|
|
|
150 |
|
|
// HOLD generator
|
151 |
|
|
// - drive HLDA low as soon as HOLD goes low
|
152 |
|
|
// - drive HLDA active if there is a HOLD during T1 or T4
|
153 |
|
|
//
|
154 |
|
|
always @(negedge CLK)
|
155 |
|
|
if (RESET)
|
156 |
|
|
HLDA <= 1'b0;
|
157 |
|
|
else begin
|
158 |
|
|
if (HOLD) begin
|
159 |
|
|
if (Tcyc==T1) HLDA <= 1'b1;
|
160 |
|
|
if (Tcyc==T4) HLDA <= 1'b1;
|
161 |
|
|
end
|
162 |
|
|
else
|
163 |
|
|
HLDA <= 1'b0;
|
164 |
|
|
end
|
165 |
|
|
|
166 |
|
|
endmodule
|
167 |
|
|
|