70 likes | 366 Views
Cascading 1-Bit Comparators. Discussion D7.0. A 1-Bit Comparator. The variable Gout is 1 if Gin = 1 or if Ein = 1 and x > y . The variable Eout is 1 if Ein = 1 and x = y . . module comp4 ( x, y, gt, eq, lt ); input [3:0] x ; wire [3:0] x ; input [3:0] y ;
E N D
Cascading 1-Bit Comparators Discussion D7.0
A 1-Bit Comparator The variable Gout is 1 if Gin = 1 or if Ein = 1 andx > y. The variable Eout is 1 if Ein = 1 andx = y.
module comp4 ( x, y, gt, eq, lt ); input [3:0] x ; wire [3:0] x ; input [3:0] y ; wire [3:0] y ; output lt ; wire lt ; output gt ; wire gt ; output eq ; wire eq ; A 4-Bit Comparator x 1 1 0 1 y 1 0 1 1 lt
A 4-Bit Comparator lt wire [4:0] G; wire [4:0] E; assign G[4] = 0; assign E[4] = 1; assign gt = G[0]; assign eq = E[0]; assign lt = ~(G[0] | E[0]);
comp1bit U3(.xi(x[3]) ,.yi(y[3]) ,.Ein(E[4]) , .Eout(E[3]) ,.Gin(G[4]) ,.Gout(G[3]) );
comp1bit U3(.xi(x[3]) ,.yi(y[3]) ,.Ein(E[4]) , .Eout(E[3]) ,.Gin(G[4]) ,.Gout(G[3]) );
comp1bit U3(.xi(x[3]) ,.yi(y[3]) ,.Ein(E[4]) ,.Eout(E[3]) , .Gin(G[4]) ,.Gout(G[3]) ); comp1bit U2(.xi(x[2]) ,.yi(y[2]) ,.Ein(E[3]) ,.Eout(E[2]) , .Gin(G[3]) ,.Gout(G[2]) ); comp1bit U1(.xi(x[1]) ,.yi(y[1]) ,.Ein(E[2]) ,.Eout(E[1]) , .Gin(G[2]) ,.Gout(G[1]) ); comp1bit U0(.xi(x[0]) ,.yi(y[0]) ,.Ein(E[1]) ,.Eout(E[0]) , .Gin(G[1]) ,.Gout(G[0]) ); endmodule