OpenCores
URL https://opencores.org/ocsvn/openhmc/openhmc/trunk

Subversion Repositories openhmc

[/] [openhmc/] [trunk/] [openHMC/] [rtl/] [building_blocks/] [fifos/] [sync/] [xilinx/] [openhmc_srl_fifo_16.v] - Blame information for rev 15

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 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_srl_fifo_16
39
 *
40
 */
41
 
42
`default_nettype none
43
 
44
module openhmc_srl_fifo_16 #(
45
`ifdef CAG_ASSERTIONS
46
                parameter DISABLE_EMPTY_ASSERT  = 0,
47
                parameter DISABLE_FULL_ASSERT   = 0,
48
`endif
49
                parameter DWIDTH                                = 8
50
        ) (
51
                input wire                              clk,
52
                input wire                              res_n,
53
                input wire [DWIDTH-1:0]  d_in,
54
                input wire                              shift_in,
55
                input wire                              shift_out,
56
 
57
                output wire [DWIDTH-1:0]d_out,
58
                output reg                              full,
59
                output reg                              empty,
60
                output reg                              almost_full,
61
                output reg                              almost_empty
62
        );
63
 
64
        reg [3:0]        count;
65
        wire            shift_out_notempty;
66
        wire            shift_in_notfull;
67
 
68
        genvar          i;
69
 
70
        assign shift_out_notempty       = (shift_out && !empty);
71
        assign shift_in_notfull         = (shift_in  && !full);
72
 
73
        generate
74
                for (i=0; i < DWIDTH; i=i+1)
75
                begin: generate_SRL16
76
                        SRL16E #(.INIT(16'h0000)) SRL16_I (
77
                                .Q(d_out[i]),   // SRL data output
78
                                .A0(count[0]),   // Select[0] input
79
                                .A1(count[1]),  // Select[1] input
80
                                .A2(count[2]),  // Select[2] input
81
                                .A3(count[3]),  // Select[3] input
82
                                .CLK(clk),
83
                                .D(d_in[i]),            // SRL data input
84
                                .CE(shift_in_notfull)
85
                        );
86
                end
87
        endgenerate
88
 
89
        `ifdef ASYNC_RES
90
        always @(posedge clk or negedge res_n) `else
91
        always @(posedge clk) `endif
92
        begin
93
                if (!res_n)
94
                begin
95
                        count                                   <= 4'b0;
96
                        full                                    <= 1'b0;
97
                        almost_full                             <= 1'b0;
98
                        empty                                   <= 1'b1;
99
                        almost_empty                    <= 1'b1;
100
                end
101
                else
102
                begin
103
                        case ({shift_in_notfull, shift_out_notempty})
104
                                2'b00: ; // nothing to do
105
                                2'b01:
106
                                begin
107
                                        if (|count)
108
                                                count           <= count - 1'b1;
109
                                        empty                   <= !(|count);
110
                                        almost_empty    <= (count <= 1);
111
                                        full                    <= 1'b0;
112
                                        almost_full             <= (count > (4'd15 - 1));
113
                                end
114
                                2'b10:
115
                                begin
116
                                        if (!empty)
117
                                                count           <= count + 1'b1;
118
                                        empty                   <= 1'b0;
119
                                        almost_empty    <= empty;
120
                                        full                    <= (count > 4'd13);
121
                                        almost_full             <= (count > (4'd13 - 1));
122
                                end
123
                                2'b11: ;
124
                        endcase
125
                end
126
        end
127
 
128
`ifdef CAG_COVERAGE
129
        full_cov:                       cover property (@(posedge clk) disable iff(!res_n) (full == 1'b1));
130
        almost_full_cov:        cover property (@(posedge clk) disable iff(!res_n) (almost_full == 1'b1));
131
        empty_cov:                      cover property (@(posedge clk) disable iff(!res_n) (empty == 1'b1));
132
        almost_empty_cov:       cover property (@(posedge clk) disable iff(!res_n) (almost_empty == 1'b1));
133
`endif // CAG_COVERAGE
134
 
135
`ifdef CAG_ASSERTIONS
136
        final
137
        begin
138
                if (DISABLE_FULL_ASSERT == 0)
139
                begin
140
                        full_set_assert: assert (!full);
141
                        almost_full_set_assert:                 assert (!almost_full);
142
                end
143
 
144
                if (DISABLE_EMPTY_ASSERT == 0)
145
                begin
146
                        almost_empty_not_set_assert:    assert (almost_empty);
147
                        empty_not_set_assert:                   assert (empty);
148
                end
149
        end
150
`endif // CAG_ASSERTIONS
151
 
152
endmodule
153
 
154
`default_nettype wire

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.