Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Best Engineering Interviews:Aeronautical EngineeringAgricultural EngineeringApplied EngineeringAssociate EngineeringAutomobile EngineeringBio EngineeringBiomedical EngineerBiomedical EngineeringBuilding Services EngineeringCAD/CAE EngineerChemical EngineeringCivil EngineeringDAE Knitting EngineersDeputy Chief Financial OfficerDesktop EngineerDiesel MechanicElectrical EngineeringElectronics CommunicationsElectronics EngineeringEmbedded Software EngineerEnergy EngineeringEnergy Oil GasEngineeringGalvanizing EngineerIndustrial EngineeringInstrumentation EngineeringLaptop RepairerMachine Learning EngineerMachine OperatorMarine EngineeringMechanical EngineeringMechatronics EngineeringNetwork EngineerNuclear EngineeringPetroleum EngineeringPlant Reliability EngineerPlumberPre EngineeringProduction EngineerRF EngineerSystem EngineeringTextile Engineer
Copyright © 2018. All Rights Reserved
Electrical Engineering Interview Question:
Given the following Verilog code, what value of "a" is displayed?
Submitted by: AdministratorGiven 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.
Submitted by: Administrator
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.
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.