1. What is a State Machine? What Are the Different Types? Explain the Difference? Which One is Most Preferable?
A state machine is a sequential logic circuit that transitions between different states based on input signals and a predefined logic. It is used to model the behavior of digital systems.
Types of State Machines:
- Moore State Machine: The output depends only on the current state.
- Mealy State Machine: The output depends on both the current state and the current inputs.
Difference:
- Moore machines are easier to design but might require more states compared to Mealy machines.
- Mealy machines produce faster outputs since they depend directly on inputs.
Most Preferable: Mealy machines are preferred in applications where speed is critical, whereas Moore machines are used when simplicity is a priority.
2. How Many 4×1 Mux Are Required for the Design of a 128×1 Mux?
To design a 128×1 multiplexer, we need 127 4×1 multiplexers.
Explanation: The hierarchical structure requires multiple stages:
- First, group the 128 inputs into sets of 4, requiring 32 multiplexers.
- Then, use 8 multiplexers for the next level, followed by 2 multiplexers, and finally 1 at the top level. Total = 32 + 8 + 2 + 1 = 43.
3. Which Flip-Flop Is Basically Used for Designing a Shift Register and Why?
D flip-flops are used for designing shift registers because they can store and shift data reliably. They have a simple setup where the output directly follows the input on the active clock edge, making them ideal for sequential shifting.
4. One Boolean Expression Will Be Given and You Have to Minimize the Expression.
When minimizing Boolean expressions:
- Use Karnaugh Maps (K-Maps) or Boolean algebra rules.
- Always verify the order of variables given in the question.
- For full adder expressions:
- Sum = A ⊕ B ⊕ C
- Carry = AB + BC + AC
5. What is Setup and Hold Time? Explain.
- Setup Time: The minimum time a signal must be stable before the clock edge.
- Hold Time: The minimum time a signal must remain stable after the clock edge.
These parameters ensure reliable data capture by flip-flops or latches.
6. Which Logic Gates Are Called Universal Logic Gates and Why?
NAND and NOR gates are called universal gates because they can be used to implement any Boolean function or logic circuit.
7. Design a Sequence Detector to Detect (1101)2.
A sequence detector can be designed using a Mealy or Moore state machine with the following steps:
- Define states for each partial match.
- Use flip-flops to implement state transitions.
- Design the output logic to trigger on the detection of “1101.”
Verilog/VHDL Questions:
8. Explain Blocking and Nonblocking Assignment.
- Blocking Assignment (
=
): Executes sequentially. Example: a = b; c = a;
- Nonblocking Assignment (
<=
): Executes concurrently. Example: a <= b; c <= a;
9. Which Assignment Will Be Used for Designing Combinational Logic Circuits?
Blocking assignments are typically used for combinational logic to ensure sequential execution within procedural blocks.
10. Write Verilog Code for 4×1 Multiplexer with Blocking and Nonblocking Assignments. Comment on the Output.
Blocking Assignment:
module mux_4x1_blocking(output reg y, input [3:0] d, input [1:0] sel);
always @(*) begin
if (sel == 2'b00) y = d[0];
else if (sel == 2'b01) y = d[1];
else if (sel == 2'b10) y = d[2];
else y = d[3];
end
endmodule
Nonblocking Assignment:
module mux_4x1_nonblocking(output reg y, input [3:0] d, input [1:0] sel);
always @(*) begin
if (sel == 2'b00) y <= d[0];
else if (sel == 2'b01) y <= d[1];
else if (sel == 2'b10) y <= d[2];
else y <= d[3];
end
endmodule
Comment: Both codes give the same output for combinational circuits. Nonblocking is more suited for sequential logic.
11. What is the Difference Between Reg
and Wire
Datatype?
- Reg: Stores values and is used in procedural blocks.
- Wire: Represents continuous connections and cannot store values.
12. Explain the Difference Between FPGA Design Flow and ASIC Design Flow.
- FPGA Design Flow: Faster and reprogrammable.
- ASIC Design Flow: More time-consuming and requires fabrication but offers better performance.
13. Some Names of FPGA Vendors.
Xilinx, Intel (Altera), Lattice, Microchip, Achronix.
14. In Which Sectors or Applications Are FPGAs Used Mostly and Why?
- Sectors: Telecom, AI/ML, aerospace, and automotive.
- Why: High flexibility and real-time performance.
15. What is the Difference Between Task and Function?
- Task: Can include delays and have multiple outputs.
- Function: Executes in zero time and returns a single value.
16. Write a Task to Detect the Bigger Number Between Two Integers.
task find_bigger(input integer a, input integer b, output integer bigger);
begin
if (a > b)
bigger = a;
else
bigger = b;
end
endtask
17. There are 8 identical balls among which one is defective . Explain how many minimum number of iterations are required to detect defective ball. (The defective ball will be having either lesser or higher weight then other balls).
- Approach:
- Divide the balls into three groups.
- Compare two groups:
- If balanced, the defective ball is in the third group.
- If unbalanced, it is in the heavier/lighter group.
- Repeat with the identified group.
- Minimum Iterations: 3. Divide into 3, then 1.
module detect_defective_ball;
int balls[8] = '{10, 10, 10, 10, 10, 10, 10, 9};
// One defective ball
int group1, group2, group3;
task compare_groups(input int g1, input int g2, input int g3);
if (g1 != g2) begin
if (g1 < g2) $display("Defective ball is in Group 1");
else $display("Defective ball is in Group 2");
end else begin
$display("Defective ball is in Group 3");
end
endtask
initial begin
group1 = balls[0] + balls[1] + balls[2];
group2 = balls[3] + balls[4] + balls[5];
group3 = balls[6] + balls[7];
compare_groups(group1, group2, group3);
end
endmodule