x393  1.0
FPGAcodeforElphelNC393camera
axi_ahci_regs.v
Go to the documentation of this file.
1 
42 `timescale 1ns/1ps
43 
44 
45 module axi_ahci_regs#(
46 // parameter ADDRESS_BITS = 8 // number of memory address bits
47  parameter ADDRESS_BITS = 10, // number of memory address bits - now fixed. Low half - RO/RW/RWC,RW1 (2-cycle write), 2-nd just RW (single-cycle)
48  parameter HBA_RESET_BITS = 9, // duration of HBA reset in aclk periods (9: ~10usec)
49  parameter RESET_TO_FIRST_ACCESS = 1 // keep port reset until first R/W any register by software
50 )(
51  input aclk, // clock - should be buffered
52  input arst, // @aclk sync reset, active high
53 
54 // AXI Write Address
55  input [31:0] awaddr, // AWADDR[31:0], input
56  input awvalid, // AWVALID, input
57  output awready, // AWREADY, output
58  input [11:0] awid, // AWID[11:0], input
59  input [ 3:0] awlen, // AWLEN[3:0], input
60  input [ 1:0] awsize, // AWSIZE[1:0], input
61  input [ 1:0] awburst, // AWBURST[1:0], input
62 // AXI PS Master GP0: Write Data
63  input [31:0] wdata, // WDATA[31:0], input
64  input wvalid, // WVALID, input
65  output wready, // WREADY, output
66  input [11:0] wid, // WID[11:0], input
67  input wlast, // WLAST, input
68  input [ 3:0] wstb, // WSTRB[3:0], input
69 // AXI PS Master GP0: Write response
70  output bvalid, // BVALID, output
71  input bready, // BREADY, input
72  output [11:0] bid, // BID[11:0], output
73  output [ 1:0] bresp, // BRESP[1:0], output
74 // AXI Read Address
75  input [31:0] araddr, // ARADDR[31:0], input
76  input arvalid, // ARVALID, input
77  output arready, // ARREADY, output
78  input [11:0] arid, // ARID[11:0], input
79  input [ 3:0] arlen, // ARLEN[3:0], input
80  input [ 1:0] arsize, // ARSIZE[1:0], input
81  input [ 1:0] arburst, // ARBURST[1:0], input
82 // AXI Read Data
83  output [31:0] rdata, // RDATA[31:0], output
84  output rvalid, // RVALID, output
85  input rready, // RREADY, input
86  output [11:0] rid, // RID[11:0], output
87  output rlast, // RLAST, output
88  output [ 1:0] rresp, // RRESP
89 
90 // HBA interface
91 // 1. Notification of data written @ hba_clk
92  output [ADDRESS_BITS-1:0] soft_write_addr, // register address written by software
93  output [31:0] soft_write_data, // register data written (after applying wstb and type (RO, RW, RWC, RW1)
94  output soft_write_en, // write enable for data write
95  // Apply next 2 resets and arst OR-ed to SATA.extrst
96  output hba_arst, // hba async reset (currently does ~ the same as port reset)
97  output port_arst, // port0 async reset by software
98  output port_arst_any, // port0 async reset by POR or software
99 
100 // 2. HBA R/W registers, use hba clock
101  input hba_clk, // SATA clock, now 75MHz
102  input hba_rst, // when PLL locked, SATA PHY reset is over, this signal is released
103  input [ADDRESS_BITS-1:0] hba_addr,
104  input hba_we,
105 // input [3:0] hba_wstb, Needed?
106  input [1:0] hba_re, // [0] - re, [1] - regen
107  input [31:0] hba_din,
108  output [31:0] hba_dout,
109 
110 // Program FSM memory
111  output reg [17:0] pgm_ad, // @aclk, address/data to program the AHCI FSM
112  output reg pgm_wa, // @aclk, address strobe to program the AHCI FSM
113  output reg pgm_wd, // @aclk, data strobe to program the AHCI FSM
114 
115 
116 
117 // other control signals
118  output reg [ 3:0] afi_wcache,
119  output reg [ 3:0] afi_rcache,
121  output was_hba_rst, // last reset was hba reset (not counting system reset)
122  output was_port_rst, // last reset was port reset
123  input [31:0] debug_in0,
124  input [31:0] debug_in1,
125  input [31:0] debug_in2,
126  input [31:0] debug_in3
127 `ifdef USE_DRP
128  ,output reg drp_en, // @aclk strobes drp_ad
129  output reg drp_we,
130  output reg [14:0] drp_addr,
131  output reg [15:0] drp_di,
132  input drp_rdy,
133  input [15:0] drp_do
134 `endif
135 `ifdef USE_DATASCOPE
136 // Datascope interface (write to memory that can be software-read)
140  input [31:0] datascope_di,
141 
145  input [31:0] datascope1_di
146 `endif
147 );
148 `ifdef USE_DRP
149  localparam DRP_ADDR = 'h3fb;
150  reg [15:0] drp_read_data;
153 `endif
154 `ifdef USE_DATASCOPE
155 // localparam AXIBRAM_BITS = ADDRESS_BITS + 1; // number of axi address outputs (one more than ADDRESS_BITS when using datascope)
156  localparam AXIBRAM_BITS = ADDRESS_BITS + 2; // number of axi address outputs (one more than ADDRESS_BITS when using datascope)
157  wire [31:0] datascope_rdata;
158  reg [1:0] datascope_sel; // read datascope memory instead of the registers
159  wire [31:0] datascope1_rdata;
160  reg [1:0] datascope1_sel; // read datascope memory instead of the registers
161  always @ (posedge aclk) begin
164  end
165 `else
166  localparam AXIBRAM_BITS = ADDRESS_BITS; // number of axi address outputs (one more than ADDRESS_BITS when using datascope)
167 `endif// RO: Device ID
168  localparam PCI_Header__ID__DID__ADDR = 'h60;
169  localparam PCI_Header__ID__DID__MASK = 'hffff0000;
170  localparam PCI_Header__ID__DID__DFLT = 'h10000;
171 // RO: Vendor ID
172  localparam PCI_Header__ID__VID__ADDR = 'h60;
173  localparam PCI_Header__ID__VID__MASK = 'hffff;
174  localparam PCI_Header__ID__VID__DFLT = 'hfffe;
175 // RW: HBA Interrupt Disable
176  localparam PCI_Header__CMD__ID__ADDR = 'h61;
177  localparam PCI_Header__CMD__ID__MASK = 'h400;
178  localparam PCI_Header__CMD__ID__DFLT = 'h0;
179 // RO: Fast Back-to-Back Enable
180  localparam PCI_Header__CMD__FBE__ADDR = 'h61;
181  localparam PCI_Header__CMD__FBE__MASK = 'h200;
182  localparam PCI_Header__CMD__FBE__DFLT = 'h0;
183 // RO: SERR Enable
184  localparam PCI_Header__CMD__SEE__ADDR = 'h61;
185  localparam PCI_Header__CMD__SEE__MASK = 'h100;
186  localparam PCI_Header__CMD__SEE__DFLT = 'h0;
187 // RO: Reserved
188  localparam PCI_Header__CMD__WCC__ADDR = 'h61;
189  localparam PCI_Header__CMD__WCC__MASK = 'h80;
190  localparam PCI_Header__CMD__WCC__DFLT = 'h0;
191 // RO: Parity Error Response Enable
192  localparam PCI_Header__CMD__PEE__ADDR = 'h61;
193  localparam PCI_Header__CMD__PEE__MASK = 'h40;
194  localparam PCI_Header__CMD__PEE__DFLT = 'h0;
195 // RO: Reserved
196  localparam PCI_Header__CMD__VGA__ADDR = 'h61;
197  localparam PCI_Header__CMD__VGA__MASK = 'h20;
198  localparam PCI_Header__CMD__VGA__DFLT = 'h0;
199 // RO: Reserved
200  localparam PCI_Header__CMD__MWIE__ADDR = 'h61;
201  localparam PCI_Header__CMD__MWIE__MASK = 'h10;
202  localparam PCI_Header__CMD__MWIE__DFLT = 'h0;
203 // RO: Reserved
204  localparam PCI_Header__CMD__SCE__ADDR = 'h61;
205  localparam PCI_Header__CMD__SCE__MASK = 'h8;
206  localparam PCI_Header__CMD__SCE__DFLT = 'h0;
207 // RW: Bus Master Enable (0 - stops any DMA)
208  localparam PCI_Header__CMD__BME__ADDR = 'h61;
209  localparam PCI_Header__CMD__BME__MASK = 'h4;
210  localparam PCI_Header__CMD__BME__DFLT = 'h0;
211 // RW: Memory Space enable (here - always?)
212  localparam PCI_Header__CMD__MSE__ADDR = 'h61;
213  localparam PCI_Header__CMD__MSE__MASK = 'h2;
214  localparam PCI_Header__CMD__MSE__DFLT = 'h0;
215 // RO: Enable IO space access (only for legacy IDE)
216  localparam PCI_Header__CMD__IOSE__ADDR = 'h61;
217  localparam PCI_Header__CMD__IOSE__MASK = 'h1;
218  localparam PCI_Header__CMD__IOSE__DFLT = 'h0;
219 // RWC: Detected Parity Error
220  localparam PCI_Header__STS__DPE__ADDR = 'h61;
221  localparam PCI_Header__STS__DPE__MASK = 'h80000000;
222  localparam PCI_Header__STS__DPE__DFLT = 'h0;
223 // RWC: Signaled System Error (HBA SERR)
224  localparam PCI_Header__STS__SSE__ADDR = 'h61;
225  localparam PCI_Header__STS__SSE__MASK = 'h40000000;
226  localparam PCI_Header__STS__SSE__DFLT = 'h0;
227 // RWC: Received Master Abort
228  localparam PCI_Header__STS__RMA__ADDR = 'h61;
229  localparam PCI_Header__STS__RMA__MASK = 'h20000000;
230  localparam PCI_Header__STS__RMA__DFLT = 'h0;
231 // RWC: Received Target Abort
232  localparam PCI_Header__STS__RTA__ADDR = 'h61;
233  localparam PCI_Header__STS__RTA__MASK = 'h10000000;
234  localparam PCI_Header__STS__RTA__DFLT = 'h0;
235 // RWC: Signaled Target Abort
236  localparam PCI_Header__STS__STA__ADDR = 'h61;
237  localparam PCI_Header__STS__STA__MASK = 'h8000000;
238  localparam PCI_Header__STS__STA__DFLT = 'h0;
239 // RO: PCI DEVSEL Timing
240  localparam PCI_Header__STS__DEVT__ADDR = 'h61;
241  localparam PCI_Header__STS__DEVT__MASK = 'h6000000;
242  localparam PCI_Header__STS__DEVT__DFLT = 'h0;
243 // RWC: Master Data Parity Error Detected
244  localparam PCI_Header__STS__DPD__ADDR = 'h61;
245  localparam PCI_Header__STS__DPD__MASK = 'h1000000;
246  localparam PCI_Header__STS__DPD__DFLT = 'h0;
247 // RO: Fast Back-To-Back Capable
248  localparam PCI_Header__STS__FBC__ADDR = 'h61;
249  localparam PCI_Header__STS__FBC__MASK = 'h800000;
250  localparam PCI_Header__STS__FBC__DFLT = 'h0;
251 // RO: 66 MHz Capable
252  localparam PCI_Header__STS__C66__ADDR = 'h61;
253  localparam PCI_Header__STS__C66__MASK = 'h200000;
254  localparam PCI_Header__STS__C66__DFLT = 'h0;
255 // RO: Capabilities List (PCI power management mandatory)
256  localparam PCI_Header__STS__CL__ADDR = 'h61;
257  localparam PCI_Header__STS__CL__MASK = 'h100000;
258  localparam PCI_Header__STS__CL__DFLT = 'h100000;
259 // RO: Interrupt Status (1 - asserted)
260  localparam PCI_Header__STS__IS__ADDR = 'h61;
261  localparam PCI_Header__STS__IS__MASK = 'h80000;
262  localparam PCI_Header__STS__IS__DFLT = 'h0;
263 // RO: HBA Revision ID
264  localparam PCI_Header__RID__RID__ADDR = 'h62;
265  localparam PCI_Header__RID__RID__MASK = 'hff;
266  localparam PCI_Header__RID__RID__DFLT = 'h2;
267 // RO: Base Class Code: 1 - Mass Storage Device
268  localparam PCI_Header__CC__BCC__ADDR = 'h62;
269  localparam PCI_Header__CC__BCC__MASK = 'hff000000;
270  localparam PCI_Header__CC__BCC__DFLT = 'h1000000;
271 // RO: Sub Class Code: 0x06 - SATA Device
272  localparam PCI_Header__CC__SCC__ADDR = 'h62;
273  localparam PCI_Header__CC__SCC__MASK = 'hff0000;
274  localparam PCI_Header__CC__SCC__DFLT = 'h60000;
275 // RO: Programming Interface: 1 - AHCI HBA major rev 1
276  localparam PCI_Header__CC__PI__ADDR = 'h62;
277  localparam PCI_Header__CC__PI__MASK = 'hff0000;
278  localparam PCI_Header__CC__PI__DFLT = 'h10000;
279 // RW: Cache Line Size
280  localparam PCI_Header__CLS__CLS__ADDR = 'h63;
281  localparam PCI_Header__CLS__CLS__MASK = 'hff;
282  localparam PCI_Header__CLS__CLS__DFLT = 'h0;
283 // RW: Master Latency Timer
284  localparam PCI_Header__MLT__MLT__ADDR = 'h63;
285  localparam PCI_Header__MLT__MLT__MASK = 'hff00;
286  localparam PCI_Header__MLT__MLT__DFLT = 'h0;
287 // RO: Multi-Function Device
288  localparam PCI_Header__HTYPE__MFDT__ADDR = 'h63;
289  localparam PCI_Header__HTYPE__MFDT__MASK = 'h8000;
290  localparam PCI_Header__HTYPE__MFDT__DFLT = 'h0;
291 // RO: Header Layout 0 - HBA uses a target device layout
292  localparam PCI_Header__HTYPE__HL__ADDR = 'h63;
293  localparam PCI_Header__HTYPE__HL__MASK = 'h7f00;
294  localparam PCI_Header__HTYPE__HL__DFLT = 'h0;
295 // RO: AHCI Base Address high bits, normally RW, but here RO to get to MAXIGP1 space
296  localparam PCI_Header__ABAR__BA__ADDR = 'h69;
297  localparam PCI_Header__ABAR__BA__MASK = 'hfffffff0;
298  localparam PCI_Header__ABAR__BA__DFLT = 'h80000000;
299 // RO: Prefetchable (this is not)
300  localparam PCI_Header__ABAR__PF__ADDR = 'h69;
301  localparam PCI_Header__ABAR__PF__MASK = 'h8;
302  localparam PCI_Header__ABAR__PF__DFLT = 'h0;
303 // RO: Type (0 - any 32-bit address, here it is hard-mapped
304  localparam PCI_Header__ABAR__TP__ADDR = 'h69;
305  localparam PCI_Header__ABAR__TP__MASK = 'h6;
306  localparam PCI_Header__ABAR__TP__DFLT = 'h0;
307 // RO: Resource Type Indicator: 0 - memory address
308  localparam PCI_Header__ABAR__RTE__ADDR = 'h69;
309  localparam PCI_Header__ABAR__RTE__MASK = 'h1;
310  localparam PCI_Header__ABAR__RTE__DFLT = 'h0;
311 // RO: SubSystem ID
312  localparam PCI_Header__SS__SSID__ADDR = 'h6b;
313  localparam PCI_Header__SS__SSID__MASK = 'hffff0000;
314  localparam PCI_Header__SS__SSID__DFLT = 'h10000;
315 // RO: SubSystem Vendor ID
316  localparam PCI_Header__SS__SSVID__ADDR = 'h6b;
317  localparam PCI_Header__SS__SSVID__MASK = 'hffff;
318  localparam PCI_Header__SS__SSVID__DFLT = 'hfffe;
319 // RO: ROM Base Address
320  localparam PCI_Header__EROM__RBA__ADDR = 'h6c;
321  localparam PCI_Header__EROM__RBA__MASK = 'hffffffff;
322  localparam PCI_Header__EROM__RBA__DFLT = 'h0;
323 // RO: Capabilities pointer
324  localparam PCI_Header__CAP__CAP__ADDR = 'h6d;
325  localparam PCI_Header__CAP__CAP__MASK = 'hff;
326  localparam PCI_Header__CAP__CAP__DFLT = 'h40;
327 // RO: Interrupt pin
328  localparam PCI_Header__INTR__IPIN__ADDR = 'h6f;
329  localparam PCI_Header__INTR__IPIN__MASK = 'hff00;
330  localparam PCI_Header__INTR__IPIN__DFLT = 'h100;
331 // RW: Interrupt Line
332  localparam PCI_Header__INTR__ILINE__ADDR = 'h6f;
333  localparam PCI_Header__INTR__ILINE__MASK = 'hff;
334  localparam PCI_Header__INTR__ILINE__DFLT = 'h0;
335 // RO: Minimal Grant
336  localparam PCI_Header__MGNT__MGNT__ADDR = 'h6f;
337  localparam PCI_Header__MGNT__MGNT__MASK = 'hff0000;
338  localparam PCI_Header__MGNT__MGNT__DFLT = 'h0;
339 // RO: Maximal Latency
340  localparam PCI_Header__MLAT__MLAT__ADDR = 'h6f;
341  localparam PCI_Header__MLAT__MLAT__MASK = 'hff000000;
342  localparam PCI_Header__MLAT__MLAT__DFLT = 'h0;
343 // RO: Next Capability pointer
344  localparam PMCAP__PID__NEXT__ADDR = 'h70;
345  localparam PMCAP__PID__NEXT__MASK = 'hff00;
346  localparam PMCAP__PID__NEXT__DFLT = 'h0;
347 // RO: This is PCI Power Management Capability
348  localparam PMCAP__PID__CID__ADDR = 'h70;
349  localparam PMCAP__PID__CID__MASK = 'hff;
350  localparam PMCAP__PID__CID__DFLT = 'h1;
351 // RO: PME_SUPPORT bits:'b01000
352  localparam PMCAP__PC__PSUP__ADDR = 'h70;
353  localparam PMCAP__PC__PSUP__MASK = 'hf8000000;
354  localparam PMCAP__PC__PSUP__DFLT = 'h40000000;
355 // RO: D2 Support - no
356  localparam PMCAP__PC__D2S__ADDR = 'h70;
357  localparam PMCAP__PC__D2S__MASK = 'h4000000;
358  localparam PMCAP__PC__D2S__DFLT = 'h0;
359 // RO: D1 Support - no
360  localparam PMCAP__PC__D1S__ADDR = 'h70;
361  localparam PMCAP__PC__D1S__MASK = 'h2000000;
362  localparam PMCAP__PC__D1S__DFLT = 'h0;
363 // RO: Maximal D3cold current
364  localparam PMCAP__PC__AUXC__ADDR = 'h70;
365  localparam PMCAP__PC__AUXC__MASK = 'h1c00000;
366  localparam PMCAP__PC__AUXC__DFLT = 'h0;
367 // RO: Device-specific initialization required
368  localparam PMCAP__PC__DSI__ADDR = 'h70;
369  localparam PMCAP__PC__DSI__MASK = 'h200000;
370  localparam PMCAP__PC__DSI__DFLT = 'h0;
371 // RO: PCI clock required to generate PME
372  localparam PMCAP__PC__PMEC__ADDR = 'h70;
373  localparam PMCAP__PC__PMEC__MASK = 'h80000;
374  localparam PMCAP__PC__PMEC__DFLT = 'h0;
375 // RO: Revision of Power Management Specification support version
376  localparam PMCAP__PC__VS__ADDR = 'h70;
377  localparam PMCAP__PC__VS__MASK = 'h70000;
378  localparam PMCAP__PC__VS__DFLT = 'h0;
379 // RWC: PME Status, set by hardware when HBA generates PME
380  localparam PMCAP__PMCS__PMES__ADDR = 'h71;
381  localparam PMCAP__PMCS__PMES__MASK = 'h8000;
382  localparam PMCAP__PMCS__PMES__DFLT = 'h0;
383 // RW: PME Enable
384  localparam PMCAP__PMCS__PMEE__ADDR = 'h71;
385  localparam PMCAP__PMCS__PMEE__MASK = 'h100;
386  localparam PMCAP__PMCS__PMEE__DFLT = 'h0;
387 // RW: Power State
388  localparam PMCAP__PMCS__PS__ADDR = 'h71;
389  localparam PMCAP__PMCS__PS__MASK = 'h3;
390  localparam PMCAP__PMCS__PS__DFLT = 'h0;
391 // RO: Supports 64-bit Addressing - no
392  localparam GHC__CAP__S64A__ADDR = 'h0;
393  localparam GHC__CAP__S64A__MASK = 'h80000000;
394  localparam GHC__CAP__S64A__DFLT = 'h0;
395 // RO: Supports Native Command Queuing - no
396  localparam GHC__CAP__SNCQ__ADDR = 'h0;
397  localparam GHC__CAP__SNCQ__MASK = 'h40000000;
398  localparam GHC__CAP__SNCQ__DFLT = 'h0;
399 // RO: Supports SNotification Register - no
400  localparam GHC__CAP__SSNTF__ADDR = 'h0;
401  localparam GHC__CAP__SSNTF__MASK = 'h20000000;
402  localparam GHC__CAP__SSNTF__DFLT = 'h0;
403 // RO: Supports Mechanical Presence Switch - no
404  localparam GHC__CAP__SMPS__ADDR = 'h0;
405  localparam GHC__CAP__SMPS__MASK = 'h10000000;
406  localparam GHC__CAP__SMPS__DFLT = 'h0;
407 // RO: Supports Staggered Spin-up - no
408  localparam GHC__CAP__SSS__ADDR = 'h0;
409  localparam GHC__CAP__SSS__MASK = 'h8000000;
410  localparam GHC__CAP__SSS__DFLT = 'h0;
411 // RO: Supports Aggressive Link Power Management - no
412  localparam GHC__CAP__SALP__ADDR = 'h0;
413  localparam GHC__CAP__SALP__MASK = 'h4000000;
414  localparam GHC__CAP__SALP__DFLT = 'h0;
415 // RO: Supports Activity LED - no
416  localparam GHC__CAP__SAL__ADDR = 'h0;
417  localparam GHC__CAP__SAL__MASK = 'h2000000;
418  localparam GHC__CAP__SAL__DFLT = 'h0;
419 // RO: Supports Command List Override - no (not capable of clearing BSY and DRQ bits, needs soft reset
420  localparam GHC__CAP__SCLO__ADDR = 'h0;
421  localparam GHC__CAP__SCLO__MASK = 'h1000000;
422  localparam GHC__CAP__SCLO__DFLT = 'h0;
423 // RO: Interface Maximal speed: 2 - Gen2, 3 - Gen3
424  localparam GHC__CAP__ISS__ADDR = 'h0;
425  localparam GHC__CAP__ISS__MASK = 'hf00000;
426  localparam GHC__CAP__ISS__DFLT = 'h200000;
427 // RO: AHCI only (0 - legacy too)
428  localparam GHC__CAP__SAM__ADDR = 'h0;
429  localparam GHC__CAP__SAM__MASK = 'h40000;
430  localparam GHC__CAP__SAM__DFLT = 'h40000;
431 // RO: Supports Port Multiplier - no
432  localparam GHC__CAP__SPM__ADDR = 'h0;
433  localparam GHC__CAP__SPM__MASK = 'h20000;
434  localparam GHC__CAP__SPM__DFLT = 'h0;
435 // RO: Supports FIS-based switching of the Port Multiplier - no
436  localparam GHC__CAP__FBSS__ADDR = 'h0;
437  localparam GHC__CAP__FBSS__MASK = 'h10000;
438  localparam GHC__CAP__FBSS__DFLT = 'h0;
439 // RO: PIO Multiple DRQ block - no
440  localparam GHC__CAP__PMD__ADDR = 'h0;
441  localparam GHC__CAP__PMD__MASK = 'h8000;
442  localparam GHC__CAP__PMD__DFLT = 'h0;
443 // RO: Slumber State Capable - no
444  localparam GHC__CAP__SSC__ADDR = 'h0;
445  localparam GHC__CAP__SSC__MASK = 'h4000;
446  localparam GHC__CAP__SSC__DFLT = 'h0;
447 // RO: Partial State Capable - no
448  localparam GHC__CAP__PSC__ADDR = 'h0;
449  localparam GHC__CAP__PSC__MASK = 'h2000;
450  localparam GHC__CAP__PSC__DFLT = 'h0;
451 // RO: Number of Command Slots, 0-based (0 means 1?)
452  localparam GHC__CAP__NSC__ADDR = 'h0;
453  localparam GHC__CAP__NSC__MASK = 'h1f00;
454  localparam GHC__CAP__NSC__DFLT = 'h0;
455 // RO: Command Completion Coalescing - no
456  localparam GHC__CAP__CCCS__ADDR = 'h0;
457  localparam GHC__CAP__CCCS__MASK = 'h80;
458  localparam GHC__CAP__CCCS__DFLT = 'h0;
459 // RO: Enclosure Management - no
460  localparam GHC__CAP__EMS__ADDR = 'h0;
461  localparam GHC__CAP__EMS__MASK = 'h40;
462  localparam GHC__CAP__EMS__DFLT = 'h0;
463 // RO: External SATA connector - yes
464  localparam GHC__CAP__SXS__ADDR = 'h0;
465  localparam GHC__CAP__SXS__MASK = 'h20;
466  localparam GHC__CAP__SXS__DFLT = 'h20;
467 // RO: Number of Ports, 0-based (0 means 1?)
468  localparam GHC__CAP__NP__ADDR = 'h0;
469  localparam GHC__CAP__NP__MASK = 'h1f;
470  localparam GHC__CAP__NP__DFLT = 'h0;
471 // RO: AHCI enable (0 - legacy)
472  localparam GHC__GHC__AE__ADDR = 'h1;
473  localparam GHC__GHC__AE__MASK = 'h80000000;
474  localparam GHC__GHC__AE__DFLT = 'h80000000;
475 // RO: MSI Revert to Single Message
476  localparam GHC__GHC__MRSM__ADDR = 'h1;
477  localparam GHC__GHC__MRSM__MASK = 'h4;
478  localparam GHC__GHC__MRSM__DFLT = 'h0;
479 // RW: Interrupt Enable (all ports)
480  localparam GHC__GHC__IE__ADDR = 'h1;
481  localparam GHC__GHC__IE__MASK = 'h2;
482  localparam GHC__GHC__IE__DFLT = 'h0;
483 // RW1: HBA reset (COMINIT, ...). Set by software, cleared by hardware, section 10.4.3
484  localparam GHC__GHC__HR__ADDR = 'h1;
485  localparam GHC__GHC__HR__MASK = 'h1;
486  localparam GHC__GHC__HR__DFLT = 'h0;
487 // RWC: Interrupt Pending Status (per port)
488  localparam GHC__IS__IPS__ADDR = 'h2;
489  localparam GHC__IS__IPS__MASK = 'hffffffff;
490  localparam GHC__IS__IPS__DFLT = 'h0;
491 // RO: Ports Implemented
492  localparam GHC__PI__PI__ADDR = 'h3;
493  localparam GHC__PI__PI__MASK = 'hffffffff;
494  localparam GHC__PI__PI__DFLT = 'h1;
495 // RO: AHCI Major Version 1.
496  localparam GHC__VS__MJR__ADDR = 'h4;
497  localparam GHC__VS__MJR__MASK = 'hffff0000;
498  localparam GHC__VS__MJR__DFLT = 'h10000;
499 // RO: AHCI Minor Version 3.1
500  localparam GHC__VS__MNR__ADDR = 'h4;
501  localparam GHC__VS__MNR__MASK = 'hffff;
502  localparam GHC__VS__MNR__DFLT = 'h301;
503 // RO: DevSleep Entrance from Slumber Only
504  localparam GHC__CAP2__DESO__ADDR = 'h9;
505  localparam GHC__CAP2__DESO__MASK = 'h20;
506  localparam GHC__CAP2__DESO__DFLT = 'h0;
507 // RO: Supports Aggressive Device Sleep Management
508  localparam GHC__CAP2__SADM__ADDR = 'h9;
509  localparam GHC__CAP2__SADM__MASK = 'h10;
510  localparam GHC__CAP2__SADM__DFLT = 'h0;
511 // RO: Supports Device Sleep
512  localparam GHC__CAP2__SDS__ADDR = 'h9;
513  localparam GHC__CAP2__SDS__MASK = 'h8;
514  localparam GHC__CAP2__SDS__DFLT = 'h0;
515 // RO: Automatic Partial to Slumber Transitions
516  localparam GHC__CAP2__APST__ADDR = 'h9;
517  localparam GHC__CAP2__APST__MASK = 'h4;
518  localparam GHC__CAP2__APST__DFLT = 'h0;
519 // RO: NVMHCI Present (section 10.15)
520  localparam GHC__CAP2__NVMP__ADDR = 'h9;
521  localparam GHC__CAP2__NVMP__MASK = 'h2;
522  localparam GHC__CAP2__NVMP__DFLT = 'h0;
523 // RO: BIOS/OS Handoff - not supported
524  localparam GHC__CAP2__BOH__ADDR = 'h9;
525  localparam GHC__CAP2__BOH__MASK = 'h1;
526  localparam GHC__CAP2__BOH__DFLT = 'h0;
527 // RW: Command List Base Address (1KB aligned)
528  localparam HBA_PORT__PxCLB__CLB__ADDR = 'h40;
529  localparam HBA_PORT__PxCLB__CLB__MASK = 'hfffffc00;
530  localparam HBA_PORT__PxCLB__CLB__DFLT = 'h80000800;
531 // RW: Command List Base Address (1KB aligned)
532  localparam HBA_PORT__PxFB__CLB__ADDR = 'h42;
533  localparam HBA_PORT__PxFB__CLB__MASK = 'hffffff00;
534  localparam HBA_PORT__PxFB__CLB__DFLT = 'h80000c00;
535 // RWC: Cold Port Detect Status
536  localparam HBA_PORT__PxIS__CPDS__ADDR = 'h44;
537  localparam HBA_PORT__PxIS__CPDS__MASK = 'h80000000;
538  localparam HBA_PORT__PxIS__CPDS__DFLT = 'h0;
539 // RWC: Task File Error Status
540  localparam HBA_PORT__PxIS__TFES__ADDR = 'h44;
541  localparam HBA_PORT__PxIS__TFES__MASK = 'h40000000;
542  localparam HBA_PORT__PxIS__TFES__DFLT = 'h0;
543 // RWC: Host Bus (PCI) Fatal error
544  localparam HBA_PORT__PxIS__HBFS__ADDR = 'h44;
545  localparam HBA_PORT__PxIS__HBFS__MASK = 'h20000000;
546  localparam HBA_PORT__PxIS__HBFS__DFLT = 'h0;
547 // RWC: ECC error R/W system memory
548  localparam HBA_PORT__PxIS__HBDS__ADDR = 'h44;
549  localparam HBA_PORT__PxIS__HBDS__MASK = 'h10000000;
550  localparam HBA_PORT__PxIS__HBDS__DFLT = 'h0;
551 // RWC: Interface Fatal Error Status (sect. 6.1.2)
552  localparam HBA_PORT__PxIS__IFS__ADDR = 'h44;
553  localparam HBA_PORT__PxIS__IFS__MASK = 'h8000000;
554  localparam HBA_PORT__PxIS__IFS__DFLT = 'h0;
555 // RWC: Interface Non-Fatal Error Status (sect. 6.1.2)
556  localparam HBA_PORT__PxIS__INFS__ADDR = 'h44;
557  localparam HBA_PORT__PxIS__INFS__MASK = 'h4000000;
558  localparam HBA_PORT__PxIS__INFS__DFLT = 'h0;
559 // RWC: Overflow Status
560  localparam HBA_PORT__PxIS__OFS__ADDR = 'h44;
561  localparam HBA_PORT__PxIS__OFS__MASK = 'h1000000;
562  localparam HBA_PORT__PxIS__OFS__DFLT = 'h0;
563 // RWC: Incorrect Port Multiplier Status
564  localparam HBA_PORT__PxIS__IPMS__ADDR = 'h44;
565  localparam HBA_PORT__PxIS__IPMS__MASK = 'h800000;
566  localparam HBA_PORT__PxIS__IPMS__DFLT = 'h0;
567 // RO: PhyRdy changed Status
568  localparam HBA_PORT__PxIS__PRCS__ADDR = 'h44;
569  localparam HBA_PORT__PxIS__PRCS__MASK = 'h400000;
570  localparam HBA_PORT__PxIS__PRCS__DFLT = 'h0;
571 // RWC: Device Mechanical Presence Status
572  localparam HBA_PORT__PxIS__DMPS__ADDR = 'h44;
573  localparam HBA_PORT__PxIS__DMPS__MASK = 'h80;
574  localparam HBA_PORT__PxIS__DMPS__DFLT = 'h0;
575 // RO: Port Connect Change Status
576  localparam HBA_PORT__PxIS__PCS__ADDR = 'h44;
577  localparam HBA_PORT__PxIS__PCS__MASK = 'h40;
578  localparam HBA_PORT__PxIS__PCS__DFLT = 'h0;
579 // RWC: Descriptor Processed
580  localparam HBA_PORT__PxIS__DPS__ADDR = 'h44;
581  localparam HBA_PORT__PxIS__DPS__MASK = 'h20;
582  localparam HBA_PORT__PxIS__DPS__DFLT = 'h0;
583 // RO: Unknown FIS
584  localparam HBA_PORT__PxIS__UFS__ADDR = 'h44;
585  localparam HBA_PORT__PxIS__UFS__MASK = 'h10;
586  localparam HBA_PORT__PxIS__UFS__DFLT = 'h0;
587 // RWC: Set Device Bits Interrupt - Set Device bits FIS with 'I' bit set
588  localparam HBA_PORT__PxIS__SDBS__ADDR = 'h44;
589  localparam HBA_PORT__PxIS__SDBS__MASK = 'h8;
590  localparam HBA_PORT__PxIS__SDBS__DFLT = 'h0;
591 // RWC: DMA Setup FIS Interrupt - DMA Setup FIS received with 'I' bit set
592  localparam HBA_PORT__PxIS__DSS__ADDR = 'h44;
593  localparam HBA_PORT__PxIS__DSS__MASK = 'h4;
594  localparam HBA_PORT__PxIS__DSS__DFLT = 'h0;
595 // RWC: PIO Setup FIS Interrupt - PIO Setup FIS received with 'I' bit set
596  localparam HBA_PORT__PxIS__PSS__ADDR = 'h44;
597  localparam HBA_PORT__PxIS__PSS__MASK = 'h2;
598  localparam HBA_PORT__PxIS__PSS__DFLT = 'h0;
599 // RWC: D2H Register FIS Interrupt - D2H Register FIS received with 'I' bit set
600  localparam HBA_PORT__PxIS__DHRS__ADDR = 'h44;
601  localparam HBA_PORT__PxIS__DHRS__MASK = 'h1;
602  localparam HBA_PORT__PxIS__DHRS__DFLT = 'h0;
603 // RW: Cold Port Detect Enable
604  localparam HBA_PORT__PxIE__CPDE__ADDR = 'h45;
605  localparam HBA_PORT__PxIE__CPDE__MASK = 'h80000000;
606  localparam HBA_PORT__PxIE__CPDE__DFLT = 'h0;
607 // RW: Task File Error Enable
608  localparam HBA_PORT__PxIE__TFEE__ADDR = 'h45;
609  localparam HBA_PORT__PxIE__TFEE__MASK = 'h40000000;
610  localparam HBA_PORT__PxIE__TFEE__DFLT = 'h0;
611 // RW: Host Bus (PCI) Fatal Error Enable
612  localparam HBA_PORT__PxIE__HBFE__ADDR = 'h45;
613  localparam HBA_PORT__PxIE__HBFE__MASK = 'h20000000;
614  localparam HBA_PORT__PxIE__HBFE__DFLT = 'h0;
615 // RW: ECC Error R/W System Memory Enable
616  localparam HBA_PORT__PxIE__HBDE__ADDR = 'h45;
617  localparam HBA_PORT__PxIE__HBDE__MASK = 'h10000000;
618  localparam HBA_PORT__PxIE__HBDE__DFLT = 'h0;
619 // RW: Interface Fatal Error Enable (sect. 6.1.2)
620  localparam HBA_PORT__PxIE__IFE__ADDR = 'h45;
621  localparam HBA_PORT__PxIE__IFE__MASK = 'h8000000;
622  localparam HBA_PORT__PxIE__IFE__DFLT = 'h0;
623 // RW: Interface Non-Fatal Error Enable (sect. 6.1.2)
624  localparam HBA_PORT__PxIE__INFE__ADDR = 'h45;
625  localparam HBA_PORT__PxIE__INFE__MASK = 'h4000000;
626  localparam HBA_PORT__PxIE__INFE__DFLT = 'h0;
627 // RW: Overflow Enable
628  localparam HBA_PORT__PxIE__OFE__ADDR = 'h45;
629  localparam HBA_PORT__PxIE__OFE__MASK = 'h1000000;
630  localparam HBA_PORT__PxIE__OFE__DFLT = 'h0;
631 // RW: Incorrect Port Multiplier Enable
632  localparam HBA_PORT__PxIE__IPME__ADDR = 'h45;
633  localparam HBA_PORT__PxIE__IPME__MASK = 'h800000;
634  localparam HBA_PORT__PxIE__IPME__DFLT = 'h0;
635 // RW: PhyRdy changed Enable
636  localparam HBA_PORT__PxIE__PRCE__ADDR = 'h45;
637  localparam HBA_PORT__PxIE__PRCE__MASK = 'h400000;
638  localparam HBA_PORT__PxIE__PRCE__DFLT = 'h0;
639 // RO: Device Mechanical Presence Interrupt Enable
640  localparam HBA_PORT__PxIE__DMPE__ADDR = 'h45;
641  localparam HBA_PORT__PxIE__DMPE__MASK = 'h80;
642  localparam HBA_PORT__PxIE__DMPE__DFLT = 'h0;
643 // RW: Port Connect Change Interrupt Enable
644  localparam HBA_PORT__PxIE__PCE__ADDR = 'h45;
645  localparam HBA_PORT__PxIE__PCE__MASK = 'h40;
646  localparam HBA_PORT__PxIE__PCE__DFLT = 'h0;
647 // RW: Descriptor Processed Interrupt Enable
648  localparam HBA_PORT__PxIE__DPE__ADDR = 'h45;
649  localparam HBA_PORT__PxIE__DPE__MASK = 'h20;
650  localparam HBA_PORT__PxIE__DPE__DFLT = 'h0;
651 // RW: Unknown FIS
652  localparam HBA_PORT__PxIE__UFE__ADDR = 'h45;
653  localparam HBA_PORT__PxIE__UFE__MASK = 'h10;
654  localparam HBA_PORT__PxIE__UFE__DFLT = 'h0;
655 // RW: Device Bits Interrupt Enable
656  localparam HBA_PORT__PxIE__SDBE__ADDR = 'h45;
657  localparam HBA_PORT__PxIE__SDBE__MASK = 'h8;
658  localparam HBA_PORT__PxIE__SDBE__DFLT = 'h0;
659 // RW: DMA Setup FIS Interrupt Enable
660  localparam HBA_PORT__PxIE__DSE__ADDR = 'h45;
661  localparam HBA_PORT__PxIE__DSE__MASK = 'h4;
662  localparam HBA_PORT__PxIE__DSE__DFLT = 'h0;
663 // RW: PIO Setup FIS Interrupt Enable
664  localparam HBA_PORT__PxIE__PSE__ADDR = 'h45;
665  localparam HBA_PORT__PxIE__PSE__MASK = 'h2;
666  localparam HBA_PORT__PxIE__PSE__DFLT = 'h0;
667 // RW: D2H Register FIS Interrupt Enable
668  localparam HBA_PORT__PxIE__DHRE__ADDR = 'h45;
669  localparam HBA_PORT__PxIE__DHRE__MASK = 'h1;
670  localparam HBA_PORT__PxIE__DHRE__DFLT = 'h0;
671 // RW: Interface Communication Control
672  localparam HBA_PORT__PxCMD__ICC__ADDR = 'h46;
673  localparam HBA_PORT__PxCMD__ICC__MASK = 'hf0000000;
674  localparam HBA_PORT__PxCMD__ICC__DFLT = 'h0;
675 // RO: Aggressive Slumber/Partial - not implemented
676  localparam HBA_PORT__PxCMD__ASP__ADDR = 'h46;
677  localparam HBA_PORT__PxCMD__ASP__MASK = 'h8000000;
678  localparam HBA_PORT__PxCMD__ASP__DFLT = 'h0;
679 // RO: Aggressive Link Power Management Enable - not implemented
680  localparam HBA_PORT__PxCMD__ALPE__ADDR = 'h46;
681  localparam HBA_PORT__PxCMD__ALPE__MASK = 'h4000000;
682  localparam HBA_PORT__PxCMD__ALPE__DFLT = 'h0;
683 // RW: Drive LED on ATAPI enable
684  localparam HBA_PORT__PxCMD__DLAE__ADDR = 'h46;
685  localparam HBA_PORT__PxCMD__DLAE__MASK = 'h2000000;
686  localparam HBA_PORT__PxCMD__DLAE__DFLT = 'h0;
687 // RW: Device is ATAPI (for activity LED)
688  localparam HBA_PORT__PxCMD__ATAPI__ADDR = 'h46;
689  localparam HBA_PORT__PxCMD__ATAPI__MASK = 'h1000000;
690  localparam HBA_PORT__PxCMD__ATAPI__DFLT = 'h0;
691 // RW: Automatic Partial to Slumber Transitions Enabled
692  localparam HBA_PORT__PxCMD__APSTE__ADDR = 'h46;
693  localparam HBA_PORT__PxCMD__APSTE__MASK = 'h800000;
694  localparam HBA_PORT__PxCMD__APSTE__DFLT = 'h0;
695 // RO: FIS-Based Switching Capable Port - not implemented
696  localparam HBA_PORT__PxCMD__FBSCP__ADDR = 'h46;
697  localparam HBA_PORT__PxCMD__FBSCP__MASK = 'h400000;
698  localparam HBA_PORT__PxCMD__FBSCP__DFLT = 'h0;
699 // RO: External SATA port
700  localparam HBA_PORT__PxCMD__ESP__ADDR = 'h46;
701  localparam HBA_PORT__PxCMD__ESP__MASK = 'h200000;
702  localparam HBA_PORT__PxCMD__ESP__DFLT = 'h200000;
703 // RO: Cold Presence Detection
704  localparam HBA_PORT__PxCMD__CPD__ADDR = 'h46;
705  localparam HBA_PORT__PxCMD__CPD__MASK = 'h100000;
706  localparam HBA_PORT__PxCMD__CPD__DFLT = 'h0;
707 // RO: Mechanical Presence Switch Attached to Port
708  localparam HBA_PORT__PxCMD__MPSP__ADDR = 'h46;
709  localparam HBA_PORT__PxCMD__MPSP__MASK = 'h80000;
710  localparam HBA_PORT__PxCMD__MPSP__DFLT = 'h0;
711 // RO: Hot Plug Capable Port
712  localparam HBA_PORT__PxCMD__HPCP__ADDR = 'h46;
713  localparam HBA_PORT__PxCMD__HPCP__MASK = 'h40000;
714  localparam HBA_PORT__PxCMD__HPCP__DFLT = 'h40000;
715 // RW: Port Multiplier Attached - not implemented (software should write this bit)
716  localparam HBA_PORT__PxCMD__PMA__ADDR = 'h46;
717  localparam HBA_PORT__PxCMD__PMA__MASK = 'h20000;
718  localparam HBA_PORT__PxCMD__PMA__DFLT = 'h0;
719 // RO: Cold Presence State
720  localparam HBA_PORT__PxCMD__CPS__ADDR = 'h46;
721  localparam HBA_PORT__PxCMD__CPS__MASK = 'h10000;
722  localparam HBA_PORT__PxCMD__CPS__DFLT = 'h0;
723 // RO: Command List Running (section 5.3.2)
724  localparam HBA_PORT__PxCMD__CR__ADDR = 'h46;
725  localparam HBA_PORT__PxCMD__CR__MASK = 'h8000;
726  localparam HBA_PORT__PxCMD__CR__DFLT = 'h0;
727 // RO: FIS Receive Running (section 10.3.2)
728  localparam HBA_PORT__PxCMD__FR__ADDR = 'h46;
729  localparam HBA_PORT__PxCMD__FR__MASK = 'h4000;
730  localparam HBA_PORT__PxCMD__FR__DFLT = 'h0;
731 // RO: Mechanical Presence Switch State
732  localparam HBA_PORT__PxCMD__MPSS__ADDR = 'h46;
733  localparam HBA_PORT__PxCMD__MPSS__MASK = 'h2000;
734  localparam HBA_PORT__PxCMD__MPSS__DFLT = 'h0;
735 // RO: Current Command Slot (when PxCMD.ST 1-> ) should be reset to 0, when 0->1 - highest priority is 0
736  localparam HBA_PORT__PxCMD__CCS__ADDR = 'h46;
737  localparam HBA_PORT__PxCMD__CCS__MASK = 'h1f00;
738  localparam HBA_PORT__PxCMD__CCS__DFLT = 'h0;
739 // RW: FIS Receive Enable (enable after FIS memory is set)
740  localparam HBA_PORT__PxCMD__FRE__ADDR = 'h46;
741  localparam HBA_PORT__PxCMD__FRE__MASK = 'h10;
742  localparam HBA_PORT__PxCMD__FRE__DFLT = 'h0;
743 // RW1: Command List Override
744  localparam HBA_PORT__PxCMD__CLO__ADDR = 'h46;
745  localparam HBA_PORT__PxCMD__CLO__MASK = 'h8;
746  localparam HBA_PORT__PxCMD__CLO__DFLT = 'h0;
747 // RO: Power On Device (RW with Cold Presence Detection)
748  localparam HBA_PORT__PxCMD__POD__ADDR = 'h46;
749  localparam HBA_PORT__PxCMD__POD__MASK = 'h4;
750  localparam HBA_PORT__PxCMD__POD__DFLT = 'h4;
751 // RO: Spin-Up Device (RW with Staggered Spin-Up Support)
752  localparam HBA_PORT__PxCMD__SUD__ADDR = 'h46;
753  localparam HBA_PORT__PxCMD__SUD__MASK = 'h2;
754  localparam HBA_PORT__PxCMD__SUD__DFLT = 'h2;
755 // RW: Start (HBA may process commands). See section 10.3.1
756  localparam HBA_PORT__PxCMD__ST__ADDR = 'h46;
757  localparam HBA_PORT__PxCMD__ST__MASK = 'h1;
758  localparam HBA_PORT__PxCMD__ST__DFLT = 'h0;
759 // RO: Latest Copy of Task File Error Register
760  localparam HBA_PORT__PxTFD__ERR__ADDR = 'h48;
761  localparam HBA_PORT__PxTFD__ERR__MASK = 'hff00;
762  localparam HBA_PORT__PxTFD__ERR__DFLT = 'h0;
763 // RO: Latest Copy of Task File Status Register: BSY
764  localparam HBA_PORT__PxTFD__STS__BSY__ADDR = 'h48;
765  localparam HBA_PORT__PxTFD__STS__BSY__MASK = 'h80;
766  localparam HBA_PORT__PxTFD__STS__BSY__DFLT = 'h0;
767 // RO: Latest Copy of Task File Status Register: command-specific bits 4..6
768  localparam HBA_PORT__PxTFD__STS__64__ADDR = 'h48;
769  localparam HBA_PORT__PxTFD__STS__64__MASK = 'h70;
770  localparam HBA_PORT__PxTFD__STS__64__DFLT = 'h0;
771 // RO: Latest Copy of Task File Status Register: DRQ
772  localparam HBA_PORT__PxTFD__STS__DRQ__ADDR = 'h48;
773  localparam HBA_PORT__PxTFD__STS__DRQ__MASK = 'h8;
774  localparam HBA_PORT__PxTFD__STS__DRQ__DFLT = 'h0;
775 // RO: Latest Copy of Task File Status Register: command-specific bits 1..2
776  localparam HBA_PORT__PxTFD__STS__12__ADDR = 'h48;
777  localparam HBA_PORT__PxTFD__STS__12__MASK = 'h6;
778  localparam HBA_PORT__PxTFD__STS__12__DFLT = 'h0;
779 // RO: Latest Copy of Task File Status Register: ERR
780  localparam HBA_PORT__PxTFD__STS__ERR__ADDR = 'h48;
781  localparam HBA_PORT__PxTFD__STS__ERR__MASK = 'h1;
782  localparam HBA_PORT__PxTFD__STS__ERR__DFLT = 'h0;
783 // RO: Data in the first D2H Register FIS
784  localparam HBA_PORT__PxSIG__SIG__ADDR = 'h49;
785  localparam HBA_PORT__PxSIG__SIG__MASK = 'hffffffff;
786  localparam HBA_PORT__PxSIG__SIG__DFLT = 'hffffffff;
787 // RO: Interface Power Management
788  localparam HBA_PORT__PxSSTS__IPM__ADDR = 'h4a;
789  localparam HBA_PORT__PxSSTS__IPM__MASK = 'hf00;
790  localparam HBA_PORT__PxSSTS__IPM__DFLT = 'h0;
791 // RO: Interface Speed
792  localparam HBA_PORT__PxSSTS__SPD__ADDR = 'h4a;
793  localparam HBA_PORT__PxSSTS__SPD__MASK = 'hf0;
794  localparam HBA_PORT__PxSSTS__SPD__DFLT = 'h0;
795 // RO: Device Detection (should be detected if COMINIT is received)
796  localparam HBA_PORT__PxSSTS__DET__ADDR = 'h4a;
797  localparam HBA_PORT__PxSSTS__DET__MASK = 'hf;
798  localparam HBA_PORT__PxSSTS__DET__DFLT = 'h0;
799 // RO: Port Multiplier Port - not used by AHCI
800  localparam HBA_PORT__PxSCTL__PMP__ADDR = 'h4b;
801  localparam HBA_PORT__PxSCTL__PMP__MASK = 'hf0000;
802  localparam HBA_PORT__PxSCTL__PMP__DFLT = 'h0;
803 // RO: Select Power Management - not used by AHCI
804  localparam HBA_PORT__PxSCTL__SPM__ADDR = 'h4b;
805  localparam HBA_PORT__PxSCTL__SPM__MASK = 'hf000;
806  localparam HBA_PORT__PxSCTL__SPM__DFLT = 'h0;
807 // RW: Interface Power Management Transitions Allowed
808  localparam HBA_PORT__PxSCTL__IPM__ADDR = 'h4b;
809  localparam HBA_PORT__PxSCTL__IPM__MASK = 'hf00;
810  localparam HBA_PORT__PxSCTL__IPM__DFLT = 'h0;
811 // RW: Interface Highest Speed
812  localparam HBA_PORT__PxSCTL__SPD__ADDR = 'h4b;
813  localparam HBA_PORT__PxSCTL__SPD__MASK = 'hf0;
814  localparam HBA_PORT__PxSCTL__SPD__DFLT = 'h0;
815 // RW: Device Detection Initialization
816  localparam HBA_PORT__PxSCTL__DET__ADDR = 'h4b;
817  localparam HBA_PORT__PxSCTL__DET__MASK = 'hf;
818  localparam HBA_PORT__PxSCTL__DET__DFLT = 'h0;
819 // RWC: Exchanged (set on COMINIT), reflected in PxIS.PCS
820  localparam HBA_PORT__PxSERR__DIAG__X__ADDR = 'h4c;
821  localparam HBA_PORT__PxSERR__DIAG__X__MASK = 'h4000000;
822  localparam HBA_PORT__PxSERR__DIAG__X__DFLT = 'h0;
823 // RWC: Unknown FIS
824  localparam HBA_PORT__PxSERR__DIAG__F__ADDR = 'h4c;
825  localparam HBA_PORT__PxSERR__DIAG__F__MASK = 'h2000000;
826  localparam HBA_PORT__PxSERR__DIAG__F__DFLT = 'h0;
827 // RWC: Transport state transition error
828  localparam HBA_PORT__PxSERR__DIAG__T__ADDR = 'h4c;
829  localparam HBA_PORT__PxSERR__DIAG__T__MASK = 'h1000000;
830  localparam HBA_PORT__PxSERR__DIAG__T__DFLT = 'h0;
831 // RWC: Link sequence error
832  localparam HBA_PORT__PxSERR__DIAG__S__ADDR = 'h4c;
833  localparam HBA_PORT__PxSERR__DIAG__S__MASK = 'h800000;
834  localparam HBA_PORT__PxSERR__DIAG__S__DFLT = 'h0;
835 // RWC: Handshake Error (i.e. Device got CRC error)
836  localparam HBA_PORT__PxSERR__DIAG__H__ADDR = 'h4c;
837  localparam HBA_PORT__PxSERR__DIAG__H__MASK = 'h400000;
838  localparam HBA_PORT__PxSERR__DIAG__H__DFLT = 'h0;
839 // RWC: CRC error in Link layer
840  localparam HBA_PORT__PxSERR__DIAG__C__ADDR = 'h4c;
841  localparam HBA_PORT__PxSERR__DIAG__C__MASK = 'h200000;
842  localparam HBA_PORT__PxSERR__DIAG__C__DFLT = 'h0;
843 // RWC: Disparity Error - not used by AHCI
844  localparam HBA_PORT__PxSERR__DIAG__D__ADDR = 'h4c;
845  localparam HBA_PORT__PxSERR__DIAG__D__MASK = 'h100000;
846  localparam HBA_PORT__PxSERR__DIAG__D__DFLT = 'h0;
847 // RWC: 10B to 8B decode error
848  localparam HBA_PORT__PxSERR__DIAG__B__ADDR = 'h4c;
849  localparam HBA_PORT__PxSERR__DIAG__B__MASK = 'h80000;
850  localparam HBA_PORT__PxSERR__DIAG__B__DFLT = 'h0;
851 // RWC: COMMWAKE signal was detected
852  localparam HBA_PORT__PxSERR__DIAG__W__ADDR = 'h4c;
853  localparam HBA_PORT__PxSERR__DIAG__W__MASK = 'h40000;
854  localparam HBA_PORT__PxSERR__DIAG__W__DFLT = 'h0;
855 // RWC: PHY Internal Error
856  localparam HBA_PORT__PxSERR__DIAG__I__ADDR = 'h4c;
857  localparam HBA_PORT__PxSERR__DIAG__I__MASK = 'h20000;
858  localparam HBA_PORT__PxSERR__DIAG__I__DFLT = 'h0;
859 // RWC: PhyRdy changed. Reflected in PxIS.PRCS bit.
860  localparam HBA_PORT__PxSERR__DIAG__N__ADDR = 'h4c;
861  localparam HBA_PORT__PxSERR__DIAG__N__MASK = 'h10000;
862  localparam HBA_PORT__PxSERR__DIAG__N__DFLT = 'h0;
863 // RWC: Internal Error
864  localparam HBA_PORT__PxSERR__ERR__E__ADDR = 'h4c;
865  localparam HBA_PORT__PxSERR__ERR__E__MASK = 'h800;
866  localparam HBA_PORT__PxSERR__ERR__E__DFLT = 'h0;
867 // RWC: Protocol Error - a violation of SATA protocol detected
868  localparam HBA_PORT__PxSERR__ERR__P__ADDR = 'h4c;
869  localparam HBA_PORT__PxSERR__ERR__P__MASK = 'h400;
870  localparam HBA_PORT__PxSERR__ERR__P__DFLT = 'h0;
871 // RWC: Persistent Communication or Data Integrity Error
872  localparam HBA_PORT__PxSERR__ERR__C__ADDR = 'h4c;
873  localparam HBA_PORT__PxSERR__ERR__C__MASK = 'h200;
874  localparam HBA_PORT__PxSERR__ERR__C__DFLT = 'h0;
875 // RWC: Transient Data Integrity Error (error not recovered by the interface)
876  localparam HBA_PORT__PxSERR__ERR__T__ADDR = 'h4c;
877  localparam HBA_PORT__PxSERR__ERR__T__MASK = 'h100;
878  localparam HBA_PORT__PxSERR__ERR__T__DFLT = 'h0;
879 // RWC: Communication between the device and host was lost but re-established
880  localparam HBA_PORT__PxSERR__ERR__M__ADDR = 'h4c;
881  localparam HBA_PORT__PxSERR__ERR__M__MASK = 'h2;
882  localparam HBA_PORT__PxSERR__ERR__M__DFLT = 'h0;
883 // RWC: Recovered Data integrity Error
884  localparam HBA_PORT__PxSERR__ERR__I__ADDR = 'h4c;
885  localparam HBA_PORT__PxSERR__ERR__I__MASK = 'h1;
886  localparam HBA_PORT__PxSERR__ERR__I__DFLT = 'h0;
887 // RW1: Device Status: bit per Port, for TAG in native queued command
888  localparam HBA_PORT__PxSACT__DS__ADDR = 'h4d;
889  localparam HBA_PORT__PxSACT__DS__MASK = 'hffffffff;
890  localparam HBA_PORT__PxSACT__DS__DFLT = 'h0;
891 // RW1: Command Issued: bit per Port, only set when PxCMD.ST==1, also cleared by PxCMD.ST: 1->0 by soft
892  localparam HBA_PORT__PxCI__CI__ADDR = 'h4e;
893  localparam HBA_PORT__PxCI__CI__MASK = 'hffffffff;
894  localparam HBA_PORT__PxCI__CI__DFLT = 'h0;
895 // RWC: PM Notify (bit per PM port)
896  localparam HBA_PORT__PxSNTF__PMN__ADDR = 'h4f;
897  localparam HBA_PORT__PxSNTF__PMN__MASK = 'hffff;
898  localparam HBA_PORT__PxSNTF__PMN__DFLT = 'h0;
899 // RO: Device with Error
900  localparam HBA_PORT__PxFBS__DWE__ADDR = 'h50;
901  localparam HBA_PORT__PxFBS__DWE__MASK = 'hf0000;
902  localparam HBA_PORT__PxFBS__DWE__DFLT = 'h0;
903 // RO: Active Device Optimization
904  localparam HBA_PORT__PxFBS__ADO__ADDR = 'h50;
905  localparam HBA_PORT__PxFBS__ADO__MASK = 'hf000;
906  localparam HBA_PORT__PxFBS__ADO__DFLT = 'h0;
907 // RW: Device To Issue
908  localparam HBA_PORT__PxFBS__DEV__ADDR = 'h50;
909  localparam HBA_PORT__PxFBS__DEV__MASK = 'hf00;
910  localparam HBA_PORT__PxFBS__DEV__DFLT = 'h0;
911 // RO: Single Device Error
912  localparam HBA_PORT__PxFBS__SDE__ADDR = 'h50;
913  localparam HBA_PORT__PxFBS__SDE__MASK = 'h4;
914  localparam HBA_PORT__PxFBS__SDE__DFLT = 'h0;
915 // RW1: Device Error Clear
916  localparam HBA_PORT__PxFBS__DEC__ADDR = 'h50;
917  localparam HBA_PORT__PxFBS__DEC__MASK = 'h2;
918  localparam HBA_PORT__PxFBS__DEC__DFLT = 'h0;
919 // RW: Enable
920  localparam HBA_PORT__PxFBS__EN__ADDR = 'h50;
921  localparam HBA_PORT__PxFBS__EN__MASK = 'h1;
922  localparam HBA_PORT__PxFBS__EN__DFLT = 'h0;
923 // RO: DITO Multiplier
924  localparam HBA_PORT__PxDEVSLP__DM__ADDR = 'h51;
925  localparam HBA_PORT__PxDEVSLP__DM__MASK = 'h1e000000;
926  localparam HBA_PORT__PxDEVSLP__DM__DFLT = 'h0;
927 // RW: Device Sleep Idle Timeout (section 8.5.1.1.1)
928  localparam HBA_PORT__PxDEVSLP__DITO__ADDR = 'h51;
929  localparam HBA_PORT__PxDEVSLP__DITO__MASK = 'h1ff8000;
930  localparam HBA_PORT__PxDEVSLP__DITO__DFLT = 'h0;
931 // RW: Minimum Device Sleep Assertion Time
932  localparam HBA_PORT__PxDEVSLP__MDAT__ADDR = 'h51;
933  localparam HBA_PORT__PxDEVSLP__MDAT__MASK = 'h7c00;
934  localparam HBA_PORT__PxDEVSLP__MDAT__DFLT = 'h0;
935 // RW: Device Sleep Exit Timeout
936  localparam HBA_PORT__PxDEVSLP__DETO__ADDR = 'h51;
937  localparam HBA_PORT__PxDEVSLP__DETO__MASK = 'h3fc;
938  localparam HBA_PORT__PxDEVSLP__DETO__DFLT = 'h0;
939 // RO: Device Sleep Present
940  localparam HBA_PORT__PxDEVSLP__DSP__ADDR = 'h51;
941  localparam HBA_PORT__PxDEVSLP__DSP__MASK = 'h2;
942  localparam HBA_PORT__PxDEVSLP__DSP__DFLT = 'h0;
943 // RO: Aggressive Device Sleep Enable
944  localparam HBA_PORT__PxDEVSLP__ADSE__ADDR = 'h51;
945  localparam HBA_PORT__PxDEVSLP__ADSE__MASK = 'h1;
946  localparam HBA_PORT__PxDEVSLP__ADSE__DFLT = 'h0;
947 // RW: SAXIHP write channel cache mode
948  localparam HBA_PORT__AFI_CACHE__WR_CM__ADDR = 'h5c;
949  localparam HBA_PORT__AFI_CACHE__WR_CM__MASK = 'hf0;
950  localparam HBA_PORT__AFI_CACHE__WR_CM__DFLT = 'h30;
951 // RW: SAXIHP read channel cache mode
952  localparam HBA_PORT__AFI_CACHE__RD_CM__ADDR = 'h5c;
953  localparam HBA_PORT__AFI_CACHE__RD_CM__MASK = 'hf;
954  localparam HBA_PORT__AFI_CACHE__RD_CM__DFLT = 'h3;
955 // RW: Address/not data for programming AHCI state machine
956  localparam HBA_PORT__PGM_AHCI_SM__AnD__ADDR = 'h5d;
957  localparam HBA_PORT__PGM_AHCI_SM__AnD__MASK = 'h1000000;
958  localparam HBA_PORT__PGM_AHCI_SM__AnD__DFLT = 'h0;
959 // RW: Program address/data for programming AHCI state machine
960  localparam HBA_PORT__PGM_AHCI_SM__PGM_AD__ADDR = 'h5d;
961  localparam HBA_PORT__PGM_AHCI_SM__PGM_AD__MASK = 'h3ffff;
962  localparam HBA_PORT__PGM_AHCI_SM__PGM_AD__DFLT = 'h0;
963 // RW: 3-bit tag to add to the recorded timestamp
964  localparam HBA_PORT__PunchTime__TAG__ADDR = 'h5e;
965  localparam HBA_PORT__PunchTime__TAG__MASK = 'h7;
966  localparam HBA_PORT__PunchTime__TAG__DFLT = 'h0;
967 
968 
969  wire [AXIBRAM_BITS-1:0] bram_waddr;
970 // wire [ADDRESS_BITS-1:0] pre_awaddr;
971  wire [AXIBRAM_BITS-1:0] bram_raddr;
972  wire [31:0] bram_rdata;
973  wire pre_bram_wen; // one cycle ahead of bram_wen, nut not masked by dev_ready
974  wire bram_wen;
975  wire [ 3:0] bram_wstb;
976  wire [31:0] bram_wdata;
977  wire [ADDRESS_BITS-1:0] bram_addr;
978 
979 
980  wire [1:0] bram_ren;
981  reg write_busy_r;
982  wire write_start_burst;
983 // wire nowrite; // delay write in read-modify-write register accesses
984 /// wire write_busy_w = write_busy_r || write_start_burst;
986  reg [31:0] bram_wdata_r;
987  reg [31:0] bram_rdata_r;
988 // reg bram_wen_d;
989  wire [63:0] regbit_type;
990  wire [31:0] ahci_regs_di;
991  reg [ 3:0] bram_wstb_r;
992  reg bram_wen_r;
993 // wire [31:0] wmask = {{8{bram_wstb[3]}},{8{bram_wstb[2]}},{8{bram_wstb[1]}},{8{bram_wstb[0]}}};
994  wire [31:0] wmask = {{8{bram_wstb_r[3]}},{8{bram_wstb_r[2]}},{8{bram_wstb_r[1]}},{8{bram_wstb_r[0]}}};
995  reg [ADDRESS_BITS-1:0] bram_waddr_r;
996 
997  reg [HBA_RESET_BITS-1:0] hba_reset_cntr; // time to keep hba_reset_r active after writing to GHC.HR
998  reg hba_rst_r; // hba _reset (currently does ~ the same as port reset)
999  reg port_rst_r; // port _reset by software
1000  reg port_arst_any_r = 1; // port _reset by software or POR
1001 
1002  wire high_sel = bram_waddr_r[ADDRESS_BITS-1]; // high addresses - use single-cycle writes without read-modify-write
1003  wire afi_cache_set_w = bram_wen_r && !high_sel && (bram_addr == HBA_PORT__AFI_CACHE__WR_CM__ADDR);
1004  wire pgm_fsm_set_w = bram_wen_r && !high_sel && (bram_addr == HBA_PORT__PGM_AHCI_SM__PGM_AD__ADDR);
1005  wire pgm_fsm_and_w = |(ahci_regs_di & HBA_PORT__PGM_AHCI_SM__AnD__MASK);
1006 
1007  wire set_hba_rst = bram_wen_r && !high_sel && (bram_addr == GHC__GHC__HR__ADDR) && (ahci_regs_di & GHC__GHC__HR__MASK);
1008  localparam HBA_PORT__PxSCTL__DET__MASK01 = HBA_PORT__PxSCTL__DET__MASK & ~1; // == 'he
1009  wire set_port_rst = bram_wen_r && !high_sel && (bram_addr == HBA_PORT__PxSCTL__DET__ADDR) &&
1010  ((ahci_regs_di & HBA_PORT__PxSCTL__DET__MASK01) == 0); // writing only 0/1
1011  // in lower 4 bits
1012 
1013  wire port_rst_on = set_port_rst && ahci_regs_di[0];
1014  reg was_hba_rst_aclk; // last reset was hba reset (not counting system reset)
1015  reg was_port_rst_aclk; // last reset was port reset
1016  reg [2:0] was_hba_rst_r; // last reset was hba reset (not counting system reset)
1017  reg [2:0] was_port_rst_r; // last reset was port reset
1018  reg [2:0] arst_r = ~0; // previous state of arst
1019  reg wait_first_access = RESET_TO_FIRST_ACCESS; // keep port reset until first access
1020  wire any_access = bram_wen_r || bram_ren[0];
1021  reg debug_rd_r = 0;
1022  reg [31:0] debug_r;
1023 
1024 
1026 
1027  assign hba_arst = hba_rst_r; // hba _reset (currently does ~ the same as port reset)
1028  assign port_arst = port_rst_r; // port _reset by software
1029  assign port_arst_any = port_arst_any_r;
1030  assign was_hba_rst = was_hba_rst_r[0];
1031  assign was_port_rst = was_port_rst_r[0];
1032 
1033 
1034  always @(posedge aclk) begin
1035 `ifdef USE_DRP
1036  if (bram_waddr == DRP_ADDR) begin
1037  drp_di <= bram_wdata[15: 0];
1038  drp_addr <= bram_wdata[30:16];
1039 // drp_we <= bram_wdata[31];
1040  end
1041 
1042  drp_en <= (bram_waddr == DRP_ADDR);
1043  drp_we <= (bram_waddr == DRP_ADDR) && bram_wdata[31];
1044 
1045  if (arst || (bram_waddr == DRP_ADDR)) drp_ready_r <= 0;
1046  else if (drp_rdy) drp_ready_r <= 1;
1047 
1048  if (drp_rdy) drp_read_data <= drp_do;
1049 
1050  if (bram_ren[0]) drp_read_r <= (bram_raddr == DRP_ADDR);
1051 
1052 `endif
1053 
1054 
1055  if (arst) write_busy_r <= 0;
1056  else if (write_start_burst) write_busy_r <= 1;
1057  else if (!pre_bram_wen) write_busy_r <= 0;
1058 
1060 
1061  bram_wstb_r <= {4{bram_wen}} & bram_wstb;
1062 
1063  bram_wen_r <= bram_wen;
1064 
1066 `ifndef NO_DEBUG_OUT
1067  `ifdef USE_DATASCOPE
1068  if (bram_ren[0]) debug_rd_r <= (&bram_raddr[ADDRESS_BITS-1:4]) &&
1069  // (bram_raddr[3:2] == 0) &&
1070  !bram_raddr[ADDRESS_BITS]; //
1071  `else
1072  if (bram_ren[0]) debug_rd_r <= (&bram_raddr[ADDRESS_BITS-1:4]); // &&
1073  // (bram_raddr[3:2] == 0); //
1074  `endif
1075 `endif // `else `ifdef NO_DEBUG_OUT
1076  if (bram_ren[0]) debug_r <= bram_raddr[1]? (bram_raddr[0] ? debug_in3: debug_in2):
1077  (bram_raddr[0] ? debug_in1: debug_in0);
1078 
1079 
1080 `ifdef USE_DRP
1083 `else
1084  if (bram_ren[1]) bram_rdata_r <= debug_rd_r? debug_r : bram_rdata;
1085 `endif
1086  end
1087 
1088  //debug_rd_r
1089 
1090  generate
1091  genvar i;
1092  for (i=0; i < 32; i=i+1) begin: bit_type_block
1093  assign ahci_regs_di[i] = (regbit_type[2*i+1] && wmask[i] && !high_sel)?
1094  ((regbit_type[2*i] && wmask[i])?
1095  (bram_rdata[i] || bram_wdata_r[i]): // 3: RW1
1096  (bram_rdata[i] && !bram_wdata_r[i])): // 2: RWC
1097  (((regbit_type[2*i] && wmask[i]) || high_sel)?
1098  (bram_wdata_r[i]): // 1: RW write new data - get here for high_sel
1099  (bram_rdata[i])); // 0: R0 (keep old data)
1100  end
1101  endgenerate
1102 
1103 // always @ (posedge aclk or posedge arst) begin
1104  always @ (posedge aclk) begin
1106  else if (any_access) wait_first_access <= 0;
1107 
1108  if (arst) port_arst_any_r <= 1;
1109  else if (set_port_rst) port_arst_any_r <= ahci_regs_di[0]; // write "1" - reset on, write 0 - reset off
1110  else if (wait_first_access && any_access) port_arst_any_r <= 0;
1111  else if (arst_r[2] && !arst_r[1]) port_arst_any_r <= wait_first_access;
1112  end
1113 
1114  always @(posedge aclk) begin
1115  if (arst) hba_reset_cntr <= 0; // 1; no HBA reset at arst
1116  else if (set_hba_rst) hba_reset_cntr <= {HBA_RESET_BITS{1'b1}};
1117  else if (|hba_reset_cntr) hba_reset_cntr <= hba_reset_cntr - 1;
1118 
1119  hba_rst_r <= hba_reset_cntr != 0;
1120 
1121  if (arst) port_rst_r <= 0;
1122  else if (set_port_rst) port_rst_r <= ahci_regs_di[0]; // write "1" - reset on, write 0 - reset off
1123 
1124  if (arst || port_rst_on) was_hba_rst_aclk <= 0;
1125  else if (set_hba_rst) was_hba_rst_aclk <= 1;
1126 
1127  if (arst || set_hba_rst) was_port_rst_aclk <= 0;
1128  else if (port_rst_on) was_port_rst_aclk <= 1;
1129 
1130  if (arst) arst_r <= ~0;
1131  else arst_r <= arst_r << 1;
1132 
1133  end
1134 
1135  always @ (hba_clk) begin
1138  end
1139 
1140 
1141 
1142  always @(posedge aclk) begin
1143  if (arst) {afi_wcache,afi_rcache} <= 8'h33;
1144  else if (afi_cache_set_w) {afi_wcache,afi_rcache} <= ahci_regs_di[7:0];
1145  end
1146 
1147  always @(posedge aclk) begin
1148  if (arst) {pgm_wa,pgm_wd} <= 0;
1149  else {pgm_wa,pgm_wd} <= {2{pgm_fsm_set_w}} & {pgm_fsm_and_w, ~pgm_fsm_and_w};
1150 
1151  if (pgm_fsm_set_w) pgm_ad <= ahci_regs_di[17:0];
1152  end
1153 
1154 
1155 
1156 /*
1157 Will generate async reset on both HBA reset(for some time) and port reset (until released)
1158 until it is more clear about GTX reset options. Such reset will be applied to both PLL and GTX,
1159 sata_phy_rst_out will be released after the sata clock is stable
1160  output soft_arst, // reset SATA PHY not relying on SATA clock
1161  // TODO: Decode from {bram_addr, ahci_regs_di}, bram_wen_d
1162  input sata_phy_rst_out, // when PLL locked, SATA PHY reset is over, this signal is released
1163  localparam GHC__GHC__HR__ADDR = 'h1;
1164  localparam GHC__GHC__HR__MASK = 'h1;
1165  localparam GHC__GHC__HR__DFLT = 'h0;
1166 
1167  reg [HBA_RESET_BITS-1:0] hba_reset_cntr; // time to keep hba_reset_r active after writing to GHC.HR
1168  reg hba_rst_r; // hba reset (currently does ~ the same as port reset)
1169  reg port_rst_r; // port reset by software
1170  .rst (1'b0), // input
1171  .rrst (hba_rst), // input
1172  .wrst (arst), // input
1173  .rclk (hba_clk), // input
1174  .wclk (aclk), // input
1175  .we (bram_wen_r && !high_sel), // input
1176  .re (soft_write_en), // input
1177  .data_in ({bram_addr, ahci_regs_di}), // input[15:0]
1178  .data_out ({soft_write_addr,soft_write_data}), // output[15:0]
1179  .nempty (soft_write_en), // output
1180  .half_empty () // output
1181 
1182 // RO: Device Detection Initialization
1183  localparam HBA_PORT__PxSCTL__DET__ADDR = 'h4b;
1184  localparam HBA_PORT__PxSCTL__DET__MASK = 'hf;
1185  localparam HBA_PORT__PxSCTL__DET__DFLT = 'h0;
1186 
1187 
1188 */
1189 
1190 
1191  axibram_write #(
1192  .ADDRESS_BITS(AXIBRAM_BITS) // in debug mode - 1 bit more than ADDERSS_BITS
1193  ) axibram_write_i (
1194  .aclk (aclk), // input
1195  .arst (arst), // input
1196  .awaddr (awaddr), // input[31:0]
1197  .awvalid (awvalid), // input
1198  .awready (awready), // output
1199  .awid (awid), // input[11:0]
1200  .awlen (awlen), // input[3:0]
1201  .awsize (awsize), // input[1:0]
1202  .awburst (awburst), // input[1:0]
1203  .wdata (wdata), // input[31:0]
1204  .wvalid (wvalid), // input
1205  .wready (wready), // output
1206  .wid (wid), // input[11:0]
1207  .wlast (wlast), // input
1208  .wstb (wstb), // input[3:0]
1209  .bvalid (bvalid), // output
1210  .bready (bready), // input
1211  .bid (bid), // output[11:0]
1212  .bresp (bresp), // output[1:0]
1213  .pre_awaddr (), //pre_awaddr), // output[9:0]
1214  .start_burst (write_start_burst), // output
1215 // .dev_ready (!nowrite && !bram_ren[0]), // input
1216  .dev_ready (!bram_wen), // input There will be no 2 bram_wen in a row
1217  .bram_wclk (), // output
1218  .bram_waddr (bram_waddr), // output[9:0]
1219  .pre_bram_wen(pre_bram_wen), // output
1220  .bram_wen (bram_wen), // output
1221  .bram_wstb (bram_wstb), // output[3:0]
1222  .bram_wdata (bram_wdata) // output[31:0]
1223  );
1224 
1225  axibram_read #(
1226  .ADDRESS_BITS(AXIBRAM_BITS) // in debug mode - 1 bit more than ADDERSS_BITS
1227  ) axibram_read_i (
1228  .aclk (aclk), // input
1229  .arst (arst), // input
1230  .araddr (araddr), // input[31:0]
1231  .arvalid (arvalid), // input
1232  .arready (arready), // output
1233  .arid (arid), // input[11:0]
1234  .arlen (arlen), // input[3:0]
1235  .arsize (arsize), // input[1:0]
1236  .arburst (arburst), // input[1:0]
1237  .rdata (rdata), // output[31:0]
1238  .rvalid (rvalid), // output reg
1239  .rready (rready), // input
1240  .rid (rid), // output[11:0] reg
1241  .rlast (rlast), // output reg
1242  .rresp (rresp), // output[1:0]
1243  .pre_araddr (), // output[9:0]
1244  .start_burst (), // output
1245  .dev_ready (!write_busy_w), // input
1246  .bram_rclk (), // output
1247  .bram_raddr (bram_raddr), // output[9:0]
1248  .bram_ren (bram_ren[0]), // output
1249  .bram_regen (bram_ren[1]), // output
1250 `ifdef USE_DATASCOPE
1253  bram_rdata_r) // input[31:0]
1254 `else
1255  .bram_rdata (bram_rdata_r) // input[31:0]
1256 `endif
1257  );
1258 
1259  // Register memory, lower half uses read-modify-write using bit type from ahci_regs_type_i ROM, 2 aclk cycles/per write and
1260  // high addresses half are just plain write registers, they heve single-cycle write
1261  // Only low registers write generates cross-clock writes over the FIFO.
1262  // All registers can be accessed in byte/word/dword mode over the AXI
1263 
1264  // Lower registers are used as AHCI memory registers, high - for AHCI command list(s), to eliminate the need to update transfer count
1265  // in the system memory.
1266 
1268  .REGISTERS_A (0),
1269  .REGISTERS_B (1),
1270  .LOG2WIDTH_A (5),
1271  .LOG2WIDTH_B (5),
1272  .WRITE_MODE_A("NO_CHANGE"),
1273  .WRITE_MODE_B("NO_CHANGE"), .INIT_00 (256'h0000000000000000000000000001030100000001000000008000000000240020)
1274 , .INIT_08 (256'h000000000024000600000000000000000000000080000C000000000080000800)
1275 , .INIT_09 (256'h000000000000000000000000000000000000000000000000FFFFFFFF00000000)
1276 , .INIT_0B (256'h0000000000000000000000000000003300000000000000000000000000000000)
1277 , .INIT_0C (256'h000000000000000000000000000000000000000001010002001000000001FFFE)
1278 , .INIT_0D (256'h000001000000000000000040000000000001FFFE000000008000000000000000)
1279 , .INIT_0E (256'h0000000000000000000000000000000000000000000000000000000040000001)
1280 
1281  ) ahci_regs_i (
1282  .clk_a (aclk), // input
1283  .addr_a (bram_addr), // input[9:0]
1284  .en_a (bram_ren[0] || bram_wen || bram_wen_r), // input
1285  .regen_a (1'b0), // input
1286  .we_a (bram_wstb_r), // input[3:0]
1287 //
1288  .data_out_a (bram_rdata), // output[31:0]
1289  .data_in_a (ahci_regs_di), // input[31:0]
1290  .clk_b (hba_clk), // input
1291  .addr_b (hba_addr), // input[9:0]
1292  .en_b (hba_we || hba_re[0]), // input
1293  .regen_b (hba_re[1]), // input
1294  .we_b ({4{hba_we}}), // input
1295  .data_out_b (hba_dout), // output[31:0]
1296  .data_in_b (hba_din) // input[31:0]
1297  );
1298 
1299  ram_var_w_var_r #(
1300  .REGISTERS (0),
1301  .LOG2WIDTH_WR (6),
1302  .LOG2WIDTH_RD (6),
1303  .DUMMY(0), .INIT_00 (256'h0000000000000000AAAAAAAAAAAAAAAA00000000000000070000000000000000)
1304 , .INIT_10 (256'h0000000000000000555555555555000000000000000000005555555555500000)
1305 , .INIT_11 (256'h000000000000000055054004000001C15551500000001555AAA28000000088AA)
1306 , .INIT_12 (256'h0000000000555555000000000000000000000000000000000000000000000000)
1307 , .INIT_13 (256'h00000000AAAAAAAAFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF002AAAAA00AA000A)
1308 , .INIT_14 (256'h000000000000000000000000000000000001555555555550000000000055000D)
1309 , .INIT_17 (256'h5555555555555555000000000000001500010005555555550000000000005555)
1310 , .INIT_18 (256'h00000000000055550000000000000000AA820000001000140000000000000000)
1311 , .INIT_1B (256'h0000000000005555000000000000000000000000000000000000000000000000)
1312 , .INIT_1C (256'h0000000000000000000000000000000000000000800100050000000000000000)
1313 
1314  ) ahci_regs_type_i (
1315  .rclk (aclk), // input
1316  .raddr (bram_addr[8:0]), // input[8:0]
1317  .ren (bram_wen && !bram_addr[9]), // input
1318  .regen (1'b0), // input
1319  .data_out (regbit_type), // output[63:0]
1320  .wclk (1'b0), // input
1321  .waddr (9'b0), // input[8:0]
1322  .we (1'b0), // input
1323  .web (8'b0), // input[7:0]
1324  .data_in (64'b0) // input[63:0]
1325  );
1326 
1327 `ifdef USE_DATASCOPE
1328  ram_var_w_var_r #(
1329  .REGISTERS (0),
1330  .LOG2WIDTH_WR (5),
1331  .LOG2WIDTH_RD (5),
1332  .DUMMY(0)
1333  ) datascope_mem_i (
1334  .rclk (aclk), // input
1335  .raddr (bram_raddr[9:0]), // input[9:0]
1336  .ren (bram_ren[0]), // input
1337  .regen (bram_ren[1]), // input
1338  .data_out (datascope_rdata), // output[31:0]
1339  .wclk (datascope_clk), // input
1340  .waddr (datascope_waddr), // input[9:0]
1341  .we (datascope_we), // input
1342  .web (8'hff), // input[7:0]
1343  .data_in (datascope_di) // input[31:0]
1344  );
1345 
1346  ram_var_w_var_r #(
1347  .REGISTERS (0),
1348  .LOG2WIDTH_WR (5),
1349  .LOG2WIDTH_RD (5),
1350  .DUMMY(0)
1351  ) datascope1_mem_i (
1352  .rclk (aclk), // input
1353  .raddr (bram_raddr[9:0]), // input[9:0]
1354  .ren (bram_ren[0]), // input
1355  .regen (bram_ren[1]), // input
1356  .data_out (datascope1_rdata), // output[31:0]
1357  .wclk (datascope1_clk), // input
1358  .waddr (datascope1_waddr), // input[9:0]
1359  .we (datascope1_we), // input
1360  .web (8'hff), // input[7:0]
1361  .data_in (datascope1_di) // input[31:0]
1362  );
1363 `endif
1364 
1366  .DATA_WIDTH(ADDRESS_BITS+32),
1367  .DATA_DEPTH(4)
1368  ) ahci_regs_set_i (
1369  .rst (1'b0), // input
1370  .rrst (hba_rst), // input
1371  .wrst (arst), // input
1372  .rclk (hba_clk), // input
1373  .wclk (aclk), // input
1374  .we (bram_wen_r && !high_sel), // input
1375  .re (soft_write_en), // input
1376  .data_in ({bram_addr, ahci_regs_di}), // input[15:0]
1377  .data_out ({soft_write_addr,soft_write_data}), // output[15:0]
1378  .nempty (soft_write_en), // output
1379  .half_empty () // output
1380  );
1381 
1383  .EXTRA_DLY(0)
1384  ) afi_cache_set_i (
1385  .rst (arst), // input
1386  .src_clk (aclk), // input
1387  .dst_clk (hba_clk), // input
1388  .in_pulse (afi_cache_set_w), // input
1389  .out_pulse (afi_cache_set), // output
1390  .busy() // output
1391  );
1392 
1393 
1394 endmodule
1395 
1396 
[ 3:0] 7arlen
Definition: axibram_read.v:53
[ 1:0] 14068rresp
Definition: axi_ahci_regs.v:88
14152was_port_rst_rreg[2:0]
[3:0] 83bram_wstb
Definition: axibram_write.v:79
14135wmaskwire[31:0]
14036RESET_TO_FIRST_ACCESS1
Definition: axi_ahci_regs.v:49
[1 << LOG2WIDTH_A-1:0] 12075data_in_a
[11:0] 6arid
Definition: axibram_read.v:52
[1 << LOG2WIDTH_WR-1:0] 11872data_in
[ 1:0] 8arsize
Definition: axibram_read.v:54
14117bram_waddrwire[AXIBRAM_BITS-1:0]
[ 3:0] 71wstb
Definition: axibram_write.v:63
14144pgm_fsm_and_wwire
ahci_regs_i ramt_var_wb_var_r
[ 1:0] 14062arburst
Definition: axi_ahci_regs.v:81
reg [14:0] 14096drp_addr
14153arst_rreg[2:0]
[14-LOG2WIDTH_WR:0] 11869waddr
14125bram_renwire[1:0]
[ 1:0] 64awsize
Definition: axibram_write.v:55
[31:0] 14093debug_in3
14114datascope_selreg[1:0]
[ADDRESS_BITS-1:0] 80bram_waddr
Definition: axibram_write.v:76
[ADDRESS_BITS-1:0] 14069soft_write_addr
Definition: axi_ahci_regs.v:92
[ 1:0] 65awburst
Definition: axibram_write.v:56
reg [15:0] 14097drp_di
reg [11:0] 13rid
Definition: axibram_read.v:60
[ADDRESS_BITS-1:0] 14105datascope1_waddr
14137hba_reset_cntrreg[HBA_RESET_BITS-1:0]
[31:0] 14090debug_in0
reg [ 3:0] 14085afi_wcache
[DATA_WIDTH-1:0] 10404data_out
14136bram_waddr_rreg[ADDRESS_BITS-1:0]
[15:0] 14099drp_do
14116datascope1_selreg[1:0]
[31:0] 10rdata
Definition: axibram_read.v:57
14142afi_cache_set_wwire
[31:0] 59awaddr
Definition: axibram_write.v:50
14129bram_wdata_rreg[31:0]
[31:0] 14046wdata
Definition: axi_ahci_regs.v:63
[11:0] 14054bid
Definition: axi_ahci_regs.v:72
[1:0] 14079hba_re
[31:0] 14056araddr
Definition: axi_ahci_regs.v:75
[14-LOG2WIDTH_B:0] 12077addr_b
14157debug_rreg[31:0]
axibram_write_i axibram_write
[ 1:0] 75bresp
Definition: axibram_write.v:68
[31:0] 14039awaddr
Definition: axi_ahci_regs.v:55
[ 3:0] 63awlen
Definition: axibram_write.v:54
[11:0] 14059arid
Definition: axi_ahci_regs.v:78
14131regbit_typewire[63:0]
[11:0] 69wid
Definition: axibram_write.v:61
[ADDRESS_BITS-1:0] 14077hba_addr
[ 1:0] 9arburst
Definition: axibram_read.v:55
reg [ 3:0] 14086afi_rcache
14154wait_first_accessreg
[31:0] 14063rdata
Definition: axi_ahci_regs.v:83
14127write_start_burstwire
14123bram_wdatawire[31:0]
afi_cache_set_i pulse_cross_clock
[14-LOG2WIDTH_A:0] 12070addr_a
[ 1:0] 14061arsize
Definition: axi_ahci_regs.v:80
[11:0] 74bid
Definition: axibram_write.v:67
[ADDRESS_BITS-1:0] 76pre_awaddr
Definition: axibram_write.v:71
[11:0] 62awid
Definition: axibram_write.v:53
[11:0] 14049wid
Definition: axi_ahci_regs.v:66
14122bram_wstbwire[3:0]
ahci_regs_set_i fifo_cross_clocks
[ 1:0] 14044awsize
Definition: axi_ahci_regs.v:60
[LOG2WIDTH_B > 3? LOG2WIDTH_B > 4?3:1:0:0] 12080we_b
[31:0] 14091debug_in1
[1 << LOG2WIDTH_RD-1:0] 11867data_out
[11:0] 14042awid
Definition: axi_ahci_regs.v:58
14124bram_addrwire[ADDRESS_BITS-1:0]
[ 1:0] 15rresp
Definition: axibram_read.v:62
14118bram_raddrwire[AXIBRAM_BITS-1:0]
[ADDRESS_BITS-1:0] 20bram_raddr
Definition: axibram_read.v:70
reg [17:0] 14082pgm_ad
[LOG2WIDTH_A > 3? LOG2WIDTH_A > 4?3:1:0:0] 12073we_a
[ 3:0] 14060arlen
Definition: axi_ahci_regs.v:79
[31:0] 14080hba_din
[11:0] 14066rid
Definition: axi_ahci_regs.v:86
14143pgm_fsm_set_wwire
14132ahci_regs_diwire[31:0]
[14-LOG2WIDTH_RD:0] 11864raddr
[31:0] 14081hba_dout
14146HBA_PORT__PxSCTL__DET__MASK01HBA_PORT__PxSCTL__DET__MASK & ~1
14112AXIBRAM_BITSADDRESS_BITS + 2
14113datascope_rdatawire[31:0]
14149was_hba_rst_aclkreg
[DATA_WIDTH-1:0] 10403data_in
[ 3:0] 14051wstb
Definition: axi_ahci_regs.v:68
[1 << LOG2WIDTH_B-1:0] 12081data_out_b
14115datascope1_rdatawire[31:0]
[31:0] 84bram_wdata
Definition: axibram_write.v:80
[ADDRESS_BITS-1:0] 14101datascope_waddr
14133bram_wstb_rreg[3:0]
[31:0] 23bram_rdata
Definition: axibram_read.v:73
[31:0] 3araddr
Definition: axibram_read.v:49
[ 1:0] 14055bresp
Definition: axi_ahci_regs.v:73
[31:0] 14070soft_write_data
Definition: axi_ahci_regs.v:93
14150was_port_rst_aclkreg
[ 1:0] 14045awburst
Definition: axi_ahci_regs.v:61
14151was_hba_rst_rreg[2:0]
[1 << LOG2WIDTH_A-1:0] 12074data_out_a
[31:0] 14107datascope1_di
[1 << LOG2WIDTH_B-1:0] 12082data_in_b
[31:0] 14092debug_in2
datascope1_mem_i ram_var_w_var_r
14109drp_read_datareg[15:0]
[ 3:0] 14043awlen
Definition: axi_ahci_regs.v:59
axibram_read_i axibram_read
14119bram_rdatawire[31:0]
[31:0] 66wdata
Definition: axibram_write.v:58
[ADDRESS_BITS-1:0] 16pre_araddr
Definition: axibram_read.v:64
14130bram_rdata_rreg[31:0]
[31:0] 14103datascope_di