Psst.. new poll here.
Psst.. new forums here.
Microsoft is blocking us again (TY IP Reputation!) so just use oauth login instead. :)
Paste
Pasted as Verilog by placebo ( 6 years ago )
/*Design a circuit that accepts as input a number
of 4-bit and will count the number of bits that are 1 in the output*/
module MyBits(b0, b1, b2, b3, B0, B1, B2);
input b0, b1, b2, b3;
output B0, B1, B2;
//These are all the wires needed
wire w1, w2, w3, w4, w5, w6, w7, w8, w9, w10, w11, w12, w13;
//These are all the NOT gates needed
not not0(n_b0, b0);
not not1(n_b1, b1);
not not2(n_b2, b2);
not not3(n_b3, b3);
//B0 is written as a SOP
and and0(B0, b0, b1, b2, b3); //m16
//B1 is written as a POS
or or0(w0, b0, b1, b2, b3); //M1
or or1(w1, b0, b1, b2, b3_n); //M2
or or2(w2, b0, b1, n_b2, b3); //M3
or or3(w3, b0, n_b1, b2, b3); //M5
or or4(w4, n_b0, b1, b2, b3); //M9
or or5(w5, n_b0, n_b1, n_b2, n_b3); //M16
and and1(B1, w0, w1, w2, w3, w4, w5);
//B2 is written as a POS
and and2(w6, n_b0, n_b1, n_b2, b3); //m2
and and3(w7, n_b0, n_b1, b2, n_b3); //m3
and and4(w8, n_b0, b1, n_b2, n_b3); //m5
and and5(w9, n_b0, b1, b2, b3); //m8
and and6(w10, b0, n_b1, n_b2, n_b3); //m9
and and7(w11, b0, n_b1, b2, b3); //m12
and and9(w12, b0, b1, n_b2, b3); //m14
and and10(w13, b0, b1, b2, n_b3); //m15
or or6(B2, w6, w7, w8, w9, w10, w11, w12, w13);
endmodule
module MyBits(b0, b1, b2, b3, B0, B1, B2);
input b0, b1, b2, b3;
output B0, B1, B2;
//B0 is written an a SOP
assign B0 = b0 & b1 & b2 & b3;
//B1 is written as a POS
assign B1 = (b0 | b1 | b2 | b3)&
(b0 | b1 | b2 | ~b3)&
(b0 | b1 | ~b2 | b3)&
(b0 | ~b1 | b2 | b3)&
(~b0 | b1 | b2 | b3)&
(~b0 | ~b1 | ~b2 | ~b3);
//B2 is written as a SOP
assign B2 = ~b0 & ~b1 & ~b2 & b3 |
~b0 & ~b1 & b2 & ~b3 |
~b0 & b1 & ~b2 & ~b3 |
~b0 & b1 & b2 & b3 |
b0 & ~b1 & ~b2 & ~b3 |
b0 & ~b1 & b2 & b3 |
b0 & b1 & ~b2 & b3 |
b0 & b1 & b2 & ~b3;
endmodule
Revise this Paste