Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 KB | None | 0 0
  1. module SUMATOR_PROPAGAT_8_BIT(cin,cout,s,x,y);
  2.  
  3. input cin;
  4. input x;
  5. input y;
  6. output reg cout;
  7. output reg s;
  8. always @(x or y) begin
  9. {cout,s}=x+y+cin;
  10. end
  11. endmodule
  12.  
  13. module TEST_SUMATOR_PROPAGAT_8_BIT;
  14. reg cin;
  15. reg [7:0] x;
  16. reg [7:0] y;
  17. wire[7:0] s;
  18. wire cout;
  19. wire c01, c12, c23, c34, c45, c56, c67;
  20. TEST_SUMATOR_PROPAGAT_8_BIT zero(.cin(cin),.cout(c01),.s(s[0]),.x(x[0]),.y(y[0]));
  21. TEST_SUMATOR_PROPAGAT_8_BIT unu(.cin(c01),.cout(c12),.s(s[1]),.x(x[1]),.y(y[1]));
  22. TEST_SUMATOR_PROPAGAT_8_BIT doi(.cin(c12),.cout(c23),.s(s[2]),.x(x[2]),.y(y[2]));
  23. TEST_SUMATOR_PROPAGAT_8_BIT trei(.cin(c23),.cout(c34),.s(s[3]),.x(x[3]),.y(y[3]));
  24. TEST_SUMATOR_PROPAGAT_8_BIT patru(.cin(c34),.cout(c45),.s(s[4]),.x(x[4]),.y(y[4]));
  25. TEST_SUMATOR_PROPAGAT_8_BIT cinci(.cin(c45),.cout(c56),.s(s[5]),.x(x[5]),.y(y[5]));
  26. TEST_SUMATOR_PROPAGAT_8_BIT sase(.cin(c56),.cout(c67),.s(s[6]),.x(x[6]),.y(y[6]));
  27. TEST_SUMATOR_PROPAGAT_8_BIT sapte(.cin(c67),.cout(cout),.s(s[7]),.x(x[7]),.y(y[7]));
  28.  
  29. initial begin
  30. #5 cin=1'b0;x=8'h20;y=8'h30;
  31. #5 cin=0'b0;x=8'h25;y=8'h30;
  32. #5 cin=0'b0;x=8'h36;y=8'h75;
  33. #5 cin=0'b0;x=8'h54;y=8'h43;
  34. #5 cin=0'b0;x=8'h42;y=8'h34;
  35. #5 cin=0'b0;x=8'h86;y=8'h76;
  36. #5 cin=0'b0;x=8'h43;y=8'h56;
  37. #5 cin=0'b0;x=8'h76;y=8'h24;
  38. #5 $finish;
  39. end
  40. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement