Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- module Lab2(input [5:0] SW, output [6:0] HEX0);
- wire [2:0] E,G;
- comparator3(
- endmodule
- module comparator1(
- //input A
- A,
- //input B
- B,
- //output A>B
- G,
- //output A=B
- E
- );
- input A,B;
- output wire G,E;
- assign G = A&(~B);
- assign E = (A&B)|(~B&~A);
- endmodule
- module comparator3(
- //input A
- A,
- //input B
- B,
- //output G A>B
- G,
- //output E A=B
- E
- );
- input [2:0] A,B;
- output wire G,E;
- reg [2:0] g,e;
- comparator1 c0(A[0],B[0],g[0],e[0]);
- comparator1 c1(A[1],B[1],g[1],e[1]);
- comparator1 c2(A[2],B[2],g[2],e[2]);
- assign E = (e[0]&e[1]&e[2]);
- assign G = g[2]|(e[2]&g[1])|(g[0]&e[1]&e[2]);
- endmodule
Advertisement
Add Comment
Please, Sign In to add comment