Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.33 KB | None | 0 0
  1. module part3 (SW, LEDR, HEX0, HEX1, HEX4, HEX6);
  2.  
  3. input [7:0] SW; //A is SW[7:4] and B is SW[3:0]
  4. output [7:0] LEDR;
  5. output [6:0] HEX0, HEX1, HEX4, HEX6;
  6.  
  7. //sevenseq(a, b, c, d, H)
  8. sevenseg i0(SW[7], SW[6], SW[5], SW[4], HEX6);
  9. sevenseg i1(SW[3], SW[2], SW[1], SW[0], HEX4);
  10.  
  11. assign LEDR = SW;
  12.  
  13. wire [3:0] w0, w1, w2, w3, w4, w5, w6;
  14. wire c0, c1, c2;
  15.  
  16. //multand ( a, b, f);
  17. multand m0(SW[7:4], SW[0], w0);
  18. multand m1(SW[7:4], SW[1], w1);
  19. multand m2(SW[7:4], SW[2], w2);
  20. multand m3(SW[7:4], SW[3], w3);
  21.  
  22. //n_bit_adder ( S,Cout, A, B, Cin);
  23. n_bit_adder #(4) ripple0(w4, c0, {1'b0, w0[3:1]}, w1, 1'b0);
  24. n_bit_adder #(4) ripple1(w5, c1, {c0, w4[3:1]}, w2, 1'b0);
  25. n_bit_adder #(4) ripple2(w6, c2, {c1, w5[3:1]}, w3, 1'b0);
  26.  
  27. // //alun(s, a, b, cin, f, ovrflw)
  28. // alun a0(3'b011, {1'b0, w0[3:1]}, w1, 1'b0, w4, c0);
  29. // alun a1(3'b011, {c0, w4[3:1]}, w2, 1'b0, w5, c1);
  30. // alun a2(3'b011, {c1, w5[3:1]}, w3, 1'b0, w6, c2);
  31.  
  32. //sevenseq(a, b, c, d, H)
  33. sevenseg s0(w6[0], w5[0], w4[0], w0[0], HEX0);
  34. sevenseg s1(c2, w6[3], w6[2], w6[1], HEX1);
  35.  
  36. endmodule
  37.  
  38.  
  39. module n_bit_adder(S, Cout, A, B, Cin);
  40. parameter n = 4;
  41.  
  42. input Cin;
  43. input [n-1: 0] A, B;
  44.  
  45. output reg [n-1: 0] S;
  46. output reg Cout;
  47.  
  48. always @(A, B, Cin)
  49. {Cout, S} = A + B + Cin;
  50.  
  51. endmodule
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement