Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

FINAL EXAMINATION FOR CPE 313 (INTRODUCTION TO HDL)

Total questions: 54

Worksheet time: 2hrs 35mins

Name
Class
Date
1.

Which term is considered a broader concept in programming, referring to a segment of code designed to accomplish a specific operation?

a)

Function

b)

Abstraction

c)

Task

d)

Parameter

2.

A core tenet of good software engineering, which is facilitated by using functions, is the:

a)

Single Responsibility Principle

b)

Don't Repeat Yourself (DRY) Principle

c)

Modularity Principle

d)

Abstraction Principle

3.

What is the primary purpose of a function's return value?

a)

To execute a side effect on the program.

b)

To print a message to the console.

c)

To send a value back to the part of the code that called it.

d)

To hold a place for an input argument.

4.

Which characteristic of a function allows users to focus on what it does rather than how it does it?

a)

Reusability

b)

Modularity

c)

Parameterization

d)

Abstraction

5.

In a function definition like def calculate_sum(a, b):, the variables a and b are called:

a)

Arguments

b)

Outputs

c)

Parameters

d)

Return Values

6.

A function that modifies a variable outside its own scope (e.g., updating a global score) is said to cause a:

a)

Return Value

b)

Parameter Violation

c)

Side Effect

d)

Modularity Breach

7.

Which concept is essential for any aspiring programmer as they are the building blocks of programming?

a)

Setup and Hold Times

b)

Combinational Logic

c)

Tasks and Functions

d)

State Machines

8.

Functions allow complex problems to be broken down into smaller, manageable pieces, supporting which concept?

a)

Career Relevance

b)

Modularity

c)

Problem Solving

d)

Abstraction

9.

What is the definition of Arguments when calling a function?

a)

Variables inside the parentheses of the function definition.

b)

The actual values passed to the function when it is called.

c)

The internal logic executed by the function.

d)

The data type of the return value.

10.

What is a function's primary role in enabling reusability?

a)

To allow code to be used in multiple places without rewriting it.

b)

To make code more complex and difficult to understand.

c)

To limit the use of code to a single instance.

d)

To increase the execution time of the program.

11.

The practice of writing functions that do one thing and do it well aligns with which principle?

a)

The DRY Principle

b)

The Abstraction Principle

c)

The Single Responsibility Principle

d)

The Black Box Concept

12.

Which of the following is NOT a benefit of using reusable functions?

a)

Reduced Code Duplication

b)

Easier Debugging

c)

Improved Readability

d)

Increased Propagation Delay

13.

According to the provided examples, validateForm() on the Frontend is classified as a Function because it:

a)

Modifies the DOM

b)

Makes a network request

c)

Returns a boolean value

d)

Saves data to a database

14.

Which analogy describes functions as specialized "Lego Bricks" that can be combined to build larger, complex programs?

a)

Cookbook

b)

Coffee Machine

c)

Black Box

d)

Building Blocks

15.

What happens inside a function, known as the "Magic Happening Inside," is the function's internal:

a)

Abstraction

b)

Logic

c)

Parameter

d)

Argument

16.

The act of using a function's name to execute its code is called:

a)

Declaration

b)

Abstraction

c)

Invocation (Calling)

d)

Parameterization

17.

What must be done for a function to be considered good reusable code?

a)

Use only a single input parameter.

b)

Be robust and handle unexpected inputs gracefully.

c)

Only use print() statements.

d)

Avoid all side effects.

18.

Which of the following best describes the Abstraction characteristic of a function?

a)

It can be called multiple times.

b)

It breaks down a large program into smaller modules.

c)

It hides the internal complexity.

d)

It can accept different inputs.

19.

What are the variables listed inside the parentheses in the function definition?

a)

Arguments

b)

Logic

c)

Return Values

d)

Parameters

20.

In the context of the makeEspresso(beans, water) analogy, the output espressoShot makes it a:

a)

Task

b)

Pure Function (returns a value)

c)

Imperative Operation

d)

Side Effect

21.

Digital circuits whose outputs depend not only on the current inputs but also on the sequence of past inputs are called:

a)

Combinational Circuits

b)

Arithmetic Circuits

c)

Sequential Circuits

d)

Hybrid Circuits

22.

What is the fundamental building block of a sequential circuit that is used to store a single bit of information (0 or 1)?

a)

Multiplexer

b)

Combinational Gate

c)

Memory Element (Flip-flop/Latch)

d)

Decoder

23.

Which memory element is level-sensitive and its output can change whenever the enable input is active?

a)

Flip-flop

b)

Latch

c)

Counter

d)

State Register

24.

Which memory element is edge-sensitive (edge-triggered), providing more predictable and reliable synchronous operation?

a)

Latch

b)

Multiplexer

c)

Flip-flop

d)

Decoder

25.

A D Flip-flop samples the value of the D input only at the:

a)

Enable input being active

b)

End of the clock period

c)

Active clock edge (e.g., rising or falling)

d)

Moment the D input changes

26.

Which flip-flop is most commonly used in synchronous digital systems?

a)

SR Flip-flop

b)

JK Flip-flop

c)

T Flip-flop

d)

D Flip-flop

27.

What is the primary function of a T Flip-flop when its T input is high (T=1)?

a)

Set to 1

b)

Reset to 0

c)

Hold the previous state

d)

Toggle (Invert the previous state)

28.

The minimum time that data must be stable before the active clock edge arrives is called the:

a)

Hold Time ( tHt_{H} )

b)

Clock Period ( TclkT_{clk} )

c)

Propagation Delay ( tPDt_{PD} )

d)

Setup Time ( tSUt_{SU} )

29.

The minimum time that data must remain stable after the active clock edge is called the:

a)

Hold Time ( tHt_{H} )

b)

Clock Skew

c)

Setup Time ( tSUt_{SU} )

d)

Metastability

30.

A sequential logic circuit that goes through a predefined sequence of states upon the application of input pulses is a:

a)

Multiplexer

b)

Decoder

c)

State Machine

d)

Counter

31.

In a synchronous counter, how are the flip-flops clocked?

a)

By a common external clock signal simultaneously

b)

By the output of the preceding flip-flop

c)

Only the first flip-flop is clocked

d)

By separate clock signals

32.

Which type of counter is also known as a Ripple Counter?

a)

A) Synchronous Counter

b)

B) By the output of the preceding flip-flop

c)

C) Asynchronous Counter

d)

D) Up Counter

33.

The main advantage of a Synchronous Counter over an Asynchronous Counter is:

a)

Lower power consumption

b)

Simpler design logic

c)

Higher speed and no cumulative propagation delays

d)

Only one bit changes per clock cycle

34.

A 5-bit binary counter is a MOD-N counter, where N is:

a)

5

b)

10

c)

32 ( 252^5 )

d)

16

35.

A BCD counter (Binary-Coded Decimal) is a type of Mod-N counter that resets after counting N states, where N is:

a)

8

b)

10 (States 0000 to 1001)

c)

16

d)

256

36.

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?

a)

Ring Counter

b)

Binary Counter

c)

Decade Counter

d)

Johnson Counter

37.

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:

a)

Combinational Logic Circuit

b)

Microprocessor

c)

Finite State Machine (FSM)

d)

Shift Register

38.

In a Moore Machine, the outputs depend only on the:

a)

Current inputs

b)

Sequence of past inputs

c)

Current state

d)

Next state logic

39.

In a Mealy Machine, the outputs depend on both the current state and the:

a)

Previous state

b)

Clock period

c)

Current inputs

d)

Output logic

40.

Which type of FSM can potentially require fewer states for the same functionality because it can react faster to inputs?

a)

Moore Machine

b)

Mealy Machine

c)

Counter

d)

State Register

41.

What is the unstable, unpredictable state a flip-flop can enter if its setup or hold time requirements are violated?

a)

Clock Skew

b)

Propagation Delay

c)

Metastability

d)

Race Condition

42.

What is the minimum number of flip-flops required to implement a state machine with five unique states?

a)

2

b)

3 ( ⌈log⁡2(5)⌉=3\lceil \log_2(5) \rceil = 3 )

c)

4

d)

5

43.

Which component of a Finite State Machine (FSM) is typically implemented using flip-flops?

a)

Next State Logic

b)

Output Logic

c)

State Register

d)

Combinational Logic Gates

44.

What is the term for the difference in arrival times of the same clock edge at different flip-flops?

a)

Propagation Delay

b)

Clock Skew

c)

Clock Period

d)

Setup Time

45.

A hold time violation occurs when the data input changes:

a)

Too late before the clock edge

b)

Too soon after the clock edge

c)

At the same time as the clock edge

d)

Only when the clock is low

46.

The design technique that involves assigning binary codes to states such that only one bit changes between adjacent states is called:

a)

Binary Encoding

b)

One-Hot Encoding

c)

BCD Encoding

d)

Gray Code Encoding

47.

Which circuit type would an Adder or Multiplexer be classified as?

a)

Sequential Logic

b)

Combinational Logic

c)

FSM

d)

Memory Element

48.

The method used to determine the flip-flop inputs required for each state transition is based on the:

a)

State Diagram

b)

State Assignment

c)

Flip-flop Excitation Table

d)

K-Map Simplification

49.

When designing a state machine, the graphical representation of the system's behavior, showing states and transitions, is the:

a)

State Table

b)

K-Map

c)

Circuit Diagram

d)

State Diagram

50.

Which counter type, derived from a shift register, produces a Gray Code output sequence?

a)

Ring Counter

b)

BCD Counter

c)

Binary Counter

d)

Johnson Counter

51.

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.

4 lines
52.

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.

4 lines
53.

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.

4 lines
54.

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

4 lines