Professional Documents
Culture Documents
DIGITAL CIRCUITS
ERIK JASTAD
10 NOV 2015
VERILOG PROJECT 1
Needed to create a circuit which gives the fewest coins possible for 25 cents in change composed of
nickels and dimes only. The circuit must recognize when it has no change to give and only dispense exact
change when it has 25 cents or more available to give. The circuit has a 2bit dime counter and a 3 bit nickel
counter for the inputs and outputs indicating the dimes and nickels to dispense, an additional output of NC
will be 1 if the circuit is unable to give change with the coins available, 0 otherwise.
I have generated a black box, truth table, k-map, reduced equations, behavioral dataflow, structural
description, test bench, and timing tables.
My first step to solving this logic circuit was to create a black box, after which I worked on the truth
table, k-map, reduced equations, coding. I spotted if I make the equation run off the NC output being a 1 or 0
I could make a lot of dont cares for the coins on the kmap allowing a simpler design.
While constructing this design I encountered two problems with the timing diagram, RN2 would have
errors until I changed the equation, also RN0 in the finished structural design with propagation delays would
spike when it was not supposed to and I had to place this output as a gate instead of the inverse of NC.
Black Box Design
My K-maps and Truth tables dont cares are derived from NC being a 1, due to this all equations are
anded with ~NC
input D1,D0;
//dimes available
input N2,N1,N0;
output NC;
//nickels available
assign #6 RN2 = ~D1 & ~D0 & N2 & N1 | N2 & N0 & ~D1 & ~D0; //6 ns delay output RN2
endmodule
//dimes available
//nickels available
output NC;
output RD1, RD0;
output RN2, RN1, RN0;
wire w1,w2,w3,w4,w5,w6;
wire c1,c2;
wire d1b,d0b,n2b,n1b,n0b;
wire wnc,iwnc;
wire wrn1rd0,wrn2,wrd1;
*/
not #(130.6)
//prop delay
U1a(n2b,N2),
U1b(n1b,N1),
U1c(n0b,N0),
U1d(d1b,D1),
U1e(d0b,D0);
and #(150,8)
//inverted N2 or ~N2
//inverted N1 or ~N1
//inverted N0 or ~N0
//inverted D1 or ~D1
//inverted D0 or ~D0
//prop delay
U2a(w2,n2b,n1b,n0b),
U2b(w3,n2b,d1b,d0b),
U2c(w4,n2b,n1b,d1b),
U3a(w5,n2b,n0b,d1b);
and #(165,9)
input inverses
//gate for w2
//gate for w3
//gate for w4
//gate for w5
//prop delay
U4a(c1,N2,N1,d1b,d0b),
U4b(c2,N2,N0,d1b,d0b);
//gate for c1
//gate for c2
and #(165,9)
//prop delay
U5a(w1,n1b,n0b,d1b,d0b);
or #(150,8)
//prop delay
U6a(w6,w2,w3,w1),
//gate cascade to U6b
U6b(wnc,w6,w4,w5),
//gate to wire wnc which is the output NC
U6c(wrn2,c1,c1,c2),
//gate for wire wrn2 which goes to RN2 output
U7a(RN0,wrn1rd0,wrn2,wrd1);
//gate for RN0 output
not #(130.6)
U1f(iwnc,wnc);
and #(150,8)
//prop delay
//inverted wNC or ~wNC wire for gates and the output RN0
//prop delay
U3b(wrn1rd0,d1b,D0,iwnc),
U3c(wrd1,D1,iwnc,iwnc);
assign
NC=wnc,
RN2=wrn2,
RN1=wrn1rd0,
RD0=wrn1rd0,
RD1=wrd1;
endmodule
input inverse
//output assignments
//wire wnc to output NC
//wire wrn2 to output RN2
//wire wrn1rd0 to output RN1
//wire wrd1rd0 to output RD0
//wire wrd1 to output RD1
//inputs
//outputs
ChangeMaker
cm0(.D1(A[1]),.D0(A[0]),.N2(A[4]),.N1(A[3]),.N0(A[2]),.NC(NC),.RD1(RD1),.RD0(RD0),.RN2(RN2),.RN1(RN1),.RN0(RN0));
//instantiated Changemaker module with assignments by name
//begin testing values
initial
begin
//for loop
for(LoopCounter=0; LoopCounter<32; LoopCounter=LoopCounter+1)
begin
#10000 A=LoopCounter;
//hold for 1000ns, set the input value
end
#10000 $finish();
end
endmodule
Timing tables
Behavioral
Structural
QTY
BILL OF MATERIALS
NOMENCLATURE
DESCRIPTION
X1
X2
X2
X2
cd74hct04
cd74hct4075
cd74hct21
cd74hct11
6 INVERTERS
TRIPLE 3 INPUT OR GATE
DUAL 4 INPUT AND GATE
TRIPLE 3 INPUT AND GATE