1 |
14 |
mjlyons |
//----------------------------------------------------------------------------
|
2 |
|
|
// user_logic.vhd - module
|
3 |
|
|
//----------------------------------------------------------------------------
|
4 |
|
|
//
|
5 |
|
|
// ***************************************************************************
|
6 |
|
|
// ** Copyright (c) 1995-2011 Xilinx, Inc. All rights reserved. **
|
7 |
|
|
// ** **
|
8 |
|
|
// ** Xilinx, Inc. **
|
9 |
|
|
// ** XILINX IS PROVIDING THIS DESIGN, CODE, OR INFORMATION "AS IS" **
|
10 |
|
|
// ** AS A COURTESY TO YOU, SOLELY FOR USE IN DEVELOPING PROGRAMS AND **
|
11 |
|
|
// ** SOLUTIONS FOR XILINX DEVICES. BY PROVIDING THIS DESIGN, CODE, **
|
12 |
|
|
// ** OR INFORMATION AS ONE POSSIBLE IMPLEMENTATION OF THIS FEATURE, **
|
13 |
|
|
// ** APPLICATION OR STANDARD, XILINX IS MAKING NO REPRESENTATION **
|
14 |
|
|
// ** THAT THIS IMPLEMENTATION IS FREE FROM ANY CLAIMS OF INFRINGEMENT, **
|
15 |
|
|
// ** AND YOU ARE RESPONSIBLE FOR OBTAINING ANY RIGHTS YOU MAY REQUIRE **
|
16 |
|
|
// ** FOR YOUR IMPLEMENTATION. XILINX EXPRESSLY DISCLAIMS ANY **
|
17 |
|
|
// ** WARRANTY WHATSOEVER WITH RESPECT TO THE ADEQUACY OF THE **
|
18 |
|
|
// ** IMPLEMENTATION, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OR **
|
19 |
|
|
// ** REPRESENTATIONS THAT THIS IMPLEMENTATION IS FREE FROM CLAIMS OF **
|
20 |
|
|
// ** INFRINGEMENT, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS **
|
21 |
|
|
// ** FOR A PARTICULAR PURPOSE. **
|
22 |
|
|
// ** **
|
23 |
|
|
// ***************************************************************************
|
24 |
|
|
//
|
25 |
|
|
//----------------------------------------------------------------------------
|
26 |
|
|
// Filename: user_logic.vhd
|
27 |
|
|
// Version: 1.00.a
|
28 |
|
|
// Description: User logic module.
|
29 |
|
|
// Date: Wed Oct 19 16:39:24 2011 (by Create and Import Peripheral Wizard)
|
30 |
|
|
// Verilog Standard: Verilog-2001
|
31 |
|
|
//----------------------------------------------------------------------------
|
32 |
|
|
// Naming Conventions:
|
33 |
|
|
// active low signals: "*_n"
|
34 |
|
|
// clock signals: "clk", "clk_div#", "clk_#x"
|
35 |
|
|
// reset signals: "rst", "rst_n"
|
36 |
|
|
// generics: "C_*"
|
37 |
|
|
// user defined types: "*_TYPE"
|
38 |
|
|
// state machine next state: "*_ns"
|
39 |
|
|
// state machine current state: "*_cs"
|
40 |
|
|
// combinatorial signals: "*_com"
|
41 |
|
|
// pipelined or register delay signals: "*_d#"
|
42 |
|
|
// counter signals: "*cnt*"
|
43 |
|
|
// clock enable signals: "*_ce"
|
44 |
|
|
// internal version of output port: "*_i"
|
45 |
|
|
// device pins: "*_pin"
|
46 |
|
|
// ports: "- Names begin with Uppercase"
|
47 |
|
|
// processes: "*_PROCESS"
|
48 |
|
|
// component instantiations: "<ENTITY_>I_<#|FUNC>"
|
49 |
|
|
//----------------------------------------------------------------------------
|
50 |
|
|
|
51 |
|
|
module user_logic
|
52 |
|
|
(
|
53 |
|
|
// -- ADD USER PORTS BELOW THIS LINE ---------------
|
54 |
|
|
// --USER ports added here
|
55 |
|
|
SPI_CLK,
|
56 |
|
|
SPI_MISO,
|
57 |
|
|
SPI_MOSI,
|
58 |
|
|
SPI_SS,
|
59 |
|
|
DebugLeds,
|
60 |
|
|
// -- ADD USER PORTS ABOVE THIS LINE ---------------
|
61 |
|
|
|
62 |
|
|
// -- DO NOT EDIT BELOW THIS LINE ------------------
|
63 |
|
|
// -- Bus protocol ports, do not add to or delete
|
64 |
|
|
Bus2IP_Clk, // Bus to IP clock
|
65 |
|
|
Bus2IP_Reset, // Bus to IP reset
|
66 |
|
|
Bus2IP_Addr, // Bus to IP address bus
|
67 |
|
|
Bus2IP_CS, // Bus to IP chip select for user logic memory selection
|
68 |
|
|
Bus2IP_RNW, // Bus to IP read/not write
|
69 |
|
|
Bus2IP_Data, // Bus to IP data bus
|
70 |
|
|
Bus2IP_BE, // Bus to IP byte enables
|
71 |
|
|
Bus2IP_RdCE, // Bus to IP read chip enable
|
72 |
|
|
Bus2IP_WrCE, // Bus to IP write chip enable
|
73 |
|
|
Bus2IP_Burst, // Bus to IP burst-mode qualifier
|
74 |
|
|
Bus2IP_BurstLength, // Bus to IP burst length
|
75 |
|
|
Bus2IP_RdReq, // Bus to IP read request
|
76 |
|
|
Bus2IP_WrReq, // Bus to IP write request
|
77 |
|
|
IP2Bus_AddrAck, // IP to Bus address acknowledgement
|
78 |
|
|
IP2Bus_Data, // IP to Bus data bus
|
79 |
|
|
IP2Bus_RdAck, // IP to Bus read transfer acknowledgement
|
80 |
|
|
IP2Bus_WrAck, // IP to Bus write transfer acknowledgement
|
81 |
|
|
IP2Bus_Error, // IP to Bus error response
|
82 |
|
|
IP2Bus_IntrEvent // IP to Bus interrupt event
|
83 |
|
|
// -- DO NOT EDIT ABOVE THIS LINE ------------------
|
84 |
|
|
); // user_logic
|
85 |
|
|
|
86 |
|
|
// -- ADD USER PARAMETERS BELOW THIS LINE ------------
|
87 |
|
|
// --USER parameters added here
|
88 |
|
|
// -- ADD USER PARAMETERS ABOVE THIS LINE ------------
|
89 |
|
|
|
90 |
|
|
// -- DO NOT EDIT BELOW THIS LINE --------------------
|
91 |
|
|
// -- Bus protocol parameters, do not add to or delete
|
92 |
|
|
parameter C_SLV_AWIDTH = 32;
|
93 |
|
|
parameter C_SLV_DWIDTH = 32;
|
94 |
|
|
parameter C_NUM_REG = 16;
|
95 |
|
|
parameter C_NUM_MEM = 1;
|
96 |
|
|
parameter C_NUM_INTR = 1;
|
97 |
|
|
// -- DO NOT EDIT ABOVE THIS LINE --------------------
|
98 |
|
|
|
99 |
|
|
// -- ADD USER PORTS BELOW THIS LINE -----------------
|
100 |
|
|
// --USER ports added here
|
101 |
|
|
input SPI_CLK;
|
102 |
|
|
output SPI_MISO;
|
103 |
|
|
input SPI_MOSI;
|
104 |
|
|
input SPI_SS;
|
105 |
|
|
output [0:7] DebugLeds;
|
106 |
|
|
// -- ADD USER PORTS ABOVE THIS LINE -----------------
|
107 |
|
|
|
108 |
|
|
// -- DO NOT EDIT BELOW THIS LINE --------------------
|
109 |
|
|
// -- Bus protocol ports, do not add to or delete
|
110 |
|
|
input Bus2IP_Clk;
|
111 |
|
|
input Bus2IP_Reset;
|
112 |
|
|
input [0 : C_SLV_AWIDTH-1] Bus2IP_Addr;
|
113 |
|
|
input [0 : C_NUM_MEM-1] Bus2IP_CS;
|
114 |
|
|
input Bus2IP_RNW;
|
115 |
|
|
input [0 : C_SLV_DWIDTH-1] Bus2IP_Data;
|
116 |
|
|
input [0 : C_SLV_DWIDTH/8-1] Bus2IP_BE;
|
117 |
|
|
input [0 : C_NUM_REG-1] Bus2IP_RdCE;
|
118 |
|
|
input [0 : C_NUM_REG-1] Bus2IP_WrCE;
|
119 |
|
|
input Bus2IP_Burst;
|
120 |
|
|
input [0 : 8] Bus2IP_BurstLength;
|
121 |
|
|
input Bus2IP_RdReq;
|
122 |
|
|
input Bus2IP_WrReq;
|
123 |
|
|
output IP2Bus_AddrAck;
|
124 |
|
|
output [0 : C_SLV_DWIDTH-1] IP2Bus_Data;
|
125 |
|
|
output IP2Bus_RdAck;
|
126 |
|
|
output IP2Bus_WrAck;
|
127 |
|
|
output IP2Bus_Error;
|
128 |
|
|
output [0 : C_NUM_INTR-1] IP2Bus_IntrEvent;
|
129 |
|
|
// -- DO NOT EDIT ABOVE THIS LINE --------------------
|
130 |
|
|
|
131 |
|
|
//----------------------------------------------------------------------------
|
132 |
|
|
// Implementation
|
133 |
|
|
//----------------------------------------------------------------------------
|
134 |
|
|
|
135 |
|
|
// --USER nets declarations added here, as needed for user logic
|
136 |
|
|
assign DebugLeds = debugLedsReg;
|
137 |
|
|
reg [7:0] debugLedsReg;
|
138 |
|
|
|
139 |
|
|
// Nets for user logic slave model s/w accessible register example
|
140 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg0;
|
141 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg1;
|
142 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg2;
|
143 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg3;
|
144 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg4;
|
145 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg5;
|
146 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg6;
|
147 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg7;
|
148 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg8;
|
149 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg9;
|
150 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg10;
|
151 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg11;
|
152 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg12;
|
153 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg13;
|
154 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg14;
|
155 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_reg15;
|
156 |
|
|
wire [0 : 15] slv_reg_write_sel;
|
157 |
|
|
wire [0 : 15] slv_reg_read_sel;
|
158 |
|
|
reg [0 : C_SLV_DWIDTH-1] slv_ip2bus_data;
|
159 |
|
|
wire slv_read_ack;
|
160 |
|
|
wire slv_write_ack;
|
161 |
|
|
integer byte_index, bit_index;
|
162 |
|
|
|
163 |
|
|
// --USER logic implementation added here
|
164 |
|
|
wire [11:0] SpiIfcMemAddr;
|
165 |
|
|
wire [7:0] SpiIfcMemData;
|
166 |
|
|
spiifc spiIfc(
|
167 |
|
|
.Reset(Bus2IP_Reset),
|
168 |
|
|
.SPI_CLK(SPI_CLK),
|
169 |
|
|
.SPI_MISO(SPI_MISO),
|
170 |
|
|
.SPI_MOSI(SPI_MOSI),
|
171 |
|
|
.SPI_SS(SPI_SS),
|
172 |
|
|
.txMemAddr(SpiIfcMemAddr),
|
173 |
|
|
.txMemData(SpiIfcMemData)
|
174 |
|
|
);
|
175 |
|
|
|
176 |
|
|
wire [31:0] douta_dummy;
|
177 |
|
|
wire [ 7:0] dinb_dummy;
|
178 |
|
|
assign dinb_dummy = 8'h00;
|
179 |
|
|
wire [11:0] byteAddr;
|
180 |
|
|
spimem your_instance_name (
|
181 |
|
|
.clka(Bus2IP_Clk), // input clka
|
182 |
|
|
.ena(Bus2IP_CS[0] & (~Bus2IP_RNW) & Bus2IP_WrReq), // input ena
|
183 |
|
|
.wea(1'b1), // input [0 : 0] wea
|
184 |
|
|
.addra({Bus2IP_Addr[20:29]}), // input [9 : 0] addra
|
185 |
|
|
.dina({Bus2IP_Data}), // input [31 : 0] dina
|
186 |
|
|
.douta(douta_dummy), // output [31 : 0] douta
|
187 |
|
|
.clkb(SPI_CLK), // input clkb
|
188 |
|
|
.enb(1'b1), // input enb
|
189 |
|
|
.web(1'b0), // input [0 : 0] web
|
190 |
|
|
.addrb(SpiIfcMemAddr), // input [11 : 0] addrb
|
191 |
|
|
.dinb(dinb_dummy), // input [7 : 0] dinb
|
192 |
|
|
.doutb(SpiIfcMemData) // output [7 : 0] doutb
|
193 |
|
|
);
|
194 |
|
|
|
195 |
|
|
// ------------------------------------------------------
|
196 |
|
|
// Example code to read/write user logic slave model s/w accessible registers
|
197 |
|
|
//
|
198 |
|
|
// Note:
|
199 |
|
|
// The example code presented here is to show you one way of reading/writing
|
200 |
|
|
// software accessible registers implemented in the user logic slave model.
|
201 |
|
|
// Each bit of the Bus2IP_WrCE/Bus2IP_RdCE signals is configured to correspond
|
202 |
|
|
// to one software accessible register by the top level template. For example,
|
203 |
|
|
// if you have four 32 bit software accessible registers in the user logic,
|
204 |
|
|
// you are basically operating on the following memory mapped registers:
|
205 |
|
|
//
|
206 |
|
|
// Bus2IP_WrCE/Bus2IP_RdCE Memory Mapped Register
|
207 |
|
|
// "1000" C_BASEADDR + 0x0
|
208 |
|
|
// "0100" C_BASEADDR + 0x4
|
209 |
|
|
// "0010" C_BASEADDR + 0x8
|
210 |
|
|
// "0001" C_BASEADDR + 0xC
|
211 |
|
|
//
|
212 |
|
|
// ------------------------------------------------------
|
213 |
|
|
|
214 |
|
|
assign
|
215 |
|
|
slv_reg_write_sel = Bus2IP_WrCE[0:15],
|
216 |
|
|
slv_reg_read_sel = Bus2IP_RdCE[0:15],
|
217 |
|
|
slv_write_ack = Bus2IP_WrCE[0] || Bus2IP_WrCE[1] || Bus2IP_WrCE[2] || Bus2IP_WrCE[3] || Bus2IP_WrCE[4] || Bus2IP_WrCE[5] || Bus2IP_WrCE[6] || Bus2IP_WrCE[7] || Bus2IP_WrCE[8] || Bus2IP_WrCE[9] || Bus2IP_WrCE[10] || Bus2IP_WrCE[11] || Bus2IP_WrCE[12] || Bus2IP_WrCE[13] || Bus2IP_WrCE[14] || Bus2IP_WrCE[15],
|
218 |
|
|
slv_read_ack = Bus2IP_RdCE[0] || Bus2IP_RdCE[1] || Bus2IP_RdCE[2] || Bus2IP_RdCE[3] || Bus2IP_RdCE[4] || Bus2IP_RdCE[5] || Bus2IP_RdCE[6] || Bus2IP_RdCE[7] || Bus2IP_RdCE[8] || Bus2IP_RdCE[9] || Bus2IP_RdCE[10] || Bus2IP_RdCE[11] || Bus2IP_RdCE[12] || Bus2IP_RdCE[13] || Bus2IP_RdCE[14] || Bus2IP_RdCE[15];
|
219 |
|
|
|
220 |
|
|
// implement slave model register(s)
|
221 |
|
|
always @( posedge Bus2IP_Clk )
|
222 |
|
|
begin: SLAVE_REG_WRITE_PROC
|
223 |
|
|
|
224 |
|
|
debugLedsReg <= {Bus2IP_CS[0], Bus2IP_RNW, Bus2IP_WrReq, IP2Bus_WrAck, 3'b0011};
|
225 |
|
|
|
226 |
|
|
if ( Bus2IP_Reset == 1 )
|
227 |
|
|
begin
|
228 |
|
|
slv_reg0 <= 0;
|
229 |
|
|
slv_reg1 <= 0;
|
230 |
|
|
slv_reg2 <= 0;
|
231 |
|
|
slv_reg3 <= 0;
|
232 |
|
|
slv_reg4 <= 0;
|
233 |
|
|
slv_reg5 <= 0;
|
234 |
|
|
slv_reg6 <= 0;
|
235 |
|
|
slv_reg7 <= 0;
|
236 |
|
|
slv_reg8 <= 0;
|
237 |
|
|
slv_reg9 <= 0;
|
238 |
|
|
slv_reg10 <= 0;
|
239 |
|
|
slv_reg11 <= 0;
|
240 |
|
|
slv_reg12 <= 0;
|
241 |
|
|
slv_reg13 <= 0;
|
242 |
|
|
slv_reg14 <= 0;
|
243 |
|
|
slv_reg15 <= 0;
|
244 |
|
|
end
|
245 |
|
|
else
|
246 |
|
|
case ( slv_reg_write_sel )
|
247 |
|
|
16'b1000000000000000 :
|
248 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
249 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
250 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
251 |
|
|
slv_reg0[bit_index] <= Bus2IP_Data[bit_index];
|
252 |
|
|
16'b0100000000000000 :
|
253 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
254 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
255 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
256 |
|
|
slv_reg1[bit_index] <= Bus2IP_Data[bit_index];
|
257 |
|
|
16'b0010000000000000 :
|
258 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
259 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
260 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
261 |
|
|
slv_reg2[bit_index] <= Bus2IP_Data[bit_index];
|
262 |
|
|
16'b0001000000000000 :
|
263 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
264 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
265 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
266 |
|
|
slv_reg3[bit_index] <= Bus2IP_Data[bit_index];
|
267 |
|
|
16'b0000100000000000 :
|
268 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
269 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
270 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
271 |
|
|
slv_reg4[bit_index] <= Bus2IP_Data[bit_index];
|
272 |
|
|
16'b0000010000000000 :
|
273 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
274 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
275 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
276 |
|
|
slv_reg5[bit_index] <= Bus2IP_Data[bit_index];
|
277 |
|
|
16'b0000001000000000 :
|
278 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
279 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
280 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
281 |
|
|
slv_reg6[bit_index] <= Bus2IP_Data[bit_index];
|
282 |
|
|
16'b0000000100000000 :
|
283 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
284 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
285 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
286 |
|
|
slv_reg7[bit_index] <= Bus2IP_Data[bit_index];
|
287 |
|
|
16'b0000000010000000 :
|
288 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
289 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
290 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
291 |
|
|
slv_reg8[bit_index] <= Bus2IP_Data[bit_index];
|
292 |
|
|
16'b0000000001000000 :
|
293 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
294 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
295 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
296 |
|
|
slv_reg9[bit_index] <= Bus2IP_Data[bit_index];
|
297 |
|
|
16'b0000000000100000 :
|
298 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
299 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
300 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
301 |
|
|
slv_reg10[bit_index] <= Bus2IP_Data[bit_index];
|
302 |
|
|
16'b0000000000010000 :
|
303 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
304 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
305 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
306 |
|
|
slv_reg11[bit_index] <= Bus2IP_Data[bit_index];
|
307 |
|
|
16'b0000000000001000 :
|
308 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
309 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
310 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
311 |
|
|
slv_reg12[bit_index] <= Bus2IP_Data[bit_index];
|
312 |
|
|
16'b0000000000000100 :
|
313 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
314 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
315 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
316 |
|
|
slv_reg13[bit_index] <= Bus2IP_Data[bit_index];
|
317 |
|
|
16'b0000000000000010 :
|
318 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
319 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
320 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
321 |
|
|
slv_reg14[bit_index] <= Bus2IP_Data[bit_index];
|
322 |
|
|
16'b0000000000000001 :
|
323 |
|
|
for ( byte_index = 0; byte_index <= (C_SLV_DWIDTH/8)-1; byte_index = byte_index+1 )
|
324 |
|
|
if ( Bus2IP_BE[byte_index] == 1 )
|
325 |
|
|
for ( bit_index = byte_index*8; bit_index <= byte_index*8+7; bit_index = bit_index+1 )
|
326 |
|
|
slv_reg15[bit_index] <= Bus2IP_Data[bit_index];
|
327 |
|
|
default : ;
|
328 |
|
|
endcase
|
329 |
|
|
|
330 |
|
|
end // SLAVE_REG_WRITE_PROC
|
331 |
|
|
|
332 |
|
|
// implement slave model register read mux
|
333 |
|
|
always @( slv_reg_read_sel or slv_reg0 or slv_reg1 or slv_reg2 or slv_reg3 or slv_reg4 or slv_reg5 or slv_reg6 or slv_reg7 or slv_reg8 or slv_reg9 or slv_reg10 or slv_reg11 or slv_reg12 or slv_reg13 or slv_reg14 or slv_reg15 )
|
334 |
|
|
begin: SLAVE_REG_READ_PROC
|
335 |
|
|
|
336 |
|
|
case ( slv_reg_read_sel )
|
337 |
|
|
16'b1000000000000000 : slv_ip2bus_data <= slv_reg0;
|
338 |
|
|
16'b0100000000000000 : slv_ip2bus_data <= slv_reg1;
|
339 |
|
|
16'b0010000000000000 : slv_ip2bus_data <= slv_reg2;
|
340 |
|
|
16'b0001000000000000 : slv_ip2bus_data <= slv_reg3;
|
341 |
|
|
16'b0000100000000000 : slv_ip2bus_data <= slv_reg4;
|
342 |
|
|
16'b0000010000000000 : slv_ip2bus_data <= slv_reg5;
|
343 |
|
|
16'b0000001000000000 : slv_ip2bus_data <= slv_reg6;
|
344 |
|
|
16'b0000000100000000 : slv_ip2bus_data <= slv_reg7;
|
345 |
|
|
16'b0000000010000000 : slv_ip2bus_data <= slv_reg8;
|
346 |
|
|
16'b0000000001000000 : slv_ip2bus_data <= slv_reg9;
|
347 |
|
|
16'b0000000000100000 : slv_ip2bus_data <= slv_reg10;
|
348 |
|
|
16'b0000000000010000 : slv_ip2bus_data <= slv_reg11;
|
349 |
|
|
16'b0000000000001000 : slv_ip2bus_data <= slv_reg12;
|
350 |
|
|
16'b0000000000000100 : slv_ip2bus_data <= slv_reg13;
|
351 |
|
|
16'b0000000000000010 : slv_ip2bus_data <= slv_reg14;
|
352 |
|
|
16'b0000000000000001 : slv_ip2bus_data <= slv_reg15;
|
353 |
|
|
default : slv_ip2bus_data <= 0;
|
354 |
|
|
endcase
|
355 |
|
|
|
356 |
|
|
end // SLAVE_REG_READ_PROC
|
357 |
|
|
|
358 |
|
|
// ------------------------------------------------------------
|
359 |
|
|
// Example code to drive IP to Bus signals
|
360 |
|
|
// ------------------------------------------------------------
|
361 |
|
|
|
362 |
|
|
assign IP2Bus_AddrAck = slv_write_ack || slv_read_ack;
|
363 |
|
|
assign IP2Bus_Data = slv_ip2bus_data;
|
364 |
|
|
assign IP2Bus_WrAck = slv_write_ack;
|
365 |
|
|
assign IP2Bus_RdAck = slv_read_ack;
|
366 |
|
|
assign IP2Bus_Error = 0;
|
367 |
|
|
|
368 |
|
|
endmodule
|