-
Notifications
You must be signed in to change notification settings - Fork 1
/
xbus_unibus.v
158 lines (128 loc) · 3.37 KB
/
xbus_unibus.v
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// xbus_unibus.v --- diagnostics interface
`timescale 1ns/1ps
`default_nettype none
module xbus_unibus (
input wire [21:0] addr,
input wire [31:0] datain,
input wire req,
input wire write,
output reg [31:0] dataout,
output wire ack,
output wire decode,
output wire interrupt,
input wire timedout,
output reg promdisable,
input wire clk,
input wire reset);
////////////////////////////////////////////////////////////////////////////////
// Unibus & XBUS NXM
reg unibus_nxm = 1'b0;
reg xbus_nxm = 1'b0;
reg clear_bus_status = 1'b0;
always @(posedge clk)
if (timedout) begin
if (addr > 22'o17400000)
unibus_nxm <= 1'b1;
else if (addr > 22'o17000000)
xbus_nxm <= 1'b1;
end else if (clear_bus_status) begin
unibus_nxm <= 1'b0;
xbus_nxm <= 1'b0;
end
////////////////////////////////////////////////////////////////////////////////
// Bus interrupts
reg unibus_int = 1'b0;
reg [7:0] unibus_vector = 8'b0;
reg xbus_int = 1'b0; // ---!!! Not used?
reg unibus_int_en = 1'b0;
reg clear_unibus_int_en = 1'b0;
reg set_unibus_int_en = 1'b0;
reg clear_bus_ints = 1'b0;
always @(posedge clk) begin
if (clear_bus_ints) begin
unibus_int <= 1'b0;
unibus_vector <= 8'b0;
end
if (set_unibus_int_en)
unibus_int_en <= 1'b1;
if (clear_unibus_int_en)
unibus_int_en <= 1'b1;
end
////////////////////////////////////////////////////////////////////////////////
task bus_write;
input [21:0] addr;
begin
case (addr)
22'o17773005: begin
if (datain[5] && datain[2] && ~datain[0])
promdisable = 1;
end
22'o17773020: begin
if (datain[10])
set_unibus_int_en = 1;
else
clear_unibus_int_en = 1;
clear_bus_ints = 1;
end
22'o17773022:
clear_bus_status = 1;
endcase
end
endtask
task bus_read;
input [21:0] addr;
begin
case (addr)
22'o17773020:
dataout = { 14'b0,
2'b0, unibus_int,
xbus_int, 2'b0,
1'b0, unibus_int_en, unibus_vector, 2'b0 };
22'o17773022:
dataout = { 28'b0, unibus_nxm, 2'b0, xbus_nxm };
endcase
end
endtask
wire in_unibus, decode_unibus;
wire in_other, decode_other;
assign in_unibus = ({addr[21:6], 6'b0} == 22'o17773000);
assign decode_unibus = req & in_unibus;
// ---!!! Not used?
assign in_other = ({addr[21:6], 6'b0} == 22'o17777700) |
({addr[21:12], 12'b0} == 22'o17740000);
assign decode_other = req & in_other;
always @(posedge clk) begin
promdisable = 0;
clear_bus_status = 0;
clear_bus_ints = 0;
set_unibus_int_en = 0;
clear_unibus_int_en = 0;
dataout = 0;
if (decode_unibus) begin
if (write) begin
bus_write(addr);
end else begin
bus_read(addr);
end
end
// ---!!! Not used?
if (decode_other)
if (write) begin
// Nothing.
end else begin
dataout = 0;
end
end
reg [1:0] ack_delayed = 0;
always @(posedge clk) begin
ack_delayed[0] <= decode;
ack_delayed[1] <= ack_delayed[0];
end
assign ack = ack_delayed[1];
assign decode = decode_unibus || decode_other;
assign interrupt = 0; // ---!!! Not used?
endmodule
`default_nettype wire
// Local Variables:
// verilog-library-directories: (".")
// End: