idec.v
上传用户:bltddc
上传日期:2020-07-09
资源大小:4428k
文件大小:7k
源码类别:

SCSI/ASPI

开发平台:

VHDL

  1. //
  2. // Copyright (c) 1999 Thomas Coonan (tcoonan@mindspring.com)
  3. //
  4. //    This source code is free software; you can redistribute it
  5. //    and/or modify it in source code form under the terms of the GNU
  6. //    General Public License as published by the Free Software
  7. //    Foundation; either version 2 of the License, or (at your option)
  8. //    any later version.
  9. //
  10. //    This program is distributed in the hope that it will be useful,
  11. //    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13. //    GNU General Public License for more details.
  14. //
  15. //    You should have received a copy of the GNU General Public License
  16. //    along with this program; if not, write to the Free Software
  17. //    Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  18. //
  19. module idec (
  20. inst,
  21. aluasel,
  22. alubsel,
  23. aluop,
  24. wwe,
  25. fwe,
  26. zwe,
  27. cwe,
  28. bdpol,
  29. option,
  30. tris
  31. );
  32. input  [11:0] inst;
  33. output [1:0] aluasel;
  34. output [1:0] alubsel;
  35. output [3:0] aluop;
  36. output wwe;
  37. output fwe;
  38. output zwe;
  39. output cwe;
  40. output bdpol;
  41. output option;
  42. output tris;
  43. reg [14:0] decodes;
  44. // For reference, the ALU Op codes are:
  45. //
  46. //   ADD  0000
  47. //   SUB  1000
  48. //   AND  0001
  49. //   OR   0010
  50. //   XOR  0011
  51. //   COM  0100
  52. //   ROR  0101
  53. //   ROL  0110
  54. //   SWAP 0111
  55. assign { aluasel, // Select source for ALU A input. 00=W, 01=SBUS, 10=K, 11=BD
  56. alubsel, // Select source for ALU B input. 00=W, 01=SBUS, 10=K, 11="1"
  57. aluop, // ALU Operation (see comments above for these codes)
  58. wwe, // W register Write Enable
  59. fwe, // File Register Write Enable
  60. zwe, // Status register Z bit update
  61. cwe, // Status register Z bit update
  62. bdpol, // Polarity on bit decode vector (0=no inversion, 1=invert)
  63. tris, // Instruction is an TRIS instruction
  64. option // Instruction is an OPTION instruction
  65. } = decodes;
  66. // This is a large combinatorial decoder.
  67. // I use the casex statement.
  68. always @(inst) begin
  69. casex (inst) // synopsys parallel_case
  70. // *** Byte-Oriented File Register Operations
  71. //
  72. //                                 A  A  ALU  W F Z C B T O
  73. //                                 L  L   O   W W W W D R P
  74. //                                 U  U   P   E E E E P I T
  75. //                                 A  B               O S
  76. //                                                    L
  77. 12'b0000_0000_0000: decodes = 15'b00_00_0000_0_0_0_0_0_0_0; // NOP
  78. 12'b0000_001X_XXXX: decodes = 15'b00_00_0010_0_1_0_0_0_0_0; // MOVWF
  79. 12'b0000_0100_0000: decodes = 15'b00_00_0011_1_0_1_0_0_0_0; // CLRW
  80. 12'b0000_011X_XXXX: decodes = 15'b00_00_0011_0_1_1_0_0_0_0; // CLRF
  81. 12'b0000_100X_XXXX: decodes = 15'b01_00_1000_1_0_1_1_0_0_0; // SUBWF (d=0)
  82. 12'b0000_101X_XXXX: decodes = 15'b01_00_1000_0_1_1_1_0_0_0; // SUBWF (d=1)
  83. 12'b0000_110X_XXXX: decodes = 15'b01_11_1000_1_0_1_0_0_0_0; // DECF  (d=0)
  84. 12'b0000_111X_XXXX: decodes = 15'b01_11_1000_0_1_1_0_0_0_0; // DECF  (d=1)
  85. 12'b0001_000X_XXXX: decodes = 15'b00_01_0010_1_0_1_0_0_0_0; // IORWF (d=0)
  86. 12'b0001_001X_XXXX: decodes = 15'b00_01_0010_0_1_1_0_0_0_0; // IORWF (d=1)
  87. 12'b0001_010X_XXXX: decodes = 15'b00_01_0001_1_0_1_0_0_0_0; // ANDWF (d=0)
  88. 12'b0001_011X_XXXX: decodes = 15'b00_01_0001_0_1_1_0_0_0_0; // ANDWF (d=1)
  89. 12'b0001_100X_XXXX: decodes = 15'b00_01_0011_1_0_1_0_0_0_0; // XORWF (d=0)
  90. 12'b0001_101X_XXXX: decodes = 15'b00_01_0011_0_1_1_0_0_0_0; // XORWF (d=1)
  91. 12'b0001_110X_XXXX: decodes = 15'b00_01_0000_1_0_1_1_0_0_0; // ADDWF (d=0)
  92. 12'b0001_111X_XXXX: decodes = 15'b00_01_0000_0_1_1_1_0_0_0; // ADDWF (d=1)
  93. 12'b0010_000X_XXXX: decodes = 15'b01_01_0010_1_0_1_0_0_0_0; // MOVF  (d=0)
  94. 12'b0010_001X_XXXX: decodes = 15'b01_01_0010_0_1_1_0_0_0_0; // MOVF  (d=1)
  95. 12'b0010_010X_XXXX: decodes = 15'b01_01_0100_1_0_1_0_0_0_0; // COMF  (d=0)
  96. 12'b0010_011X_XXXX: decodes = 15'b01_01_0100_0_1_1_0_0_0_0; // COMF  (d=1)
  97. 12'b0010_100X_XXXX: decodes = 15'b01_11_0000_1_0_1_0_0_0_0; // INCF  (d=0)
  98. 12'b0010_101X_XXXX: decodes = 15'b01_11_0000_0_1_1_0_0_0_0; // INCF  (d=1)
  99. 12'b0010_110X_XXXX: decodes = 15'b01_11_1000_1_0_0_0_0_0_0; // DECFSZ(d=0)
  100. 12'b0010_111X_XXXX: decodes = 15'b01_11_1000_0_1_0_0_0_0_0; // DECFSZ(d=1)
  101. 12'b0011_000X_XXXX: decodes = 15'b01_01_0101_1_0_0_1_0_0_0; // RRF   (d=0)
  102. 12'b0011_001X_XXXX: decodes = 15'b01_01_0101_0_1_0_1_0_0_0; // RRF   (d=1)
  103. 12'b0011_010X_XXXX: decodes = 15'b01_01_0110_1_0_0_1_0_0_0; // RLF   (d=0)
  104. 12'b0011_011X_XXXX: decodes = 15'b01_01_0110_0_1_0_1_0_0_0; // RLF   (d=1)
  105. 12'b0011_100X_XXXX: decodes = 15'b01_01_0111_1_0_0_0_0_0_0; // SWAPF (d=0)
  106. 12'b0011_101X_XXXX: decodes = 15'b01_01_0111_0_1_0_0_0_0_0; // SWAPF (d=1)
  107. 12'b0011_110X_XXXX: decodes = 15'b01_11_0000_1_0_0_0_0_0_0; // INCFSZ(d=0)
  108. 12'b0011_111X_XXXX: decodes = 15'b01_11_0000_0_1_0_0_0_0_0; // INCFSZ(d=1)
  109. // *** Bit-Oriented File Register Operations
  110.                 //
  111. //                                 A  A  ALU  W F Z C B T O
  112. //                                 L  L   O   W W W W D R P
  113. //                                 U  U   P   E E E E P I T
  114. //                                 A  B               O S
  115. //                                                    L
  116. 12'b0100_XXXX_XXXX: decodes = 15'b11_01_0001_0_1_0_0_1_0_0; // BCF
  117. 12'b0101_XXXX_XXXX: decodes = 15'b11_01_0010_0_1_0_0_0_0_0; // BSF
  118. 12'b0110_XXXX_XXXX: decodes = 15'b11_01_0001_0_0_0_0_0_0_0; // BTFSC
  119. 12'b0111_XXXX_XXXX: decodes = 15'b11_01_0001_0_0_0_0_0_0_0; // BTFSS
  120. // *** Literal and Control Operations
  121.                 //
  122. //                                 A  A  ALU  W F Z C B T O
  123. //                                 L  L   O   W W W W D R P
  124. //                                 U  U   P   E E E E P I T
  125. //                                 A  B               O S
  126. //                                                    L
  127. 12'b0000_0000_0010: decodes = 15'b00_00_0010_0_1_0_0_0_0_1; // OPTION
  128. 12'b0000_0000_0011: decodes = 15'b00_00_0000_0_0_0_0_0_0_0; // SLEEP
  129. 12'b0000_0000_0100: decodes = 15'b00_00_0000_0_0_0_0_0_0_0; // CLRWDT
  130. 12'b0000_0000_0101: decodes = 15'b00_00_0000_0_1_0_0_0_1_0; // TRIS 5
  131. 12'b0000_0000_0110: decodes = 15'b00_00_0010_0_1_0_0_0_1_0; // TRIS 6
  132. 12'b0000_0000_0111: decodes = 15'b00_00_0010_0_1_0_0_0_1_0; // TRIS 7
  133.                 //
  134. //                                 A  A  ALU  W F Z C B T O
  135. //                                 L  L   O   W W W W D R P
  136. //                                 U  U   P   E E E E P I T
  137. //                                 A  B               O S
  138. //                                                    L
  139. 12'b1000_XXXX_XXXX: decodes = 15'b10_10_0010_1_0_0_0_0_0_0; // RETLW
  140. 12'b1001_XXXX_XXXX: decodes = 15'b10_10_0010_0_0_0_0_0_0_0; // CALL
  141. 12'b101X_XXXX_XXXX: decodes = 15'b10_10_0010_0_0_0_0_0_0_0; // GOTO
  142. 12'b1100_XXXX_XXXX: decodes = 15'b10_10_0010_1_0_0_0_0_0_0; // MOVLW
  143. 12'b1101_XXXX_XXXX: decodes = 15'b00_10_0010_1_0_1_0_0_0_0; // IORLW
  144. 12'b1110_XXXX_XXXX: decodes = 15'b00_10_0001_1_0_1_0_0_0_0; // ANDLW
  145. 12'b1111_XXXX_XXXX: decodes = 15'b00_10_0011_1_0_1_0_0_0_0; // XORLW
  146. default:
  147. decodes = 15'b00_00_0000_0_0_0_0_0_0_0;
  148. endcase
  149. end
  150. endmodule