The third assignment focuses on the Transaction-class, but effects most components on the functional layer. As a reminder, objects of the transaction class are generated in the generator and are sent to the Driver and the Checker. The class must have the class members as stated below. The new and ToString methods should remain unmodified.
class transaction;
rand bit [1:0] instruction_type;
rand bit [2:0] instruction_selection;
rand bit [2:0] operand_selection;
function new();
this.instruction_type = 2'h0;
this.instruction_selection = 3'h0;
this.operand_selection = 3'h0;
endfunction : new
function string toString();
return $sformatf("Instruction: %02x %02x %02x (%02x) ", this.instruction_type, this.instruction_selection, this.operand_selection, this.toByte);
endfunction : toString
function byte toByte();
return byte'(this.instruction_type * 2**(6-1) + this.instruction_selection * 2**(3-1) + this.operand_selection);
endfunction : toByte;
endclass : transaction
program assignment3();
transaction tra;
initial
begin
/* COMPLETE THIS CODE */
end
endprogram : assignment3
For this assignment the program assignment3 should generate:
Note that: