summaryrefslogtreecommitdiff
path: root/midterm/CST456-Midterm Exam.md
blob: b943e082bd90242ef748816ad3393650307a7304 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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.