forked from ZipCPU/wb2axip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
wbc2pipeline.v
188 lines (179 loc) · 4.85 KB
/
wbc2pipeline.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
////////////////////////////////////////////////////////////////////////////////
//
// Filename: wbc2pipeline.v
// {{{
// Project: WB2AXIPSP: bus bridges and other odds and ends
//
// Purpose: Takes a WB classic connection from a master, and converts it
// to WB pipelined for the slave.
//
// If you don't see an `ifdef FORMAL section below, then this core hasn't
// (yet) been formally verified. Use it at your own risk.
//
// Creator: Dan Gisselquist, Ph.D.
// Gisselquist Technology, LLC
//
////////////////////////////////////////////////////////////////////////////////
// }}}
// Copyright (C) 2019-2022, Gisselquist Technology, LLC
// {{{
// This file is part of the WB2AXIP project.
//
// The WB2AXIP project contains free software and gateware, licensed under the
// Apache License, Version 2.0 (the "License"). You may not use this project,
// or this file, except in compliance with the License. You may obtain a copy
// of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
// WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
// License for the specific language governing permissions and limitations
// under the License.
//
////////////////////////////////////////////////////////////////////////////////
//
//
`default_nettype none
// }}}
module wbc2pipeline #(
// {{{
parameter AW = 12,
DW = 32
// }}}
) (
// {{{
//
input wire i_clk, i_reset,
//
// Incoming WB classic port
input wire i_scyc, i_sstb, i_swe,
input wire [AW-1:0] i_saddr,
input wire [DW-1:0] i_sdata,
input wire [DW/8-1:0] i_ssel,
output reg o_sack,
output reg [DW-1:0] o_sdata,
output reg o_serr,
input wire [3-1:0] i_scti,
input wire [2-1:0] i_sbte,
//
// Outgoing WB pipelined port
output reg o_mcyc, o_mstb, o_mwe,
output reg [AW-1:0] o_maddr,
output reg [DW-1:0] o_mdata,
output reg [DW/8-1:0] o_msel,
input wire i_mstall,
input wire i_mack,
input wire [DW-1:0] i_mdata,
input wire i_merr
// }}}
);
reg last_stb;
// last_stb
// {{{
initial last_stb = 0;
always @(posedge i_clk)
if (i_reset || !i_sstb || o_sack || o_serr)
last_stb <= 0;
else if (!i_mstall)
last_stb <= 1;
// }}}
// Combinatorial assignments to the downstream port
// {{{
always @(*)
begin
o_mcyc = i_scyc && (!o_serr);
o_mstb = i_sstb & !last_stb && (!o_serr);
o_mwe = i_swe;
o_maddr = i_saddr;
o_mdata = i_sdata;
o_msel = i_ssel;
end
// }}}
// o_sack, o_serr
// {{{
initial o_sack = 0;
initial o_serr = 0;
always @(posedge i_clk)
if (i_reset || !i_sstb || o_sack || o_serr)
begin
o_sack <= 0;
o_serr <= 0;
end else begin
if (i_mack)
o_sack <= 1;
if (i_merr)
o_serr <= 1;
end
// }}}
// o_sdata
// {{{
always @(posedge i_clk)
if (i_mack)
o_sdata <= i_mdata;
// }}}
// Make Verilator happy
// {{{
// Verilator lint_off UNUSED
wire [4:0] unused;
assign unused = { i_scti, i_sbte };
// Verilator lint_on UNUSED
// }}}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
//
// Formal properties
// {{{
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
`ifdef FORMAL
////////////////////////////////////////////////////////////////////////
//
//
//
////////////////////////////////////////////////////////////////////////
//
//
localparam F_LGDEPTH = 1;
reg [F_LGDEPTH-1:0] f_nreqs, f_nacks, f_outstanding;
reg f_past_valid;
initial f_past_valid = 0;
always @(posedge i_clk)
f_past_valid = 1;
always @(*)
if (!f_past_valid)
assume(i_reset);
////////////////////////////////////////////////////////////////////////
//
// Upstream Wishbone classic slave properties
// {{{
////////////////////////////////////////////////////////////////////////
//
fwbc_slave #(.AW(AW), .DW(DW)) incoming (i_clk, i_reset,
i_scyc, i_sstb, i_swe, i_saddr, i_sdata, i_ssel,
i_scti, i_sbte,
o_sack, o_sdata, o_serr, 1'b0);
// }}}
////////////////////////////////////////////////////////////////////////
//
// Downstream Wishbone pipeline slave properties
// {{{
////////////////////////////////////////////////////////////////////////
//
fwb_master #(.AW(AW), .DW(DW),
.F_MAX_STALL(3),
.F_MAX_ACK_DELAY(3),
.F_LGDEPTH(1)) pipelined (i_clk, i_reset,
o_mcyc, o_mstb, o_mwe, o_maddr, o_mdata, o_msel,
i_mack, i_mstall, i_mdata, i_merr,
f_nreqs, f_nacks, f_outstanding);
// }}}
`endif
// }}}
endmodule
`ifndef YOSYS
`default_nettype wire
`endif