summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-19 16:17:04 -0800
committerFuwn <[email protected]>2026-02-19 16:19:35 -0800
commit319ae0c3a1562aac63a75860552d4ce30775e405 (patch)
treedec41bf5d27f968a7c2bbf0e68d61f88c21de793
parentfeat(lab_5): Implement lab (diff)
downloadcst456-319ae0c3a1562aac63a75860552d4ce30775e405.tar.xz
cst456-319ae0c3a1562aac63a75860552d4ce30775e405.zip
feat(midterm): Add instructions
-rw-r--r--midterm/CST456-Midterm Exam.md103
-rw-r--r--midterm/CST456-Midterm Exam.pdfbin0 -> 184450 bytes
-rw-r--r--midterm/SIM/run_sim_cli.bat4
-rw-r--r--midterm/SIM/run_sim_gui.bat3
-rw-r--r--midterm/SIM/xsim_cfg.tcl3
-rw-r--r--midterm/image1.pngbin0 -> 33752 bytes
6 files changed, 113 insertions, 0 deletions
diff --git a/midterm/CST456-Midterm Exam.md b/midterm/CST456-Midterm Exam.md
new file mode 100644
index 0000000..b943e08
--- /dev/null
+++ b/midterm/CST456-Midterm Exam.md
@@ -0,0 +1,103 @@
+# CST456-Midterm Exam
+
+**CST456 – Midterm Exam**
+
+Write a hierarchical testbench for following ALU:
+
+**Design Under Verification (DUV)**
+
+The ALU contains the following ports:
+
+| **Port Name** | **Signal Type** | **Direction** | **Number of Bits** |
+| --- | --- | --- | --- |
+| clk | Clock | Input | 1 |
+| op_start | Control | Input | 1 |
+| operation | Control | Input | 2 |
+| operand_a | Data | Input | 8 |
+| operand_b | Data | Input | 8 |
+| result | Data | Output | 16 |
+
+At the rising edge of the clock, if op_start is asserted (== 1’b1)
+
+then the operation, operand_a, and operand_b signals are latched into
+
+the ALU. Exactly two clock cycles later the result of the operation is
+
+read from the result port. The ALU supports the following operations:
+
+| **Name** | **Value** | **Description** |
+| --- | --- | --- |
+| ADD | 2’b00 | operand_a is added to operand_b. Only the lower nine bits of the result are used. |
+| MULT | 2’b01 | operand_a is multiplied with operand_b. This is an unsigned operation and all sixteen bits of the result are used. |
+| OR | 2’b10 | operand_a is bitwise ORed with operand_b. Only the lower eight bits of the result are used. |
+| AND | 2’b11 | operand_a is bitwise ANDed with operand_b. Only the lower eight bits of the result are used. |
+
+Figure 1 shows a timing diagram for the addition operation, where 1 + 3 = 4.
+
+![](./image1.png)
+
+**Figure 1 - Timing diagram for an addition operation.**
+
+**Hierarchical Testbench**
+
+The hierarchical testbench should consists of following modules:
+
+1.Interface module:
+
+The interface is a module that holds all the signals of the DUT. Interface should not have any task or function. But should have a clocking block
+
+2.Transaction module:
+
+Transaction module should define the variables to be randomized. Also any print, info, etc. should be defined within transaction module.
+
+3.Scoreboard and Monitor combined module:
+
+This module must have one function and one task. Function
+
+(compute_expected_value) should receive the input values
+
+from transaction module and calculate the expected values
+
+and perform the comparison of the expected output and DUV
+
+output. The task (check) should receive the values of input
+
+and output from interface and should pass them to
+
+transaction module. Task should call the
+
+compute_expected_value function to calculate expected
+
+output.
+
+4.Bus functional module (BFM):
+
+Bus functional model should perform the randomization
+
+process in a task (drive). It should also perform the data
+
+transfer from transaction module to interface and interface
+
+to transaction module in another task(drive_trxn).
+
+Testbench should not contain any program block. BFM’s drive task
+
+and scoreboard’s check task must be the only ones called within
+
+testbench. Testbench should use fork statement. The clock must
+
+be also created within the testbench. Every combination of
+
+inputs, expected result, and real result must be printed to the
+
+command window using a print function defined in the transaction
+
+module.
+
+**(You can use the example in Lecture 4 (pp.30-34) as a reference)**
+
+**Midterm Submission**
+
+Zip the entire contents of the midterm directory and submit it to
+
+canvas. \ No newline at end of file
diff --git a/midterm/CST456-Midterm Exam.pdf b/midterm/CST456-Midterm Exam.pdf
new file mode 100644
index 0000000..253239f
--- /dev/null
+++ b/midterm/CST456-Midterm Exam.pdf
Binary files differ
diff --git a/midterm/SIM/run_sim_cli.bat b/midterm/SIM/run_sim_cli.bat
new file mode 100644
index 0000000..eee735f
--- /dev/null
+++ b/midterm/SIM/run_sim_cli.bat
@@ -0,0 +1,4 @@
+call C:\Xilinx\Vivado\2022.1\bin\xvlog -nolog -sv -i ../SRC ../SRC/tb.sv ../SRC/duv.sv
+if %ERRORLEVEL% EQU 0 call C:\Xilinx\Vivado\2022.1\bin\xelab -nolog -debug all tb
+if %ERRORLEVEL% EQU 0 call C:\Xilinx\Vivado\2022.1\bin\xsim tb -R
+pause
diff --git a/midterm/SIM/run_sim_gui.bat b/midterm/SIM/run_sim_gui.bat
new file mode 100644
index 0000000..1af4eeb
--- /dev/null
+++ b/midterm/SIM/run_sim_gui.bat
@@ -0,0 +1,3 @@
+call C:\Xilinx\Vivado\2022.1\bin\xvlog -nolog -sv -i ../SRC ../SRC/tb.sv ../SRC/duv.sv
+if %ERRORLEVEL% EQU 0 call C:\Xilinx\Vivado\2022.1\bin\xelab -nolog -debug all tb
+if %ERRORLEVEL% EQU 0 call C:\Xilinx\Vivado\2022.1\bin\xsim tb -gui
diff --git a/midterm/SIM/xsim_cfg.tcl b/midterm/SIM/xsim_cfg.tcl
new file mode 100644
index 0000000..b7c49f5
--- /dev/null
+++ b/midterm/SIM/xsim_cfg.tcl
@@ -0,0 +1,3 @@
+log_wave -recursive *
+run all
+exit \ No newline at end of file
diff --git a/midterm/image1.png b/midterm/image1.png
new file mode 100644
index 0000000..b337587
--- /dev/null
+++ b/midterm/image1.png
Binary files differ