Advertisement
Guest User

cuberoot.v

a guest
Jun 9th, 2016
81
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. `timescale 1ns / 1ps
  2. //////////////////////////////////////////////////////////////////////////////////
  3. // Company:
  4. // Engineer:
  5. //
  6. // Create Date: 14:26:53 10/26/2013
  7. // Design Name:
  8. // Module Name: CubeRoot
  9. // Project Name:
  10. // Target Devices:
  11. // Tool versions:
  12. // Description:
  13. //
  14. // Dependencies:
  15. //
  16. // Revision:
  17. // Revision 0.01 - File Created
  18. // Additional Comments:
  19. //
  20. //////////////////////////////////////////////////////////////////////////////////
  21. module CubeRoot(Number, clk, Answer, Remainder, NumberLevel1, NumberLevel2, NumberLevel3, NumberLevel4, NumberLevel5, NumberLevel6, NumberLevel7, NumberLevel8, NumberLevel9, NumberLevel10);
  22.  
  23. input [63:0] Number;
  24. input clk;
  25. output [21:0] Answer;
  26. output [63:0] Remainder;
  27. output NumberLevel1, NumberLevel2, NumberLevel3, NumberLevel4, NumberLevel5, NumberLevel6, NumberLevel7, NumberLevel8, NumberLevel9, NumberLevel10;
  28.  
  29. // First Level //////////////////////////////////////////////////////////////////////////////////////////////////////////
  30.  
  31. reg [3:0] Add1Level1;
  32. wire [3:0] Add1Level1Wire = Add1Level1;
  33.  
  34. always @* begin
  35. Add1Level1 = {2'b0, Number[63]} - 3'd1;
  36. end
  37.  
  38. reg [63:0] NumberLevel1;
  39. reg AnswerLevel1;
  40.  
  41. always @(posedge clk) begin
  42. if(!Add1Level1Wire[3]) begin
  43. NumberLevel1 <= {Add1Level1Wire[0], Number[62:0]};
  44. end
  45. else begin
  46. NumberLevel1 <= Number;
  47. end
  48. AnswerLevel1 <= !Add1Level1Wire[3];
  49. end
  50.  
  51. reg [4:0] Add2Level1;
  52. wire [4:0] Add2Level1Wire = Add2Level1;
  53.  
  54. always @* begin
  55. Add2Level1 = {!Add1Level1Wire[3], 4'b0} + {!Add1Level1Wire, 1'b0};
  56. end
  57.  
  58. reg [2:0] Add3Level1;
  59. wire [2:0] Add3Level1Wire = Add3Level1;
  60.  
  61. always @* begin
  62. Add3Level1 = {!Add1Level1Wire[3], 2'b0} + {!Add1Level1Wire, 1'b0};
  63. end
  64.  
  65. reg [4:0] Add4Level1;
  66. wire [4:0] Add4Level1Wire = Add4Level1;
  67.  
  68. always @* begin
  69. if(!Add1Level1Wire[3]) begin
  70. Add4Level1 = 1 + Add2Level1Wire;
  71. end
  72. else begin
  73. Add4Level1 = 1 - Add3Level1Wire;
  74. end
  75. end
  76.  
  77. reg [4:0] PLevel1;
  78.  
  79. always @(posedge clk) begin
  80. PLevel1 <= Add4Level1Wire;
  81. end
  82.  
  83. // Second Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  84.  
  85. reg [6:0] Add1Level2;
  86. wire [6:0] Add1Level2Wire = Add1Level2;
  87.  
  88. always @* begin
  89. Add1Level2 = {2'b0, NumberLevel1[63:60]} - PLevel1;
  90. end
  91.  
  92. reg [63:0] NumberLevel2;
  93. reg [1:0] AnswerLevel2;
  94.  
  95. always @(posedge clk) begin
  96. if(!Add1Level2Wire[6]) begin
  97. NumberLevel2 <= {Add1Level2Wire[5:0], NumberLevel1[59:0]};
  98. end
  99. else begin
  100. NumberLevel2 <= NumberLevel1;
  101. end
  102. AnswerLevel2 <= {AnswerLevel1, !Add1Level2Wire[6]};
  103. end
  104.  
  105. reg [5:0] Add2Level2;
  106. wire [5:0] Add2Level2Wire = Add2Level2;
  107.  
  108. always @* begin
  109. Add2Level2 = {AnswerLevel1, !Add1Level2Wire[6], 4'b0} + {AnswerLevel1, !Add1Level2Wire[6], 1'b0};
  110. end
  111.  
  112. reg [6:0] Add3Level2;
  113. wire [6:0] Add3Level2Wire = Add3Level2;
  114.  
  115. always @* begin
  116. Add3Level2 = {AnswerLevel1, !Add1Level2Wire[6], 2'b0} + {AnswerLevel1, !Add1Level2Wire[6], 1'b0};
  117. end
  118.  
  119. reg [4:0] Add4Level2;
  120. wire [4:0] Add4Level2Wire = Add4Level2;
  121.  
  122. always @* begin
  123. Add4Level2 = {PLevel1, 2'b0} - 3;
  124. end
  125.  
  126. reg [6:0] Add5Level2;
  127. wire [6:0] Add5Level2Wire = Add5Level2;
  128.  
  129. always @* begin
  130. if(!Add1Level2Wire[6]) begin
  131. Add5Level2 = Add4Level2Wire + Add2Level2Wire;
  132. end
  133. else begin
  134. Add5Level2 = Add4Level2Wire - Add3Level2Wire;
  135. end
  136. end
  137.  
  138. reg [6:0] PLevel2;
  139.  
  140. always @(posedge clk) begin
  141. PLevel2 <= Add5Level2Wire;
  142. end
  143.  
  144. // Third Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  145.  
  146. reg [9:0] Add1Level3;
  147. wire [9:0] Add1Level3Wire = Add1Level3;
  148.  
  149. always @* begin
  150. Add1Level3 = {2'b0, NumberLevel2[63:57]} - PLevel2;
  151. end
  152.  
  153. reg [63:0] NumberLevel3;
  154. reg [2:0] AnswerLevel3;
  155.  
  156. always @(posedge clk) begin
  157. if(!Add1Level3Wire[9]) begin
  158. NumberLevel3 <= {Add1Level3Wire[8:0], NumberLevel2[56:0]};
  159. end
  160. else begin
  161. NumberLevel3 <= NumberLevel2;
  162. end
  163. AnswerLevel3 <= {AnswerLevel2, !Add1Level3Wire[9]};
  164. end
  165.  
  166. reg [6:0] Add2Level3;
  167. wire [6:0] Add2Level3Wire = Add2Level3;
  168.  
  169. always @* begin
  170. Add2Level3 = {AnswerLevel2, !Add1Level3Wire[9], 4'b0} + {AnswerLevel2, !Add1Level3Wire[9], 1'b0};
  171. end
  172.  
  173. reg [5:0] Add3Level3;
  174. wire [5:0] Add3Level3Wire = Add3Level3;
  175.  
  176. always @* begin
  177. Add3Level3 = {AnswerLevel2, !Add1Level3Wire[9], 2'b0} + {AnswerLevel2, !Add1Level3Wire[9], 1'b0};
  178. end
  179.  
  180. reg [8:0] Add4Level3;
  181. wire [8:0] Add4Level3Wire = Add4Level3;
  182.  
  183. always @* begin
  184. Add4Level3 = {PLevel2, 2'b0} - 3;
  185. end
  186.  
  187. reg [9:0] Add5Level3;
  188. wire [9:0] Add5Level3Wire = Add5Level3;
  189.  
  190. always @* begin
  191. if(!Add1Level3Wire[9]) begin
  192. Add5Level3 = Add4Level3Wire + Add2Level3Wire;
  193. end
  194. else begin
  195. Add5Level3 = Add4Level3Wire - Add3Level3Wire;
  196. end
  197. end
  198.  
  199. reg [9:0] PLevel3;
  200.  
  201. always @(posedge clk) begin
  202. PLevel3 <= Add5Level3Wire;
  203. end
  204.  
  205. // Fourth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  206.  
  207. reg [12:0] Add1Level4;
  208. wire [12:0] Add1Level4Wire = Add1Level4;
  209.  
  210. always @* begin
  211. Add1Level4 = {2'b0, NumberLevel3[63:54]} - PLevel3;
  212. end
  213.  
  214. reg [63:0] NumberLevel4;
  215. reg [3:0] AnswerLevel4;
  216.  
  217. always @(posedge clk) begin
  218. if(!Add1Level4Wire[12]) begin
  219. NumberLevel4 <= {Add1Level4Wire[11:0], NumberLevel3[53:0]};
  220. end
  221. else begin
  222. NumberLevel4 <= NumberLevel3;
  223. end
  224. AnswerLevel4 <= {AnswerLevel3, !Add1Level4Wire[12]};
  225. end
  226.  
  227. reg [8:0] Add2Level4;
  228. wire [8:0] Add2Level4Wire = Add2Level4;
  229.  
  230. always @* begin
  231. Add2Level4 = {AnswerLevel3, !Add1Level4Wire[12], 4'b0} + {AnswerLevel3, !Add1Level4Wire[12], 1'b0};
  232. end
  233.  
  234. reg [6:0] Add3Level4;
  235. wire [6:0] Add3Level4Wire = Add3Level4;
  236.  
  237. always @* begin
  238. Add3Level4 = {AnswerLevel3, !Add1Level4Wire[12], 2'b0} + {AnswerLevel3, !Add1Level4Wire[12], 1'b0};
  239. end
  240.  
  241. reg [11:0] Add4Level4;
  242. wire [11:0] Add4Level4Wire = Add4Level4;
  243.  
  244. always @* begin
  245. Add4Level4 = {PLevel3, 2'b0} - 3;
  246. end
  247.  
  248. reg [11:0] Add5Level4;
  249. wire [11:0] Add5Level4Wire = Add5Level4;
  250.  
  251. always @* begin
  252. if(!Add1Level4Wire[12]) begin
  253. Add5Level4 = Add4Level4Wire + Add2Level4Wire;
  254. end
  255. else begin
  256. Add5Level4 = Add4Level4Wire - Add3Level4Wire;
  257. end
  258. end
  259.  
  260. reg [11:0] PLevel4;
  261.  
  262. always @(posedge clk) begin
  263. PLevel4 <= Add5Level4Wire;
  264. end
  265.  
  266. // Fifth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  267.  
  268. reg [15:0] Add1Level5;
  269. wire [15:0] Add1Level5Wire = Add1Level5;
  270.  
  271. always @* begin
  272. Add1Level5 = {2'b0, NumberLevel4[63:51]} - PLevel4;
  273. end
  274.  
  275. reg [63:0] NumberLevel5;
  276. reg [4:0] AnswerLevel5;
  277.  
  278. always @(posedge clk) begin
  279. if(!Add1Level5Wire[15]) begin
  280. NumberLevel5 <= {Add1Level5Wire[14:0], NumberLevel4[50:0]};
  281. end
  282. else begin
  283. NumberLevel5 <= NumberLevel4;
  284. end
  285. AnswerLevel5 <= {AnswerLevel4, !Add1Level5Wire[15]};
  286. end
  287.  
  288. reg [9:0] Add2Level5;
  289. wire [9:0] Add2Level5Wire = Add2Level5;
  290.  
  291. always @* begin
  292. Add2Level5 = {AnswerLevel4, !Add1Level5Wire[15], 4'b0} + {AnswerLevel4, !Add1Level5Wire[15], 1'b0};
  293. end
  294.  
  295. reg [7:0] Add3Level5;
  296. wire [7:0] Add3Level5Wire = Add3Level5;
  297.  
  298. always @* begin
  299. Add3Level5 = {AnswerLevel4, !Add1Level5Wire[15], 2'b0} + {AnswerLevel4, !Add1Level5Wire[15], 1'b0};
  300. end
  301.  
  302. reg [13:0] Add4Level5;
  303. wire [13:0] Add4Level5Wire = Add4Level5;
  304.  
  305. always @* begin
  306. Add4Level5 = {PLevel4, 2'b0} - 3;
  307. end
  308.  
  309. reg [13:0] Add5Level5;
  310. wire [13:0] Add5Level5Wire = Add5Level5;
  311.  
  312. always @* begin
  313. if(!Add1Level5Wire[12]) begin
  314. Add5Level5 = Add4Level5Wire + Add2Level5Wire;
  315. end
  316. else begin
  317. Add5Level5 = Add4Level5Wire - Add3Level5Wire;
  318. end
  319. end
  320.  
  321. reg [13:0] PLevel5;
  322.  
  323. always @(posedge clk) begin
  324. PLevel5 <= Add5Level5Wire;
  325. end
  326.  
  327. // Sixth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  328.  
  329. reg [18:0] Add1Level6;
  330. wire [18:0] Add1Level6Wire = Add1Level6;
  331.  
  332. always @* begin
  333. Add1Level6 = {2'b0, NumberLevel5[63:48]} - PLevel5;
  334. end
  335.  
  336. reg [63:0] NumberLevel6;
  337. reg [5:0] AnswerLevel6;
  338.  
  339. always @(posedge clk) begin
  340. if(!Add1Level6Wire[18]) begin
  341. NumberLevel6 <= {Add1Level6Wire[17:0], NumberLevel5[47:0]};
  342. end
  343. else begin
  344. NumberLevel6 <= NumberLevel5;
  345. end
  346. AnswerLevel6 <= {AnswerLevel5, !Add1Level6Wire[18]};
  347. end
  348.  
  349. reg [10:0] Add2Level6;
  350. wire [10:0] Add2Level6Wire = Add2Level6;
  351.  
  352. always @* begin
  353. Add2Level6 = {AnswerLevel5, !Add1Level6Wire[18], 4'b0} + {AnswerLevel5, !Add1Level6Wire[18], 1'b0};
  354. end
  355.  
  356. reg [8:0] Add3Level6;
  357. wire [8:0] Add3Level6Wire = Add3Level6;
  358.  
  359. always @* begin
  360. Add3Level6 = {AnswerLevel5, !Add1Level6Wire[18], 2'b0} + {AnswerLevel5, !Add1Level6Wire[18], 1'b0};
  361. end
  362.  
  363. reg [15:0] Add4Level6;
  364. wire [15:0] Add4Level6Wire = Add4Level6;
  365.  
  366. always @* begin
  367. Add4Level6 = {PLevel5, 2'b0} - 3;
  368. end
  369.  
  370. reg [15:0] Add5Level6;
  371. wire [15:0] Add5Level6Wire = Add5Level6;
  372.  
  373. always @* begin
  374. if(!Add1Level6Wire[18]) begin
  375. Add5Level6 = Add4Level6Wire + Add2Level6Wire;
  376. end
  377. else begin
  378. Add5Level6 = Add4Level6Wire - Add3Level6Wire;
  379. end
  380. end
  381.  
  382. reg [15:0] PLevel6;
  383.  
  384. always @(posedge clk) begin
  385. PLevel6 <= Add5Level6Wire;
  386. end
  387.  
  388. // Seventh Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  389.  
  390. reg [21:0] Add1Level7;
  391. wire [21:0] Add1Level7Wire = Add1Level7;
  392.  
  393. always @* begin
  394. Add1Level7 = {2'b0, NumberLevel6[63:45]} - PLevel6;
  395. end
  396.  
  397. reg [63:0] NumberLevel7;
  398. reg [6:0] AnswerLevel7;
  399.  
  400. always @(posedge clk) begin
  401. if(!Add1Level7Wire[21]) begin
  402. NumberLevel7 <= {Add1Level7Wire[20:0], NumberLevel6[44:0]};
  403. end
  404. else begin
  405. NumberLevel7 <= NumberLevel6;
  406. end
  407. AnswerLevel7 <= {AnswerLevel6, !Add1Level7Wire[21]};
  408. end
  409.  
  410. reg [11:0] Add2Level7;
  411. wire [11:0] Add2Level7Wire = Add2Level7;
  412.  
  413. always @* begin
  414. Add2Level7 = {AnswerLevel6, !Add1Level7Wire[21], 4'b0} + {AnswerLevel6, !Add1Level7Wire[21], 1'b0};
  415. end
  416.  
  417. reg [9:0] Add3Level7;
  418. wire [9:0] Add3Level7Wire = Add3Level7;
  419.  
  420. always @* begin
  421. Add3Level7 = {AnswerLevel6, !Add1Level7Wire[21], 2'b0} + {AnswerLevel6, !Add1Level7Wire[21], 1'b0};
  422. end
  423.  
  424. reg [17:0] Add4Level7;
  425. wire [17:0] Add4Level7Wire = Add4Level7;
  426.  
  427. always @* begin
  428. Add4Level7 = {PLevel6, 2'b0} - 3;
  429. end
  430.  
  431. reg [17:0] Add5Level7;
  432. wire [17:0] Add5Level7Wire = Add5Level7;
  433.  
  434. always @* begin
  435. if(!Add1Level7Wire[21]) begin
  436. Add5Level7 = Add4Level7Wire + Add2Level7Wire;
  437. end
  438. else begin
  439. Add5Level7 = Add4Level7Wire - Add3Level7Wire;
  440. end
  441. end
  442.  
  443. reg [17:0] PLevel7;
  444.  
  445. always @(posedge clk) begin
  446. PLevel7 <= Add5Level7Wire;
  447. end
  448.  
  449. // Eighth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  450.  
  451. reg [24:0] Add1Level8;
  452. wire [24:0] Add1Level8Wire = Add1Level8;
  453.  
  454. always @* begin
  455. Add1Level8 = {2'b0, NumberLevel7[63:42]} - PLevel7;
  456. end
  457.  
  458. reg [63:0] NumberLevel8;
  459. reg [7:0] AnswerLevel8;
  460.  
  461. always @(posedge clk) begin
  462. if(!Add1Level8Wire[24]) begin
  463. NumberLevel8 <= {Add1Level8Wire[23:0], NumberLevel7[41:0]};
  464. end
  465. else begin
  466. NumberLevel8 <= NumberLevel7;
  467. end
  468. AnswerLevel8 <= {AnswerLevel7, !Add1Level8Wire[24]};
  469. end
  470.  
  471. reg [12:0] Add2Level8;
  472. wire [12:0] Add2Level8Wire = Add2Level8;
  473.  
  474. always @* begin
  475. Add2Level8 = {AnswerLevel7, !Add1Level8Wire[24], 4'b0} + {AnswerLevel7, !Add1Level8Wire[24], 1'b0};
  476. end
  477.  
  478. reg [10:0] Add3Level8;
  479. wire [10:0] Add3Level8Wire = Add3Level8;
  480.  
  481. always @* begin
  482. Add3Level8 = {AnswerLevel7, !Add1Level8Wire[24], 2'b0} + {AnswerLevel7, !Add1Level8Wire[24], 1'b0};
  483. end
  484.  
  485. reg [19:0] Add4Level8;
  486. wire [19:0] Add4Level8Wire = Add4Level8;
  487.  
  488. always @* begin
  489. Add4Level8 = {PLevel7, 2'b0} - 3;
  490. end
  491.  
  492. reg [19:0] Add5Level8;
  493. wire [19:0] Add5Level8Wire = Add5Level8;
  494.  
  495. always @* begin
  496. if(!Add1Level8Wire[24]) begin
  497. Add5Level8 = Add4Level8Wire + Add2Level8Wire;
  498. end
  499. else begin
  500. Add5Level8 = Add4Level8Wire - Add3Level8Wire;
  501. end
  502. end
  503.  
  504. reg [19:0] PLevel8;
  505.  
  506. always @(posedge clk) begin
  507. PLevel8 <= Add5Level8Wire;
  508. end
  509.  
  510. // Ninth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  511.  
  512. reg [27:0] Add1Level9;
  513. wire [27:0] Add1Level9Wire = Add1Level9;
  514.  
  515. always @* begin
  516. Add1Level9 = {2'b0, NumberLevel8[63:39]} - PLevel8;
  517. end
  518.  
  519. reg [63:0] NumberLevel9;
  520. reg [8:0] AnswerLevel9;
  521.  
  522. always @(posedge clk) begin
  523. if(!Add1Level9Wire[27]) begin
  524. NumberLevel9 <= {Add1Level9Wire[26:0], NumberLevel8[38:0]};
  525. end
  526. else begin
  527. NumberLevel9 <= NumberLevel8;
  528. end
  529. AnswerLevel9 <= {AnswerLevel8, !Add1Level9Wire[27]};
  530. end
  531.  
  532. reg [13:0] Add2Level9;
  533. wire [13:0] Add2Level9Wire = Add2Level9;
  534.  
  535. always @* begin
  536. Add2Level9 = {AnswerLevel8, !Add1Level9Wire[27], 4'b0} + {AnswerLevel8, !Add1Level9Wire[27], 1'b0};
  537. end
  538.  
  539. reg [11:0] Add3Level9;
  540. wire [11:0] Add3Level9Wire = Add3Level9;
  541.  
  542. always @* begin
  543. Add3Level9 = {AnswerLevel8, !Add1Level9Wire[27], 2'b0} + {AnswerLevel8, !Add1Level9Wire[27], 1'b0};
  544. end
  545.  
  546. reg [21:0] Add4Level9;
  547. wire [21:0] Add4Level9Wire = Add4Level9;
  548.  
  549. always @* begin
  550. Add4Level9 = {PLevel8, 2'b0} - 3;
  551. end
  552.  
  553. reg [21:0] Add5Level9;
  554. wire [21:0] Add5Level9Wire = Add5Level9;
  555.  
  556. always @* begin
  557. if(!Add1Level9Wire[27]) begin
  558. Add5Level9 = Add4Level9Wire + Add2Level9Wire;
  559. end
  560. else begin
  561. Add5Level9 = Add4Level9Wire - Add3Level9Wire;
  562. end
  563. end
  564.  
  565. reg [21:0] PLevel9;
  566.  
  567. always @(posedge clk) begin
  568. PLevel9 <= Add5Level9Wire;
  569. end
  570.  
  571. // Tenth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  572.  
  573. reg [30:0] Add1Level10;
  574. wire [30:0] Add1Level10Wire = Add1Level10;
  575.  
  576. always @* begin
  577. Add1Level10 = {2'b0, NumberLevel9[63:36]} - PLevel9;
  578. end
  579.  
  580. reg [63:0] NumberLevel10;
  581. reg [9:0] AnswerLevel10;
  582.  
  583. always @(posedge clk) begin
  584. if(!Add1Level10Wire[30]) begin
  585. NumberLevel10 <= {Add1Level10Wire[29:0], NumberLevel9[35:0]};
  586. end
  587. else begin
  588. NumberLevel10 <= NumberLevel9;
  589. end
  590. AnswerLevel10 <= {AnswerLevel9, !Add1Level10Wire[30]};
  591. end
  592.  
  593. reg [14:0] Add2Level10;
  594. wire [14:0] Add2Level10Wire = Add2Level10;
  595.  
  596. always @* begin
  597. Add2Level10 = {AnswerLevel9, !Add1Level10Wire[30], 4'b0} + {AnswerLevel9, !Add1Level10Wire[30], 1'b0};
  598. end
  599.  
  600. reg [12:0] Add3Level10;
  601. wire [12:0] Add3Level10Wire = Add3Level10;
  602.  
  603. always @* begin
  604. Add3Level10 = {AnswerLevel9, !Add1Level10Wire[30], 2'b0} + {AnswerLevel9, !Add1Level10Wire[30], 1'b0};
  605. end
  606.  
  607. reg [23:0] Add4Level10;
  608. wire [23:0] Add4Level10Wire = Add4Level10;
  609.  
  610. always @* begin
  611. Add4Level10 = {PLevel9, 2'b0} - 3;
  612. end
  613.  
  614. reg [23:0] Add5Level10;
  615. wire [23:0] Add5Level10Wire = Add5Level10;
  616.  
  617. always @* begin
  618. if(!Add1Level10Wire[30]) begin
  619. Add5Level10 = Add4Level10Wire + Add2Level10Wire;
  620. end
  621. else begin
  622. Add5Level10 = Add4Level10Wire - Add3Level10Wire;
  623. end
  624. end
  625.  
  626. reg [23:0] PLevel10;
  627.  
  628. always @(posedge clk) begin
  629. PLevel10 <= Add5Level10Wire;
  630. end
  631.  
  632. // Eleventh Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  633.  
  634. reg [33:0] Add1Level11;
  635. wire [33:0] Add1Level11Wire = Add1Level11;
  636.  
  637. always @* begin
  638. Add1Level11 = {2'b0, NumberLevel10[63:33]} - PLevel10;
  639. end
  640.  
  641. reg [63:0] NumberLevel11;
  642. reg [10:0] AnswerLevel11;
  643.  
  644. always @(posedge clk) begin
  645. if(!Add1Level11Wire[33]) begin
  646. NumberLevel11 <= {Add1Level11Wire[32:0], NumberLevel10[32:0]};
  647. end
  648. else begin
  649. NumberLevel11 <= NumberLevel10;
  650. end
  651. AnswerLevel11 <= {AnswerLevel10, !Add1Level11Wire[33]};
  652. end
  653.  
  654. reg [15:0] Add2Level11;
  655. wire [15:0] Add2Level11Wire = Add2Level11;
  656.  
  657. always @* begin
  658. Add2Level11 = {AnswerLevel10, !Add1Level11Wire[33], 4'b0} + {AnswerLevel10, !Add1Level11Wire[33], 1'b0};
  659. end
  660.  
  661. reg [13:0] Add3Level11;
  662. wire [13:0] Add3Level11Wire = Add3Level11;
  663.  
  664. always @* begin
  665. Add3Level11 = {AnswerLevel10, !Add1Level11Wire[33], 2'b0} + {AnswerLevel10, !Add1Level11Wire[33], 1'b0};
  666. end
  667.  
  668. reg [25:0] Add4Level11;
  669. wire [25:0] Add4Level11Wire = Add4Level11;
  670.  
  671. always @* begin
  672. Add4Level11 = {PLevel10, 2'b0} - 3;
  673. end
  674.  
  675. reg [25:0] Add5Level11;
  676. wire [25:0] Add5Level11Wire = Add5Level11;
  677.  
  678. always @* begin
  679. if(!Add1Level11Wire[33]) begin
  680. Add5Level11 = Add4Level11Wire + Add2Level11Wire;
  681. end
  682. else begin
  683. Add5Level11 = Add4Level11Wire - Add3Level11Wire;
  684. end
  685. end
  686.  
  687. reg [25:0] PLevel11;
  688.  
  689. always @(posedge clk) begin
  690. PLevel11 <= Add5Level11Wire;
  691. end
  692.  
  693. // Twelveth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  694.  
  695. reg [36:0] Add1Level12;
  696. wire [36:0] Add1Level12Wire = Add1Level12;
  697.  
  698. always @* begin
  699. Add1Level12 = {2'b0, NumberLevel11[63:30]} - PLevel11;
  700. end
  701.  
  702. reg [63:0] NumberLevel12;
  703. reg [11:0] AnswerLevel12;
  704.  
  705. always @(posedge clk) begin
  706. if(!Add1Level12Wire[36]) begin
  707. NumberLevel12 <= {Add1Level12Wire[35:0], NumberLevel11[29:0]};
  708. end
  709. else begin
  710. NumberLevel12 <= NumberLevel11;
  711. end
  712. AnswerLevel12 <= {AnswerLevel11, !Add1Level12Wire[36]};
  713. end
  714.  
  715. reg [16:0] Add2Level12;
  716. wire [16:0] Add2Level12Wire = Add2Level12;
  717.  
  718. always @* begin
  719. Add2Level12 = {AnswerLevel11, !Add1Level12Wire[36], 4'b0} + {AnswerLevel11, !Add1Level12Wire[36], 1'b0};
  720. end
  721.  
  722. reg [14:0] Add3Level12;
  723. wire [14:0] Add3Level12Wire = Add3Level12;
  724.  
  725. always @* begin
  726. Add3Level12 = {AnswerLevel11, !Add1Level12Wire[36], 2'b0} + {AnswerLevel11, !Add1Level12Wire[36], 1'b0};
  727. end
  728.  
  729. reg [27:0] Add4Level12;
  730. wire [27:0] Add4Level12Wire = Add4Level12;
  731.  
  732. always @* begin
  733. Add4Level12 = {PLevel11, 2'b0} - 3;
  734. end
  735.  
  736. reg [27:0] Add5Level12;
  737. wire [27:0] Add5Level12Wire = Add5Level12;
  738.  
  739. always @* begin
  740. if(!Add1Level12Wire[36]) begin
  741. Add5Level12 = Add4Level12Wire + Add2Level12Wire;
  742. end
  743. else begin
  744. Add5Level12 = Add4Level12Wire - Add3Level12Wire;
  745. end
  746. end
  747.  
  748. reg [27:0] PLevel12;
  749.  
  750. always @(posedge clk) begin
  751. PLevel12 <= Add5Level12Wire;
  752. end
  753.  
  754. // Thirteenth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  755.  
  756. reg [39:0] Add1Level13;
  757. wire [39:0] Add1Level13Wire = Add1Level13;
  758.  
  759. always @* begin
  760. Add1Level13 = {2'b0, NumberLevel12[63:27]} - PLevel12;
  761. end
  762.  
  763. reg [63:0] NumberLevel13;
  764. reg [12:0] AnswerLevel13;
  765.  
  766. always @(posedge clk) begin
  767. if(!Add1Level13Wire[39]) begin
  768. NumberLevel13 <= {Add1Level13Wire[38:0], NumberLevel12[26:0]};
  769. end
  770. else begin
  771. NumberLevel13 <= NumberLevel12;
  772. end
  773. AnswerLevel13 <= {AnswerLevel12, !Add1Level13Wire[39]};
  774. end
  775.  
  776. reg [17:0] Add2Level13;
  777. wire [17:0] Add2Level13Wire = Add2Level13;
  778.  
  779. always @* begin
  780. Add2Level13 = {AnswerLevel12, !Add1Level13Wire[39], 4'b0} + {AnswerLevel12, !Add1Level13Wire[39], 1'b0};
  781. end
  782.  
  783. reg [15:0] Add3Level13;
  784. wire [15:0] Add3Level13Wire = Add3Level13;
  785.  
  786. always @* begin
  787. Add3Level13 = {AnswerLevel12, !Add1Level13Wire[39], 2'b0} + {AnswerLevel12, !Add1Level13Wire[39], 1'b0};
  788. end
  789.  
  790. reg [29:0] Add4Level13;
  791. wire [29:0] Add4Level13Wire = Add4Level13;
  792.  
  793. always @* begin
  794. Add4Level13 = {PLevel12, 2'b0} - 3;
  795. end
  796.  
  797. reg [29:0] Add5Level13;
  798. wire [29:0] Add5Level13Wire = Add5Level13;
  799.  
  800. always @* begin
  801. if(!Add1Level13Wire[39]) begin
  802. Add5Level13 = Add4Level13Wire + Add2Level13Wire;
  803. end
  804. else begin
  805. Add5Level13 = Add4Level13Wire - Add3Level13Wire;
  806. end
  807. end
  808.  
  809. reg [29:0] PLevel13;
  810.  
  811. always @(posedge clk) begin
  812. PLevel13 <= Add5Level13Wire;
  813. end
  814.  
  815. // Fourteenth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  816.  
  817. reg [42:0] Add1Level14;
  818. wire [42:0] Add1Level14Wire = Add1Level14;
  819.  
  820. always @* begin
  821. Add1Level14 = {2'b0, NumberLevel13[63:24]} - PLevel13;
  822. end
  823.  
  824. reg [63:0] NumberLevel14;
  825. reg [13:0] AnswerLevel14;
  826.  
  827. always @(posedge clk) begin
  828. if(!Add1Level14Wire[42]) begin
  829. NumberLevel14 <= {Add1Level14Wire[41:0], NumberLevel13[23:0]};
  830. end
  831. else begin
  832. NumberLevel14 <= NumberLevel13;
  833. end
  834. AnswerLevel14 <= {AnswerLevel13, !Add1Level14Wire[42]};
  835. end
  836.  
  837. reg [18:0] Add2Level14;
  838. wire [18:0] Add2Level14Wire = Add2Level14;
  839.  
  840. always @* begin
  841. Add2Level14 = {AnswerLevel13, !Add1Level14Wire[42], 4'b0} + {AnswerLevel13, !Add1Level14Wire[42], 1'b0};
  842. end
  843.  
  844. reg [16:0] Add3Level14;
  845. wire [16:0] Add3Level14Wire = Add3Level14;
  846.  
  847. always @* begin
  848. Add3Level14 = {AnswerLevel13, !Add1Level14Wire[42], 2'b0} + {AnswerLevel13, !Add1Level14Wire[42], 1'b0};
  849. end
  850.  
  851. reg [31:0] Add4Level14;
  852. wire [31:0] Add4Level14Wire = Add4Level14;
  853.  
  854. always @* begin
  855. Add4Level14 = {PLevel13, 2'b0} - 3;
  856. end
  857.  
  858. reg [31:0] Add5Level14;
  859. wire [31:0] Add5Level14Wire = Add5Level14;
  860.  
  861. always @* begin
  862. if(!Add1Level14Wire[42]) begin
  863. Add5Level14 = Add4Level14Wire + Add2Level14Wire;
  864. end
  865. else begin
  866. Add5Level14 = Add4Level14Wire - Add3Level14Wire;
  867. end
  868. end
  869.  
  870. reg [31:0] PLevel14;
  871.  
  872. always @(posedge clk) begin
  873. PLevel14 <= Add5Level14Wire;
  874. end
  875.  
  876.  
  877. // Fifteenth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  878.  
  879. reg [45:0] Add1Level15;
  880. wire [45:0] Add1Level15Wire = Add1Level15;
  881.  
  882. always @* begin
  883. Add1Level15 = {2'b0, NumberLevel14[63:21]} - PLevel14;
  884. end
  885.  
  886. reg [63:0] NumberLevel15;
  887. reg [14:0] AnswerLevel15;
  888.  
  889. always @(posedge clk) begin
  890. if(!Add1Level15Wire[45]) begin
  891. NumberLevel15 <= {Add1Level15Wire[44:0], NumberLevel14[20:0]};
  892. end
  893. else begin
  894. NumberLevel15 <= NumberLevel14;
  895. end
  896. AnswerLevel15 <= {AnswerLevel14, !Add1Level15Wire[45]};
  897. end
  898.  
  899. reg [19:0] Add2Level15;
  900. wire [19:0] Add2Level15Wire = Add2Level15;
  901.  
  902. always @* begin
  903. Add2Level15 = {AnswerLevel14, !Add1Level15Wire[45], 4'b0} + {AnswerLevel14, !Add1Level15Wire[45], 1'b0};
  904. end
  905.  
  906. reg [17:0] Add3Level15;
  907. wire [17:0] Add3Level15Wire = Add3Level15;
  908.  
  909. always @* begin
  910. Add3Level15 = {AnswerLevel14, !Add1Level15Wire[45], 2'b0} + {AnswerLevel14, !Add1Level15Wire[45], 1'b0};
  911. end
  912.  
  913. reg [33:0] Add4Level15;
  914. wire [33:0] Add4Level15Wire = Add4Level15;
  915.  
  916. always @* begin
  917. Add4Level15 = {PLevel14, 2'b0} - 3;
  918. end
  919.  
  920. reg [33:0] Add5Level15;
  921. wire [33:0] Add5Level15Wire = Add5Level15;
  922.  
  923. always @* begin
  924. if(!Add1Level15Wire[45]) begin
  925. Add5Level15 = Add4Level15Wire + Add2Level15Wire;
  926. end
  927. else begin
  928. Add5Level15 = Add4Level15Wire - Add3Level15Wire;
  929. end
  930. end
  931.  
  932. reg [33:0] PLevel15;
  933.  
  934. always @(posedge clk) begin
  935. PLevel15 <= Add5Level15Wire;
  936. end
  937.  
  938. // Sixteenth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  939.  
  940. reg [48:0] Add1Level16;
  941. wire [48:0] Add1Level16Wire = Add1Level16;
  942.  
  943. always @* begin
  944. Add1Level16 = {2'b0, NumberLevel15[63:18]} - PLevel15;
  945. end
  946.  
  947. reg [63:0] NumberLevel16;
  948. reg [15:0] AnswerLevel16;
  949.  
  950. always @(posedge clk) begin
  951. if(!Add1Level16Wire[48]) begin
  952. NumberLevel16 <= {Add1Level16Wire[47:0], NumberLevel15[17:0]};
  953. end
  954. else begin
  955. NumberLevel16 <= NumberLevel15;
  956. end
  957. AnswerLevel16 <= {AnswerLevel15, !Add1Level16Wire[48]};
  958. end
  959.  
  960. reg [20:0] Add2Level16;
  961. wire [20:0] Add2Level16Wire = Add2Level16;
  962.  
  963. always @* begin
  964. Add2Level16 = {AnswerLevel15, !Add1Level16Wire[48], 4'b0} + {AnswerLevel15, !Add1Level16Wire[48], 1'b0};
  965. end
  966.  
  967. reg [18:0] Add3Level16;
  968. wire [18:0] Add3Level16Wire = Add3Level16;
  969.  
  970. always @* begin
  971. Add3Level16 = {AnswerLevel15, !Add1Level16Wire[48], 2'b0} + {AnswerLevel15, !Add1Level16Wire[48], 1'b0};
  972. end
  973.  
  974. reg [35:0] Add4Level16;
  975. wire [35:0] Add4Level16Wire = Add4Level16;
  976.  
  977. always @* begin
  978. Add4Level16 = {PLevel15, 2'b0} - 3;
  979. end
  980.  
  981. reg [35:0] Add5Level16;
  982. wire [35:0] Add5Level16Wire = Add5Level16;
  983.  
  984. always @* begin
  985. if(!Add1Level16Wire[48]) begin
  986. Add5Level16 = Add4Level16Wire + Add2Level16Wire;
  987. end
  988. else begin
  989. Add5Level16 = Add4Level16Wire - Add3Level16Wire;
  990. end
  991. end
  992.  
  993. reg [35:0] PLevel16;
  994.  
  995. always @(posedge clk) begin
  996. PLevel16 <= Add5Level16Wire;
  997. end
  998.  
  999. // Seventeenth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  1000.  
  1001. reg [51:0] Add1Level17;
  1002. wire [51:0] Add1Level17Wire = Add1Level17;
  1003.  
  1004. always @* begin
  1005. Add1Level17 = {2'b0, NumberLevel16[63:15]} - PLevel16;
  1006. end
  1007.  
  1008. reg [63:0] NumberLevel17;
  1009. reg [16:0] AnswerLevel17;
  1010.  
  1011. always @(posedge clk) begin
  1012. if(!Add1Level17Wire[51]) begin
  1013. NumberLevel17 <= {Add1Level17Wire[50:0], NumberLevel16[14:0]};
  1014. end
  1015. else begin
  1016. NumberLevel17 <= NumberLevel16;
  1017. end
  1018. AnswerLevel17 <= {AnswerLevel16, !Add1Level17Wire[51]};
  1019. end
  1020.  
  1021. reg [21:0] Add2Level17;
  1022. wire [21:0] Add2Level17Wire = Add2Level17;
  1023.  
  1024. always @* begin
  1025. Add2Level17 = {AnswerLevel16, !Add1Level17Wire[51], 4'b0} + {AnswerLevel16, !Add1Level17Wire[51], 1'b0};
  1026. end
  1027.  
  1028. reg [19:0] Add3Level17;
  1029. wire [19:0] Add3Level17Wire = Add3Level17;
  1030.  
  1031. always @* begin
  1032. Add3Level17 = {AnswerLevel16, !Add1Level17Wire[51], 2'b0} + {AnswerLevel16, !Add1Level17Wire[51], 1'b0};
  1033. end
  1034.  
  1035. reg [37:0] Add4Level17;
  1036. wire [37:0] Add4Level17Wire = Add4Level17;
  1037.  
  1038. always @* begin
  1039. Add4Level17 = {PLevel16, 2'b0} - 3;
  1040. end
  1041.  
  1042. reg [37:0] Add5Level17;
  1043. wire [37:0] Add5Level17Wire = Add5Level17;
  1044.  
  1045. always @* begin
  1046. if(!Add1Level17Wire[51]) begin
  1047. Add5Level17 = Add4Level17Wire + Add2Level17Wire;
  1048. end
  1049. else begin
  1050. Add5Level17 = Add4Level17Wire - Add3Level17Wire;
  1051. end
  1052. end
  1053.  
  1054. reg [37:0] PLevel17;
  1055.  
  1056. always @(posedge clk) begin
  1057. PLevel17 <= Add5Level17Wire;
  1058. end
  1059.  
  1060. // Eighteenth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  1061.  
  1062. reg [54:0] Add1Level18;
  1063. wire [54:0] Add1Level18Wire = Add1Level18;
  1064.  
  1065. always @* begin
  1066. Add1Level18 = {2'b0, NumberLevel17[63:12]} - PLevel17;
  1067. end
  1068.  
  1069. reg [63:0] NumberLevel18;
  1070. reg [17:0] AnswerLevel18;
  1071.  
  1072. always @(posedge clk) begin
  1073. if(!Add1Level18Wire[54]) begin
  1074. NumberLevel18 <= {Add1Level18Wire[53:0], NumberLevel17[11:0]};
  1075. end
  1076. else begin
  1077. NumberLevel18 <= NumberLevel17;
  1078. end
  1079. AnswerLevel18 <= {AnswerLevel17, !Add1Level18Wire[54]};
  1080. end
  1081.  
  1082. reg [22:0] Add2Level18;
  1083. wire [22:0] Add2Level18Wire = Add2Level18;
  1084.  
  1085. always @* begin
  1086. Add2Level18 = {AnswerLevel17, !Add1Level18Wire[54], 4'b0} + {AnswerLevel17, !Add1Level18Wire[54], 1'b0};
  1087. end
  1088.  
  1089. reg [20:0] Add3Level18;
  1090. wire [20:0] Add3Level18Wire = Add3Level18;
  1091.  
  1092. always @* begin
  1093. Add3Level18 = {AnswerLevel17, !Add1Level18Wire[54], 2'b0} + {AnswerLevel17, !Add1Level18Wire[54], 1'b0};
  1094. end
  1095.  
  1096. reg [39:0] Add4Level18;
  1097. wire [39:0] Add4Level18Wire = Add4Level18;
  1098.  
  1099. always @* begin
  1100. Add4Level18 = {PLevel17, 2'b0} - 3;
  1101. end
  1102.  
  1103. reg [39:0] Add5Level18;
  1104. wire [39:0] Add5Level18Wire = Add5Level18;
  1105.  
  1106. always @* begin
  1107. if(!Add1Level18Wire[54]) begin
  1108. Add5Level18 = Add4Level18Wire + Add2Level18Wire;
  1109. end
  1110. else begin
  1111. Add5Level18 = Add4Level18Wire - Add3Level18Wire;
  1112. end
  1113. end
  1114.  
  1115. reg [39:0] PLevel18;
  1116.  
  1117. always @(posedge clk) begin
  1118. PLevel18 <= Add5Level18Wire;
  1119. end
  1120.  
  1121.  
  1122. // Nineteenth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  1123.  
  1124. reg [57:0] Add1Level19;
  1125. wire [57:0] Add1Level19Wire = Add1Level19;
  1126.  
  1127. always @* begin
  1128. Add1Level19 = {2'b0, NumberLevel18[63:9]} - PLevel18;
  1129. end
  1130.  
  1131. reg [63:0] NumberLevel19;
  1132. reg [18:0] AnswerLevel19;
  1133.  
  1134. always @(posedge clk) begin
  1135. if(!Add1Level19Wire[57]) begin
  1136. NumberLevel19 <= {Add1Level19Wire[56:0], NumberLevel18[8:0]};
  1137. end
  1138. else begin
  1139. NumberLevel19 <= NumberLevel18;
  1140. end
  1141. AnswerLevel19 <= {AnswerLevel18, !Add1Level19Wire[57]};
  1142. end
  1143.  
  1144. reg [23:0] Add2Level19;
  1145. wire [23:0] Add2Level19Wire = Add2Level19;
  1146.  
  1147. always @* begin
  1148. Add2Level19 = {AnswerLevel18, !Add1Level19Wire[57], 4'b0} + {AnswerLevel18, !Add1Level19Wire[57], 1'b0};
  1149. end
  1150.  
  1151. reg [21:0] Add3Level19;
  1152. wire [21:0] Add3Level19Wire = Add3Level19;
  1153.  
  1154. always @* begin
  1155. Add3Level19 = {AnswerLevel18, !Add1Level19Wire[57], 2'b0} + {AnswerLevel18, !Add1Level19Wire[57], 1'b0};
  1156. end
  1157.  
  1158. reg [41:0] Add4Level19;
  1159. wire [41:0] Add4Level19Wire = Add4Level19;
  1160.  
  1161. always @* begin
  1162. Add4Level19 = {PLevel18, 2'b0} - 3;
  1163. end
  1164.  
  1165. reg [41:0] Add5Level19;
  1166. wire [41:0] Add5Level19Wire = Add5Level19;
  1167.  
  1168. always @* begin
  1169. if(!Add1Level19Wire[57]) begin
  1170. Add5Level19 = Add4Level19Wire + Add2Level19Wire;
  1171. end
  1172. else begin
  1173. Add5Level19 = Add4Level19Wire - Add3Level19Wire;
  1174. end
  1175. end
  1176.  
  1177. reg [41:0] PLevel19;
  1178.  
  1179. always @(posedge clk) begin
  1180. PLevel19 <= Add5Level19Wire;
  1181. end
  1182.  
  1183. // Twentyth Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  1184.  
  1185. reg [60:0] Add1Level20;
  1186. wire [60:0] Add1Level20Wire = Add1Level20;
  1187.  
  1188. always @* begin
  1189. Add1Level20 = {2'b0, NumberLevel19[63:6]} - PLevel19;
  1190. end
  1191.  
  1192. reg [63:0] NumberLevel20;
  1193. reg [19:0] AnswerLevel20;
  1194.  
  1195. always @(posedge clk) begin
  1196. if(!Add1Level20Wire[60]) begin
  1197. NumberLevel20 <= {Add1Level20Wire[59:0], NumberLevel19[5:0]};
  1198. end
  1199. else begin
  1200. NumberLevel20 <= NumberLevel19;
  1201. end
  1202. AnswerLevel20 <= {AnswerLevel19, !Add1Level20Wire[60]};
  1203. end
  1204.  
  1205. reg [24:0] Add2Level20;
  1206. wire [24:0] Add2Level20Wire = Add2Level20;
  1207.  
  1208. always @* begin
  1209. Add2Level20 = {AnswerLevel19, !Add1Level20Wire[60], 4'b0} + {AnswerLevel19, !Add1Level20Wire[60], 1'b0};
  1210. end
  1211.  
  1212. reg [22:0] Add3Level20;
  1213. wire [22:0] Add3Level20Wire = Add3Level20;
  1214.  
  1215. always @* begin
  1216. Add3Level20 = {AnswerLevel19, !Add1Level20Wire[60], 2'b0} + {AnswerLevel19, !Add1Level20Wire[60], 1'b0};
  1217. end
  1218.  
  1219. reg [43:0] Add4Level20;
  1220. wire [43:0] Add4Level20Wire = Add4Level20;
  1221.  
  1222. always @* begin
  1223. Add4Level20 = {PLevel19, 2'b0} - 3;
  1224. end
  1225.  
  1226. reg [43:0] Add5Level20;
  1227. wire [43:0] Add5Level20Wire = Add5Level20;
  1228.  
  1229. always @* begin
  1230. if(!Add1Level20Wire[60]) begin
  1231. Add5Level20 = Add4Level20Wire + Add2Level20Wire;
  1232. end
  1233. else begin
  1234. Add5Level20 = Add4Level20Wire - Add3Level20Wire;
  1235. end
  1236. end
  1237.  
  1238. reg [43:0] PLevel20;
  1239.  
  1240. always @(posedge clk) begin
  1241. PLevel20 <= Add5Level20Wire;
  1242. end
  1243.  
  1244.  
  1245. // TwentyFirstst Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  1246.  
  1247. reg [63:0] Add1Level21;
  1248. wire [63:0] Add1Level21Wire = Add1Level21;
  1249.  
  1250. always @* begin
  1251. Add1Level21 = {2'b0, NumberLevel20[63:3]} - PLevel20;
  1252. end
  1253.  
  1254. reg [63:0] NumberLevel21;
  1255. reg [20:0] AnswerLevel21;
  1256.  
  1257. always @(posedge clk) begin
  1258. if(!Add1Level21Wire[63]) begin
  1259. NumberLevel21 <= {Add1Level21Wire[62:0], NumberLevel20[2:0]};
  1260. end
  1261. else begin
  1262. NumberLevel21 <= NumberLevel20;
  1263. end
  1264. AnswerLevel21 <= {AnswerLevel20, !Add1Level21Wire[63]};
  1265. end
  1266.  
  1267. reg [25:0] Add2Level21;
  1268. wire [25:0] Add2Level21Wire = Add2Level21;
  1269.  
  1270. always @* begin
  1271. Add2Level21 = {AnswerLevel20, !Add1Level21Wire[63], 4'b0} + {AnswerLevel20, !Add1Level21Wire[63], 1'b0};
  1272. end
  1273.  
  1274. reg [23:0] Add3Level21;
  1275. wire [23:0] Add3Level21Wire = Add3Level21;
  1276.  
  1277. always @* begin
  1278. Add3Level21 = {AnswerLevel20, !Add1Level21Wire[63], 2'b0} + {AnswerLevel20, !Add1Level21Wire[63], 1'b0};
  1279. end
  1280.  
  1281. reg [45:0] Add4Level21;
  1282. wire [45:0] Add4Level21Wire = Add4Level21;
  1283.  
  1284. always @* begin
  1285. Add4Level21 = {PLevel20, 2'b0} - 3;
  1286. end
  1287.  
  1288. reg [45:0] Add5Level21;
  1289. wire [45:0] Add5Level21Wire = Add5Level21;
  1290.  
  1291. always @* begin
  1292. if(!Add1Level21Wire[63]) begin
  1293. Add5Level21 = Add4Level21Wire + Add2Level21Wire;
  1294. end
  1295. else begin
  1296. Add5Level21 = Add4Level21Wire - Add3Level21Wire;
  1297. end
  1298. end
  1299.  
  1300. reg [45:0] PLevel21;
  1301.  
  1302. always @(posedge clk) begin
  1303. PLevel21 <= Add5Level21Wire;
  1304. end
  1305.  
  1306.  
  1307. // TwentySecondnd Level /////////////////////////////////////////////////////////////////////////////////////////////////////////
  1308.  
  1309. reg [66:0] Add1Level22;
  1310. wire [66:0] Add1Level22Wire = Add1Level22;
  1311.  
  1312. always @* begin
  1313. Add1Level22 = {2'b0, NumberLevel21} - PLevel21;
  1314. end
  1315.  
  1316. reg [63:0] NumberLevel22;
  1317. reg [21:0] AnswerLevel22;
  1318.  
  1319. always @(posedge clk) begin
  1320. if(!Add1Level22Wire[66]) begin
  1321. NumberLevel22 <= Add1Level22Wire[63:0];
  1322. end
  1323. else begin
  1324. NumberLevel22 <= NumberLevel21;
  1325. end
  1326. AnswerLevel22 <= {AnswerLevel21, !Add1Level22Wire[66]};
  1327. end
  1328.  
  1329. assign Answer = AnswerLevel22;
  1330. assign Remainder = NumberLevel22;
  1331.  
  1332. endmodule
Advertisement
RAW Paste Data Copied
Advertisement