-
Notifications
You must be signed in to change notification settings - Fork 1
/
xbus_spy.v
70 lines (51 loc) · 1.47 KB
/
xbus_spy.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
// xbus_spy.v --- ---!!!
/* verilator lint_off WIDTH */
`timescale 1ns/1ps
`default_nettype none
module xbus_spy
(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,
input wire [15:0] spyin,
output reg [15:0] spyout,
output wire [3:0] spyreg,
output wire spyrd,
output wire spywr,
input wire clk,
input wire reset);
////////////////////////////////////////////////////////////////////////////////
reg [2:0] ack_delayed = 0;
reg [2:0] ack_state = 0;
wire spyrd_d;
always @(posedge clk) begin
ack_delayed <= { ack_delayed[1:0], decode};
ack_state <= { ack_state[1:0], ~ack_delayed[0] && decode };
end
assign spyrd_d = ack_state[1] && ~write;
always @(posedge clk) begin
if (spyrd_d) begin
dataout <= spyin;
end
if (req & decode) begin
if (write) begin
spyout <= datain[15:0];
end else begin
// Nothing on read.
end
end
end
assign decode = req & ({addr[21:6], 6'b0} == 22'o17766000);
assign ack = ack_delayed[2];
////////////////////////////////////////////////////////////////////////////////
assign spyreg = addr[3:0];
assign spyrd = ack_state[0] && ~write;
assign spywr = ack_state[0] && write;
endmodule
`default_nettype wire
// Local Variables:
// verilog-library-directories: (".")
// End: