0% found this document useful (0 votes)
57 views

Chapter 6. Dataflow Modeling: 6.7 Exercises

1. A full subtractor module is described with Verilog including I/O ports and logic equations for the difference (D) and borrow (B) outputs. It is instantiated and tested with all input combinations from a truth table. 2. A 4-bit magnitude comparator module is described with Verilog to compare two 4-bit inputs A and B bit-by-bit using an intermediate xnor variable and logic equations for outputs indicating if A is greater than, less than, or equal to B. 3. A 4-bit synchronous counter module is described with Verilog using master-slave JK flip-flops, a clear signal, and count enable signal. It is instantiated and tested with different

Uploaded by

Raffi Sk
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views

Chapter 6. Dataflow Modeling: 6.7 Exercises

1. A full subtractor module is described with Verilog including I/O ports and logic equations for the difference (D) and borrow (B) outputs. It is instantiated and tested with all input combinations from a truth table. 2. A 4-bit magnitude comparator module is described with Verilog to compare two 4-bit inputs A and B bit-by-bit using an intermediate xnor variable and logic equations for outputs indicating if A is greater than, less than, or equal to B. 3. A 4-bit synchronous counter module is described with Verilog using master-slave JK flip-flops, a clear signal, and count enable signal. It is instantiated and tested with different

Uploaded by

Raffi Sk
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Chapter 6.

Dataflow Modeling
6.7 Exercises 1. A full subtractor has three 1-bit inputs x,y,and z(previous borrow) and two 1-bit outputs D(difference) and B(borrow). The logic equations for D and B are as follows: D=x.y.z + x.y.z + x.y.z + x.y.z B=x.y + x.z + y.z Write the full Verilog description for the substractor module, including I/O ports (Remember that + in logic equations corresponds to a logical or operator (||) in dataflow). Instantiate the subtractor inside a stimulus block and test all eight possible combinations of x,y,and z given in the following truth table. X 0 0 0 0 1 1 1 1 my answer: Y 0 0 1 1 0 0 1 1 Z 0 1 0 1 0 1 0 1 B 0 1 1 1 0 0 0 1 D 0 1 1 0 1 0 0 1

2. A magnitude comparator checks if one number is greater than or equal to or less than another number. A 4-bit magnitude comparator takes two 4-bit numbers, A and B, as input. We write the bits in A and B as follows. The leftmost bit is the most significant bit. A=A(3)A(2)A(1)A(0) B=B(3)B(2)B(1)B(0)

The magnitude can be compared by comparing the numbers bit by bit, starting with the most significant bit. If any bit mismatches, the number with bit 0 is the lower number. To realize this functionality in logic equations, let us define an intermediate variable. Notice that the function below is an xnor function. x(i)=A(i)B(i)+A(i)B(i) The three outputs of the magnitude comparator are A_gt_B,A_lt_B,A_eq_B. They are define with the following logic equations: A_gt_B=A(3)B(3) + x(3).A(2).B(2)' + x(3).x(2).A(1).B(1)' + x(3).x(2).x(1).A(0).B(0)' A_lt_B = A(3)'.B(3) + x(3).A(2)'.B(2) + x(3).x(2).A(1)'.B(1) + x(3).x(2).x(1).A(0)'.B(0) A_eq_B = x(3).x(2).x(1).x(0) Write the Verilog description of the module magnitude_comparator. Instantiate the magnitude comparator inside the stimulus module and try out a few combinations of A and B. my answer:

3. A synchronous counter can be designed by using master-slave JK flipflops. Design a 4-bit synchronous counter. Circuit diagrams for the synchronous counter and the JK flipflop are given below. The clear signal is active low. Data gets latched on the positive edge of clock, and the output of the flipflop appears on the negative edge of clock. Counting is disabled when count_enable signal is low. Write the dataflow description for the synchronous counter. Write a stimulus file that exercises clear and count_enable. Display the output count Q[3:0].

my answer: ps6.6 J

You might also like