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

Subversion Repositories pcie_ds_dma

[/] [pcie_ds_dma/] [trunk/] [core/] [ds_dma64/] [pcie_src/] [pcie_core64_m1/] [source/] [cmm_intr.v] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 dsmv
 
2
//-----------------------------------------------------------------------------
3
//
4
// (c) Copyright 2009-2010 Xilinx, Inc. All rights reserved.
5
//
6
// This file contains confidential and proprietary information
7
// of Xilinx, Inc. and is protected under U.S. and
8
// international copyright and other intellectual property
9
// laws.
10
//
11
// DISCLAIMER
12
// This disclaimer is not a license and does not grant any
13
// rights to the materials distributed herewith. Except as
14
// otherwise provided in a valid license issued to you by
15
// Xilinx, and to the maximum extent permitted by applicable
16
// law: (1) THESE MATERIALS ARE MADE AVAILABLE "AS IS" AND
17
// WITH ALL FAULTS, AND XILINX HEREBY DISCLAIMS ALL WARRANTIES
18
// AND CONDITIONS, EXPRESS, IMPLIED, OR STATUTORY, INCLUDING
19
// BUT NOT LIMITED TO WARRANTIES OF MERCHANTABILITY, NON-
20
// INFRINGEMENT, OR FITNESS FOR ANY PARTICULAR PURPOSE; and
21
// (2) Xilinx shall not be liable (whether in contract or tort,
22
// including negligence, or under any other theory of
23
// liability) for any loss or damage of any kind or nature
24
// related to, arising under or in connection with these
25
// materials, including for any direct, or any indirect,
26
// special, incidental, or consequential loss or damage
27
// (including loss of data, profits, goodwill, or any type of
28
// loss or damage suffered as a result of any action brought
29
// by a third party) even if such damage or loss was
30
// reasonably foreseeable or Xilinx had been advised of the
31
// possibility of the same.
32
//
33
// CRITICAL APPLICATIONS
34
// Xilinx products are not designed or intended to be fail-
35
// safe, or for use in any application requiring fail-safe
36
// performance, such as life-support or safety devices or
37
// systems, Class III medical devices, nuclear facilities,
38
// applications related to the deployment of airbags, or any
39
// other applications that could lead to death, personal
40
// injury, or severe property or environmental damage
41
// (individually and collectively, "Critical
42
// Applications"). Customer assumes the sole risk and
43
// liability of any use of Xilinx products in Critical
44
// Applications, subject only to applicable laws and
45
// regulations governing limitations on product liability.
46
//
47
// THIS COPYRIGHT NOTICE AND DISCLAIMER MUST BE RETAINED AS
48
// PART OF THIS FILE AT ALL TIMES.
49
//
50
//-----------------------------------------------------------------------------
51
// Project    : V5-Block Plus for PCI Express
52
// File       : cmm_intr.v
53
//--------------------------------------------------------------------------------
54
//--------------------------------------------------------------------------------
55
 
56
`define FFD 1
57
 
58
module cmm_intr (
59
                signaledint,         // Outputs
60
                intr_req_valid,
61
                intr_req_type,
62
                intr_rdy,
63
                cfg_interrupt_n,     // Inputs
64
                cfg_interrupt_assert_n,
65
                cfg_interrupt_di,
66
                cfg_interrupt_mmenable,
67
                msi_data,
68
                intr_vector,
69
                command,
70
                msi_control,
71
                msi_laddr,
72
                msi_haddr,
73
                intr_grant,
74
                cfg,
75
                rst,
76
                clk
77
                ) /* synthesis syn_hier ="hard"*/;
78
 
79
//This indicates (to Status register) that a Legacy Interrupt has been sent
80
output         signaledint;          // Outputs
81
output         intr_req_valid;
82
output  [1:0]  intr_req_type;
83
output         intr_rdy;
84
 
85
output [7:0]   intr_vector;
86
input          cfg_interrupt_assert_n;
87
input  [7:0]   cfg_interrupt_di;
88
input  [15:0]  msi_data;
89
input  [2:0]   cfg_interrupt_mmenable;
90
input          cfg_interrupt_n;     // Inputs
91
input  [15:0]  command;
92
input  [15:0]  msi_control;
93
input  [31:0]  msi_laddr;
94
input  [31:0]  msi_haddr;
95
input          intr_grant;
96
input [1023:0] cfg;
97
input          rst;
98
input          clk;
99
 
100
reg         signaledint;          // Outputs
101
wire        intr_rdy;
102
 
103
reg         q_intr_req_valid;
104
reg  [1:0]  q_intr_req_type;
105
 
106
// notes 
107
// msi_control[0] is msi_mode
108
// 64 bit address capable bit 7 of message control
109
// This design supports only one message 
110
// command [10] is interrupt disable
111
 
112
parameter [1:0] IDLE          = 2'b00;
113
parameter [1:0] SEND_MSI      = 2'b01;
114
parameter [1:0] SEND_ASSERT   = 2'b10;
115
parameter [1:0] SEND_DEASSERT = 2'b11;
116
 
117
wire msi_64;
118
wire msi_mode;
119
wire intx_mode;
120
wire bus_master_en;
121
wire intr_req;
122
reg       allow_int;
123
reg [1:0] state;
124
reg [1:0] next_state;
125
 
126
assign msi_64 = msi_control[7] &&  (msi_haddr != 0);
127
assign msi_mode      = msi_control[0];
128
assign intx_mode     = ~command[10];
129
assign bus_master_en = command[2];
130
assign intr_req = !cfg_interrupt_n && allow_int;
131
 
132
reg intr_req_q = 0;
133
reg intr_rdyx  = 0;
134
reg cfg_interrupt_assert_n_q = 1;
135
reg [7:0] cfg_interrupt_di_q = 0;
136
reg [7:0] intr_vector        = 0;
137
 
138
always @(posedge clk or posedge rst) begin
139
   if (rst) begin
140
      intr_req_q <= #`FFD 1'b0;
141
      allow_int  <= #`FFD 1'b0;
142
      intr_rdyx  <= #`FFD 1'b0;
143
      cfg_interrupt_assert_n_q  <= #`FFD 1'b1;
144
   end else begin
145
      intr_req_q <= #`FFD intr_req;
146
      allow_int  <= #`FFD ((msi_mode && bus_master_en) || (!msi_mode && intx_mode));
147
      intr_rdyx  <= #`FFD (state != IDLE) && intr_grant;
148
      cfg_interrupt_assert_n_q  <= #`FFD cfg_interrupt_assert_n;
149
   end
150
end
151
 
152
always @(posedge clk) begin
153
   cfg_interrupt_di_q <= #`FFD cfg_interrupt_di;
154
end
155
 
156
always @(posedge clk) begin
157
   //This override will permit the user to alter all 8 MSI bits
158
   if (cfg[467]) begin
159
     intr_vector          <= #`FFD cfg_interrupt_di_q[7:0];
160
   end else if (intr_req_q) begin
161
     casez ({msi_mode,cfg_interrupt_mmenable})
162
     4'b0???: intr_vector <= #`FFD cfg_interrupt_di_q[7:0];
163
     4'b1000: intr_vector <= #`FFD msi_data[7:0];
164
     4'b1001: intr_vector <= #`FFD {msi_data[7:1],cfg_interrupt_di_q[0]};
165
     4'b1010: intr_vector <= #`FFD {msi_data[7:2],cfg_interrupt_di_q[1:0]};
166
     4'b1011: intr_vector <= #`FFD {msi_data[7:3],cfg_interrupt_di_q[2:0]};
167
     4'b1100: intr_vector <= #`FFD {msi_data[7:4],cfg_interrupt_di_q[3:0]};
168
     4'b1101: intr_vector <= #`FFD {msi_data[7:5],cfg_interrupt_di_q[4:0]};
169
     default: intr_vector <= #`FFD {msi_data[7:5],cfg_interrupt_di_q[4:0]};
170
     endcase
171
   end
172
end
173
 
174
wire        intr_req_valid = q_intr_req_valid;
175
wire [1:0]  intr_req_type  = q_intr_req_type;
176
reg         intr_rdy_q;
177
 
178
always @(posedge clk) begin
179
   if (rst) begin
180
      intr_rdy_q     <= #`FFD 0;
181
   end else begin
182
      intr_rdy_q     <= #`FFD intr_rdy;
183
   end
184
end
185
 
186
wire send_assert;
187
wire send_deassert;
188
wire send_msi;
189
 
190
assign send_assert  = !msi_mode && intr_req_q && ~cfg_interrupt_assert_n_q &&
191
                      ~(intr_rdy || intr_rdy_q);
192
assign send_deassert= !msi_mode && intr_req_q &&  cfg_interrupt_assert_n_q &&
193
                      ~(intr_rdy || intr_rdy_q);
194
assign send_msi     =  msi_mode && intr_req_q &&
195
                      ~(intr_rdy || intr_rdy_q);
196
 
197
always @(posedge clk) begin
198
   if (rst) begin
199
      state          <= #`FFD IDLE;
200
   end
201
   else begin
202
      state          <= #`FFD next_state;
203
   end
204
end
205
 
206
always @*
207
begin
208
   next_state = IDLE;
209
   signaledint = 0;
210
   q_intr_req_type = 0;
211
   q_intr_req_valid = 0;
212
 
213
   case (state) // synthesis full_case parallel_case 
214
      IDLE : begin
215
                q_intr_req_type = 0;
216
                q_intr_req_valid = 0;
217
                signaledint = 0;
218
 
219
                if (send_msi) begin
220
                   next_state = SEND_MSI;
221
                end
222
                else if (send_assert) begin
223
                   next_state = SEND_ASSERT;
224
                end
225
                else if (send_deassert) begin
226
                   next_state = SEND_DEASSERT;
227
                end
228
                else begin
229
                   next_state = IDLE;
230
                end
231
             end
232
  SEND_MSI : begin
233
                q_intr_req_type = msi_64 ? 2'b11 : 2'b10;
234
 
235
                if (intr_grant) begin
236
                   q_intr_req_valid = 0;
237
                   next_state = IDLE;
238
                   signaledint = 0;
239
                end
240
                else begin
241
                   q_intr_req_valid = 1;
242
                   next_state = SEND_MSI;
243
                   signaledint = 0;
244
                end
245
             end
246
 SEND_ASSERT : begin
247
                q_intr_req_type = 2'b00;
248
 
249
                if (intr_grant) begin
250
                   q_intr_req_valid = 0;
251
                   next_state = IDLE;
252
                   signaledint = 1;
253
                end
254
                else begin
255
                   q_intr_req_valid = 1;
256
                   next_state = SEND_ASSERT;
257
                   signaledint = 0;
258
                end
259
             end
260
 SEND_DEASSERT : begin
261
                q_intr_req_type = 2'b01;
262
 
263
                if (intr_grant) begin
264
                   q_intr_req_valid = 0;
265
                   next_state = IDLE;
266
                   signaledint = 1;
267
                end
268
                else begin
269
                   q_intr_req_valid = 1;
270
                   next_state = SEND_DEASSERT;
271
                   signaledint = 0;
272
                end
273
             end
274
   endcase
275
end
276
 
277
assign intr_rdy = intr_rdyx;
278
 
279
endmodule

powered by: WebSVN 2.1.0

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