1. In a star connected three phase transformer the

* a) Three phases are connected together at the start point
* b) Three phases are separate
* c) Neutral conductor is connected to a single phase
* d) Neutral conductor is electrically separated

Answer - a

2. A single-phase double-wound transformer consists of

* a) A single core mounted winding
* b) A winding that carries the difference between IP and IS
* c) A single solid core
* d) Two electrically separated coils

Answer - d

3. One method of insulating windings is to use

* a) Shelac
* b) High reluctance silicon steel
* c) Low frequency dust cores
* d) PVC

Answer - a

4. The usual method of insulating core laminations is

* a) Low reluctance silicon steel
* b) Surface oxidization
* c) High frequency air cores
* d) Cellulose paper

Answer - b

5. If a motor is required to start against a large starting current, it is usual to use

* a) Direct on line starter
* b) Face plate starter
* c) Step down centre tapped starter
* d) Rotor resistance starter

Answer - d

6. In a shunt-wound motor the field coil is connected in

* a) Series with the armature
* b) Series with the motor
* c) parallel with the armature
* d) parallel with the motor

Answer - c

7. When the field windings of an electrical machine are not connected to its own armature, it is known as

* a) Self- excited
* b) Polyphase
* c) Separately-excited
* d) Synchronous

Answer - c

8. With a star-delta starter, the windings are brought out to a terminal box. The voltage applied to the windings at starting is

* a) VL ÷ v3
* b) VL x v3
* c) VPhase ÷ v3
* d) VPhase x v3

Answer - a

9. Particular starting arrangements are used when a motor has a rating greater than

* a) 370 microwatts
* b) 0.37 watts
* c) 37 watts
* d) 370 watts

Answer - d

10. An isolator built into a panel is used for

* a) Normal load switching
* b) Fault load switching
* c) Short circuit protection
* d) No load switching

Answer - d

Download Interview PDF

11. A device with a BS EN number has been

* a) Agreed for use only within the UK
* b) Agreed for operational use within the EU
* c) Standardized for all operational uses only in the UK
* d) Standardized for use in the EU

Answer - d

12. Q8 BS 7671 provides appropriate advice on

* a) Heights of panels
* b) Design of panels
* c) Environmental conditions
* d) Instrumentation

Answer - c

13. What degree of protection is specified for protection against a BS finger?

* a) IP4XB
* b) IP5XB
* c) IP6XB
* d) IPXXB

Answer - d

14. Which of the following is statutory?

* a) BS 7671
* b) On-Site Guide
* c) Electricity at Work Regulations
* d) GS 38

Answer - c

15. Which of the following are appropriate tests for a completed panel?

* a) Flash testing of components
* b) Insulation resistance and polarity
* c) Inspection of conductors for current carrying capacity
* d) Identification of conductors

Answer - b

16. The purpose of a switch is to open or close a circuit

* a) In the event of a fault current
* b) Under load conditions
* c) Under overload conditions
* d) Automatically after a fault has been repaired

Answer - b

17. A common type of cable termination used for ribbon cables in panel building is

* a) Pin
* b) Lug
* c) Insulation displacement
* d) Screw

Answer - c

18. A moving coil meter is not used on an ac circuit because

* a) It cannot read very small variations
* b) The direction of the deflection depends upon the direction of the current
* c) It is non linear
* d) It does not use the damping effect

Answer - b

19. To ensure safe isolation, voltage indicating devices

* a) Must comply with BS 7671
* b) Are used to prove the circuit dead only
* c) Are used to prove the circuit was alive only
* d) Must be “proved” prior to and “re-proved” after isolation

Answer - d

20. Which of the following is not a factor, which would affect the type of termination?

* a) Circuit design current
* b) Physical space around terminations
* c) Presence of solid foreign bodies
* d) Size of conductor

Answer - c

21. Which of the following has an adverse effect on installed equipment?

* a) Eddy current damping
* b) Air damping
* c) Ambient temperature
* d) Operating temperature

Answer - c

22. The purpose of a visual inspection is to ensure compliance with BS 7671, Section

* a) 601
* b) 712
* c) 413
* d) 314

Answer - b

23. The purpose of a method statement is to

* a) Ensure compliance with BS 7671
* b) Identify a safe working practice
* c) Provide a training document for staff
* d) Provide instructions to be followed at all times

Answer - b

24. Electrostatic sensitive equipment, in transit, need not be protected against damage from

* a) High temperature
* b) Dust and fibers
* c) Moisture ingress
* d) Day light

Answer - d

25. To facilitate ease of installation and assembly of equipment reference is made to

* a) BS 7430
* b) Manufacturer's catalogues
* c) GS 38
* d) Data charts

Answer - d

Download Interview PDF

26. When a voltmeter is connected in a circuit it is essential that it

* a) Has a very low resistance
* b) Has a very high resistance
* c) Is connected in series with the supply
* d) Is connected in series with the load

Answer - b

27. When an ammeter is connected in a circuit it is essential that it

* a) Has a very low resistance
* b) Has a very high resistance
* c) Is connected across the supply
* d) Is connected across the load

Answer - a

28. Which of the following has an impact upon earthing?

* a) BS EN 60439-01
* b) BS 4491
* c) BS 4444
* d) BS EN 60898

Answer - c

29. Which of the following is a statutory piece of legislation?

* a) BS 7671
* b) IEE Guidance Notes
* c) Electricity at Work Regulations
* d) IEE On-Site Guide

Answer - c

30. Which of the following lamps would not normally form part of a highway electrical system?

* a) Low pressure mercury (T8-T12)
* b) Low pressure mercury (MBF)
* c) Metal halide (MBI)
* d) Incandescent Lamp (100W)

Answer - d

31. Which legislation states the need to avoid live working unless unreasonable in all circumstances?

* a) BS 7671
* b) Guidance Notes 3
* c) On-Site Guide
* d) The Electricity at Work Regulations

Answer - d

32. To facilitate safe isolation, voltage indicating devices

* a) Must comply with BS 7671
* b) Are used to prove the circuit was dead only
* c) Are used to prove the circuit was alive only
* d) Are “proved” prior to and “re-proved” after isolation

Answer - d

33. Instruments should be regularly calibrated to

* a) Support local industry
* b) Ensure accuracy when testing
* c) Ensure operative is up to date
* d) Provide a training exercise for operatives

Answer - b

34. Relevant information for re commissioning street furniture can be found in

* a) IEE Guidance Notes 7
* b) Works instructions
* c) The Electricity Supply Regulations
* d) The Petroleum (Consolidation) Act 1928

Answer - b

35. Voltage indication devices need to be proved to ensure

* a) That the lamp has not gone
* b) That the highway furniture has been installed correctly
* c) Safe working conditions
* d) The correct operation of street furniture

Answer - c

36. It is necessary to avoid skin contact with quartz lamps, as it

* a) Reduces the life of the lamp
* b) Could cause burns
* c) Generates excessive heat
* d) Lengthens lampworking life

Answer - a

37. Which of the following is a statutory document applicable to operatives carrying out installation and maintenance of highway electrical equipment?

* a) The Laying of Cables in Public Highways
* b) H.S.E guidance H.S.G 47 (Avoiding danger from underground and overhead services)
* c) The Personal Protective Equipment at Work Regulations
* d) Electricity Association G39/1

Answer - c

38. Which of the following is a non-statutory document?

* a) The New Roads and Street Works Act
* b) The Electricity Safety, Quality, and Continuity Regulations 2002
* c) BS 7671
* d) The Electrical Equipment (Safety) Regulations

Answer - c

39. Which of the following normally form part of a highway electrical system?

* a) Current transformers and photoelectrical control units
* b) Voltage transformers and RCD's
* c) Igniters and transformers
* d) Power factor meter and isolators

Answer - c

40. Low-pressure mercury- vapor lamps should be disposed of by

* a) Throwing in a skip
* b) Putting in a glass recycle point (clear glass only)
* c) Using a suitable lamp crusher
* d) Putting in the refuse bins, which are collected weekly?

Answer - c

Download Interview PDF

41. When carrying out maintenance work on a distribution board in a busy walkway, it is advisable to protect others by the use of a

* a) Warning sign
* b) Safety barrier
* c) Temporary bollard
* d) Audible warning device

Answer - b

42. In order to understand the operating procedure for a particular item of equipment, the best source of information would be the

* a) Company sales representative
* b) Manufacturers' manual
* c) Manufacturers' catalogue
* d) Circuit diagram

Answer - b

43. Guidance on regular inspection and testing of portable appliances can be found in

* a) BS 7671 Requirements for Electrical Installation
* b) IEE Guidance Note 3 Inspection and testing
* c) IEE Code of Practice for In-Service Inspection and Testing of Electrical Equipment
* d) IEE on Site Guide

Answer - c

44. Certain discharge luminaries mounted above rotating machine can give the appearance that the machine is at a standstill. This effect is known as

* a) Stroboscopic effect
* b) Robotic effect
* c) Rotor effect
* d) Telescopic effect

Answer - a

45. Once a low-pressure mercury vapour lamp has lit, the purpose of the choke/ballast unit is to

* a) Discharge voltage
* b) Correct power factor
* c) Suppress radio interference
* d) Limit lamp current

Answer - d

46. Balancing loads over three phases will reduce

* a) Phase currents
* b) Earth faults
* c) Neutral currents
* d) Overloads

Answer - c

47. In order to facilitate maintenance of a complex electrical system, the sequence of control for isolation can be best shown using a

* a) Block diagram
* b) Layout drawing
* c) Circuit diagram
* d) Bar chart

Answer - a

48. In order to prevent danger during maintenance operations, a voltage warning notice is required on all electrical accessories where

* a) Voltage is present
* b) The voltage exceeds 230V and such voltage would not be expected
* c) The voltage exceeds 400V
* d) The voltage is below 230V

Answer - b

49. The Electricity at Work Regulations state that electrical equipment must be maintained to prevent danger. Electrical equipment is defined as all small items of battery-powered equipment up to and including overhead power lines rated at

* a) 230V
* b) 400V
* c) 33kV
* d) 400kV

Answer - d

50. The four electrical tests that should be carried out on a new ring final circuit before it is energized are

* a) Continuity of protective conductors, continuity of ring final circuits, insulation, - resistance and polarity
* b) Continuity of ring final circuits, insulation resistance, polarity, and earth fault loop - impedance
* c) Insulation resistance, polarity, earth fault loop impedance and continuity of protective - conductors
* d) Polarity, earth fault loop-impedance, continuity of protective conductors and Continuity of ring final circuits

Answer - a

51. A 50 mm x 50 mm steel trunking has a tabulated space factor of 1037. If the tabulated factor for PVC cable having a cross sectional area of 6 mm2 is 21.2, the maximum number of these cables that can be installed into the trunking is

* a) 47
* b) 48
* c) 49
* d) 50

Answer - b

52. The most suitable item of equipment to mark a straight line in order to install a horizontal conduit over a distance of 4 m is a

* a) Plumb line
* b) Spirit level
* c) Steel tape
* d) Chalk line

Answer - d

53. A residual current device will disconnect under

* a) short circuit conditions only
* b) Both earth fault and short circuit conditions
* c) Earth fault conditions only
* d) Overload conditions only

Answer - c

54. An earthing arrangement that has a PEN conductor is

* a) TN-C-S
* b) TN-S
* c) TT
* d) IT

Answer - a

55. A non-maintained emergency light is classified as NM3. This means that the luminary will illuminate during

* a) Normal conditions then automatically switch off after three hours
* b) Any power failure for up to three hours
* c) Both normal and power failure conditions then automatically switch off after three hours
* d) Power failures that last longer than three hours but not shorter than three hours

Answer - b

Download Interview PDF

56. A circuit wired in 1.5 mm2 thermoplastic (PVC) twin with CPC cable is protected by a 16 A device and is used to supply a 230 V 3 kW water heater. If the cable has a rated voltage drop of 29 mV/A/m and the circuit is 24 m long, the actual voltage drop will be

* a) 2.08V
* b) 9.07V
* c) 11.14V
* d) 69V

Answer - b

57. The maximum operating temperature for a thermoplastic (pace) insulated cable with copper conductors is

* a) 60 OC
* b) 70 OC
* c) 105 OC
* d) 160 OC

Answer - b

58. For a drawing having a scale of 1:50, a wall 10 m long would be drawn to a length of

* a) 10 mm
* b) 20 cm
* c) 50 cm
* d) 10050 mm

Answer - b

59. Which of the following is a non-statutory regulation?

* a) Electricity at Work Regulations
* b) Health and Safety at Work Act
* c) Electricity Safety, Quality, and Continuity Regulations
* d) BS 7671- Requirements for Electrical Installations

Answer - d

60. If a circuit protective device requires 200 A in order to disconnect in the required time, the overall impedance of the earth fault path for a 230 V circuit protected by the device must not exceed

* a) 0.86 O
* b) 1.15 O
* c) 2.15 O
* d) 2.30 O

Answer - b

61. Which of the following is a transmission voltage?

* a) 400 kV
* b) 33 kV
* c) 400 V
* d) 230 V

Answer - a

62. The ratio of the true power to apparent power in an ac circuit is the

* a) Power consumption
* b) Harmonic current
* c) Power factor
* d) Reactive power

Answer - c

63. In order to determine the amount of accessories required for a particular contract, the best method would be to use the layout drawings and a

* a) Site diary
* b) Take off sheet
* c) Day work sheet
* d) Time sheet

Answer - b

64. In order to prove safe isolation of an electrical circuit, it is essential to use

* a) A multi-meter
* b) An insulation resistance tester
* c) An approved voltage indicator
* d) A low reading ohmmeter

Answer - c

65. A suitable means of recording the number of visitors on a large construction site is by the use of a

* a) Day work sheet
* b) Timesheet
* c) Take off sheet
* d) Visitors book

Answer - d

66. On a large construction site, inductions are carried out for new members of staff in order to inform them of the

* a) Location of the canteen
* b) Requirements within BS 7671
* c) Fire safety procedure
* d) Location of the nearest wholesaler

Answer - d

67. Before any work is done within an electrical installation, the first procedure would be to

* a) Carry out a risk assessment
* b) Turn off the main switch
* c) Remove all components
* d) Install temporary supplies

Answer - c

68. The order in which they should be carried out is

* a) 1, 3, 2, 4, 5
* b) 1, 2, 3, 4, 5
* c) 2, 1, 4, 3, 5
* d) 2, 3, 1, 4, 5

Answer - a

69. The five main stages of the risk assessment procedure are:

* a) Identify
* b) Evaluate
* c) Record
* d) Implement
* e) Review

Answer - b

70. A particular extension lead used on a construction site is colored yellow to

* a) Indicate its mechanical stress properties
* b) Enable it to be seen in the dark
* c) Indicate the supply voltage to it
* d) Enable it to be to be identified as suitable for site use

Answer - c

Download Interview PDF

71. A 110 V, centre-tapped earth, reduced low voltage supply for power tools provides a voltage of

* a) 25 V between live conductors
* b) 55 V to earth
* c) 110 V to earth
* d) 12 V SELV

Answer - b

72. The purpose of a bonding conductor is to provide

* a) An earth fault path
* b) An equal potential zone
* c) Short circuit protection
* d) Overload protection

Answer - b

73. The white or grey PVC outer layer of a twin and CPC flat thermoplastic (PVC) cable is the

* a) conductor
* b) Insulation
* c) Conductor
* d) Sheath

Answer - d

74. A mass of 20 kg is to be raised by a hoist 2 m in 30 seconds. Assuming no losses, the power required to raise this load is

* a) 13.08 Watts
* b) 196.2 Watts
* c) 392.4 Watts
* d) 1200 Watts

Answer - a

75. Where P = V I. The value V can be determined using

* a) V = _I_P
* b) V = P I
* c) V = P - I
* d) V = _P_I

Answer - d

76. Four resistors having values of 2 O, 2 O, 5 O, and 20 O are connected in a parallel circuit arrangement. The total resistance of this circuit is

* a) 0.8 O
* b) 1.25 O
* c) 29 O
* d) 400 O

Answer - a

77. An increase in current through a conductor will lead to

* a) A decrease in conductor temperature
* b) A decrease in conductor resistance
* c) An increase in insulation resistance
* d) An increase in conductor temperature

Answer - d

78. A single rotation of an alternator, intended to provide a 50 Hz supply frequency, will take

* a) 2 ms
* b) 20 ms
* c) 50 ms
* d) 5000 ms

Answer - b

79. The Tesla is the unit of

* a) Magnetic flux
* b) Molecular flux
* c) Magnetic flux density
* d) Molecular flux density

Answer - c

80. Using a scale of 1:50, a 10 mm measurement taken from a plan would be equal to an actual measurement of

* a) 5 mm
* b) 5 cm
* c) 0.5 m
* d) 5 m

Answer - c

81. To ensure that a particular item of electro technical equipment meets a particular British Standard or BSEN Harmonized Standard, the best source of information would be the

* a) manufacturer of the equipment
* b) British Standards Institute
* c) Institute of Electrical Engineers
* d) Supplier of the equipment

Answer - a

82. An independent regulatory body responsible for monitoring standards of electrical installation contractors is the

* a) Electrical Institute Council
* b) Institute of Electrical Engineers
* c) National Electrical Contractors Institute Inspection Council
* d) National Inspection Council for Electrical Installation Contractors

Answer - d

83. CO2 fire extinguishers are indicated by the color code

* a) Black
* b) Red
* c) Beige
* d) Blue

Answer - a

84. The type of fire extinguisher, which would not be suitable for flammable liquids, is

* a) Dry powder
* b) Water
* c) Carbon dioxide
* d) Foam

Answer - b

85. First aid points are indicated using signs bearing a white cross on a

* a) Yellow background
* b) Blue background
* c) Red background
* d) Green background

Answer - d

Download Interview PDF

86. When carrying out repairs to the base of a street lighting column it is essential to wear

* a) A safety harness
* b) High visibility clothes
* c) Gauntlets
* d) High voltage clothing

Answer - b

87. Prior to using an electric saw on a construction site, a user check finds that the insulation on the supply flex is damaged. The correct procedure would be to

* a) Replace the cord with a new one
* b) Report the damage to a supervisor after use
* c) Repair the cord with insulation tape
* d) Report the damage to a supervisor before use

Answer - d

88. Which of the following documents is non-statutory?

* a) Health and Safety at Work Act
* b) Electricity at Work Regulations
* c) COSHH
* d) BS 7671- Requirements for Electrical Installations

Answer - d

89. Draw the state diagram for a circuit that outputs?

Draw the state diagram for a circuit that outputs a "1" if the aggregate serial binary input is divisible by 5. For instance, if the input stream is 1, 0, 1, we output a "1" (since 101 is 5). If we then get a "0", the aggregate total is 10, so we output another "1" (and so on).

We don't need to keep track of the entire string of numbers - if something is divisible by 5, it doesn't matter if it's 250 or 0, so we can just reset to 0. So we really only need to keep track of "0" through "4".

90. Design a four-input NAND gate using only two-input NAND gates

Basically, you can tie the inputs of a NAND gate together to get an inverter, so...

91. Explain the differences between "Direct Mapped", "Fully Associative", and "Set Associative" caches

If each block has only one place it can appear in the cache, the cache is said to be direct mapped. The mapping is usually (block-frame address) modulo (number of blocks in cache).
If a block can be placed anywhere in the cache, the cache is said to be fully associative.
If a block can be placed in a restricted set of places in the cache, the cache is said to be set associative. A set is a group of two or more blocks in the cache. A block is first mapped onto a set, and then the block can be placed anywhere within the set. The set is usually chosen by bit selection; that is, (block-frame address) modulo (number of sets in cache). If there are n blocks in a set, the cache placement is called n-way set associative.

92. Given the following FIFO and rules, how deep does the FIFO need to be to prevent underflowing or overflowing?

Given the following FIFO and rules, how deep does the FIFO need to be to prevent underflowing or overflowing?
RULES:
1) frequency(clk_A) = frequency(clk_B) / 4
2) period(en_B) = period(clk_A) * 100
3) duty_cycle(en_B) = 25%



Assume clk_B = 100MHz (10ns)

From (1), clk_A = 25MHz (40ns)

From (2), period(en_B) = 40ns * 400 = 4000ns, but we only output for 1000ns, due to (3), so 3000ns of the enable we are doing no output work.

Therefore, FIFO size = 3000ns/40ns = 75 entries.

93. Write a function to output a diamond shape according to the given (odd) input?

Examples: Input is 5 Input is 7


* *
*** ***
***** *****
*** *******
* *****
***
*


### BEGIN PERL SNIPET ###
for ($i = 1; $i <= (($input * 2) - 1); $i += 2) {
if ($i <= $input) {
$stars = $i;
$spaces = ($input - $stars) / 2;
while ($spaces--) { print " "; }
while ($stars--) { print "*"; }
} else {
$spaces = ($i - $input) / 2;
$stars = $input - ($spaces * 2);
while ($spaces--) { print " "; }
while ($stars--) { print "*"; }
}
print "n";
}
### END PERL SNIPET ###

94. Write a function to determine whether a string is a palindrome (same forward as reverse, such as "radar" or "mom")

/* BEGIN C SNIPET */

#include

void is_palindrome ( char *in_str ) {
char *tmp_str;
int i, length;

length = strlen ( *in_str );
for ( i = 0; i < length; i++ ) {
*tmp_str[length-i-1] = *in_str[i];
}
if ( 0 == strcmp ( *tmp_str, *in_str ) ) printf ("String is a palindrome");
else printf ("String is not a palindrome");
}

/* END C SNIPET */

95. In C, explain the difference between the & operator and the * operator?

& is the address operator, and it creates pointer values.
* is the indirection operator, and it preferences pointers to access the object pointed to.

Example:
In the following example, the pointer ip is assigned the address of variable i (&i). After that assignment, the expression *ip refers to the same object denoted by i:

int i, j, *ip;
ip = &i;
i = 22;
j = *ip; /* j now has the value 22 */
*ip = 17; /* i now has the value 17 */

96. Write the code for finding the factorial of a passed integer. Use a recursive subroutine?

// BEGIN PERL SNIPET

sub factorial {
my $y = shift;
if ( $y > 1 ) {
return $y * &factorial( $y - 1 );
} else {
return 1;
}
}

// END PERL SNIPET

97. Write the code to sort an array of integers?

/* BEGIN C SNIPET */

void bubblesort (int x[], int lim) {
int i, j, temp;

for (i = 0; i < lim; i++) {
for (j = 0; j < lim-1-i; j++) {

if (x[j] > x[j+1]) {
temp = x[j];
x[j] = x[j+1];
x[j+1] = temp;

} /* end if */
} /* end for j */
} /* end for i */
} /* end bubblesort */

/* END C SNIPET */

Some optimizations that can be made are that a single-element array does not need to be sorted; therefore, the "for i" loop only needs to go from 0 to lim-1. Next, if at some point during the iterations, we go through the entire array WITHOUT performing a swap, the complete array has been sorted, and we do not need to continue. We can watch for this by adding a variable to keep track of whether we have performed a swap on this iteration.

98. What is the difference between running the following snipet of code on Verilog vs Vera?

What is the difference between running the following snipet of code on Verilog vs Vera?

fork {
task_one();
#10;
task_one();
}

task task_one() {
cnt = 0;
for (i = 0; i < 50; i++) {
cnt++;
}
}

99. Using the given, draw the waveforms for the following versions of a?

Using the given, draw the waveforms for the following versions of a (each version is separate, i.e. not in the same run):
reg clk;
reg a;

always #10 clk = ~clk;

(1) always @(clk) a = #5 clk;
(2) always @(clk) a = #10 clk;
(3) always @(clk) a = #15 clk;

Now, change a to wire, and draw for:

(4) assign #5 a = clk;
(5) assign #10 a = clk;
(6) assign #15 a = clk;

100. What is the difference between:
c = foo ? a : b;
and
if (foo) c = a;
else c = b;

The ? merges answers if the condition is "x", so for instance if foo = 1'bx, a = 'b10, and b = 'b11, you'd get c = 'b1x.
On the other hand, if treats Xs or Zs as FALSE, so you'd always get c = b.

Download Interview PDF

101. What is the difference between the following two lines of Verilog code?

What is the difference between the following two lines of Verilog code?
#5 a = b;
a = #5 b;


#5 a = b; Wait five time units before doing the action for "a = b;".
The value assigned to a will be the value of b 5 time units hence.

a = #5 b; The value of b is calculated and stored in an internal temp register.
After five time units, assign this stored value to a.

102. Given the following snipet of Verilog code draw out the waveforms for clk?

Given the following snipet of Verilog code, draw out the waveforms for clk and a
always @(clk) begin
a = 0;
#5 a = 1;
end


10 30 50 70 90 110 130
___ ___ ___ ___ ___ ___ ___
clk ___| |___| |___| |___| |___| |___| |___| |___


a ___________________________________________________________


This obviously is not what we wanted, so to get closer, you could use
"always @ (posedge clk)" instead, and you'd get


10 30 50 70 90 110 130
___ ___ ___ ___ ___ ___ ___
clk ___| |___| |___| |___| |___| |___| |___| |___

___ ___
a _______________________| |___________________| |_______

103. Given the following Verilog code, what value of "a" is displayed?

Given the following Verilog code, what value of "a" is displayed?
always @(clk) begin
a = 0;
a <= 1;
$display(a);
end


This is a tricky one! Verilog scheduling semantics basically imply a four-level deep queue for the current simulation time:

1: Active Events (blocking statements)
2: Inactive Events (#0 delays, etc)
3: Non-Blocking Assign Updates (non-blocking statements)
4: Monitor Events ($display, $monitor, etc).

Since the "a = 0" is an active event, it is scheduled into the 1st "queue". The "a <= 1" is a non-blocking event, so it's placed into the 3rd queue. Finally, the display statement is placed into the 4th queue.
Only events in the active queue are completed this sim cycle, so the "a = 0" happens, and then the display shows a = 0. If we were to look at the value of a in the next sim cycle, it would show 1.

104. What is the difference between a Verilog task and a Verilog function?

The following rules distinguish tasks from functions:
A function shall execute in one simulation time unit;
a task can contain time-controlling statements.
A function cannot enable a task;
a task can enable other tasks or functions.
A function shall have at least one input type argument and shall not have an output or inout type argument;
a task can have zero or more arguments of any type.
A function shall return a single value; a task shall not return a value.