1 |
11 |
juko |
/*
|
2 |
|
|
* .--------------. .----------------. .------------.
|
3 |
|
|
* | .------------. | .--------------. | .----------. |
|
4 |
|
|
* | | ____ ____ | | | ____ ____ | | | ______ | |
|
5 |
|
|
* | ||_ || _|| | ||_ \ / _|| | | .' ___ || |
|
6 |
|
|
* ___ _ __ ___ _ __ | | | |__| | | | | | \/ | | | |/ .' \_|| |
|
7 |
|
|
* / _ \| '_ \ / _ \ '_ \ | | | __ | | | | | |\ /| | | | || | | |
|
8 |
|
|
* (_) | |_) | __/ | | || | _| | | |_ | | | _| |_\/_| |_ | | |\ `.___.'\| |
|
9 |
|
|
* \___/| .__/ \___|_| |_|| ||____||____|| | ||_____||_____|| | | `._____.'| |
|
10 |
|
|
* | | | | | | | | | | | |
|
11 |
|
|
* |_| | '------------' | '--------------' | '----------' |
|
12 |
|
|
* '--------------' '----------------' '------------'
|
13 |
|
|
*
|
14 |
|
|
* openHMC - An Open Source Hybrid Memory Cube Controller
|
15 |
|
|
* (C) Copyright 2014 Computer Architecture Group - University of Heidelberg
|
16 |
|
|
* www.ziti.uni-heidelberg.de
|
17 |
|
|
* B6, 26
|
18 |
|
|
* 68159 Mannheim
|
19 |
|
|
* Germany
|
20 |
|
|
*
|
21 |
|
|
* Contact: openhmc@ziti.uni-heidelberg.de
|
22 |
|
|
* http://ra.ziti.uni-heidelberg.de/openhmc
|
23 |
|
|
*
|
24 |
|
|
* This source file is free software: you can redistribute it and/or modify
|
25 |
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
26 |
|
|
* the Free Software Foundation, either version 3 of the License, or
|
27 |
|
|
* (at your option) any later version.
|
28 |
|
|
*
|
29 |
|
|
* This source file is distributed in the hope that it will be useful,
|
30 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
31 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
32 |
|
|
* GNU Lesser General Public License for more details.
|
33 |
|
|
*
|
34 |
|
|
* You should have received a copy of the GNU Lesser General Public License
|
35 |
|
|
* along with this source file. If not, see <http://www.gnu.org/licenses/>.
|
36 |
|
|
*
|
37 |
|
|
*
|
38 |
|
|
* Module name: openhmc_sync_fifo_reg_stage
|
39 |
|
|
*
|
40 |
|
|
*/
|
41 |
|
|
|
42 |
|
|
`default_nettype none
|
43 |
|
|
|
44 |
|
|
module openhmc_sync_fifo_reg_stage #(parameter DWIDTH = 8)(
|
45 |
|
|
input wire clk,
|
46 |
|
|
input wire res_n,
|
47 |
|
|
input wire [DWIDTH-1:0] d_in,
|
48 |
|
|
input wire [DWIDTH-1:0] d_in_p,
|
49 |
|
|
input wire p_full, // full signal from the previous stage
|
50 |
|
|
input wire n_full, // full signal from the next stage
|
51 |
|
|
input wire si,
|
52 |
|
|
input wire so,
|
53 |
|
|
output reg full, // full = '1' -> this stage has a valid entry
|
54 |
|
|
output reg [DWIDTH-1:0] d_out
|
55 |
|
|
);
|
56 |
|
|
|
57 |
|
|
//=====================================================================================================
|
58 |
|
|
//-----------------------------------------------------------------------------------------------------
|
59 |
|
|
//---------WIRING AND SIGNAL STUFF---------------------------------------------------------------------
|
60 |
|
|
//-----------------------------------------------------------------------------------------------------
|
61 |
|
|
//=====================================================================================================
|
62 |
|
|
|
63 |
|
|
wire en, muxi;
|
64 |
|
|
|
65 |
|
|
assign en = (si & so & full) // so and si, shift through
|
66 |
|
|
| (si & ~so & ~full && n_full) // shift in new value
|
67 |
|
|
| (~si & so & p_full); // shift through
|
68 |
|
|
|
69 |
|
|
assign muxi = (si & ~so) | (si & so & ~p_full & full);
|
70 |
|
|
|
71 |
|
|
//=====================================================================================================
|
72 |
|
|
//-----------------------------------------------------------------------------------------------------
|
73 |
|
|
//---------LOGIC STARTS HERE---------------------------------------------------------------------------
|
74 |
|
|
//-----------------------------------------------------------------------------------------------------
|
75 |
|
|
//=====================================================================================================
|
76 |
|
|
|
77 |
|
|
always @ (posedge clk or negedge res_n) begin
|
78 |
|
|
if (!res_n) begin
|
79 |
|
|
full <= 1'b0;
|
80 |
|
|
d_out <= {DWIDTH{1'b0}};
|
81 |
|
|
end else begin
|
82 |
|
|
if (en) begin
|
83 |
|
|
if (muxi) begin
|
84 |
|
|
d_out <= d_in; // enter new value when enabled
|
85 |
|
|
end else begin
|
86 |
|
|
d_out <= d_in_p; // shift through
|
87 |
|
|
end
|
88 |
|
|
end
|
89 |
|
|
|
90 |
|
|
full <= (full & si) // stay full while si to other stage
|
91 |
|
|
| (full & ~si & ~so) // hold full
|
92 |
|
|
| (~si & so & p_full) // keep full as long as prev stage is full
|
93 |
|
|
| (si & ~so & n_full); // fill this stage by si
|
94 |
|
|
end
|
95 |
|
|
end
|
96 |
|
|
|
97 |
|
|
endmodule
|
98 |
|
|
|
99 |
|
|
`default_nettype wire
|
100 |
|
|
|