1 |
2 |
robfinch |
`timescale 1ns / 1ps
|
2 |
|
|
// ============================================================================
|
3 |
|
|
// __
|
4 |
|
|
// \\__/ o\ (C) 2015-2022 Robert Finch, Waterloo
|
5 |
|
|
// \ __ / All rights reserved.
|
6 |
|
|
// \/_// robfinch@finitron.ca
|
7 |
|
|
// ||
|
8 |
|
|
//
|
9 |
|
|
// BSD 3-Clause License
|
10 |
|
|
// Redistribution and use in source and binary forms, with or without
|
11 |
|
|
// modification, are permitted provided that the following conditions are met:
|
12 |
|
|
//
|
13 |
|
|
// 1. Redistributions of source code must retain the above copyright notice, this
|
14 |
|
|
// list of conditions and the following disclaimer.
|
15 |
|
|
//
|
16 |
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice,
|
17 |
|
|
// this list of conditions and the following disclaimer in the documentation
|
18 |
|
|
// and/or other materials provided with the distribution.
|
19 |
|
|
//
|
20 |
|
|
// 3. Neither the name of the copyright holder nor the names of its
|
21 |
|
|
// contributors may be used to endorse or promote products derived from
|
22 |
|
|
// this software without specific prior written permission.
|
23 |
|
|
//
|
24 |
|
|
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
25 |
|
|
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
26 |
|
|
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
27 |
|
|
// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
28 |
|
|
// FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
29 |
|
|
// DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
30 |
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
31 |
|
|
// CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
32 |
|
|
// OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
33 |
|
|
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
34 |
|
|
//
|
35 |
|
|
// ============================================================================
|
36 |
|
|
//
|
37 |
|
|
import mpmc8_pkg::*;
|
38 |
|
|
|
39 |
|
|
module mpmc8_addr_select(rst, clk, state, ch,
|
40 |
|
|
we0, we1, we2, we3, we4, we5, we6, we7,
|
41 |
|
|
adr0, adr1, adr2, adr3, adr4, adr5, adr6, adr7,
|
42 |
|
|
adr);
|
43 |
|
|
parameter S0 = 3'd7;
|
44 |
|
|
parameter S1 = 3'd1;
|
45 |
|
|
parameter S2 = 3'd0;
|
46 |
|
|
parameter S3 = 3'd0;
|
47 |
|
|
parameter S4 = 3'd0;
|
48 |
|
|
parameter S5 = 3'd3;
|
49 |
|
|
parameter S6 = 3'd0;
|
50 |
|
|
parameter S7 = 3'd3;
|
51 |
|
|
input rst;
|
52 |
|
|
input clk;
|
53 |
|
|
input [3:0] state;
|
54 |
|
|
input [3:0] ch;
|
55 |
|
|
input we0;
|
56 |
|
|
input we1;
|
57 |
|
|
input we2;
|
58 |
|
|
input we3;
|
59 |
|
|
input we4;
|
60 |
|
|
input we5;
|
61 |
|
|
input we6;
|
62 |
|
|
input we7;
|
63 |
|
|
input [31:0] adr0;
|
64 |
|
|
input [31:0] adr1;
|
65 |
|
|
input [31:0] adr2;
|
66 |
|
|
input [31:0] adr3;
|
67 |
|
|
input [31:0] adr4;
|
68 |
|
|
input [31:0] adr5;
|
69 |
|
|
input [31:0] adr6;
|
70 |
|
|
input [31:0] adr7;
|
71 |
|
|
output reg [31:0] adr;
|
72 |
|
|
|
73 |
|
|
// Select the address input
|
74 |
|
|
reg [31:0] adrx;
|
75 |
|
|
always_ff @(posedge clk)
|
76 |
|
|
if (state==IDLE) begin
|
77 |
|
|
case(ch)
|
78 |
|
|
3'd0: if (we0)
|
79 |
|
|
adrx <= {adr0[AMSB:4],4'h0};
|
80 |
|
|
else
|
81 |
|
|
case(S0)
|
82 |
|
|
3'd0: adrx <= {adr0[AMSB:4],4'h0};
|
83 |
|
|
3'd1: adrx <= {adr0[AMSB:5],5'h0};
|
84 |
|
|
3'd3: adrx <= {adr0[AMSB:6],6'h0};
|
85 |
|
|
3'd7: adrx <= {adr0[AMSB:7],7'h0};
|
86 |
|
|
default: adrx <= {adr0[AMSB:7],7'h0};
|
87 |
|
|
endcase
|
88 |
|
|
3'd1: if (we1)
|
89 |
|
|
adrx <= {adr1[AMSB:4],4'h0};
|
90 |
|
|
else
|
91 |
|
|
case(S1)
|
92 |
|
|
3'd0: adrx <= {adr1[AMSB:4],4'h0};
|
93 |
|
|
3'd1: adrx <= {adr1[AMSB:5],5'h0};
|
94 |
|
|
3'd3: adrx <= {adr1[AMSB:6],6'h0};
|
95 |
|
|
3'd7: adrx <= {adr1[AMSB:7],7'h0};
|
96 |
|
|
default: adrx <= {adr1[AMSB:5],5'h0};
|
97 |
|
|
endcase
|
98 |
|
|
3'd2: if (we2)
|
99 |
|
|
adrx <= {adr2[AMSB:4],4'h0};
|
100 |
|
|
else
|
101 |
|
|
case(S2)
|
102 |
|
|
3'd0: adrx <= {adr2[AMSB:4],4'h0};
|
103 |
|
|
3'd1: adrx <= {adr2[AMSB:5],5'h0};
|
104 |
|
|
3'd3: adrx <= {adr2[AMSB:6],6'h0};
|
105 |
|
|
3'd7: adrx <= {adr2[AMSB:7],7'h0};
|
106 |
|
|
default: adrx <= {adr2[AMSB:4],4'h0};
|
107 |
|
|
endcase
|
108 |
|
|
3'd3: if (we3)
|
109 |
|
|
adrx <= {adr3[AMSB:4],4'h0};
|
110 |
|
|
else
|
111 |
|
|
case(S3)
|
112 |
|
|
3'd0: adrx <= {adr3[AMSB:4],4'h0};
|
113 |
|
|
3'd1: adrx <= {adr3[AMSB:5],5'h0};
|
114 |
|
|
3'd3: adrx <= {adr3[AMSB:6],6'h0};
|
115 |
|
|
3'd7: adrx <= {adr3[AMSB:7],7'h0};
|
116 |
|
|
default: adrx <= {adr3[AMSB:4],4'h0};
|
117 |
|
|
endcase
|
118 |
|
|
3'd4: if (we4)
|
119 |
|
|
adrx <= {adr4[AMSB:4],4'h0};
|
120 |
|
|
else
|
121 |
|
|
case(S4)
|
122 |
|
|
3'd0: adrx <= {adr4[AMSB:4],4'h0};
|
123 |
|
|
3'd1: adrx <= {adr4[AMSB:5],5'h0};
|
124 |
|
|
3'd3: adrx <= {adr4[AMSB:6],6'h0};
|
125 |
|
|
3'd7: adrx <= {adr4[AMSB:7],7'h0};
|
126 |
|
|
default: adrx <= {adr4[AMSB:4],4'h0};
|
127 |
|
|
endcase
|
128 |
|
|
3'd5: if (we5)
|
129 |
|
|
adrx <= {adr5[AMSB:6],6'h0};
|
130 |
|
|
else
|
131 |
|
|
case(S5)
|
132 |
|
|
3'd0: adrx <= {adr5[AMSB:4],4'h0};
|
133 |
|
|
3'd1: adrx <= {adr5[AMSB:5],5'h0};
|
134 |
|
|
3'd3: adrx <= {adr5[AMSB:6],6'h0};
|
135 |
|
|
3'd7: adrx <= {adr5[AMSB:7],7'h0};
|
136 |
|
|
default: adrx <= {adr5[AMSB:6],6'h0};
|
137 |
|
|
endcase
|
138 |
|
|
3'd6: if (we6)
|
139 |
|
|
adrx <= {adr6[AMSB:4],4'h0};
|
140 |
|
|
else
|
141 |
|
|
case(S6)
|
142 |
|
|
3'd0: adrx <= {adr6[AMSB:4],4'h0};
|
143 |
|
|
3'd1: adrx <= {adr6[AMSB:5],5'h0};
|
144 |
|
|
3'd3: adrx <= {adr6[AMSB:6],6'h0};
|
145 |
|
|
3'd7: adrx <= {adr6[AMSB:7],7'h0};
|
146 |
|
|
default: adrx <= {adr6[AMSB:4],4'h0};
|
147 |
|
|
endcase
|
148 |
|
|
3'd7: if (we7)
|
149 |
|
|
adrx <= {adr7[AMSB:4],4'h0};
|
150 |
|
|
else
|
151 |
|
|
case(S7)
|
152 |
|
|
3'd0: adrx <= {adr7[AMSB:4],4'h0};
|
153 |
|
|
3'd1: adrx <= {adr7[AMSB:5],5'h0};
|
154 |
|
|
3'd3: adrx <= {adr7[AMSB:6],6'h0};
|
155 |
|
|
3'd7: adrx <= {adr7[AMSB:7],7'h0};
|
156 |
|
|
default: adrx <= {adr7[AMSB:6],6'h0};
|
157 |
|
|
endcase
|
158 |
|
|
default: adrx <= 29'h1FFFFFF0;
|
159 |
|
|
endcase
|
160 |
|
|
end
|
161 |
|
|
always_ff @(posedge clk)
|
162 |
|
|
if (rst)
|
163 |
|
|
adr <= 32'h1FFFFFF0;
|
164 |
|
|
else if (state==PRESET1)
|
165 |
|
|
adr <= adrx;
|
166 |
|
|
|
167 |
|
|
endmodule
|