cla_8bits.v
上传用户:saul_905
上传日期:2013-11-27
资源大小:184k
文件大小:2k
源码类别:

VHDL/FPGA/Verilog

开发平台:

Visual C++

  1. module cla_8bits(a,b,c0,c8,s);
  2. input     [7:0]       a,b;
  3. input                 c0;
  4. output                c8;
  5. output    [7:0]       s;
  6. reg       [7:0]       p,q;
  7. reg       [7:1]       c;
  8. reg       [7:0]       s;
  9. reg                   c8;
  10. always@(a or b or c0)
  11. begin
  12.          p=a|b;
  13.          q=a&b;
  14.          
  15.          c[1]=q[0]  |  p[0]&c0;
  16.          c[2]=q[1]  |  p[1]&q[0]  |  p[1]&p[0]&c0;
  17.          c[3]=q[2]  |  p[2]&q[1]  |  p[2]&p[1]&q[0]  |  p[2]&p[1]&p[0]&c0;
  18.          c[4]=q[3]  |  p[3]&q[2]  |  p[3]&p[2]&q[1]  |  p[3]&p[2]&p[1]&q[0]  |  p[3]&p[2]&p[1]&p[0]&c0;
  19.          c[5]=q[4]  |  p[4]&q[3]  |  p[4]&p[3]&q[2]  |  p[4]&p[3]&p[2]&q[1]  |  p[4]&p[3]&p[2]&p[1]&q[0]  |  p[4]&p[3]&p[2]&p[1]&p[0]&c0;
  20.          c[6]=q[5]  |  p[5]&q[4]  |  p[5]&p[4]&q[3]  |  p[5]&p[4]&p[3]&q[2]  |  p[5]&p[4]&p[3]&p[2]&q[1]  |  p[5]&p[4]&p[3]&p[2]&p[1]&q[0]  |  p[5]&p[4]&p[3]&p[2]&p[1]&p[0]&c0;
  21.          c[7]=q[6]  |  p[6]&q[5]  |  p[6]&p[5]&q[4]  |  p[6]&p[5]&p[4]&q[3]  |  p[6]&p[5]&p[4]&p[3]&q[2]  |  p[6]&p[5]&p[4]&p[3]&p[2]&q[1]  |  p[6]&p[5]&p[4]&p[3]&p[2]&p[1]&q[0]  |  p[6]&p[5]&p[4]&p[3]&p[2]&p[1]&p[0]&c0;
  22.          c8  =q[7]  |  p[7]&q[6]  |  p[7]&p[6]&q[5]  |  p[7]&p[6]&p[5]&q[4]  |  p[7]&p[6]&p[5]&p[4]&q[3]  |  p[7]&p[6]&p[5]&p[4]&p[3]&q[2]  |  p[7]&p[6]&p[5]&p[4]&p[3]&p[2]&q[1]  |  p[7]&p[6]&p[5]&p[4]&p[3]&p[2]&p[1]&q[0]  |  p[7]&p[6]&p[5]&p[4]&p[3]&p[2]&p[1]&p[0]&c0;
  23. s[0]=p[0]^q[0]^c0;
  24. s[1]=p[1]^q[1]^c[1];
  25. s[2]=p[2]^q[2]^c[2];
  26. s[3]=p[3]^q[3]^c[3];
  27. s[4]=p[4]^q[4]^c[4];
  28. s[5]=p[5]^q[5]^c[5];
  29. s[6]=p[6]^q[6]^c[6];
  30. s[7]=p[7]^q[7]^c[7];
  31. end
  32. endmodule