WorksheetsFINAL EXAMINATION FOR CPE 313 (INTRODUCTION TO HDL)
Total questions: 54
Worksheet time: 2hrs 35mins
Which term is considered a broader concept in programming, referring to a segment of code designed to accomplish a specific operation?
Function
Abstraction
Task
Parameter
A core tenet of good software engineering, which is facilitated by using functions, is the:
Single Responsibility Principle
Don't Repeat Yourself (DRY) Principle
Modularity Principle
Abstraction Principle
What is the primary purpose of a function's return value?
To execute a side effect on the program.
To print a message to the console.
To send a value back to the part of the code that called it.
To hold a place for an input argument.
Which characteristic of a function allows users to focus on what it does rather than how it does it?
Reusability
Modularity
Parameterization
Abstraction
In a function definition like def calculate_sum(a, b):, the variables a and b are called:
Arguments
Outputs
Parameters
Return Values
A function that modifies a variable outside its own scope (e.g., updating a global score) is said to cause a:
Return Value
Parameter Violation
Side Effect
Modularity Breach
Which concept is essential for any aspiring programmer as they are the building blocks of programming?
Setup and Hold Times
Combinational Logic
Tasks and Functions
State Machines
Functions allow complex problems to be broken down into smaller, manageable pieces, supporting which concept?
Career Relevance
Modularity
Problem Solving
Abstraction
What is the definition of Arguments when calling a function?
Variables inside the parentheses of the function definition.
The actual values passed to the function when it is called.
The internal logic executed by the function.
The data type of the return value.
What is a function's primary role in enabling reusability?
To allow code to be used in multiple places without rewriting it.
To make code more complex and difficult to understand.
To limit the use of code to a single instance.
To increase the execution time of the program.
The practice of writing functions that do one thing and do it well aligns with which principle?
The DRY Principle
The Abstraction Principle
The Single Responsibility Principle
The Black Box Concept
Which of the following is NOT a benefit of using reusable functions?
Reduced Code Duplication
Easier Debugging
Improved Readability
Increased Propagation Delay
According to the provided examples, validateForm() on the Frontend is classified as a Function because it:
Modifies the DOM
Makes a network request
Returns a boolean value
Saves data to a database
Which analogy describes functions as specialized "Lego Bricks" that can be combined to build larger, complex programs?
Cookbook
Coffee Machine
Black Box
Building Blocks
What happens inside a function, known as the "Magic Happening Inside," is the function's internal:
Abstraction
Logic
Parameter
Argument
The act of using a function's name to execute its code is called:
Declaration
Abstraction
Invocation (Calling)
Parameterization
What must be done for a function to be considered good reusable code?
Use only a single input parameter.
Be robust and handle unexpected inputs gracefully.
Only use print() statements.
Avoid all side effects.
Which of the following best describes the Abstraction characteristic of a function?
It can be called multiple times.
It breaks down a large program into smaller modules.
It hides the internal complexity.
It can accept different inputs.
What are the variables listed inside the parentheses in the function definition?
Arguments
Logic
Return Values
Parameters
In the context of the makeEspresso(beans, water) analogy, the output espressoShot makes it a:
Task
Pure Function (returns a value)
Imperative Operation
Side Effect
Digital circuits whose outputs depend not only on the current inputs but also on the sequence of past inputs are called:
Combinational Circuits
Arithmetic Circuits
Sequential Circuits
Hybrid Circuits
What is the fundamental building block of a sequential circuit that is used to store a single bit of information (0 or 1)?
Multiplexer
Combinational Gate
Memory Element (Flip-flop/Latch)
Decoder
Which memory element is level-sensitive and its output can change whenever the enable input is active?
Flip-flop
Latch
Counter
State Register
Which memory element is edge-sensitive (edge-triggered), providing more predictable and reliable synchronous operation?
Latch
Multiplexer
Flip-flop
Decoder
A D Flip-flop samples the value of the D input only at the:
Enable input being active
End of the clock period
Active clock edge (e.g., rising or falling)
Moment the D input changes
Which flip-flop is most commonly used in synchronous digital systems?
SR Flip-flop
JK Flip-flop
T Flip-flop
D Flip-flop
What is the primary function of a T Flip-flop when its T input is high (T=1)?
Set to 1
Reset to 0
Hold the previous state
Toggle (Invert the previous state)
The minimum time that data must be stable before the active clock edge arrives is called the:
Hold Time ( tH )
Clock Period ( Tclk )
Propagation Delay ( tPD )
Setup Time ( tSU )
The minimum time that data must remain stable after the active clock edge is called the:
Hold Time ( tH )
Clock Skew
Setup Time ( tSU )
Metastability
A sequential logic circuit that goes through a predefined sequence of states upon the application of input pulses is a:
Multiplexer
Decoder
State Machine
Counter
In a synchronous counter, how are the flip-flops clocked?
By a common external clock signal simultaneously
By the output of the preceding flip-flop
Only the first flip-flop is clocked
By separate clock signals
Which type of counter is also known as a Ripple Counter?
A) Synchronous Counter
B) By the output of the preceding flip-flop
C) Asynchronous Counter
D) Up Counter
The main advantage of a Synchronous Counter over an Asynchronous Counter is:
Lower power consumption
Simpler design logic
Higher speed and no cumulative propagation delays
Only one bit changes per clock cycle
A 5-bit binary counter is a MOD-N counter, where N is:
5
10
32 ( 25 )
16
A BCD counter (Binary-Coded Decimal) is a type of Mod-N counter that resets after counting N states, where N is:
8
10 (States 0000 to 1001)
16
256
Which counter is a circular shift register where the output of the last stage is inverted and connected to the input of the first stage?
Ring Counter
Binary Counter
Decade Counter
Johnson Counter
A system that can be in one of a finite number of states at any given time and changes states in response to inputs is a:
Combinational Logic Circuit
Microprocessor
Finite State Machine (FSM)
Shift Register
In a Moore Machine, the outputs depend only on the:
Current inputs
Sequence of past inputs
Current state
Next state logic
In a Mealy Machine, the outputs depend on both the current state and the:
Previous state
Clock period
Current inputs
Output logic
Which type of FSM can potentially require fewer states for the same functionality because it can react faster to inputs?
Moore Machine
Mealy Machine
Counter
State Register
What is the unstable, unpredictable state a flip-flop can enter if its setup or hold time requirements are violated?
Clock Skew
Propagation Delay
Metastability
Race Condition
What is the minimum number of flip-flops required to implement a state machine with five unique states?
2
3 ( ⌈log2(5)⌉=3 )
4
5
Which component of a Finite State Machine (FSM) is typically implemented using flip-flops?
Next State Logic
Output Logic
State Register
Combinational Logic Gates
What is the term for the difference in arrival times of the same clock edge at different flip-flops?
Propagation Delay
Clock Skew
Clock Period
Setup Time
A hold time violation occurs when the data input changes:
Too late before the clock edge
Too soon after the clock edge
At the same time as the clock edge
Only when the clock is low
The design technique that involves assigning binary codes to states such that only one bit changes between adjacent states is called:
Binary Encoding
One-Hot Encoding
BCD Encoding
Gray Code Encoding
Which circuit type would an Adder or Multiplexer be classified as?
Sequential Logic
Combinational Logic
FSM
Memory Element
The method used to determine the flip-flop inputs required for each state transition is based on the:
State Diagram
State Assignment
Flip-flop Excitation Table
K-Map Simplification
When designing a state machine, the graphical representation of the system's behavior, showing states and transitions, is the:
State Table
K-Map
Circuit Diagram
State Diagram
Which counter type, derived from a shift register, produces a Gray Code output sequence?
Ring Counter
BCD Counter
Binary Counter
Johnson Counter
Code Writing (Function) Write a function named calculate_area that accepts two parameters: length and width. The function should multiply these two values and return the result.
Code Calling (Task) Write a conceptual code snippet to demonstrate how to call a task named save_user_data and pass the inputs "Alice", "alice@email.com", and "secure_pass" to it. Assume the task does not return a value.
Code Writing (Return Keyword) Write a function check_positive that takes a number x. If x > 0, it should return the boolean value True. Otherwise, it should return False. Use the return keyword.
Debugging/DRY Principle The following code is inefficient. Rewrite it using a reusable function to follow the DRY Principle (Don't Repeat Yourself).
area1 = 5 * 10
area2 = 8 * 4
area3 = 12 * 6
