Digital Logic RTL Amp Verilog Interview Questions Preview
Digital Logic RTL Amp Verilog Interview Questions Preview
m
RTL & Verilog
co
e.
Interview Questions
od
C
og
ril
Ve
VerilogCode.com
VerilogCode.com Page 1
Copyright © 2015 by VerilogCode.com
m
except for the use of brief quotations in a book review.
co
e.
Ordering Information:
od
Quantity sales. Special discounts are available on quantity purchases by corporations,
associations, and others. Orders by U.S. trade bookstores and wholesalers, please visit:
www.VerilogCode.com
C
og
Printed in the United States of America
ril
Ve
Revision 1.0
ISBN13:
9781512021462
ISBN10:
1512021466
www.VerilogCode.com
VerilogCode.com Page 2
Digital Logic
RTL & Verilog
m
Interview Questions
co
e.
od
C
og
ril
Ve
VerilogCode.com Page 3
m
co
e.
od
C
og
ril
Ve
VerilogCode.com Page 4
Digital logic
RTL & VeriloG
m
Interview Questions
co
e.
od
C
og
About the Author:
ril
Trey Johnson has been designing digital logic circuits and writing
Ve
RTL code in both Verilog and VHDL languages for almost twenty years.
Johnson has been granted three United States Patents for his
digital design solutions. He is the founder of
VerilogCode.comwhich is a
website dedicated to sharing information about Verilog and RTL design.
Please visit the website for more digital design and job interview
questions and to also share your own experiences.
VerilogCode.com Page 5
m
co
e.
od
C
og
ril
Ve
VerilogCode.com Page 6
m
co
e.
od
This book is dedicated to Brandi, Tucker, Gunner and Alexa
C
og
Thank you for riding with me on life’s waves of change,
ril
VerilogCode.com Page 7
m
co
e.
od
C
og
ril
Ve
VerilogCode.com Page 8
Table of Contents
Introduction…………………………………………… 17
m
co
RTL Logic Design Questions …………………..……. 29
e.
od
Clock Dividers, Clock Gating, and Reset Questions…. 49
C
og
Clock Domain Crossing Questions …………………. 59
ril
VerilogCode.com Page 9
m
co
e.
od
C
og
ril
Ve
VerilogCode.com Page 10
List of Questions
RTL Verilog Syntax Questions
m
4. Verilog code for bitwise reduction
co
5. Verilog code multiplying and dividing by powers of 2
6. Verilog code for sign extension and concatenation
e.
7. Write Verilog Code for asynchronous and synchronousFlip Flops
8. Verilog coding what are three ways to code a mux
od
9. What type of circuit would the synthesis tool create for mux code
10. Verilog code for latch versus flip flop and draw timing diagram
C
RTL Logic Design Questions
og
ril
11. Design a circuit to detect if a signal transitions in any direction
12. Design a circuit to detect a 1 cycle high pulse (synchronously)
Ve
VerilogCode.com Page 11
Clock Domain Crossing Questions
m
Power Related Questions
co
36. Describe two components of power
e.
37. Describe how to reduce static power
38. Describe how to reduce Dynamic power
od
39. Describe low power RTL coding techniques
C
Refresher: Digital Logic Questions og
40. What is definition of setup and hold time for a flip flop
ril
41. Venn Diagram and Boolean Logic
Ve
VerilogCode.com Page 12
List of Figures
1. Blocking Statements and Equivalent Gates (Fig. 1)
2. Nonblocking Statements and Equivalent Gates (Fig. 2)
3. Timing Diagram capture with latch and flip flop (Fig.3)
4. Latch vs. Flip Flop timing diagram (Fig. 4)
5. Equivalent Gates from RTL code in Ex. 11 (Fig. 5)
m
6. Timing Diagram for Edge Detection using clocks (Fig. 6)
co
7. Sequence Detector using FSM (Fig. 7)
8. Decoder Circuit Shift Register and Combinatorial Logic (Fig. 8)
e.
9. Write the Verilog code to produce the above waveform (Fig. 9)
od
10. Classic Synchronizer Circuit using 2 Flip Flops (Fig. 10)
11. Circuit to detect low to high transition (Fig. 11)
C
12. BCD to Gray Code (Fig. 12) og
13. Circuit to Generate Fibonacci Series (Fig. 13)
14. Write Verilog Code to Produce this Timing Diagram (Fig. 14)
ril
15. 5TAP Digital FIR filter
(Fig. 15)
Ve
m
1. Operator: & versus && (Ex. 1)
co
2. Operator: | versus || (Ex.2 )
3. Operator: ~ versus ! (Ex. 3)
e.
4. Bitwise Operators (Ex. 4)
od
5. Bitwise Reduction (Ex. 5)
6. Shift Operations (Ex. 6)
C
7. Concatenation Operations (Ex. 7)og
8. Verilog coding styles for a 4:1 mux (Ex. 8)
9. Priority Encoder
ril
(Ex. 9)
10. Parallel Muxing Scheme using full case statement (Ex. 10)
Ve
11. Verilog code for Latch and Flip Flop (Ex. 11)
12. Verilog Code for Edge Detection (Ex. 12)
13. Circuit to detect pulse
(Ex. 13)
14. Example Verilog Code for Fig. 9waveform (Ex. 14)
15. Verilog Code for 3bit Gray Code (Ex. 15)
16. Verilog code to convert BCD to Gray Code (Ex. 16)
17. FIFO control logic (Ex. 17)
18. FSM states for divisible by 3 circuit (Ex. 18)
19. Verilog code for Fibonacci Generation (Ex. 19)
20. Verilog code to generate one second, minute, and hour (Ex. 20)
21. Verilog Code for Fig. 14 Timing Diagram (Ex. 21)
22. Verilog Code for Clock Divide by 2 (Ex. 22)
23. Verilog Code for Clock Divide by 3 with 5050 duty cycle (Ex.23)
24. Example Verilog Code for Generic Clock Divide by N (Ex. 24)
25. Example Verilog Code for Glitch Free Clock Gate (Ex. 25)
26. Asynchronous Edge Detection Circuit with no clocks
(Ex. 26)
27. Verilog code for Reset synchronization (Ex. 27)
28. Start/Stop Conditions for Counters
(Ex. 28)
VerilogCode.com Page 14
List of Tables
1. Asynchronous versus Synchronous Flip Flops (Table 1)
2. Inverter Gate, Truth Table, and transistorlevel circuit
(Table 2)
3. NAND Gate, Truth Table, and transistorlevel circuit
(Table 3)
4. NOR Gate, Truth Table, and transistorlevel circuit (Table 4)
5. AND Gate, Truth Table, and transistorlevel circuit
(Table 5)
m
6. OR Gate, Truth Table, and transistorlevel circuit (Table 6)
co
7. Semiconductor Manufacturing Processing Nodes
(Table 7)
8. Truth Table for an Adder (Table 8)
e.
9. Inverter Implemented with 2:1 mux (Table 9)
od
10. AND Gate Implemented with 2:1 mux (Table 10)
11. OR Gate Implemented with 2:1 mux (Table 11)
C
12. NAND Gate Implemented with 2:1 mux and inverter (Table 12)
13. NOR Gate Implemented with 2:1 mux and inverter
og (Table 13)
14. XOR Gate Implemented with 2:1 mux and inverter (Table 14)
ril
15. XNOR Gate Implemented with 2:1 mux and inverter (Table 15)
16. XOR Gate Used as Controlled Inverter (Table 16)
Ve
VerilogCode.com Page 15
m
co
e.
od
C
og
ril
Ve
VerilogCode.com Page 16
Introduction
I’m 30,000 feet above the ground, on a plane headed to San Diego
for a job interview. I’m a little anxious, and I take some comfort in
looking out of the small window pane next to me. My eyes wander back
m
down to the magazine article sitting on my lap, then I read these words:
co
Transitions
“ .
That’s all life is, and it’s tougher than physics.
e.
From school to work to retirement to dead ”.
od
The magazine article is about children who are interviewing for
C
preschool, and the most important characteristic that the administrators
adapt
look for is how well can the child
og
to change with new surroundings
and new rules. But this article could have been written about me: an
ril
engineer who spent eighteen years working for the same company, and
Ve
Interviewing for a job is like going on a date; at first you may feel
a little nervous or awkward, but after some time and more interviews you
soon become more comfortable and confident. Do not get discouraged in
VerilogCode.com Page 17
the beginning! The job interviewing experience can be daunting. It will
test your mental toughness. I experienced headaches during my first few
interviews because of the long hours of mental stress. But the saying is
practice makes perfect
true that . After several more interview attempts, I
became more comfortable, developed a sense of calmness, and felt more
prepared to answer the questions.
m
I’ve encountered many different types of interview questions
co
ranging from real world practical examples, to academic textbook or
e.
theoretical questions (usually asked by people with PHDs with not much
od
practical experience), to tricky questions using some obscure circuit
(which would never be applicable in the real world), to behavioral
C
questions (usually asked by Human Resource representatives). This
og
book focuses on real world practical examples, and it also discusses some
of the tricky and obscure questions that are asked. Preparing for
ril
behavioral questions is important and is covered on our website.
Ve
This book is a great starting place for you to begin preparing for
your job interview. This book provides you with a broad range of
information and covers many topics. By the end of this book, you will
have more knowledge and insight into the types of digital design interview
questions being asked in the field of semiconductor digital design.
Remember that life will always bring about change, and it’s how
well you can transition and adapt that is important. Have a strong and
positive attitude and you will succeed!
VerilogCode.com Page 18
m
co
e.
od
C
og
ril
RTL Verilog Syntax Questions
Ve
VerilogCode.com Page 19
m
co
e.
od
C
og
ril
Ve
VerilogCode.com Page 20
1. What is the difference between blocking and
non-block statements, and when are they used?
m
evaluation and assignment is done. Consider the following code (E is
co
assigned the immediate new value of C):
e.
od
C
og
ril
Ve
VerilogCode.com Page 21
2. Explain the difference between logical and bitwise
operators
m
co
For bitwise operations resulting in an AND gate, use the & operator
e.
and
assign C = A & B; //This will create an gate
od
For conditional and
if statements, use the && operator
C
if ( cond1 == 1’b1 && cond2 == 1’b1) {...}
og
Operator: & versus &&
(Ex. 1)
ril
Ve
For conditional or
if statements , use the || operator
if ( cond1 == 1’b1 || cond2 == 1’b1) {...}
Operator: | versus ||
(Ex.2 )
VerilogCode.com Page 22
3. Write code for logic gates:
and, or, xor, nand, nor,
xnor
assign C = (A & B); AND
// gate
assign C = (A | B); OR
// gate
assign C = (A ^ B); XOR
// gate
assign C = ~(A & B); NAND
// gate
m
assign C = ~(A | B); NOR
// gate
co
assign C = ~(A ^ B); XNOR
// gate
e.
Bitwise Operators
(Ex. 4)
od
4. How can you bitwise reduce a multibit signal?
C
wire [15:0] databus; og
wire all_ones_detected;
ril
wire is_databus_odd;
Ve
wire signal_not_zero;
AND
assign all_ones_detected = &databus; // all the bits together;
assign is_databus_odd = ^databus; // XOR
all the bits together;
assign signal_not_zero = |databus; // OR all the bits together;
Bitwise Reduction
(Ex. 5)
VerilogCode.com Page 23
7. What are three ways to code a 4:1 mux in Verilog?
Assume the 4:1 mux inputs are named ‘A, B, C, D’, you will need
select
a 2bit output
line (to choose between 4 inputs) and have a 1bit :
Coding Style 1:
m
assign output = (select == 2’b00 ) ? A :
co
(select == 2’b01) ? B :
(select ==2’b10) ? C : D;
e.
od
Coding Style 2:
C
always @(*)
if (select == 2’b00) og
output <= A;
ril
else if (select == 2’b01)
Ve
output <= B;
else if (select == 2’b10)
output <=C;
else
output <= D;
Coding Style 3:
always @(*)
case (select):
2’b00: output <= A;
2’b01: output <= B;
2’b10: output <= C;
2’b11: output <= D;
end case;
Verilog coding styles for a 4:1 mux
(Ex. 8)
You could also instantiate a mux cell directly if it exists in your library.
VerilogCode.com Page 24
8. What circuit would synthesis create for previous
mux coding styles?
m
assign output = (select == 2’b00) ? A :
co
(select == 2’b01) ? B :
e.
(select ==2’b10) ? C :
D;
od
C
Style 2:
always @(*) og
if (select == 2’b00)
ril
output <= A;
Ve
VerilogCode.com Page 25
9. Write Code for Asynchronous/Synchronous Flip
Flops and discuss the pros and cons of each
Asynchronous Synchronous
m
negedge rst) If (!rst )
Verilog
co
If (!rst ) Q <= #1 1’b0;
Code Q <= #1 1’b0; else
e.
else Q <= #1 D;
Q <= #1 D;
od
C
og
ril
Schematic
Ve
VerilogCode.com Page 26
10. Write Verilog to capture input below with a latch
and a flip flop, and draw the timing outputs of each.
m
co
Timing Diagram capture input into a latch and flip flop
(Fig. 3)
e.
//purposely coding latch
od
always @(clk or input)
if (clk == 1’b1)
C
Q_latch <= input;
og
//flip flop coding a Latch
ril
always @(posedge clk)
Ve
The outputs of the latch and flip flop is below in the timing diagram:
The output of the flip flop only changes on the rising edge of clock, and
will equal the value of the input captured at the rising edge of clock. The
latch output will follow the input signal while the latch is open (in this
case while clock is high). When the latch closes (clock is low), the output
holds its previous value.
VerilogCode.com Page 27
m
co
e.
od
C
og
ril
Ve
VerilogCode.com Page 28
m
co
e.
od
C
og
ril
RTL Logic Design Questions
Ve
VerilogCode.com Page 29
m
co
e.
od
C
og
ril
Ve
VerilogCode.com Page 30
11. Design a circuit that can detect if an input signal
transitions in either direction. Draw a timing diagram.
For this answer let’s assume there is a clock available, and also the
input signal D is on the same clock domain as our circuit. As with all
interview questions, you should state your assumptions before answering
m
the questions or confirm with the interviewer so you are both on the same
co
page.
The easiest way to detect if an input signal has changed it simply
e.
compare current signal at time T to the previous version of the signal at
od
time t1. Therefore, a flip flop is used to capture the signal, and then you
can compare it to the previous version of the same signal:
C
og
//capture the signal to have a delayed version
ril
always @ ( posedge clk or negedge reset)
Ve
if (~reset)
Q <= #1 1'b0;
else
Q <= #1 D;
m
co
e.
od
C
og
Timing Diagram for Edge Detection using clocks
(Fig. 6)
ril
12. Design a circuit to detect a 1 cycle pulse input
Ve
Using delay states to remember the state of the signal for previous two
cycles, you can simple check for 0, 1, then 0. You could also use an FSM.
Circuit to detect pulse
(Ex. 13)
VerilogCode.com Page 32
13. Design a sequence detector for the pattern: 10110
m
state). You need to check if some of the sequence has already started and
co
go back to the appropriate state.
e.
od
C
og
ril
Ve
VerilogCode.com Page 33
This is the end of the free preview PDF.
m
figures and drawings, and 28 Verilog examples,
co
then please purchase the PDF from our website:
e.
od
C
VerilogCode.com
og
ril
Ve
VerilogCode.com Page 34