TheLegace

Lab2

Sep 25th, 2011
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. module Lab2(input [5:0] SW, output [6:0] HEX0);
  2.     wire [2:0] E,G;
  3.    
  4.     comparator3(
  5. endmodule
  6.  
  7. module comparator1(
  8.     //input A
  9.     A,
  10.     //input B
  11.     B,
  12.     //output A>B
  13.     G,
  14.     //output A=B
  15.     E
  16. );
  17.     input A,B;
  18.     output wire G,E;
  19.    
  20.     assign G = A&(~B);
  21.     assign E = (A&B)|(~B&~A);
  22. endmodule
  23.  
  24. module comparator3(
  25.     //input A
  26.     A,
  27.     //input B
  28.     B,
  29.     //output G A>B
  30.     G,
  31.     //output E A=B
  32.     E
  33. );
  34.     input [2:0] A,B;
  35.     output wire G,E;
  36.     reg [2:0] g,e;
  37.    
  38.     comparator1 c0(A[0],B[0],g[0],e[0]);
  39.     comparator1 c1(A[1],B[1],g[1],e[1]);
  40.     comparator1 c2(A[2],B[2],g[2],e[2]);
  41.    
  42.     assign E = (e[0]&e[1]&e[2]);
  43.     assign G = g[2]|(e[2]&g[1])|(g[0]&e[1]&e[2]);
  44.    
  45.    
  46. endmodule
Advertisement
Add Comment
Please, Sign In to add comment