Docsity

EE 231 HW 9: Solving Problems with D Flip-Flops & Verilog - Prof. William Rison, Assignments of Digital Electronics

Toggle sidebar
bg1
EE 231
Homework Assignment 9
Due Oct. 29, 2008
Probelm 5.16 (a). You do not have to draw the logic diagram. Just
find equations for the inputs to the two D flip-flops. The output
of the circuit should be the present state. Is this a Mealy
machine or a Moore machine?
1.
Problem 5.17. The string of bits comes in least significa nt bit
first. Find the equation for the input to the D flip-flop, and draw
a logic dia gram to implement the function. (Hint: T his function
can be implemented with only two states, so requires only one
flip-flop. From Page 11 of the text: "T he 2's complement ca n be
formed by leaving all lea st significant 0's and the first 1
unchanged, and replacing 1's with 0's and 0's with 1's in all
other higher significant digits.") Is this a Mealy machine or a
Moore machine?
2.
Problem 5.19 (a). You do not have to draw the logic diagram. Just
find equations for the inputs to the D flip-flops. Is this a Mealy
machine or a Moore machine?
3.
Problem 5.23.4.
Write a Verilog program to implement Problem 5.16 (a).5.
Write a Verilog program to implement Problem 5.17.6.
Write a Verilog program to implement Problem 5.19 (a).7.
Bill Rison, <ri[email protected] >
EE 231 Homework Assignment #9 http://www.ee.nmt.edu/~rison/ee231/hw/hw09.html
1 of 1 10 /28/2008 01:25 PM
pf3
pf4
pf5

Partial preview of the text

Download EE 231 HW 9: Solving Problems with D Flip-Flops & Verilog - Prof. William Rison and more Assignments Digital Electronics in PDF only on Docsity!

EE 231

Homework Assignment 9

Due Oct. 29, 2008

Probelm 5.16 (a). You do not have to draw the logic diagram. Just

find equations for the inputs to the two D flip-flops. T he output

of the circuit should be the present state. Is this a Mealy

machine or a Moore machine?

Problem 5.17. T he string of bits comes in least significant bit

first. Find the equation for the input to the D flip-flop, and draw

a logic diagram to implement the function. (Hint: T his function

can be implemented with only two states, so requires only one

flip-flop. From Page 11 of the text: "T he 2's complement can be

formed by leaving all least significant 0's and the first 1

unchanged, and replacing 1's with 0's and 0's with 1's in all

other higher significant digits.") Is this a Mealy machine or a

Moore machine?

Problem 5.19 (a). You do not have to draw the logic diagram. Just

find equations for the inputs to the D flip-flops. Is this a Mealy

machine or a Moore machine?

4. Problem 5.23.

5. Write a Verilog program to implement Problem 5.16 (a).

6. Write a Verilog program to implement Problem 5.17.

7. Write a Verilog program to implement Problem 5.19 (a).

Bill Rison, <[email protected] >

EE 231 Homework Assignment #9 http://www.ee.nmt.edu/~rison/ee231/hw/hw09.html

1 of 1 10/28/2008 01:25 PM

* Solve Probelm 5.19 (a) using state diagram directly */ module p_5_19 ( input clock, reset, x, output reg y );

reg [2:0] state;

always @ ( posedge clock, negedge reset) if (~reset) state <= 3’b000; else case (state) 3’b000: if (x) state <= 3’b100; else state <= 3’b011; 3’b001: if (x) state <= 3’b100; else state <= 3’b001; 3’b010: if (x) state <= 3’b000; else state <= 3’b010; 3’b011: if (x) state <= 3’b010; else state <= 3’b001; 3’b100: if (x) state <= 3’b011; else state <= 3’b010; 3’b101: state <= 3’bxxx; 3’b110: state <= 3’bxxx; 3’b111: state <= 3’bxxx; endcase

always @ (state, x) case (state) 3’b000: y = x; 3’b001: y = x; 3’b010: y = x; 3’b011: y = x; 3’b100: y = 1’b0; 3’b101: y = 1’bx; 3’b110: y = 1’bx; 3’b111: y = 1’bx; endcase

endmodule

_* Solve Probelm 5.19 (a) using combinatinal logic to generate next state

  • and outputs */_ module p_5_19 ( input clock, reset, x, output y );

reg A,B,C;

always @ ( posedge clock, negedge reset) if (~reset) {A,B,C} <= 3’b000; else begin A <= ~A & ~B & x; B <= A | (~C & ~x) | (B & C & x); C <= (A & x) | (C & ~x) | (~A & ~B & ~x); end

assign y = ~A & x;

endmodule

Oct 28, 08 11:46 hw09_soln.v Page 3/

Printed by

Tuesday October 28, 2008 hw09_soln.v 2/