usbf_crc16.v 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. //-----------------------------------------------------------------
  2. // USB Serial Port
  3. // V0.1
  4. // Ultra-Embedded.com
  5. // Copyright 2020
  6. //
  7. // Email: admin@ultra-embedded.com
  8. //
  9. // License: LGPL
  10. //-----------------------------------------------------------------
  11. //
  12. // This source file may be used and distributed without
  13. // restriction provided that this copyright statement is not
  14. // removed from the file and that any derivative work contains
  15. // the original copyright notice and the associated disclaimer.
  16. //
  17. // This source file is free software; you can redistribute it
  18. // and/or modify it under the terms of the GNU Lesser General
  19. // Public License as published by the Free Software Foundation;
  20. // either version 2.1 of the License, or (at your option) any
  21. // later version.
  22. //
  23. // This source is distributed in the hope that it will be
  24. // useful, but WITHOUT ANY WARRANTY; without even the implied
  25. // warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  26. // PURPOSE. See the GNU Lesser General Public License for more
  27. // details.
  28. //
  29. // You should have received a copy of the GNU Lesser General
  30. // Public License along with this source; if not, write to the
  31. // Free Software Foundation, Inc., 59 Temple Place, Suite 330,
  32. // Boston, MA 02111-1307 USA
  33. //-----------------------------------------------------------------
  34. //-----------------------------------------------------------------
  35. // Generated File
  36. //-----------------------------------------------------------------
  37. module usbf_crc16
  38. (
  39. // Inputs
  40. input [ 15:0] crc_in_i
  41. ,input [ 7:0] din_i
  42. // Outputs
  43. ,output [ 15:0] crc_out_o
  44. );
  45. //-----------------------------------------------------------------
  46. // Logic
  47. //-----------------------------------------------------------------
  48. assign crc_out_o[15] = din_i[0] ^ din_i[1] ^ din_i[2] ^ din_i[3] ^ din_i[4] ^ din_i[5] ^ din_i[6] ^ din_i[7] ^
  49. crc_in_i[7] ^ crc_in_i[6] ^ crc_in_i[5] ^ crc_in_i[4] ^ crc_in_i[3] ^ crc_in_i[2] ^ crc_in_i[1] ^ crc_in_i[0];
  50. assign crc_out_o[14] = din_i[0] ^ din_i[1] ^ din_i[2] ^ din_i[3] ^ din_i[4] ^ din_i[5] ^ din_i[6] ^
  51. crc_in_i[6] ^ crc_in_i[5] ^ crc_in_i[4] ^ crc_in_i[3] ^ crc_in_i[2] ^ crc_in_i[1] ^ crc_in_i[0];
  52. assign crc_out_o[13] = din_i[6] ^ din_i[7] ^
  53. crc_in_i[7] ^ crc_in_i[6];
  54. assign crc_out_o[12] = din_i[5] ^ din_i[6] ^
  55. crc_in_i[6] ^ crc_in_i[5];
  56. assign crc_out_o[11] = din_i[4] ^ din_i[5] ^
  57. crc_in_i[5] ^ crc_in_i[4];
  58. assign crc_out_o[10] = din_i[3] ^ din_i[4] ^
  59. crc_in_i[4] ^ crc_in_i[3];
  60. assign crc_out_o[9] = din_i[2] ^ din_i[3] ^
  61. crc_in_i[3] ^ crc_in_i[2];
  62. assign crc_out_o[8] = din_i[1] ^ din_i[2] ^
  63. crc_in_i[2] ^ crc_in_i[1];
  64. assign crc_out_o[7] = din_i[0] ^ din_i[1] ^
  65. crc_in_i[15] ^ crc_in_i[1] ^ crc_in_i[0];
  66. assign crc_out_o[6] = din_i[0] ^
  67. crc_in_i[14] ^ crc_in_i[0];
  68. assign crc_out_o[5] = crc_in_i[13];
  69. assign crc_out_o[4] = crc_in_i[12];
  70. assign crc_out_o[3] = crc_in_i[11];
  71. assign crc_out_o[2] = crc_in_i[10];
  72. assign crc_out_o[1] = crc_in_i[9];
  73. assign crc_out_o[0] = din_i[0] ^ din_i[1] ^ din_i[2] ^ din_i[3] ^ din_i[4] ^ din_i[5] ^ din_i[6] ^ din_i[7] ^
  74. crc_in_i[8] ^ crc_in_i[7] ^ crc_in_i[6] ^ crc_in_i[5] ^ crc_in_i[4] ^ crc_in_i[3] ^ crc_in_i[2] ^ crc_in_i[1] ^ crc_in_i[0];
  75. endmodule