mbus_mon.v
3.06 KB
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
module mbus_mon(clock, reset_l, p_valid_l, e_valid_l, e_ok_l, int_l,
sys_ad, sys_cmd);
`include "rcp.vh"
`include "define.vh"
input clock;
input reset_l;
input e_valid_l;
input e_ok_l;
input int_l;
input p_valid_l;
input [SYS_AD_SIZE-1:0] sys_ad;
input [SYS_CMD_SIZE-1:0] sys_cmd;
reg read_cycle;
reg write_cycle;
reg e_ok_l_d1;
reg sys_cmd_data;
reg sys_cmd_write;
reg sys_cmd_block;
reg [SYS_CMD_BLOCK_SIZE-1:0] sys_cmd_block_size;
reg monitor_enable;
initial monitor_enable = $test$plusargs("mbus_mon");
always @(posedge clock) begin
if (!reset_l) begin
read_cycle <= LOW;
write_cycle <= LOW;
e_ok_l_d1 <= HIGH;
end
else if (monitor_enable) begin
if (read_cycle) begin
if (!e_valid_l) begin
if (sys_cmd[SYS_CMD_MORE]) begin
$display(`CLOCK_COUNT, " : mbus read data next - data = %h", sys_ad);
end
else begin
$display(`CLOCK_COUNT, " : mbus read data last - data = %h", sys_ad);
read_cycle <= LOW;
end
end
end
else if (write_cycle) begin
if (!p_valid_l) begin
if (sys_cmd[SYS_CMD_MORE]) begin
$display(`CLOCK_COUNT, " : mbus write data next - data = %h", sys_ad);
end
else begin
$display(`CLOCK_COUNT, " : mbus write data last - data = %h", sys_ad);
write_cycle <= LOW;
end
end
else begin
$display("%m: Panic! p_valid_l unexpectly deasserted - %h", p_valid_l);
$finish;
end
end
else if (!p_valid_l && !e_ok_l && !e_ok_l_d1) begin
{sys_cmd_data, sys_cmd_write, sys_cmd_block, sys_cmd_block_size} = sys_cmd;
casez ({sys_cmd_data, sys_cmd_write, sys_cmd_block})
'b000 : begin
$display(`CLOCK_COUNT, " : mbus read word - address = %h, length = %h",
sys_ad, sys_cmd_block_size);
read_cycle <= HIGH;
end
'b001 : begin
$display(`CLOCK_COUNT, " : mbus read block - address = %h, length = %h",
sys_ad, sys_cmd_block_size);
read_cycle <= HIGH;
end
'b010 : begin
$display(`CLOCK_COUNT, " : mbus write word - address = %h, length = %h",
sys_ad, sys_cmd_block_size);
write_cycle <= HIGH;
end
'b011 : begin
$display(`CLOCK_COUNT, " : mbus write block - address = %h, length = %h",
sys_ad, sys_cmd_block_size);
write_cycle <= HIGH;
end
'b1?? : begin
$display("%m: Panic! Data command during command cycle - %h", sys_cmd);
$finish;
end
default : begin
$display("%m: Panic! Unknown processor command - %h", sys_cmd);
$finish;
end
endcase
end
end
e_ok_l_d1 <= e_ok_l;
end
endmodule