summaryrefslogtreecommitdiff
path: root/lab_3/SRC/interface.sv
blob: aec4d933da6ef689bb4fcccb9f7ae97688ebc249 (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
interface intf (
    input logic clk
);
  // [Step 1] Wildcard import the enumeration typedef from the typedef_pkg package.
  import typedef_pkg::*;

  // [Step 2] Declare the signals, other than clk, that will connect to the DUV.
  logic op_start;
  logic [1:0] operation;
  logic [7:0] operand_a;
  logic [7:0] operand_b;
  logic [15:0] result;

  // [Step 3] Implement the execute_op task.
  task execute_op(input operation_t op, input logic [7:0] op_a, input logic [7:0] op_b,
                  output logic [15:0] res);
    // Set inputs and start operation
    operation = op;
    operand_a = op_a;
    operand_b = op_b;
    op_start  = 1'b1;

    @(posedge clk);

    op_start = 1'b0;

    // Wait 2 cycles for result
    @(posedge clk);
    @(posedge clk);

    res = result;
  endtask
endinterface : intf