pci_conf_space(1).v
上传用户:quan1896
上传日期:2014-05-14
资源大小:211k
文件大小:170k
源码类别:

并行计算

开发平台:

Others

  1. latency_timer <= 8'h00 ; cache_line_size_reg <= 8'h00 ;
  2. // ALL pci_base address registers are the same as pci_baX registers !
  3. interrupt_line <= 8'h00 ;
  4. `ifdef HOST
  5.   `ifdef NO_CNF_IMAGE // if PCI bridge is HOST and IMAGE0 is assigned as general image space
  6.   `ifdef PCI_IMAGE0  
  7.         pci_img_ctrl0_bit2_1 <= {`PCI_AT_EN0, 1'b0} ;
  8. pci_ba0_bit31_8 <= 24'h0000_00 ;
  9. pci_ba0_bit0 <= `PCI_BA0_MEM_IO ;
  10. pci_am0 <= `PCI_AM0 ; 
  11. pci_ta0 <= `PCI_TA0 ;//fr2201 translation address 
  12.   `endif
  13.   `else
  14. pci_ba0_bit31_8 <= 24'h0000_00 ;
  15.   `endif
  16.   `endif
  17.         `ifdef GUEST
  18. pci_ba0_bit31_8 <= 24'h0000_00 ;
  19. `endif
  20. pci_img_ctrl1_bit2_1 <= {`PCI_AT_EN1, 1'b0} ;
  21. pci_ba1_bit31_8 <= 24'h0000_00 ; 
  22. `ifdef HOST
  23. pci_ba1_bit0 <= `PCI_BA1_MEM_IO ;
  24. `endif
  25. pci_am1 <= `PCI_AM1;
  26. pci_ta1 <=  `PCI_TA1 ;//FR2201 translation address ;
  27. `ifdef PCI_IMAGE2
  28.         pci_img_ctrl2_bit2_1 <= {`PCI_AT_EN2, 1'b0} ;
  29. pci_ba2_bit31_8 <= 24'h0000_00 ; 
  30. `ifdef HOST
  31. pci_ba2_bit0 <= `PCI_BA2_MEM_IO ;
  32. `endif
  33. pci_am2 <= `PCI_AM2;
  34. pci_ta2 <= `PCI_TA2 ;//FR2201 translation address ;
  35. `endif
  36. `ifdef PCI_IMAGE3
  37.         pci_img_ctrl3_bit2_1 <= {`PCI_AT_EN3, 1'b0} ; //FR2201 when defined enabled
  38.             
  39.          pci_ba3_bit31_8 <= 24'h0000_00 ; 
  40.          `ifdef HOST
  41.          pci_ba3_bit0 <= `PCI_BA3_MEM_IO ;
  42.          `endif
  43.          pci_am3 <= `PCI_AM3;
  44. pci_ta3 <= `PCI_TA3 ;//FR2201 translation address ;
  45. `endif
  46. `ifdef PCI_IMAGE4
  47.         pci_img_ctrl4_bit2_1 <= {`PCI_AT_EN4, 1'b0} ; //FR2201 when defined enabled
  48.         
  49. pci_ba4_bit31_8 <= 24'h0000_00 ; 
  50. `ifdef HOST
  51. pci_ba4_bit0 <= `PCI_BA4_MEM_IO ;
  52. `endif
  53. pci_am4 <= `PCI_AM4;
  54. pci_ta4 <= `PCI_TA4 ;//FR2201  translation address ;
  55. `endif
  56. `ifdef PCI_IMAGE5
  57.         pci_img_ctrl5_bit2_1 <= {`PCI_AT_EN5, 1'b0} ; //FR2201 when defined enabled
  58.         
  59. pci_ba5_bit31_8 <= 24'h0000_00 ; 
  60. `ifdef HOST
  61. pci_ba5_bit0 <= `PCI_BA5_MEM_IO ;
  62. `endif
  63. pci_am5 <= `PCI_AM5; //FR2201  pci_am0 
  64. pci_ta5 <= `PCI_TA5 ;//FR2201  translation address ;
  65. `endif
  66. /*pci_err_cs_bit31_24 ; pci_err_cs_bit10; pci_err_cs_bit9 ; pci_err_cs_bit8 ;*/ pci_err_cs_bit0 <= 1'h0 ;
  67. /*pci_err_addr ;*/
  68.         /*pci_err_data ;*/
  69. //
  70. wb_img_ctrl1_bit2_0 <= {`WB_AT_EN1, 2'b00} ;
  71.         
  72. wb_ba1_bit31_12 <=`WB_BA1; //FR2201 Address bar 
  73. wb_ba1_bit0 <=`WB_BA1_MEM_IO;//
  74. wb_am1 <= `WB_AM1 ;//FR2201 Address mask 
  75. wb_ta1 <= `WB_TA1 ;//FR2201 20'h0000_0 ;
  76.         `ifdef WB_IMAGE2
  77.         wb_img_ctrl2_bit2_0 <= {`WB_AT_EN2, 2'b00} ; 
  78.           
  79. wb_ba2_bit31_12 <=`WB_BA2; //FR2201 Address bar  
  80. wb_ba2_bit0 <=`WB_BA2_MEM_IO;//
  81. wb_am2 <=`WB_AM2 ;//FR2201 Address mask
  82. wb_ta2 <=`WB_TA2 ;//FR2201 translation address ;
  83. `endif
  84. `ifdef WB_IMAGE3
  85.         wb_img_ctrl3_bit2_0 <= {`WB_AT_EN3, 2'b00} ; 
  86.           
  87. wb_ba3_bit31_12 <=`WB_BA3; //FR2201 Address bar  
  88. wb_ba3_bit0 <=`WB_BA3_MEM_IO;//
  89. wb_am3 <=`WB_AM3 ;//FR2201 Address mask
  90. wb_ta3 <=`WB_TA3 ;//FR2201 translation address ;
  91. `endif
  92. `ifdef WB_IMAGE4
  93.         wb_img_ctrl4_bit2_0 <= {`WB_AT_EN4, 2'b00} ; 
  94.           
  95. wb_ba4_bit31_12 <=`WB_BA4; //FR2201 Address bar 
  96. wb_ba4_bit0 <=`WB_BA4_MEM_IO;//
  97. wb_am4 <=`WB_AM4 ;//FR2201 Address mask
  98. wb_ta4 <=`WB_TA4 ;//FR2201 translation address ;
  99. `endif
  100. `ifdef WB_IMAGE5
  101.         wb_img_ctrl5_bit2_0 <= {`WB_AT_EN5, 2'b00} ;
  102.           
  103.          wb_ba5_bit31_12 <=`WB_BA5; //FR2201 Address bar  ;
  104.          wb_ba5_bit0 <=`WB_BA5_MEM_IO;//FR2201 1'h0 ;
  105. wb_am5 <=`WB_AM5 ;//FR2201  Address mask
  106. wb_ta5 <=`WB_TA5 ;//FR2201  translation address ;
  107. `endif
  108. /*wb_err_cs_bit31_24 ; wb_err_cs_bit10 ; wb_err_cs_bit9 ; wb_err_cs_bit8 ;*/ wb_err_cs_bit0 <= 1'h0 ;
  109. /*wb_err_addr ;*/
  110. /*wb_err_data ;*/
  111. `ifdef HOST
  112.          cnf_addr_bit23_2 <= 22'h0000_00 ; cnf_addr_bit0 <= 1'h0 ;
  113. `endif
  114. icr_bit31 <= 1'h0 ;
  115. `ifdef HOST
  116. icr_bit2_0 <= 3'h0 ;
  117. icr_bit4_3 <= 2'h0 ;
  118. `else
  119. icr_bit2_0[2:0] <= 3'h0 ;
  120. `endif
  121. /*isr_bit4_3 ; isr_bit2_0 ;*/
  122.         // Not register bit; used only internally after reset!
  123.         init_complete <= 1'b0 ;
  124.     `ifdef GUEST
  125.         rst_inactive_sync <= 1'b0 ;
  126.         rst_inactive      <= 1'b0 ;
  127.     `endif
  128.         `ifdef PCI_CPCI_HS_IMPLEMENT
  129.             /*hs_ins hs_ext*/ hs_loo <= 1'b0; hs_eim <= 1'b0;
  130.             // Not register bits; used only internally after reset!
  131.             /*hs_ins_armed hs_ext_armed*/
  132.         `endif
  133. end
  134. /* -----------------------------------------------------------------------------------------------------------
  135. Following register bits should have asynchronous RESET & SET! That is why they are IMPLEMENTED separately
  136. after this ALWAYS block!!! (for every register bit, there are two D-FF implemented)
  137. status_bit15_11[15] <= 1'b1 ;
  138. status_bit15_11[14] <= 1'b1 ;
  139. status_bit15_11[13] <= 1'b1 ;
  140. status_bit15_11[12] <= 1'b1 ;
  141. status_bit15_11[11] <= 1'b1 ;
  142. status_bit8 <= 1'b1 ;
  143. pci_err_cs_bit10 <= 1'b1 ;
  144. pci_err_cs_bit9 <= 1'b1 ;
  145. pci_err_cs_bit8 <= 1'b1 ;
  146. pci_err_cs_bit31_24 <= { pci_error_be, pci_error_bc } ;
  147. pci_err_addr <= pci_error_addr ;
  148. pci_err_data <= pci_error_data ;
  149. wb_err_cs_bit10 <= 1'b1 ;
  150. wb_err_cs_bit9 <= 1'b1 ;
  151. wb_err_cs_bit8 <= 1'b1 ;
  152. wb_err_cs_bit31_24 <= { wb_error_be, wb_error_bc } ;
  153. wb_err_addr <= wb_error_addr ;
  154. wb_err_data <= wb_error_data ;
  155. isr_bit4_0[4] <= 1'b1 & icr_bit4_0[4] ;
  156. isr_bit4_0[3] <= 1'b1 & icr_bit4_0[3] ;
  157. isr_bit4_0[2] <= 1'b1 & icr_bit4_0[2] ;
  158. isr_bit4_0[1] <= 1'b1 & icr_bit4_0[1] ;
  159. isr_bit4_0[0] <= 1'b1 & icr_bit4_0[0] ;
  160.         hs_ins; hs_ext;
  161. -----------------------------------------------------------------------------------------------------------*/
  162. // Here follows normal writting to registers (only to their valid bits) !
  163. else
  164. begin
  165. if (w_we)
  166. begin
  167. // PCI header - configuration space
  168. if (w_reg_select_dec[0]) // w_conf_address[5:2] = 4'h1:
  169. begin
  170. if (~w_byte_en[1])
  171. command_bit8 <= w_conf_data[8] ;
  172. if (~w_byte_en[0])
  173. begin
  174. command_bit6 <= w_conf_data[6] ;
  175. command_bit2_0 <= w_conf_data[2:0] ;
  176. end
  177. end
  178. if (w_reg_select_dec[1]) // w_conf_address[5:2] = 4'h3:
  179. begin
  180. if (~w_byte_en[1])
  181. latency_timer <= w_conf_data[15:8] ;
  182. if (~w_byte_en[0])
  183. cache_line_size_reg <= w_conf_data[7:0] ;
  184. end
  185. //             if (w_reg_select_dec[4]) // w_conf_address[5:2] = 4'h4:
  186. // Also used with IMAGE0
  187. //             if (w_reg_select_dec[8]) // w_conf_address[5:2] = 4'h5:
  188. // Also used with IMAGE1
  189. //             if (w_reg_select_dec[12]) // w_conf_address[5:2] = 4'h6:
  190. // Also used with IMAGE2
  191. //             if (w_reg_select_dec[16]) // w_conf_address[5:2] = 4'h7:
  192. // Also used with IMAGE3
  193. //             if (w_reg_select_dec[20]) // w_conf_address[5:2] = 4'h8:
  194. // Also used with IMAGE4
  195. //             if (w_reg_select_dec[24]) // w_conf_address[5:2] = 4'h9:
  196. // Also used with IMAGE5 and IMAGE6
  197. if (w_reg_select_dec[2]) // w_conf_address[5:2] = 4'hf:
  198. begin
  199. if (~w_byte_en[0])
  200. interrupt_line <= w_conf_data[7:0] ;
  201. end
  202. // PCI target - configuration space
  203. `ifdef HOST
  204.   `ifdef NO_CNF_IMAGE
  205. `ifdef PCI_IMAGE0 // if PCI bridge is HOST and IMAGE0 is assigned as general image space
  206. if (w_reg_select_dec[3]) // case (w_conf_address[7:2]) = `P_IMG_CTRL0_ADDR:
  207. begin
  208. if (~w_byte_en[0])
  209. pci_img_ctrl0_bit2_1 <= w_conf_data[2:1] ;
  210. end
  211.             if (w_reg_select_dec[4]) // case (w_conf_address[7:2]) = `P_BA0_ADDR:
  212. begin
  213. if (~w_byte_en[3])
  214. pci_ba0_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
  215. if (~w_byte_en[2])
  216. pci_ba0_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
  217. if (~w_byte_en[1])
  218. pci_ba0_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  219. if (~w_byte_en[0])
  220. pci_ba0_bit0 <= w_conf_data[0] ;
  221. end
  222.             if (w_reg_select_dec[5]) // case (w_conf_address[7:2]) = `P_AM0_ADDR:
  223. begin
  224. if (~w_byte_en[3])
  225. pci_am0[31:24] <= w_conf_pdata_reduced[31:24] ;
  226. if (~w_byte_en[2])
  227. pci_am0[23:16] <= w_conf_pdata_reduced[23:16] ;
  228. if (~w_byte_en[1])
  229. pci_am0[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  230. end
  231.             if (w_reg_select_dec[6]) // case (w_conf_address[7:2]) = `P_TA0_ADDR:
  232. begin
  233. if (~w_byte_en[3])
  234. pci_ta0[31:24] <= w_conf_pdata_reduced[31:24] ;
  235. if (~w_byte_en[2])
  236. pci_ta0[23:16] <= w_conf_pdata_reduced[23:16] ;
  237. if (~w_byte_en[1])
  238. pci_ta0[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  239. end
  240. `endif
  241.   `else
  242.             if (w_reg_select_dec[4]) // case (w_conf_address[7:2]) = `P_BA0_ADDR:
  243. begin
  244. if (~w_byte_en[3])
  245. pci_ba0_bit31_8[31:24] <= w_conf_data[31:24] ;
  246. if (~w_byte_en[2])
  247. pci_ba0_bit31_8[23:16] <= w_conf_data[23:16] ;
  248. if (~w_byte_en[1])
  249. pci_ba0_bit31_8[15:12] <= w_conf_data[15:12] ;
  250. end
  251.   `endif
  252. `endif
  253. `ifdef GUEST
  254.             if (w_reg_select_dec[4]) // case (w_conf_address[7:2]) = `P_BA0_ADDR:
  255. begin
  256. if (~w_byte_en[3])
  257. pci_ba0_bit31_8[31:24] <= w_conf_data[31:24] ;
  258. if (~w_byte_en[2])
  259. pci_ba0_bit31_8[23:16] <= w_conf_data[23:16] ;
  260. if (~w_byte_en[1])
  261. pci_ba0_bit31_8[15:12] <= w_conf_data[15:12] ;
  262. end
  263. `endif
  264.             if (w_reg_select_dec[7]) // case (w_conf_address[7:2]) = `P_IMG_CTRL1_ADDR:
  265. begin
  266. if (~w_byte_en[0])
  267. pci_img_ctrl1_bit2_1 <= w_conf_data[2:1] ;
  268. end
  269.             if (w_reg_select_dec[8]) // case (w_conf_address[7:2]) = `P_BA1_ADDR:
  270. begin
  271. if (~w_byte_en[3])
  272. pci_ba1_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
  273. if (~w_byte_en[2])
  274. pci_ba1_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
  275. if (~w_byte_en[1])
  276. pci_ba1_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  277. `ifdef HOST
  278. if (~w_byte_en[0])
  279. pci_ba1_bit0 <= w_conf_data[0] ;
  280. `endif
  281. end
  282.             if (w_reg_select_dec[9]) // case (w_conf_address[7:2]) = `P_AM1_ADDR:
  283. begin
  284. if (~w_byte_en[3])
  285. pci_am1[31:24] <= w_conf_pdata_reduced[31:24] ;
  286. if (~w_byte_en[2])
  287. pci_am1[23:16] <= w_conf_pdata_reduced[23:16] ;
  288. if (~w_byte_en[1])
  289. pci_am1[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  290. end
  291.             if (w_reg_select_dec[10]) // case (w_conf_address[7:2]) = `P_TA1_ADDR:
  292. begin
  293. if (~w_byte_en[3])
  294. pci_ta1[31:24] <= w_conf_pdata_reduced[31:24] ;
  295. if (~w_byte_en[2])
  296. pci_ta1[23:16] <= w_conf_pdata_reduced[23:16] ;
  297. if (~w_byte_en[1])
  298. pci_ta1[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  299. end
  300. `ifdef PCI_IMAGE2
  301.             if (w_reg_select_dec[11]) // case (w_conf_address[7:2]) = `P_IMG_CTRL2_ADDR:
  302. begin
  303. if (~w_byte_en[0])
  304. pci_img_ctrl2_bit2_1 <= w_conf_data[2:1] ;
  305. end
  306.             if (w_reg_select_dec[12]) // case (w_conf_address[7:2]) = `P_BA2_ADDR:
  307. begin
  308. if (~w_byte_en[3])
  309. pci_ba2_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
  310. if (~w_byte_en[2])
  311. pci_ba2_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
  312. if (~w_byte_en[1])
  313. pci_ba2_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  314. `ifdef HOST
  315. if (~w_byte_en[0])
  316. pci_ba2_bit0 <= w_conf_data[0] ;
  317. `endif
  318. end
  319.             if (w_reg_select_dec[13]) // case (w_conf_address[7:2]) = `P_AM2_ADDR:
  320. begin
  321. if (~w_byte_en[3])
  322. pci_am2[31:24] <= w_conf_pdata_reduced[31:24] ;
  323. if (~w_byte_en[2])
  324. pci_am2[23:16] <= w_conf_pdata_reduced[23:16] ;
  325. if (~w_byte_en[1])
  326. pci_am2[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  327. end
  328.             if (w_reg_select_dec[14]) // case (w_conf_address[7:2]) = `P_TA2_ADDR:
  329. begin
  330. if (~w_byte_en[3])
  331. pci_ta2[31:24] <= w_conf_pdata_reduced[31:24] ;
  332. if (~w_byte_en[2])
  333. pci_ta2[23:16] <= w_conf_pdata_reduced[23:16] ;
  334. if (~w_byte_en[1])
  335. pci_ta2[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  336. end
  337. `endif
  338. `ifdef PCI_IMAGE3
  339.             if (w_reg_select_dec[15]) // case (w_conf_address[7:2]) = `P_IMG_CTRL3_ADDR:
  340. begin
  341. if (~w_byte_en[0])
  342. pci_img_ctrl3_bit2_1 <= w_conf_data[2:1] ;
  343. end
  344.             if (w_reg_select_dec[16]) // case (w_conf_address[7:2]) = `P_BA3_ADDR:
  345. begin
  346. if (~w_byte_en[3])
  347. pci_ba3_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
  348. if (~w_byte_en[2])
  349. pci_ba3_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
  350. if (~w_byte_en[1])
  351. pci_ba3_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  352. `ifdef HOST
  353. if (~w_byte_en[0])
  354. pci_ba3_bit0 <= w_conf_data[0] ;
  355. `endif
  356. end
  357.             if (w_reg_select_dec[17]) // case (w_conf_address[7:2]) = `P_AM3_ADDR:
  358. begin
  359. if (~w_byte_en[3])
  360. pci_am3[31:24] <= w_conf_pdata_reduced[31:24] ;
  361. if (~w_byte_en[2])
  362. pci_am3[23:16] <= w_conf_pdata_reduced[23:16] ;
  363. if (~w_byte_en[1])
  364. pci_am3[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  365. end
  366.             if (w_reg_select_dec[18]) // case (w_conf_address[7:2]) = `P_TA3_ADDR:
  367. begin
  368. if (~w_byte_en[3])
  369. pci_ta3[31:24] <= w_conf_pdata_reduced[31:24] ;
  370. if (~w_byte_en[2])
  371. pci_ta3[23:16] <= w_conf_pdata_reduced[23:16] ;
  372. if (~w_byte_en[1])
  373. pci_ta3[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  374. end
  375. `endif
  376. `ifdef PCI_IMAGE4
  377.             if (w_reg_select_dec[19]) // case (w_conf_address[7:2]) = `P_IMG_CTRL4_ADDR:
  378. begin
  379. if (~w_byte_en[0])
  380. pci_img_ctrl4_bit2_1 <= w_conf_data[2:1] ;
  381. end
  382.             if (w_reg_select_dec[20]) // case (w_conf_address[7:2]) = `P_BA4_ADDR:
  383. begin
  384. if (~w_byte_en[3])
  385. pci_ba4_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
  386. if (~w_byte_en[2])
  387. pci_ba4_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
  388. if (~w_byte_en[1])
  389. pci_ba4_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  390. `ifdef HOST
  391. if (~w_byte_en[0])
  392. pci_ba4_bit0 <= w_conf_data[0] ;
  393. `endif
  394. end
  395.             if (w_reg_select_dec[21]) // case (w_conf_address[7:2]) = `P_AM4_ADDR:
  396. begin
  397. if (~w_byte_en[3])
  398. pci_am4[31:24] <= w_conf_pdata_reduced[31:24] ;
  399. if (~w_byte_en[2])
  400. pci_am4[23:16] <= w_conf_pdata_reduced[23:16] ;
  401. if (~w_byte_en[1])
  402. pci_am4[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  403. end
  404.             if (w_reg_select_dec[22]) // case (w_conf_address[7:2]) = `P_TA4_ADDR:
  405. begin
  406. if (~w_byte_en[3])
  407. pci_ta4[31:24] <= w_conf_pdata_reduced[31:24] ;
  408. if (~w_byte_en[2])
  409. pci_ta4[23:16] <= w_conf_pdata_reduced[23:16] ;
  410. if (~w_byte_en[1])
  411. pci_ta4[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  412. end
  413. `endif
  414. `ifdef PCI_IMAGE5
  415.             if (w_reg_select_dec[23]) // case (w_conf_address[7:2]) = `P_IMG_CTRL5_ADDR:
  416. begin
  417. if (~w_byte_en[0])
  418. pci_img_ctrl5_bit2_1 <= w_conf_data[2:1] ;
  419. end
  420.             if (w_reg_select_dec[24]) // case (w_conf_address[7:2]) = `P_BA5_ADDR:
  421. begin
  422. if (~w_byte_en[3])
  423. pci_ba5_bit31_8[31:24] <= w_conf_pdata_reduced[31:24] ;
  424. if (~w_byte_en[2])
  425. pci_ba5_bit31_8[23:16] <= w_conf_pdata_reduced[23:16] ;
  426. if (~w_byte_en[1])
  427. pci_ba5_bit31_8[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  428. `ifdef HOST
  429. if (~w_byte_en[0])
  430. pci_ba5_bit0 <= w_conf_data[0] ;
  431. `endif
  432. end
  433.             if (w_reg_select_dec[25]) // case (w_conf_address[7:2]) = `P_AM5_ADDR:
  434. begin
  435. if (~w_byte_en[3])
  436. pci_am5[31:24] <= w_conf_pdata_reduced[31:24] ;
  437. if (~w_byte_en[2])
  438. pci_am5[23:16] <= w_conf_pdata_reduced[23:16] ;
  439. if (~w_byte_en[1])
  440. pci_am5[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  441. end
  442.             if (w_reg_select_dec[26]) // case (w_conf_address[7:2]) = `P_TA5_ADDR:
  443. begin
  444. if (~w_byte_en[3])
  445. pci_ta5[31:24] <= w_conf_pdata_reduced[31:24] ;
  446. if (~w_byte_en[2])
  447. pci_ta5[23:16] <= w_conf_pdata_reduced[23:16] ;
  448. if (~w_byte_en[1])
  449. pci_ta5[15: 8] <= w_conf_pdata_reduced[15: 8] ;
  450. end
  451. `endif
  452.             if (w_reg_select_dec[27]) // case (w_conf_address[7:2]) = `P_ERR_CS_ADDR:
  453. begin
  454. if (~w_byte_en[0])
  455. pci_err_cs_bit0 <= w_conf_data[0] ;
  456. end
  457. // WB slave - configuration space
  458. if (w_reg_select_dec[30]) // case (w_conf_address[7:2]) = `W_IMG_CTRL1_ADDR:
  459. begin
  460. if (~w_byte_en[0])
  461. wb_img_ctrl1_bit2_0 <= w_conf_data[2:0] ;
  462. end
  463. if (w_reg_select_dec[31]) // case (w_conf_address[7:2]) = `W_BA1_ADDR:
  464. begin
  465. if (~w_byte_en[3])
  466. wb_ba1_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
  467. if (~w_byte_en[2])
  468. wb_ba1_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
  469. if (~w_byte_en[1])
  470. wb_ba1_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
  471. if (~w_byte_en[0])
  472. wb_ba1_bit0 <= w_conf_data[0] ;
  473. end
  474. if (w_reg_select_dec[32]) // case (w_conf_address[7:2]) = `W_AM1_ADDR:
  475. begin
  476. if (~w_byte_en[3])
  477. wb_am1[31:24] <= w_conf_wdata_reduced[31:24] ;
  478. if (~w_byte_en[2])
  479. wb_am1[23:16] <= w_conf_wdata_reduced[23:16] ;
  480. if (~w_byte_en[1])
  481. wb_am1[15:12] <= w_conf_wdata_reduced[15:12] ;
  482. end
  483. if (w_reg_select_dec[33]) // case (w_conf_address[7:2]) = `W_TA1_ADDR:
  484. begin
  485. if (~w_byte_en[3])
  486. wb_ta1[31:24] <= w_conf_wdata_reduced[31:24] ;
  487. if (~w_byte_en[2])
  488. wb_ta1[23:16] <= w_conf_wdata_reduced[23:16] ;
  489. if (~w_byte_en[1])
  490. wb_ta1[15:12] <= w_conf_wdata_reduced[15:12] ;
  491. end
  492. `ifdef WB_IMAGE2
  493. if (w_reg_select_dec[34]) // case (w_conf_address[7:2]) = `W_IMG_CTRL2_ADDR:
  494. begin
  495. if (~w_byte_en[0])
  496. wb_img_ctrl2_bit2_0 <= w_conf_data[2:0] ;
  497. end
  498. if (w_reg_select_dec[35]) // case (w_conf_address[7:2]) = `W_BA2_ADDR:
  499. begin
  500. if (~w_byte_en[3])
  501. wb_ba2_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
  502. if (~w_byte_en[2])
  503. wb_ba2_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
  504. if (~w_byte_en[1])
  505. wb_ba2_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
  506. if (~w_byte_en[0])
  507. wb_ba2_bit0 <= w_conf_data[0] ;
  508. end
  509. if (w_reg_select_dec[36]) // case (w_conf_address[7:2]) = `W_AM2_ADDR:
  510. begin
  511. if (~w_byte_en[3])
  512. wb_am2[31:24] <= w_conf_wdata_reduced[31:24] ;
  513. if (~w_byte_en[2])
  514. wb_am2[23:16] <= w_conf_wdata_reduced[23:16] ;
  515. if (~w_byte_en[1])
  516. wb_am2[15:12] <= w_conf_wdata_reduced[15:12] ;
  517. end
  518. if (w_reg_select_dec[37]) // case (w_conf_address[7:2]) = `W_TA2_ADDR:
  519. begin
  520. if (~w_byte_en[3])
  521. wb_ta2[31:24] <= w_conf_wdata_reduced[31:24] ;
  522. if (~w_byte_en[2])
  523. wb_ta2[23:16] <= w_conf_wdata_reduced[23:16] ;
  524. if (~w_byte_en[1])
  525. wb_ta2[15:12] <= w_conf_wdata_reduced[15:12] ;
  526. end
  527. `endif
  528. `ifdef WB_IMAGE3
  529. if (w_reg_select_dec[38]) // case (w_conf_address[7:2]) = `W_IMG_CTRL3_ADDR:
  530. begin
  531. if (~w_byte_en[0])
  532. wb_img_ctrl3_bit2_0 <= w_conf_data[2:0] ;
  533. end
  534. if (w_reg_select_dec[39]) // case (w_conf_address[7:2]) = `W_BA3_ADDR:
  535. begin
  536. if (~w_byte_en[3])
  537. wb_ba3_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
  538. if (~w_byte_en[2])
  539. wb_ba3_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
  540. if (~w_byte_en[1])
  541. wb_ba3_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
  542. if (~w_byte_en[0])
  543. wb_ba3_bit0 <= w_conf_data[0] ;
  544. end
  545. if (w_reg_select_dec[40]) // case (w_conf_address[7:2]) = `W_AM3_ADDR:
  546. begin
  547. if (~w_byte_en[3])
  548. wb_am3[31:24] <= w_conf_wdata_reduced[31:24] ;
  549. if (~w_byte_en[2])
  550. wb_am3[23:16] <= w_conf_wdata_reduced[23:16] ;
  551. if (~w_byte_en[1])
  552. wb_am3[15:12] <= w_conf_wdata_reduced[15:12] ;
  553. end
  554. if (w_reg_select_dec[41]) // case (w_conf_address[7:2]) = `W_TA3_ADDR:
  555. begin
  556. if (~w_byte_en[3])
  557. wb_ta3[31:24] <= w_conf_wdata_reduced[31:24] ;
  558. if (~w_byte_en[2])
  559. wb_ta3[23:16] <= w_conf_wdata_reduced[23:16] ;
  560. if (~w_byte_en[1])
  561. wb_ta3[15:12] <= w_conf_wdata_reduced[15:12] ;
  562. end
  563. `endif
  564. `ifdef WB_IMAGE4
  565. if (w_reg_select_dec[42]) // case (w_conf_address[7:2]) = `W_IMG_CTRL4_ADDR:
  566. begin
  567. if (~w_byte_en[0])
  568. wb_img_ctrl4_bit2_0 <= w_conf_data[2:0] ;
  569. end
  570. if (w_reg_select_dec[43]) // case (w_conf_address[7:2]) = `W_BA4_ADDR:
  571. begin
  572. if (~w_byte_en[3])
  573. wb_ba4_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
  574. if (~w_byte_en[2])
  575. wb_ba4_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
  576. if (~w_byte_en[1])
  577. wb_ba4_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
  578. if (~w_byte_en[0])
  579. wb_ba4_bit0 <= w_conf_data[0] ;
  580. end
  581. if (w_reg_select_dec[44]) // case (w_conf_address[7:2]) = `W_AM4_ADDR:
  582. begin
  583. if (~w_byte_en[3])
  584. wb_am4[31:24] <= w_conf_wdata_reduced[31:24] ;
  585. if (~w_byte_en[2])
  586. wb_am4[23:16] <= w_conf_wdata_reduced[23:16] ;
  587. if (~w_byte_en[1])
  588. wb_am4[15:12] <= w_conf_wdata_reduced[15:12] ;
  589. end
  590. if (w_reg_select_dec[45]) // case (w_conf_address[7:2]) = `W_TA4_ADDR:
  591. begin
  592. if (~w_byte_en[3])
  593. wb_ta4[31:24] <= w_conf_wdata_reduced[31:24] ;
  594. if (~w_byte_en[2])
  595. wb_ta4[23:16] <= w_conf_wdata_reduced[23:16] ;
  596. if (~w_byte_en[1])
  597. wb_ta4[15:12] <= w_conf_wdata_reduced[15:12] ;
  598. end
  599. `endif
  600. `ifdef WB_IMAGE5
  601. if (w_reg_select_dec[46]) // case (w_conf_address[7:2]) = `W_IMG_CTRL5_ADDR:
  602. begin
  603. if (~w_byte_en[0])
  604. wb_img_ctrl5_bit2_0 <= w_conf_data[2:0] ;
  605. end
  606. if (w_reg_select_dec[47]) // case (w_conf_address[7:2]) = `W_BA5_ADDR:
  607. begin
  608. if (~w_byte_en[3])
  609. wb_ba5_bit31_12[31:24] <= w_conf_wdata_reduced[31:24] ;
  610. if (~w_byte_en[2])
  611. wb_ba5_bit31_12[23:16] <= w_conf_wdata_reduced[23:16] ;
  612. if (~w_byte_en[1])
  613. wb_ba5_bit31_12[15:12] <= w_conf_wdata_reduced[15:12] ;
  614. if (~w_byte_en[0])
  615. wb_ba5_bit0 <= w_conf_data[0] ;
  616. end
  617. if (w_reg_select_dec[48]) // case (w_conf_address[7:2]) = `W_AM5_ADDR:
  618. begin
  619. if (~w_byte_en[3])
  620. wb_am5[31:24] <= w_conf_wdata_reduced[31:24] ;
  621. if (~w_byte_en[2])
  622. wb_am5[23:16] <= w_conf_wdata_reduced[23:16] ;
  623. if (~w_byte_en[1])
  624. wb_am5[15:12] <= w_conf_wdata_reduced[15:12] ;
  625. end
  626. if (w_reg_select_dec[49]) // case (w_conf_address[7:2]) = `W_TA5_ADDR:
  627. begin
  628. if (~w_byte_en[3])
  629. wb_ta5[31:24] <= w_conf_wdata_reduced[31:24] ;
  630. if (~w_byte_en[2])
  631. wb_ta5[23:16] <= w_conf_wdata_reduced[23:16] ;
  632. if (~w_byte_en[1])
  633. wb_ta5[15:12] <= w_conf_wdata_reduced[15:12] ;
  634. end
  635. `endif
  636. if (w_reg_select_dec[50]) // case (w_conf_address[7:2]) = `W_ERR_CS_ADDR:
  637. begin
  638. if (~w_byte_en[0])
  639. wb_err_cs_bit0 <= w_conf_data[0] ;
  640. end
  641. `ifdef HOST
  642. if (w_reg_select_dec[53]) // case (w_conf_address[7:2]) = `CNF_ADDR_ADDR:
  643. begin
  644. if (~w_byte_en[2])
  645. cnf_addr_bit23_2[23:16] <= w_conf_data[23:16] ;
  646. if (~w_byte_en[1])
  647. cnf_addr_bit23_2[15:8] <= w_conf_data[15:8] ;
  648. if (~w_byte_en[0])
  649. begin
  650. cnf_addr_bit23_2[7:2] <= w_conf_data[7:2] ;
  651. cnf_addr_bit0 <= w_conf_data[0] ;
  652. end
  653. end
  654. `endif
  655. // `CNF_DATA_ADDR: implemented elsewhere !!!
  656. // `INT_ACK_ADDR : implemented elsewhere !!!
  657.             if (w_reg_select_dec[54]) // case (w_conf_address[7:2]) = `ICR_ADDR:
  658. begin
  659. if (~w_byte_en[3])
  660. icr_bit31 <= w_conf_data[31] ;
  661. if (~w_byte_en[0])
  662.                     begin
  663. `ifdef HOST
  664. icr_bit4_3 <= w_conf_data[4:3] ;
  665. icr_bit2_0 <= w_conf_data[2:0] ;
  666. `else
  667. icr_bit2_0[2:0] <= w_conf_data[2:0] ;
  668. `endif
  669.                     end
  670.                 end
  671. `ifdef PCI_CPCI_HS_IMPLEMENT
  672.                 if (w_reg_select_dec[56])
  673.                 begin
  674.                     if (~w_byte_en[2])
  675.                     begin
  676.                         hs_loo <= w_conf_data[19];
  677.                         hs_eim <= w_conf_data[17];
  678.                     end
  679.                 end
  680. `endif
  681. end // end of we
  682.         // Not register bits; used only internally after reset!
  683.     `ifdef GUEST
  684.         rst_inactive_sync <= 1'b1               ;
  685.         rst_inactive      <= rst_inactive_sync  ;
  686.     `endif
  687.         if (rst_inactive & ~init_complete & init_cfg_done)
  688.             init_complete <= 1'b1 ;
  689. end
  690. end
  691. // implementation of read only device identification registers
  692. always@(posedge w_clock or posedge reset)
  693. begin
  694.     if (reset)
  695.     begin
  696.         r_vendor_id         <= `HEADER_VENDOR_ID        ;
  697.         r_device_id         <= `HEADER_DEVICE_ID        ;
  698.         r_revision_id       <= `HEADER_REVISION_ID      ;
  699.         r_subsys_vendor_id  <= `HEADER_SUBSYS_VENDOR_ID ;
  700.         r_subsys_id         <= `HEADER_SUBSYS_ID        ;
  701.         r_max_lat           <= `HEADER_MAX_LAT          ;
  702.         r_min_gnt           <= `HEADER_MIN_GNT          ;
  703.     end else
  704.     begin
  705.         if (init_we)
  706.         begin
  707.             if (spoci_reg_num == 'h0)
  708.             begin
  709.                 r_vendor_id <= spoci_dat[15: 0] ;
  710.                 r_device_id <= spoci_dat[31:16] ;
  711.             end
  712.             if (spoci_reg_num == 'hB)
  713.             begin
  714.                 r_subsys_vendor_id  <= spoci_dat[15: 0] ;
  715.                 r_subsys_id         <= spoci_dat[31:16] ;
  716.             end
  717.             if (spoci_reg_num == 'h2)
  718.             begin
  719.                 r_revision_id   <= spoci_dat[ 7: 0] ;
  720.             end
  721.             if (spoci_reg_num == 'hF)
  722.             begin
  723.                 r_max_lat <= spoci_dat[31:24] ;
  724.                 r_min_gnt <= spoci_dat[23:16] ;
  725.             end
  726.         end        
  727.     end
  728. end
  729. // This signals are synchronous resets for registers, whic occures when asynchronous RESET is '1' or
  730. // data '1' is synchronously written into them!
  731. reg delete_status_bit15 ;
  732. reg delete_status_bit14 ;
  733. reg delete_status_bit13 ;
  734. reg delete_status_bit12 ;
  735. reg delete_status_bit11 ;
  736. reg delete_status_bit8 ;
  737. reg delete_pci_err_cs_bit8 ;
  738. reg delete_wb_err_cs_bit8 ;
  739. reg delete_isr_bit4 ;
  740. reg delete_isr_bit3 ;
  741. reg delete_isr_bit2 ;
  742. reg delete_isr_bit1 ;
  743. // This are aditional register bits, which are resets when their value is '1' !!!
  744. always@(w_we or w_reg_select_dec or w_conf_data or w_byte_en)
  745. begin
  746. // I' is written into, then it also sets signals to '1'
  747. delete_status_bit15  = w_conf_data[31] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
  748. delete_status_bit14  = w_conf_data[30] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
  749. delete_status_bit13  = w_conf_data[29] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
  750. delete_status_bit12  = w_conf_data[28] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
  751. delete_status_bit11  = w_conf_data[27] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
  752. delete_status_bit8   = w_conf_data[24] & !w_byte_en[3] & w_we & w_reg_select_dec[0] ;
  753. delete_pci_err_cs_bit8  = w_conf_data[8]  & !w_byte_en[1] & w_we & w_reg_select_dec[27] ;
  754. delete_wb_err_cs_bit8  = w_conf_data[8]  & !w_byte_en[1] & w_we & w_reg_select_dec[50] ;
  755. delete_isr_bit4  = w_conf_data[4]  & !w_byte_en[0] & w_we & w_reg_select_dec[55] ;
  756. delete_isr_bit3  = w_conf_data[3]  & !w_byte_en[0] & w_we & w_reg_select_dec[55] ;
  757. delete_isr_bit2  = w_conf_data[2]  & !w_byte_en[0] & w_we & w_reg_select_dec[55] ;
  758. delete_isr_bit1  = w_conf_data[1]  & !w_byte_en[0] & w_we & w_reg_select_dec[55] ;
  759. end
  760. // STATUS BITS of PCI Header status register
  761. `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
  762. // Set and clear FF
  763. always@(posedge pci_clk or posedge reset)
  764. begin
  765. if (reset) // Asynchronous reset
  766. status_bit15_11[15] <= 1'b0 ;
  767. else
  768. begin
  769. if (perr_in) // Synchronous set
  770. status_bit15_11[15] <= 1'b1 ;
  771. else if (delete_status_bit15) // Synchronous reset
  772. status_bit15_11[15] <= 1'b0 ;
  773. end
  774. end
  775. // Set and clear FF
  776. always@(posedge pci_clk or posedge reset)
  777. begin
  778. if (reset) // Asynchronous reset
  779. status_bit15_11[14] <= 1'b0 ;
  780. else
  781. begin
  782. if (serr_in) // Synchronous set
  783. status_bit15_11[14] <= 1'b1 ;
  784. else if (delete_status_bit14) // Synchronous reset
  785. status_bit15_11[14] <= 1'b0 ;
  786. end
  787. end
  788. // Set and clear FF
  789. always@(posedge pci_clk or posedge reset)
  790. begin
  791. if (reset) // Asynchronous reset
  792. status_bit15_11[13] <= 1'b0 ;
  793. else
  794. begin
  795. if (master_abort_recv) // Synchronous set
  796. status_bit15_11[13] <= 1'b1 ;
  797. else if (delete_status_bit13) // Synchronous reset
  798. status_bit15_11[13] <= 1'b0 ;
  799. end
  800. end
  801. // Set and clear FF
  802. always@(posedge pci_clk or posedge reset)
  803. begin
  804. if (reset) // Asynchronous reset
  805. status_bit15_11[12] <= 1'b0 ;
  806. else
  807. begin
  808. if (target_abort_recv) // Synchronous set
  809. status_bit15_11[12] <= 1'b1 ;
  810. else if (delete_status_bit12) // Synchronous reset
  811. status_bit15_11[12] <= 1'b0 ;
  812. end
  813. end
  814. // Set and clear FF
  815. always@(posedge pci_clk or posedge reset)
  816. begin
  817. if (reset) // Asynchronous reset
  818. status_bit15_11[11] <= 1'b0 ;
  819. else
  820. begin
  821. if (target_abort_set) // Synchronous set
  822. status_bit15_11[11] <= 1'b1 ;
  823. else if (delete_status_bit11) // Synchronous reset
  824. status_bit15_11[11] <= 1'b0 ;
  825. end
  826. end
  827. // Set and clear FF
  828. always@(posedge pci_clk or posedge reset)
  829. begin
  830. if (reset) // Asynchronous reset
  831. status_bit8 <= 1'b0 ;
  832. else
  833. begin
  834. if (master_data_par_err) // Synchronous set
  835. status_bit8 <= 1'b1 ;
  836. else if (delete_status_bit8) // Synchronous reset
  837. status_bit8 <= 1'b0 ;
  838. end
  839. end
  840. `else // not SYNCHRONEOUS_CLOCK_DOMAINS
  841.   `ifdef HOST
  842. reg [15:11] set_status_bit15_11;
  843. reg set_status_bit8;
  844. wire delete_set_status_bit15;
  845. wire delete_set_status_bit14;
  846. wire delete_set_status_bit13;
  847. wire delete_set_status_bit12;
  848. wire delete_set_status_bit11;
  849. wire delete_set_status_bit8;
  850. wire block_set_status_bit15;
  851. wire block_set_status_bit14;
  852. wire block_set_status_bit13;
  853. wire block_set_status_bit12;
  854. wire block_set_status_bit11;
  855. wire block_set_status_bit8;
  856. // Synchronization module for clearing FF between two clock domains
  857. pci_sync_module sync_status_15
  858. (
  859. .set_clk_in (pci_clk),
  860. .delete_clk_in (wb_clk),
  861. .reset_in (reset),
  862. .delete_set_out (delete_set_status_bit15),
  863. .block_set_out (block_set_status_bit15),
  864. .delete_in (delete_status_bit15)
  865. );
  866. // Setting FF
  867. always@(posedge pci_clk or posedge reset)
  868. begin
  869. if (reset) // Asynchronous reset
  870. set_status_bit15_11[15] <= 1'b0 ;
  871. else
  872. begin
  873. if (perr_in) // Synchronous set
  874. set_status_bit15_11[15] <= 1'b1 ;
  875. else if (delete_set_status_bit15) // Synchronous reset
  876. set_status_bit15_11[15] <= 1'b0 ;
  877. end
  878. end
  879. // Synchronization module for clearing FF between two clock domains
  880. pci_sync_module sync_status_14
  881. (
  882. .set_clk_in (pci_clk),
  883. .delete_clk_in (wb_clk),
  884. .reset_in (reset),
  885. .delete_set_out (delete_set_status_bit14),
  886. .block_set_out (block_set_status_bit14),
  887. .delete_in (delete_status_bit14)
  888. );
  889. // Setting FF
  890. always@(posedge pci_clk or posedge reset)
  891. begin
  892. if (reset) // Asynchronous reset
  893. set_status_bit15_11[14] <= 1'b0 ;
  894. else
  895. begin
  896. if (serr_in) // Synchronous set
  897. set_status_bit15_11[14] <= 1'b1 ;
  898. else if (delete_set_status_bit14) // Synchronous reset
  899. set_status_bit15_11[14] <= 1'b0 ;
  900. end
  901. end
  902. // Synchronization module for clearing FF between two clock domains
  903. pci_sync_module sync_status_13
  904. (
  905. .set_clk_in (pci_clk),
  906. .delete_clk_in (wb_clk),
  907. .reset_in (reset),
  908. .delete_set_out (delete_set_status_bit13),
  909. .block_set_out (block_set_status_bit13),
  910. .delete_in (delete_status_bit13)
  911. );
  912. // Setting FF
  913. always@(posedge pci_clk or posedge reset)
  914. begin
  915. if (reset) // Asynchronous reset
  916. set_status_bit15_11[13] <= 1'b0 ;
  917. else
  918. begin
  919. if (master_abort_recv) // Synchronous set
  920. set_status_bit15_11[13] <= 1'b1 ;
  921. else if (delete_set_status_bit13) // Synchronous reset
  922. set_status_bit15_11[13] <= 1'b0 ;
  923. end
  924. end
  925. // Synchronization module for clearing FF between two clock domains
  926. pci_sync_module sync_status_12
  927. (
  928. .set_clk_in (pci_clk),
  929. .delete_clk_in (wb_clk),
  930. .reset_in (reset),
  931. .delete_set_out (delete_set_status_bit12),
  932. .block_set_out (block_set_status_bit12),
  933. .delete_in (delete_status_bit12)
  934. );
  935. // Setting FF
  936. always@(posedge pci_clk or posedge reset)
  937. begin
  938. if (reset) // Asynchronous reset
  939. set_status_bit15_11[12] <= 1'b0 ;
  940. else
  941. begin
  942. if (target_abort_recv) // Synchronous set
  943. set_status_bit15_11[12] <= 1'b1 ;
  944. else if (delete_set_status_bit12) // Synchronous reset
  945. set_status_bit15_11[12] <= 1'b0 ;
  946. end
  947. end
  948. // Synchronization module for clearing FF between two clock domains
  949. pci_sync_module sync_status_11
  950. (
  951. .set_clk_in (pci_clk),
  952. .delete_clk_in (wb_clk),
  953. .reset_in (reset),
  954. .delete_set_out (delete_set_status_bit11),
  955. .block_set_out (block_set_status_bit11),
  956. .delete_in (delete_status_bit11)
  957. );
  958. // Setting FF
  959. always@(posedge pci_clk or posedge reset)
  960. begin
  961. if (reset) // Asynchronous reset
  962. set_status_bit15_11[11] <= 1'b0 ;
  963. else
  964. begin
  965. if (target_abort_set) // Synchronous set
  966. set_status_bit15_11[11] <= 1'b1 ;
  967. else if (delete_set_status_bit11) // Synchronous reset
  968. set_status_bit15_11[11] <= 1'b0 ;
  969. end
  970. end
  971. // Synchronization module for clearing FF between two clock domains
  972. pci_sync_module sync_status_8
  973. (
  974. .set_clk_in (pci_clk),
  975. .delete_clk_in (wb_clk),
  976. .reset_in (reset),
  977. .delete_set_out (delete_set_status_bit8),
  978. .block_set_out (block_set_status_bit8),
  979. .delete_in (delete_status_bit8)
  980. );
  981. // Setting FF
  982. always@(posedge pci_clk or posedge reset)
  983. begin
  984. if (reset) // Asynchronous reset
  985. set_status_bit8 <= 1'b0 ;
  986. else
  987. begin
  988. if (master_data_par_err) // Synchronous set
  989. set_status_bit8 <= 1'b1 ;
  990. else if (delete_set_status_bit8) // Synchronous reset
  991. set_status_bit8 <= 1'b0 ;
  992. end
  993. end
  994. wire [5:0] status_bits = {set_status_bit15_11[15] && !block_set_status_bit15,
  995.  set_status_bit15_11[14] && !block_set_status_bit14,
  996.  set_status_bit15_11[13] && !block_set_status_bit13,
  997.  set_status_bit15_11[12] && !block_set_status_bit12,
  998.  set_status_bit15_11[11] && !block_set_status_bit11,
  999.  set_status_bit8  && !block_set_status_bit8 } ;
  1000. wire [5:0] meta_status_bits ;
  1001. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1002. pci_synchronizer_flop   #(6, 0) status_bits_sync
  1003. (
  1004.     .data_in        (status_bits),
  1005.     .clk_out        (wb_clk),
  1006.     .sync_data_out  (meta_status_bits),
  1007.     .async_reset    (reset)
  1008. ) ;
  1009. always@(posedge wb_clk or posedge reset)
  1010. begin
  1011.     if (reset)
  1012.     begin
  1013.         status_bit15_11[15:11] <= 5'b0 ;
  1014.         status_bit8 <= 1'b0 ;
  1015.     end
  1016.     else
  1017.     begin
  1018.         status_bit15_11[15:11] <= meta_status_bits[5:1] ;
  1019.         status_bit8 <= meta_status_bits[0] ;
  1020.     end
  1021. end
  1022.   `else // GUEST
  1023. // Set and clear FF
  1024. always@(posedge pci_clk or posedge reset)
  1025. begin
  1026. if (reset) // Asynchronous reset
  1027. status_bit15_11[15] <= 1'b0 ;
  1028. else
  1029. begin
  1030. if (perr_in) // Synchronous set
  1031. status_bit15_11[15] <= 1'b1 ;
  1032. else if (delete_status_bit15) // Synchronous reset
  1033. status_bit15_11[15] <= 1'b0 ;
  1034. end
  1035. end
  1036. // Set and clear FF
  1037. always@(posedge pci_clk or posedge reset)
  1038. begin
  1039. if (reset) // Asynchronous reset
  1040. status_bit15_11[14] <= 1'b0 ;
  1041. else
  1042. begin
  1043. if (serr_in) // Synchronous set
  1044. status_bit15_11[14] <= 1'b1 ;
  1045. else if (delete_status_bit14) // Synchronous reset
  1046. status_bit15_11[14] <= 1'b0 ;
  1047. end
  1048. end
  1049. // Set and clear FF
  1050. always@(posedge pci_clk or posedge reset)
  1051. begin
  1052. if (reset) // Asynchronous reset
  1053. status_bit15_11[13] <= 1'b0 ;
  1054. else
  1055. begin
  1056. if (master_abort_recv) // Synchronous set
  1057. status_bit15_11[13] <= 1'b1 ;
  1058. else if (delete_status_bit13) // Synchronous reset
  1059. status_bit15_11[13] <= 1'b0 ;
  1060. end
  1061. end
  1062. // Set and clear FF
  1063. always@(posedge pci_clk or posedge reset)
  1064. begin
  1065. if (reset) // Asynchronous reset
  1066. status_bit15_11[12] <= 1'b0 ;
  1067. else
  1068. begin
  1069. if (target_abort_recv) // Synchronous set
  1070. status_bit15_11[12] <= 1'b1 ;
  1071. else if (delete_status_bit12) // Synchronous reset
  1072. status_bit15_11[12] <= 1'b0 ;
  1073. end
  1074. end
  1075. // Set and clear FF
  1076. always@(posedge pci_clk or posedge reset)
  1077. begin
  1078. if (reset) // Asynchronous reset
  1079. status_bit15_11[11] <= 1'b0 ;
  1080. else
  1081. begin
  1082. if (target_abort_set) // Synchronous set
  1083. status_bit15_11[11] <= 1'b1 ;
  1084. else if (delete_status_bit11) // Synchronous reset
  1085. status_bit15_11[11] <= 1'b0 ;
  1086. end
  1087. end
  1088. // Set and clear FF
  1089. always@(posedge pci_clk or posedge reset)
  1090. begin
  1091. if (reset) // Asynchronous reset
  1092. status_bit8 <= 1'b0 ;
  1093. else
  1094. begin
  1095. if (master_data_par_err) // Synchronous set
  1096. status_bit8 <= 1'b1 ;
  1097. else if (delete_status_bit8) // Synchronous reset
  1098. status_bit8 <= 1'b0 ;
  1099. end
  1100. end
  1101.   `endif
  1102. `endif
  1103. // STATUS BITS of P_ERR_CS - PCI error control and status register
  1104. `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
  1105. // Set and clear FF
  1106. always@(posedge pci_clk or posedge reset)
  1107. begin
  1108. if (reset) // Asynchronous reset
  1109. pci_err_cs_bit8 <= 1'b0 ;
  1110. else
  1111. begin
  1112. if (pci_error_sig && pci_err_cs_bit0) // Synchronous set
  1113. pci_err_cs_bit8 <= 1'b1 ;
  1114. else if (delete_pci_err_cs_bit8) // Synchronous reset
  1115. pci_err_cs_bit8 <= 1'b0 ;
  1116. end
  1117. end
  1118. `else // not SYNCHRONEOUS_CLOCK_DOMAINS
  1119.   `ifdef HOST
  1120. // Set and clear FF
  1121. always@(posedge wb_clk or posedge reset)
  1122. begin
  1123. if (reset) // Asynchronous reset
  1124. pci_err_cs_bit8 <= 1'b0 ;
  1125. else
  1126. begin
  1127. if (pci_error_sig && pci_err_cs_bit0) // Synchronous set
  1128. pci_err_cs_bit8 <= 1'b1 ;
  1129. else if (delete_pci_err_cs_bit8) // Synchronous reset
  1130. pci_err_cs_bit8 <= 1'b0 ;
  1131. end
  1132. end
  1133.   `else // GUEST
  1134. reg set_pci_err_cs_bit8;
  1135. wire delete_set_pci_err_cs_bit8;
  1136. wire block_set_pci_err_cs_bit8;
  1137. // Synchronization module for clearing FF between two clock domains
  1138. pci_sync_module sync_pci_err_cs_8
  1139. (
  1140. .set_clk_in (wb_clk),
  1141. .delete_clk_in (pci_clk),
  1142. .reset_in (reset),
  1143. .delete_set_out (delete_set_pci_err_cs_bit8),
  1144. .block_set_out (block_set_pci_err_cs_bit8),
  1145. .delete_in (delete_pci_err_cs_bit8)
  1146. );
  1147. // Setting FF
  1148. always@(posedge wb_clk or posedge reset)
  1149. begin
  1150. if (reset) // Asynchronous reset
  1151. set_pci_err_cs_bit8 <= 1'b0 ;
  1152. else
  1153. begin
  1154. if (pci_error_sig && pci_err_cs_bit0) // Synchronous set
  1155. set_pci_err_cs_bit8 <= 1'b1 ;
  1156. else if (delete_set_pci_err_cs_bit8) // Synchronous reset
  1157. set_pci_err_cs_bit8 <= 1'b0 ;
  1158. end
  1159. end
  1160. wire pci_err_cs_bits = set_pci_err_cs_bit8 && !block_set_pci_err_cs_bit8 ;
  1161. wire meta_pci_err_cs_bits ;
  1162. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1163. pci_synchronizer_flop #(1,0) pci_err_cs_bits_sync
  1164. (
  1165.     .data_in        (pci_err_cs_bits),
  1166.     .clk_out        (pci_clk),
  1167.     .sync_data_out  (meta_pci_err_cs_bits),
  1168.     .async_reset    (reset)
  1169. ) ;
  1170. always@(posedge pci_clk or posedge reset)
  1171. begin
  1172.     if (reset)
  1173.         pci_err_cs_bit8 <= 1'b0 ;
  1174.     else
  1175.         pci_err_cs_bit8 <= meta_pci_err_cs_bits ;
  1176. end
  1177.   `endif
  1178. `endif
  1179. // Set and clear FF
  1180. always@(posedge wb_clk or posedge reset)
  1181. begin
  1182. if (reset) // Asynchronous reset
  1183. pci_err_cs_bit10 <= 1'b0 ;
  1184. else
  1185. begin
  1186. if (pci_error_sig) // Synchronous report
  1187. pci_err_cs_bit10 <= pci_error_rty_exp ;
  1188. end
  1189. end
  1190. // Set and clear FF
  1191. always@(posedge wb_clk or posedge reset)
  1192. begin
  1193. if (reset) // Asynchronous reset
  1194. pci_err_cs_bit9 <= 1'b0 ;
  1195. else
  1196. begin
  1197. if (pci_error_sig) // Synchronous report
  1198. pci_err_cs_bit9 <= pci_error_es ;
  1199. end
  1200. end
  1201. // Set and clear FF
  1202. always@(posedge wb_clk or posedge reset)
  1203. begin
  1204. if (reset) // Asynchronous reset
  1205.     begin
  1206. pci_err_cs_bit31_24 <= 8'h00 ;
  1207. pci_err_addr <= 32'h0000_0000 ;
  1208. pci_err_data <= 32'h0000_0000 ;
  1209.     end
  1210. else
  1211. if (pci_error_sig) // Synchronous report
  1212. begin
  1213. pci_err_cs_bit31_24 <= { pci_error_be, pci_error_bc } ;
  1214. pci_err_addr <= pci_error_addr ;
  1215. pci_err_data <= pci_error_data ;
  1216. end
  1217. end
  1218. // STATUS BITS of W_ERR_CS - WB error control and status register
  1219. `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
  1220. // Set and clear FF
  1221. always@(posedge pci_clk or posedge reset)
  1222. begin
  1223. if (reset) // Asynchronous reset
  1224. wb_err_cs_bit8 <= 1'b0 ;
  1225. else
  1226. begin
  1227. if (wb_error_sig && wb_err_cs_bit0) // Synchronous set
  1228. wb_err_cs_bit8 <= 1'b1 ;
  1229. else if (delete_wb_err_cs_bit8) // Synchronous reset
  1230. wb_err_cs_bit8 <= 1'b0 ;
  1231. end
  1232. end
  1233. `else // not SYNCHRONEOUS_CLOCK_DOMAINS
  1234.   `ifdef HOST
  1235. reg set_wb_err_cs_bit8;
  1236. wire delete_set_wb_err_cs_bit8;
  1237. wire block_set_wb_err_cs_bit8;
  1238. // Synchronization module for clearing FF between two clock domains
  1239. pci_sync_module sync_wb_err_cs_8
  1240. (
  1241. .set_clk_in (pci_clk),
  1242. .delete_clk_in (wb_clk),
  1243. .reset_in (reset),
  1244. .delete_set_out (delete_set_wb_err_cs_bit8),
  1245. .block_set_out (block_set_wb_err_cs_bit8),
  1246. .delete_in (delete_wb_err_cs_bit8)
  1247. );
  1248. // Setting FF
  1249. always@(posedge pci_clk or posedge reset)
  1250. begin
  1251. if (reset) // Asynchronous reset
  1252. set_wb_err_cs_bit8 <= 1'b0 ;
  1253. else
  1254. begin
  1255. if (wb_error_sig && wb_err_cs_bit0) // Synchronous set
  1256. set_wb_err_cs_bit8 <= 1'b1 ;
  1257. else if (delete_set_wb_err_cs_bit8) // Synchronous reset
  1258. set_wb_err_cs_bit8 <= 1'b0 ;
  1259. end
  1260. end
  1261. wire wb_err_cs_bits = set_wb_err_cs_bit8 && !block_set_wb_err_cs_bit8 ;
  1262. wire meta_wb_err_cs_bits ;
  1263. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1264. pci_synchronizer_flop #(1,0) wb_err_cs_bits_sync
  1265. (
  1266.     .data_in        (wb_err_cs_bits),
  1267.     .clk_out        (wb_clk),
  1268.     .sync_data_out  (meta_wb_err_cs_bits),
  1269.     .async_reset    (reset)
  1270. ) ;
  1271. always@(posedge wb_clk or posedge reset)
  1272. begin
  1273.     if (reset)
  1274.         wb_err_cs_bit8 <= 1'b0 ;
  1275.     else
  1276.         wb_err_cs_bit8 <= meta_wb_err_cs_bits ;
  1277. end
  1278.   `else // GUEST
  1279. // Set and clear FF
  1280. always@(posedge pci_clk or posedge reset)
  1281. begin
  1282. if (reset) // Asynchronous reset
  1283. wb_err_cs_bit8 <= 1'b0 ;
  1284. else
  1285. begin
  1286. if (wb_error_sig && wb_err_cs_bit0) // Synchronous set
  1287. wb_err_cs_bit8 <= 1'b1 ;
  1288. else if (delete_wb_err_cs_bit8) // Synchronous reset
  1289. wb_err_cs_bit8 <= 1'b0 ;
  1290. end
  1291. end
  1292.   `endif
  1293. `endif
  1294. /* // Set and clear FF
  1295. always@(posedge pci_clk or posedge reset)
  1296. begin
  1297. if (reset) // Asynchronous reset
  1298. wb_err_cs_bit10 <= 1'b0 ;
  1299. else
  1300. begin
  1301. if (wb_error_sig) // Synchronous report
  1302. wb_err_cs_bit10 <= wb_error_rty_exp ;
  1303. end
  1304. end */
  1305. // Set and clear FF
  1306. always@(posedge pci_clk or posedge reset)
  1307. begin
  1308. if (reset) // Asynchronous reset
  1309. wb_err_cs_bit9 <= 1'b0 ;
  1310. else
  1311. begin
  1312. if (wb_error_sig) // Synchronous report
  1313. wb_err_cs_bit9 <= wb_error_es ;
  1314. end
  1315. end
  1316. // Set and clear FF
  1317. always@(posedge pci_clk or posedge reset)
  1318. begin
  1319. if (reset) // Asynchronous reset
  1320.     begin
  1321. wb_err_cs_bit31_24 <= 8'h00 ;
  1322. wb_err_addr <= 32'h0000_0000 ;
  1323. wb_err_data <= 32'h0000_0000 ;
  1324.     end
  1325. else
  1326. if (wb_error_sig)
  1327. begin
  1328. wb_err_cs_bit31_24 <= { wb_error_be, wb_error_bc } ;
  1329. wb_err_addr <= wb_error_addr ;
  1330. wb_err_data <= wb_error_data ;
  1331. end
  1332. end
  1333. // SERR_INT and PERR_INT STATUS BITS of ISR - interrupt status register
  1334. `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
  1335.   `ifdef HOST
  1336. // Set and clear FF
  1337. always@(posedge pci_clk or posedge reset)
  1338. begin
  1339. if (reset) // Asynchronous reset
  1340. isr_bit4_3[4] <= 1'b0 ;
  1341. else
  1342. begin
  1343. if (isr_sys_err_int && icr_bit4_3[4]) // Synchronous set
  1344. isr_bit4_3[4] <= 1'b1 ;
  1345. else if (delete_isr_bit4) // Synchronous reset
  1346. isr_bit4_3[4] <= 1'b0 ;
  1347. end
  1348. end
  1349. // Set and clear FF
  1350. always@(posedge pci_clk or posedge reset)
  1351. begin
  1352. if (reset) // Asynchronous reset
  1353. isr_bit4_3[3] <= 1'b0 ;
  1354. else
  1355. begin
  1356. if (isr_par_err_int && icr_bit4_3[3]) // Synchronous set
  1357. isr_bit4_3[3] <= 1'b1 ;
  1358. else if (delete_isr_bit3) // Synchronous reset
  1359. isr_bit4_3[3] <= 1'b0 ;
  1360. end
  1361. end
  1362.   `endif
  1363. `else // not SYNCHRONEOUS_CLOCK_DOMAINS
  1364.   `ifdef HOST
  1365. reg [4:3] set_isr_bit4_3;
  1366. wire delete_set_isr_bit4;
  1367. wire delete_set_isr_bit3;
  1368. wire block_set_isr_bit4;
  1369. wire block_set_isr_bit3;
  1370. // Synchronization module for clearing FF between two clock domains
  1371. pci_sync_module sync_isr_4
  1372. (
  1373. .set_clk_in (pci_clk),
  1374. .delete_clk_in (wb_clk),
  1375. .reset_in (reset),
  1376. .delete_set_out (delete_set_isr_bit4),
  1377. .block_set_out (block_set_isr_bit4),
  1378. .delete_in (delete_isr_bit4)
  1379. );
  1380. // Setting FF
  1381. always@(posedge pci_clk or posedge reset)
  1382. begin
  1383. if (reset) // Asynchronous reset
  1384. set_isr_bit4_3[4] <= 1'b0 ;
  1385. else
  1386. begin
  1387. if (isr_sys_err_int && icr_bit4_3[4]) // Synchronous set
  1388. set_isr_bit4_3[4] <= 1'b1 ;
  1389. else if (delete_set_isr_bit4) // Synchronous reset
  1390. set_isr_bit4_3[4] <= 1'b0 ;
  1391. end
  1392. end
  1393. // Synchronization module for clearing FF between two clock domains
  1394. pci_sync_module sync_isr_3
  1395. (
  1396. .set_clk_in (pci_clk),
  1397. .delete_clk_in (wb_clk),
  1398. .reset_in (reset),
  1399. .delete_set_out (delete_set_isr_bit3),
  1400. .block_set_out (block_set_isr_bit3),
  1401. .delete_in (delete_isr_bit3)
  1402. );
  1403. // Setting FF
  1404. always@(posedge pci_clk or posedge reset)
  1405. begin
  1406. if (reset) // Asynchronous reset
  1407. set_isr_bit4_3[3] <= 1'b0 ;
  1408. else
  1409. begin
  1410. if (isr_par_err_int && icr_bit4_3[3]) // Synchronous set
  1411. set_isr_bit4_3[3] <= 1'b1 ;
  1412. else if (delete_set_isr_bit3) // Synchronous reset
  1413. set_isr_bit4_3[3] <= 1'b0 ;
  1414. end
  1415. end
  1416. wire [4:3] isr_bits4_3 = {set_isr_bit4_3[4] && !block_set_isr_bit4,
  1417.  set_isr_bit4_3[3] && !block_set_isr_bit3 } ;
  1418. wire [4:3] meta_isr_bits4_3 ;
  1419. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1420. pci_synchronizer_flop   #(2, 0) isr_bits_sync
  1421. (
  1422.     .data_in        (isr_bits4_3),
  1423.     .clk_out        (wb_clk),
  1424.     .sync_data_out  (meta_isr_bits4_3),
  1425.     .async_reset    (reset)
  1426. ) ;
  1427. always@(posedge wb_clk or posedge reset)
  1428. begin
  1429.     if (reset)
  1430.         isr_bit4_3[4:3] <= 2'b0 ;
  1431.     else
  1432.         isr_bit4_3[4:3] <= meta_isr_bits4_3[4:3] ;
  1433. end
  1434.   `endif
  1435. `endif
  1436. // PCI_EINT and WB_EINT STATUS BITS of ISR - interrupt status register
  1437. `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
  1438.   // WB_EINT STATUS BIT
  1439. // Set and clear FF
  1440. always@(posedge pci_clk or posedge reset)
  1441. begin
  1442. if (reset) // Asynchronous reset
  1443. isr_bit2_0[1] <= 1'b0 ;
  1444. else
  1445. begin
  1446. if (wb_error_sig && icr_bit2_0[1] && wb_err_cs_bit0) // Synchronous set
  1447. isr_bit2_0[1] <= 1'b1 ;
  1448. else if (delete_isr_bit1) // Synchronous reset
  1449. isr_bit2_0[1] <= 1'b0 ;
  1450. end
  1451. end
  1452.   // PCI_EINT STATUS BIT
  1453. // Set and clear FF
  1454. always@(posedge pci_clk or posedge reset)
  1455. begin
  1456. if (reset) // Asynchronous reset
  1457. isr_bit2_0[2] <= 1'b0 ;
  1458. else
  1459. begin
  1460. if (pci_error_sig && icr_bit2_0[2] && pci_err_cs_bit0) // Synchronous set
  1461. isr_bit2_0[2] <= 1'b1 ;
  1462. else if (delete_isr_bit2) // Synchronous reset
  1463. isr_bit2_0[2] <= 1'b0 ;
  1464. end
  1465. end
  1466. `else // not SYNCHRONEOUS_CLOCK_DOMAINS
  1467.   `ifdef HOST
  1468.   // WB_EINT STATUS BIT
  1469. reg set_isr_bit1;
  1470. wire delete_set_isr_bit1;
  1471. wire block_set_isr_bit1;
  1472. // Synchronization module for clearing FF between two clock domains
  1473. pci_sync_module sync_isr_1
  1474. (
  1475. .set_clk_in (pci_clk),
  1476. .delete_clk_in (wb_clk),
  1477. .reset_in (reset),
  1478. .delete_set_out (delete_set_isr_bit1),
  1479. .block_set_out (block_set_isr_bit1),
  1480. .delete_in (delete_isr_bit1)
  1481. );
  1482. // Setting FF
  1483. always@(posedge pci_clk or posedge reset)
  1484. begin
  1485. if (reset) // Asynchronous reset
  1486. set_isr_bit1 <= 1'b0 ;
  1487. else
  1488. begin
  1489. if (wb_error_sig && icr_bit2_0[1] && wb_err_cs_bit0) // Synchronous set
  1490. set_isr_bit1 <= 1'b1 ;
  1491. else if (delete_set_isr_bit1) // Synchronous reset
  1492. set_isr_bit1 <= 1'b0 ;
  1493. end
  1494. end
  1495. wire isr_bit1 = set_isr_bit1 && !block_set_isr_bit1 ;
  1496. wire meta_isr_bit1 ;
  1497. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1498. pci_synchronizer_flop   #(1, 0) isr_bit1_sync
  1499. (
  1500.     .data_in        (isr_bit1),
  1501.     .clk_out        (wb_clk),
  1502.     .sync_data_out  (meta_isr_bit1),
  1503.     .async_reset    (reset)
  1504. ) ;
  1505. always@(posedge wb_clk or posedge reset)
  1506. begin
  1507.     if (reset)
  1508.         isr_bit2_0[1] <= 1'b0 ;
  1509.     else
  1510.         isr_bit2_0[1] <= meta_isr_bit1 ;
  1511. end
  1512.   // PCI_EINT STATUS BIT
  1513. // Set and clear FF
  1514. always@(posedge wb_clk or posedge reset)
  1515. begin
  1516. if (reset) // Asynchronous reset
  1517. isr_bit2_0[2] <= 1'b0 ;
  1518. else
  1519. begin
  1520. if (pci_error_sig && icr_bit2_0[2] && pci_err_cs_bit0) // Synchronous set
  1521. isr_bit2_0[2] <= 1'b1 ;
  1522. else if (delete_isr_bit2) // Synchronous reset
  1523. isr_bit2_0[2] <= 1'b0 ;
  1524. end
  1525. end
  1526.   `else // GUEST
  1527.   // WB_EINT STATUS BIT
  1528. // Set and clear FF
  1529. always@(posedge pci_clk or posedge reset)
  1530. begin
  1531. if (reset) // Asynchronous reset
  1532. isr_bit2_0[1] <= 1'b0 ;
  1533. else
  1534. begin
  1535. if (wb_error_sig && icr_bit2_0[1] && wb_err_cs_bit0) // Synchronous set
  1536. isr_bit2_0[1] <= 1'b1 ;
  1537. else if (delete_isr_bit1) // Synchronous reset
  1538. isr_bit2_0[1] <= 1'b0 ;
  1539. end
  1540. end
  1541.   // PCI_EINT STATUS BIT
  1542. reg set_isr_bit2;
  1543. wire delete_set_isr_bit2;
  1544. wire block_set_isr_bit2;
  1545. // Synchronization module for clearing FF between two clock domains
  1546. pci_sync_module sync_isr_2
  1547. (
  1548. .set_clk_in (wb_clk),
  1549. .delete_clk_in (pci_clk),
  1550. .reset_in (reset),
  1551. .delete_set_out (delete_set_isr_bit2),
  1552. .block_set_out (block_set_isr_bit2),
  1553. .delete_in (delete_isr_bit2)
  1554. );
  1555. // Setting FF
  1556. always@(posedge wb_clk or posedge reset)
  1557. begin
  1558. if (reset) // Asynchronous reset
  1559. set_isr_bit2 <= 1'b0 ;
  1560. else
  1561. begin
  1562. if (pci_error_sig && icr_bit2_0[2] && pci_err_cs_bit0) // Synchronous set
  1563. set_isr_bit2 <= 1'b1 ;
  1564. else if (delete_set_isr_bit2) // Synchronous reset
  1565. set_isr_bit2 <= 1'b0 ;
  1566. end
  1567. end
  1568. wire isr_bit2 = set_isr_bit2 && !block_set_isr_bit2 ;
  1569. wire meta_isr_bit2 ;
  1570. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1571. pci_synchronizer_flop   #(1, 0) isr_bit2_sync
  1572. (
  1573.     .data_in        (isr_bit2),
  1574.     .clk_out        (pci_clk),
  1575.     .sync_data_out  (meta_isr_bit2),
  1576.     .async_reset    (reset)
  1577. ) ;
  1578. always@(posedge pci_clk or posedge reset)
  1579. begin
  1580.     if (reset)
  1581.         isr_bit2_0[2] <= 1'b0 ;
  1582.     else
  1583.         isr_bit2_0[2] <= meta_isr_bit2 ;
  1584. end
  1585.   `endif
  1586. `endif
  1587. // INT BIT of ISR - interrupt status register
  1588. `ifdef HOST
  1589. wire isr_int_prop_bit = isr_int_prop && icr_bit2_0[0] ;
  1590. wire meta_isr_int_prop_bit ;
  1591. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1592. pci_synchronizer_flop   #(1, 0) isr_bit0_sync
  1593. (
  1594.     .data_in        (isr_int_prop_bit),
  1595.     .clk_out        (wb_clk),
  1596.     .sync_data_out  (meta_isr_int_prop_bit),
  1597.     .async_reset    (reset)
  1598. ) ;
  1599. always@(posedge wb_clk or posedge reset)
  1600. begin
  1601.     if (reset)
  1602.         isr_bit2_0[0] <= 1'b0 ;
  1603.     else
  1604.         isr_bit2_0[0] <= meta_isr_int_prop_bit ;
  1605. end
  1606. `else // GUEST
  1607.   `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
  1608. wire isr_int_prop_bit = isr_int_prop && icr_bit2_0[0] ;
  1609. always@(posedge pci_clk or posedge reset)
  1610. begin
  1611.     if (reset)
  1612.         isr_bit2_0[0] <= 1'b0 ;
  1613.     else
  1614.         isr_bit2_0[0] <= isr_int_prop_bit ;
  1615. end
  1616.   `else // not SYNCHRONEOUS_CLOCK_DOMAINS
  1617. wire isr_int_prop_bit = isr_int_prop && icr_bit2_0[0] ;
  1618. wire meta_isr_int_prop_bit ;
  1619. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1620. pci_synchronizer_flop   #(1, 0) isr_bit0_sync
  1621. (
  1622.     .data_in        (isr_int_prop_bit),
  1623.     .clk_out        (pci_clk),
  1624.     .sync_data_out  (meta_isr_int_prop_bit),
  1625.     .async_reset    (reset)
  1626. ) ;
  1627. always@(posedge pci_clk or posedge reset)
  1628. begin
  1629.     if (reset)
  1630.         isr_bit2_0[0] <= 1'b0 ;
  1631.     else
  1632.         isr_bit2_0[0] <= meta_isr_int_prop_bit ;
  1633. end
  1634.   `endif
  1635. `endif
  1636. // INT PIN
  1637. wire int_in;
  1638. wire int_meta;
  1639. reg interrupt_out;
  1640. `ifdef HOST
  1641.  `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
  1642. assign int_in = isr_int_prop_bit || isr_bit2_0[1] || isr_bit2_0[2] || isr_bit4_3[3]  || isr_bit4_3[4];
  1643.  `else // not SYNCHRONEOUS_CLOCK_DOMAINS
  1644. assign int_in = isr_int_prop_bit || isr_bit1      || isr_bit2_0[2] || isr_bits4_3[3] || isr_bits4_3[4];
  1645.  `endif
  1646. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1647. pci_synchronizer_flop   #(1, 0) int_pin_sync
  1648. (
  1649.     .data_in        (int_in),
  1650.     .clk_out        (wb_clk),
  1651.     .sync_data_out  (int_meta),
  1652.     .async_reset    (reset)
  1653. ) ;
  1654. always@(posedge wb_clk or posedge reset)
  1655. begin
  1656.     if (reset)
  1657.         interrupt_out <= 1'b0 ;
  1658.     else
  1659.         interrupt_out <= int_meta ;
  1660. end
  1661. `else // GUEST
  1662.  `ifdef SYNCHRONEOUS_CLOCK_DOMAINS
  1663. assign int_in = isr_int_prop_bit || isr_bit2_0[1] || isr_bit2_0[2];
  1664.  `else // not SYNCHRONEOUS_CLOCK_DOMAINS
  1665. assign int_in = isr_int_prop_bit || isr_bit2_0[1] || isr_bit2;
  1666.  `endif
  1667. // interemediate stage to clk synchronization flip - flops - this ones are prone to metastability
  1668. pci_synchronizer_flop   #(1, 0) int_pin_sync
  1669. (
  1670.     .data_in        (int_in),
  1671.     .clk_out        (pci_clk),
  1672.     .sync_data_out  (int_meta),
  1673.     .async_reset    (reset)
  1674. ) ;
  1675. always@(posedge pci_clk or posedge reset)
  1676. begin
  1677.     if (reset)
  1678.         interrupt_out <= 1'b0 ;
  1679.     else
  1680.         interrupt_out <= int_meta ;
  1681. end
  1682. `endif
  1683. `ifdef PCI_CPCI_HS_IMPLEMENT
  1684.     reg [hs_es_cnt_width - 1:0] hs_es_cnt ; // debounce counter
  1685.     reg hs_es_in_state,   // current state of ejector switch input - synchronized
  1686.         hs_es_sync,       // synchronization flop for ejector switch input
  1687.         hs_es_cur_state ; // current valid state of ejector switch
  1688. `ifdef ACTIVE_HIGH_OE
  1689.     wire oe_active_val = 1'b1 ;
  1690. `endif
  1691. `ifdef ACTIVE_LOW_OE
  1692.     wire oe_active_val = 1'b0 ;
  1693. `endif
  1694. always@(posedge pci_clk or posedge reset)
  1695. begin
  1696.     if (reset)
  1697.         begin
  1698.         hs_ins          <= 1'b0 ;
  1699.             hs_ins_armed    <= 1'b1 ;
  1700.             hs_ext          <= 1'b0 ;
  1701.             hs_ext_armed    <= 1'b0 ;
  1702.             hs_es_in_state  <= 1'b0 ;
  1703.             hs_es_sync      <= 1'b0 ;
  1704.             hs_es_cur_state <= 1'b0 ;
  1705.             hs_es_cnt       <= 'h0  ;
  1706.         `ifdef ACTIVE_LOW_OE
  1707.             pci_cpci_hs_enum_oe_o   <= 1'b1 ;
  1708.             pci_cpci_hs_led_oe_o    <= 1'b0 ;
  1709.         `endif
  1710.         `ifdef ACTIVE_HIGH_OE
  1711.             pci_cpci_hs_enum_oe_o   <= 1'b0 ;
  1712.             pci_cpci_hs_led_oe_o    <= 1'b1 ;
  1713.         `endif
  1714.         end
  1715.     else
  1716.         begin
  1717.             // INS
  1718.             if (hs_ins)
  1719.             begin
  1720.                 if (w_conf_data[23] & ~w_byte_en[2] & w_we & w_reg_select_dec[56]) // clear
  1721.                     hs_ins <= 1'b0 ;
  1722.             end
  1723.             else if (hs_ins_armed)  // set
  1724.                 hs_ins <= init_complete & (hs_es_cur_state == 1'b1) ;
  1725.             // INS armed
  1726.             if (~hs_ins & hs_ins_armed & init_complete & (hs_es_cur_state == 1'b1)) // clear
  1727.                 hs_ins_armed <= 1'b0 ;
  1728.             else if (hs_ext)  // set
  1729.                 hs_ins_armed <= w_conf_data[22] & ~w_byte_en[2] & w_we & w_reg_select_dec[56] ;
  1730.             // EXT
  1731.             if (hs_ext) // clear
  1732.             begin
  1733.                 if (w_conf_data[22] & ~w_byte_en[2] & w_we & w_reg_select_dec[56])
  1734.                     hs_ext <= 1'b0 ;
  1735.             end
  1736.             else if (hs_ext_armed)  // set
  1737.                 hs_ext <= (hs_es_cur_state == 1'b0) ;
  1738.             // EXT armed
  1739.             if (~hs_ext & hs_ext_armed & (hs_es_cur_state == 1'b0)) // clear
  1740.                 hs_ext_armed <= 1'b0 ;
  1741.             else if (hs_ins)  // set
  1742.                 hs_ext_armed <= w_conf_data[23] & !w_byte_en[2] & w_we & w_reg_select_dec[56] ;
  1743.             // ejector switch debounce counter logic
  1744.             hs_es_sync     <= pci_cpci_hs_es_i  ;
  1745.             hs_es_in_state <= hs_es_sync        ;
  1746.             if (hs_es_in_state == hs_es_cur_state)
  1747.                 hs_es_cnt <= 'h0 ;
  1748.             else
  1749.                 hs_es_cnt <= hs_es_cnt + 1'b1 ;
  1750.             if (hs_es_cnt == {hs_es_cnt_width{1'b1}})
  1751.                 hs_es_cur_state <= hs_es_in_state ;
  1752.             if ((hs_ins | hs_ext) & ~hs_eim)
  1753.                 pci_cpci_hs_enum_oe_o   <=  oe_active_val   ;
  1754.             else
  1755.                 pci_cpci_hs_enum_oe_o   <= ~oe_active_val   ;
  1756.             if (~init_complete | hs_loo)
  1757.                 pci_cpci_hs_led_oe_o    <=  oe_active_val   ;
  1758.             else
  1759.                 pci_cpci_hs_led_oe_o    <= ~oe_active_val   ;
  1760.         end
  1761. end
  1762. `endif
  1763. `ifdef PCI_SPOCI
  1764.     wire spoci_write_done,
  1765.          spoci_dat_rdy   ,
  1766.          spoci_no_ack    ;
  1767.     wire [ 7: 0] spoci_wdat ;
  1768.     wire [ 7: 0] spoci_rdat ;
  1769.     // power on configuration control and status register    
  1770.     always@(posedge pci_clk or posedge reset)
  1771. begin
  1772.     if (reset)
  1773.         begin
  1774.             spoci_cs_nack   <= 1'b0 ;
  1775.             spoci_cs_write  <= 1'b0 ;
  1776.             spoci_cs_read   <= 1'b0 ;
  1777.             spoci_cs_adr    <= 'h0  ;
  1778.             spoci_cs_dat    <= 'h0  ;
  1779.         end
  1780.         else
  1781.         begin
  1782.             if (spoci_cs_write)
  1783.             begin
  1784.                 if (spoci_write_done | spoci_no_ack)
  1785.                     spoci_cs_write <= 1'b0 ;
  1786.             end
  1787.             else if ( w_we & (w_conf_address[9:2] == 8'hFF) & ~w_byte_en[3])
  1788.                 spoci_cs_write <= w_conf_data[25] ;
  1789.             if (spoci_cs_read)
  1790.             begin
  1791.                 if (spoci_dat_rdy | spoci_no_ack)
  1792.                     spoci_cs_read <= 1'b0          ;
  1793.             end
  1794.             else if ( w_we & (w_conf_address[9:2] == 8'hFF) & ~w_byte_en[3] )
  1795.                 spoci_cs_read <= w_conf_data[24] ;
  1796.             if (spoci_cs_nack)
  1797.             begin
  1798.                 if ( w_we & (w_conf_address[9:2] == 8'hFF) & ~w_byte_en[3] & w_conf_data[31] )
  1799.                     spoci_cs_nack <= 1'b0 ;
  1800.             end
  1801.             else if (spoci_cs_write | spoci_cs_read | ~init_cfg_done)
  1802.             begin
  1803.                 spoci_cs_nack <= spoci_no_ack ;
  1804.             end
  1805.             if ( w_we & (w_conf_address[9:2] == 8'hFF) )
  1806.             begin
  1807.                 if (~w_byte_en[2])
  1808.                     spoci_cs_adr[10: 8] <= w_conf_data[18:16] ;
  1809.                 if (~w_byte_en[1])
  1810.                     spoci_cs_adr[ 7: 0] <= w_conf_data[15: 8] ;
  1811.             end
  1812.             if ( w_we & (w_conf_address[9:2] == 8'hFF) & ~w_byte_en[0] )
  1813.                 spoci_cs_dat <= w_conf_data[ 7: 0] ;
  1814.             else if (spoci_cs_read & spoci_dat_rdy)
  1815.                 spoci_cs_dat <= spoci_rdat ;
  1816.             
  1817.         end
  1818.     end
  1819.     reg [ 2 : 0] bytes_received ;
  1820.     always@(posedge pci_clk or posedge reset)
  1821. begin
  1822.     if (reset)
  1823.         begin
  1824.             init_we         <= 1'b0 ;
  1825.             init_cfg_done   <= 1'b0 ;
  1826.             bytes_received  <= 1'b0 ;
  1827.             spoci_dat       <= 'h0  ;
  1828.             spoci_reg_num   <= 'h0  ;
  1829.         end
  1830.         else if (~init_cfg_done)
  1831.         begin
  1832.             if (spoci_dat_rdy)
  1833.             begin
  1834.                 case (bytes_received)
  1835.                 'h0:spoci_reg_num       <= spoci_rdat   ;
  1836.                 'h1:spoci_dat[ 7: 0]    <= spoci_rdat   ;
  1837.                 'h2:spoci_dat[15: 8]    <= spoci_rdat   ;
  1838.                 'h3:spoci_dat[23:16]    <= spoci_rdat   ;
  1839.                 'h4:spoci_dat[31:24]    <= spoci_rdat   ;
  1840.                 default:
  1841.                 begin
  1842.                     spoci_dat       <= 32'hxxxx_xxxx    ;
  1843.                     spoci_reg_num   <= 'hxx             ;
  1844.                 end
  1845.                 endcase
  1846.             end
  1847.             if (init_we)
  1848.                 bytes_received <= 'h0 ;
  1849.             else if (spoci_dat_rdy)
  1850.                 bytes_received <= bytes_received + 1'b1 ;
  1851.             if (init_we)
  1852.                 init_we <= 1'b0 ;
  1853.             else if (bytes_received == 'h5)
  1854.                 init_we <= 1'b1 ;
  1855.             
  1856.             if (spoci_no_ack | ((bytes_received == 'h1) & (spoci_reg_num == 'hff)) )
  1857.                 init_cfg_done <= 1'b1 ;
  1858.         end
  1859.     end
  1860.     assign spoci_wdat = spoci_cs_dat ;
  1861.     pci_spoci_ctrl i_pci_spoci_ctrl
  1862.     (
  1863.         .reset_i            (reset                          ),
  1864.         .clk_i              (pci_clk                        ),
  1865.         .do_rnd_read_i      (spoci_cs_read                  ),
  1866.         .do_seq_read_i      (rst_inactive & ~init_cfg_done  ),
  1867.         .do_write_i         (spoci_cs_write                 ),
  1868.         .write_done_o       (spoci_write_done               ),
  1869.         .dat_rdy_o          (spoci_dat_rdy                  ),
  1870.         .no_ack_o           (spoci_no_ack                   ),
  1871.         .adr_i              (spoci_cs_adr                   ),
  1872.         .dat_i              (spoci_wdat                     ),
  1873.         .dat_o              (spoci_rdat                     ),
  1874.         .pci_spoci_sda_i    (spoci_sda_i                    ),
  1875.         .pci_spoci_sda_oe_o (spoci_sda_oe_o                 ),
  1876.         .pci_spoci_scl_oe_o (spoci_scl_oe_o                 )
  1877.     );
  1878. `endif
  1879. /*-----------------------------------------------------------------------------------------------------------
  1880.         OUTPUTs from registers !!!
  1881. -----------------------------------------------------------------------------------------------------------*/
  1882. // if bridge is HOST then write clock is equal to WB clock, and synchronization of outputs has to be done
  1883. `ifdef HOST
  1884.   wire [3:0] command_bits = {command_bit8, command_bit6, command_bit2_0[1:0]} ;
  1885.   wire [3:0] meta_command_bits ;
  1886.   reg  [3:0] sync_command_bits ;
  1887.   pci_synchronizer_flop   #(4, 0)  command_bits_sync
  1888.   (
  1889.       .data_in        (command_bits),
  1890.       .clk_out        (pci_clk),
  1891.       .sync_data_out  (meta_command_bits),
  1892.       .async_reset    (reset)
  1893.   ) ;
  1894.   always@(posedge pci_clk or posedge reset)
  1895.   begin
  1896.       if (reset)
  1897.           sync_command_bits <= 4'b0 ;
  1898.       else
  1899.           sync_command_bits <= meta_command_bits ;
  1900.   end
  1901.   wire  sync_command_bit8 = sync_command_bits[3] ;
  1902.   wire  sync_command_bit6 = sync_command_bits[2] ;
  1903.   wire  sync_command_bit1 = sync_command_bits[1] ;
  1904.   wire  sync_command_bit0 = sync_command_bits[0] ;
  1905.   wire  sync_command_bit2 = command_bit2_0[2] ;
  1906. `else // GUEST
  1907.   wire       command_bit = command_bit2_0[2] ;
  1908.   wire       meta_command_bit ;
  1909.   reg        sync_command_bit ;
  1910.   pci_synchronizer_flop   #(1, 0) command_bit_sync
  1911.   (
  1912.       .data_in        (command_bit),
  1913.       .clk_out        (pci_clk),
  1914.       .sync_data_out  (meta_command_bit),
  1915.       .async_reset    (reset)
  1916.   ) ;
  1917.   always@(posedge pci_clk or posedge reset)
  1918.   begin
  1919.       if (reset)
  1920.           sync_command_bit <= 1'b0 ;
  1921.       else
  1922.           sync_command_bit <= meta_command_bit ;
  1923.   end
  1924.   wire  sync_command_bit8 = command_bit8 ;
  1925.   wire  sync_command_bit6 = command_bit6 ;
  1926.   wire  sync_command_bit1 = command_bit2_0[1] ;
  1927.   wire  sync_command_bit0 = command_bit2_0[0] ;
  1928.   wire  sync_command_bit2 = sync_command_bit ;
  1929. `endif
  1930. // PCI header outputs from command register
  1931. assign serr_enable = sync_command_bit8 & pci_init_complete_out ;           // to PCI clock
  1932. assign perr_response = sync_command_bit6 & pci_init_complete_out ;         // to PCI clock
  1933. assign pci_master_enable = sync_command_bit2 & wb_init_complete_out ;      // to WB clock
  1934. assign memory_space_enable = sync_command_bit1 & pci_init_complete_out ;   // to PCI clock
  1935. assign io_space_enable = sync_command_bit0 & pci_init_complete_out     ;   // to PCI clock
  1936. // if bridge is HOST then write clock is equal to WB clock, and synchronization of outputs has to be done
  1937. // We don't support cache line sizes smaller that 4 and it must have last two bits zero!!!
  1938. wire cache_lsize_not_zero = ((cache_line_size_reg[7] || cache_line_size_reg[6] || cache_line_size_reg[5] ||
  1939.  cache_line_size_reg[4] || cache_line_size_reg[3] || cache_line_size_reg[2]) &&
  1940. (!cache_line_size_reg[1] && !cache_line_size_reg[0]) );
  1941. `ifdef HOST
  1942.   wire [7:2] cache_lsize_to_pci_bits = { cache_line_size_reg[7:2] } ;
  1943.   wire [7:2] meta_cache_lsize_to_pci_bits ;
  1944.   reg  [7:2] sync_cache_lsize_to_pci_bits ;
  1945.   pci_synchronizer_flop   #(6, 0)  cache_lsize_to_pci_bits_sync
  1946.   (
  1947.       .data_in        (cache_lsize_to_pci_bits),
  1948.       .clk_out        (pci_clk),
  1949.       .sync_data_out  (meta_cache_lsize_to_pci_bits),
  1950.       .async_reset    (reset)
  1951.   ) ;
  1952.   always@(posedge pci_clk or posedge reset)
  1953.   begin
  1954.       if (reset)
  1955.           sync_cache_lsize_to_pci_bits <= 6'b0 ;
  1956.       else
  1957.           sync_cache_lsize_to_pci_bits <= meta_cache_lsize_to_pci_bits ;
  1958.   end
  1959.   wire [7:2] sync_cache_line_size_to_pci_reg = sync_cache_lsize_to_pci_bits[7:2] ;
  1960.   wire [7:2] sync_cache_line_size_to_wb_reg = cache_line_size_reg[7:2] ;
  1961.   wire  sync_cache_lsize_not_zero_to_wb = cache_lsize_not_zero ;
  1962. // Latency timer is sinchronized only to PCI clock when bridge implementation is HOST
  1963.   wire [7:0] latency_timer_bits = latency_timer ;
  1964.   wire [7:0] meta_latency_timer_bits ;
  1965.   reg  [7:0] sync_latency_timer_bits ;
  1966.   pci_synchronizer_flop   #(8, 0)  latency_timer_bits_sync
  1967.   (
  1968.       .data_in        (latency_timer_bits),
  1969.       .clk_out        (pci_clk),
  1970.       .sync_data_out  (meta_latency_timer_bits),
  1971.       .async_reset    (reset)
  1972.   ) ;
  1973.   always@(posedge pci_clk or posedge reset)
  1974.   begin
  1975.       if (reset)
  1976.           sync_latency_timer_bits <= 8'b0 ;
  1977.       else
  1978.           sync_latency_timer_bits <= meta_latency_timer_bits ;
  1979.   end
  1980.   wire [7:0] sync_latency_timer = sync_latency_timer_bits ;
  1981. `else // GUEST
  1982.   wire [8:2] cache_lsize_to_wb_bits = { cache_lsize_not_zero, cache_line_size_reg[7:2] } ;
  1983.   wire [8:2] meta_cache_lsize_to_wb_bits ;
  1984.   reg  [8:2] sync_cache_lsize_to_wb_bits ;
  1985.   pci_synchronizer_flop   #(7, 0)  cache_lsize_to_wb_bits_sync
  1986.   (
  1987.       .data_in        (cache_lsize_to_wb_bits),
  1988.       .clk_out        (wb_clk),
  1989.       .sync_data_out  (meta_cache_lsize_to_wb_bits),
  1990.       .async_reset    (reset)
  1991.   ) ;
  1992.   always@(posedge wb_clk or posedge reset)
  1993.   begin
  1994.       if (reset)
  1995.           sync_cache_lsize_to_wb_bits <= 7'b0 ;
  1996.       else
  1997.           sync_cache_lsize_to_wb_bits <= meta_cache_lsize_to_wb_bits ;
  1998.   end
  1999.   wire [7:2] sync_cache_line_size_to_pci_reg = cache_line_size_reg[7:2] ;
  2000.   wire [7:2] sync_cache_line_size_to_wb_reg = sync_cache_lsize_to_wb_bits[7:2] ;
  2001.   wire  sync_cache_lsize_not_zero_to_wb = sync_cache_lsize_to_wb_bits[8] ;
  2002. // Latency timer
  2003.   wire [7:0] sync_latency_timer = latency_timer ;
  2004. `endif
  2005. // PCI header output from cache_line_size, latency timer and interrupt pin
  2006. assign cache_line_size_to_pci = {sync_cache_line_size_to_pci_reg, 2'h0} ;  // [7 : 0] to PCI clock
  2007. assign cache_line_size_to_wb = {sync_cache_line_size_to_wb_reg, 2'h0} ;   // [7 : 0] to WB clock
  2008. assign cache_lsize_not_zero_to_wb = sync_cache_lsize_not_zero_to_wb ;
  2009. assign latency_tim[7 : 0]     = sync_latency_timer ;         // to PCI clock
  2010. //assign int_pin[2 : 0]         = r_interrupt_pin ;
  2011. assign int_out    = interrupt_out ;
  2012. // PCI output from image registers
  2013. //   base address, address mask, translation address and control registers are sinchronized in PCI_DECODER.V module
  2014. `ifdef HOST
  2015.     `ifdef NO_CNF_IMAGE
  2016.         assign pci_base_addr0 = pci_ba0_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2017.     `else
  2018.         assign      pci_base_addr0 = pci_ba0_bit31_8[31:12] ;
  2019.     `endif
  2020. `endif
  2021. `ifdef GUEST
  2022.     assign  pci_base_addr0 = pci_ba0_bit31_8[31:12] ;
  2023. `endif
  2024. assign pci_base_addr1 = pci_ba1_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2025. assign pci_base_addr2 = pci_ba2_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2026. assign pci_base_addr3 = pci_ba3_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2027. assign pci_base_addr4 = pci_ba4_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2028. assign pci_base_addr5 = pci_ba5_bit31_8[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2029. assign pci_memory_io0 = pci_ba0_bit0 ;
  2030. assign pci_memory_io1 = pci_ba1_bit0 ;
  2031. assign pci_memory_io2 = pci_ba2_bit0 ;
  2032. assign pci_memory_io3 = pci_ba3_bit0 ;
  2033. assign pci_memory_io4 = pci_ba4_bit0 ;
  2034. assign pci_memory_io5 = pci_ba5_bit0 ;
  2035. assign pci_addr_mask0 = pci_am0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2036. assign pci_addr_mask1 = pci_am1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2037. assign pci_addr_mask2 = pci_am2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2038. assign pci_addr_mask3 = pci_am3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2039. assign pci_addr_mask4 = pci_am4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2040. assign pci_addr_mask5 = pci_am5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2041. assign pci_tran_addr0 = pci_ta0[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2042. assign pci_tran_addr1 = pci_ta1[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2043. assign pci_tran_addr2 = pci_ta2[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2044. assign pci_tran_addr3 = pci_ta3[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2045. assign pci_tran_addr4 = pci_ta4[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2046. assign pci_tran_addr5 = pci_ta5[31:(32-`PCI_NUM_OF_DEC_ADDR_LINES)] ;
  2047. assign pci_img_ctrl0[2 : 1] = pci_img_ctrl0_bit2_1 ;
  2048. assign pci_img_ctrl1[2 : 1] = pci_img_ctrl1_bit2_1 ;
  2049. assign pci_img_ctrl2[2 : 1] = pci_img_ctrl2_bit2_1 ;
  2050. assign pci_img_ctrl3[2 : 1] = pci_img_ctrl3_bit2_1 ;
  2051. assign pci_img_ctrl4[2 : 1] = pci_img_ctrl4_bit2_1 ;
  2052. assign pci_img_ctrl5[2 : 1] = pci_img_ctrl5_bit2_1 ;
  2053. // WISHBONE output from image registers
  2054. //   base address, address mask, translation address and control registers are sinchronized in DECODER.V module
  2055. assign wb_base_addr0 = wb_ba0_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2056. assign wb_base_addr1 = wb_ba1_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2057. assign wb_base_addr2 = wb_ba2_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2058. assign wb_base_addr3 = wb_ba3_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2059. assign wb_base_addr4 = wb_ba4_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2060. assign wb_base_addr5 = wb_ba5_bit31_12[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2061. assign wb_memory_io0 = wb_ba0_bit0 ;
  2062. assign wb_memory_io1 = wb_ba1_bit0 ;
  2063. assign wb_memory_io2 = wb_ba2_bit0 ;
  2064. assign wb_memory_io3 = wb_ba3_bit0 ;
  2065. assign wb_memory_io4 = wb_ba4_bit0 ;
  2066. assign wb_memory_io5 = wb_ba5_bit0 ;
  2067. assign wb_addr_mask0 = wb_am0[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2068. assign wb_addr_mask1 = wb_am1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2069. assign wb_addr_mask2 = wb_am2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2070. assign wb_addr_mask3 = wb_am3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2071. assign wb_addr_mask4 = wb_am4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2072. assign wb_addr_mask5 = wb_am5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2073. assign wb_tran_addr0 = wb_ta0[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2074. assign wb_tran_addr1 = wb_ta1[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2075. assign wb_tran_addr2 = wb_ta2[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2076. assign wb_tran_addr3 = wb_ta3[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2077. assign wb_tran_addr4 = wb_ta4[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2078. assign wb_tran_addr5 = wb_ta5[31:(32-`WB_NUM_OF_DEC_ADDR_LINES)] ;
  2079. assign wb_img_ctrl0[2 : 0] = wb_img_ctrl0_bit2_0 ;
  2080. assign wb_img_ctrl1[2 : 0] = wb_img_ctrl1_bit2_0 ;
  2081. assign wb_img_ctrl2[2 : 0] = wb_img_ctrl2_bit2_0 ;
  2082. assign wb_img_ctrl3[2 : 0] = wb_img_ctrl3_bit2_0 ;
  2083. assign wb_img_ctrl4[2 : 0] = wb_img_ctrl4_bit2_0 ;
  2084. assign wb_img_ctrl5[2 : 0] = wb_img_ctrl5_bit2_0 ;
  2085. // GENERAL output from conf. cycle generation register & int. control register
  2086. assign config_addr[23 : 0] = { cnf_addr_bit23_2, 1'b0, cnf_addr_bit0 } ;
  2087. assign icr_soft_res = icr_bit31 ;
  2088. endmodule
  2089.                     
  2090. </pre>
  2091. <hr />
  2092. <address><span style="font-size: smaller">FreeBSD-CVSweb &lt;<a href="mailto:freebsd-cvsweb@FreeBSD.org">freebsd-cvsweb@FreeBSD.org</a>&gt;</span></address>
  2093. </body>
  2094. </html>
  2095. <!-- pf_body_end -->
  2096. </td>
  2097. <td><img width=15 src="/images/dotty.gif"></td>
  2098. </tr></table>
  2099. <xcenter>
  2100. <p>
  2101. <table width=100% cellpadding=0 cellspacing=0 border=0>
  2102.       <tr><td align=right valign=bottom><a title='Top' href='#top'><img border=0 alt='Top' src='/images/hr_up.gif'></a></td></tr>
  2103.       <tr><td background='/images/hpd.gif'><img height=1 border=0 src='/images/dotty.gif'></td></tr><tr><td height=4><img height=4 src='/images/dotty.gif'></td></tr></table>
  2104. &nbsp;
  2105. <br>
  2106. <!--
  2107. <table border=0 cellpadding=0 cellspacing=1 bgcolor=#ffffff><tr><td>
  2108. <table cellpadding=0 cellspacing=0 border=0 bgcolor=#ffffff><tr><td>
  2109. //-->
  2110. <script type="text/javascript"><!--
  2111. google_ad_client = "pub-9285819221080148";
  2112. google_alternate_color = "FFFFFF";
  2113. google_ad_width = 728;
  2114. google_ad_height = 90;
  2115. google_ad_format = "728x90_as";
  2116. google_ad_type = "text_image";
  2117. google_ad_channel ="3034172958";
  2118. google_color_border = "ffffff";
  2119. google_color_bg = "ffffff";
  2120. google_color_link = "444488";
  2121. google_color_url = "b00000";
  2122. google_color_text = "666666";
  2123. //--></script>
  2124. <script type="text/javascript"
  2125.   src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
  2126. </script>
  2127. <!--
  2128. </td></tr></table>
  2129. </td></tr></table>
  2130. //-->
  2131. </center>
  2132. <img border=0 src="/images/dotty.gif" height=1 width=400>
  2133. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2134. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2135. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2136. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2137. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2138. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2139. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2140. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2141. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2142. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2143. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2144. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2145. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2146. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2147. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2148. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2149. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2150. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2151. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2152. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2153. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2154. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2155. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2156. <img border=0 src="/images/dotty.gif" height=1 width=30>
  2157. </td></tr>
  2158. </table>
  2159. &nbsp;
  2160. </td></tr>
  2161. <tr bgcolor=#000000><td><img height=1 src="/images/dotty.gif"></td></tr>
  2162. </table>
  2163. <table background="/images/topbg.gif" width=100% cellpadding=0 cellspacing=0 border=0 bgcolor=#aaddff>
  2164. <tr><td align=right>
  2165. Copyright (c) 1999-2007 OPENCORES.ORG. All rights reserved. &nbsp;
  2166. </td></tr>
  2167. <tr><td>
  2168. &nbsp;
  2169. </td></tr>
  2170. </table>
  2171. </td>
  2172. <td width=1 bgcolor=#000000><img width=1 src="/images/dotty.gif"></td>
  2173. <td width=1 bgcolor=#f0f0c8><img width=1 src="/images/dotty.gif"></td>
  2174. </tr></table>
  2175. </center>
  2176. <!-- pf_footer_start -->
  2177.   </body>
  2178. </html>
  2179. <!-- pf_footer_end -->