Skip to content
Permalink
Browse files

test cleanup

  • Loading branch information
Utkarsh Mathur
Utkarsh Mathur committed Apr 23, 2018
1 parent 9e6646d commit 246c64d4accc2337bcc0da924679d8d6cd8c9df0
Showing with 19 additions and 39 deletions.
  1. +9 −6 tb/driver.sv
  2. +2 −6 tb/test.sv
  3. +8 −26 tb/tests.sv
  4. +0 −1 tb/top.sv
@@ -5,6 +5,9 @@ class Driver extends Agent;
integer dynInstCount = 0;
integer instMemIndex;
integer stallCnt = 0;
// TODO: quick fix: 1st instruction is not being clocked
// so clock it twice
bit redoInst = 1;

Instruction dInst;
while(1) begin
@@ -15,10 +18,10 @@ class Driver extends Agent;
// Feeding in trace
// To feed in asm, uncomment pc - base_addr
instMemIndex = dynInstCount; // driverIf.pc - `BASE_ADDR;
dynInstCount += 1;
if( instMemIndex < 0 || instMemIndex >= getInstMemSize() || dynInstCount >= `DYN_INST_CNT ) begin
$display("\t\tinstMemIndex: %0d, getInstMemSize: %0d, dynInstCount: %0d, DYN_INST_CNT: %0d",
instMemIndex, getInstMemSize(), dynInstCount, `DYN_INST_CNT );
if( !redoInst )
dynInstCount += 1;
if( instMemIndex < 0 || instMemIndex >= getInstMemSize() ) begin
$display("\t\tinstMemIndex: %0d, getInstMemSize: %0d", instMemIndex, getInstMemSize());
$display("\t\tGracefully exitting testcase");
break;
end
@@ -40,7 +43,8 @@ class Driver extends Agent;
end
else
stallCnt += 1;


redoInst = 0;
// One clock delay
@(posedge driverIf.clk);
end
@@ -68,7 +72,6 @@ class Driver extends Agent;
`endif
writeDataMem( driverIf.Data_addr, driverIf.Data_din );
end

// One clock delay
@(posedge driverIf.clk);
end
@@ -17,19 +17,15 @@ class Test; //{
// all tests. It doesn't have LD/SD and BR as mem warmup
// is not done
virtual function void sequenceInstr();
integer numTrans = 1 + 8 + 700;
integer numTrans = 8 + 700;
Instruction instMemEntry = new;
env.instMem = new [numTrans];

// TODO: quick fix: fix in driver to not miss first instruction
instMemEntry.create(AND, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
pushInst(instMemEntry);

for( int i = 0; i < 8; i++ ) begin
instMemEntry.create(AND, i, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
pushInst(instMemEntry);
end
for( int i = 0; i < numTrans - 8 - 1; i++ ) begin
for( int i = 0; i < numTrans - 8; i++ ) begin
// Basic instructions
opcode_t opList[] = {ADD, /*BR,*/ AND, NOT/*, LD, LDR, LDI, LEA, ST, STI, STR*/};

@@ -9,32 +9,24 @@ class MaxOneBrStoreLoadTest extends Test;

// Populates env's instruct mem
virtual function void sequenceInstr();
integer numTrans = 1 + 8 + 1000;
integer numTrans = 8 + 1000;
integer count = 8;
Instruction instMemEntry = new;
env.instMem = new [numTrans];

// TODO: quick fix: fix in driver to not miss first instruction
instMemEntry.create(AND, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
pushInst(instMemEntry);

for( int i = 0; i < 8; i++ ) begin
instMemEntry.create(AND, i, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
pushInst(instMemEntry);
end

for( int i = 0; i < numTrans - 8 - 1; i++ ) begin
for( int i = 0; i < numTrans - 8; i++ ) begin
if( instMemEntry.randomize()
with {
if( count <= 0 )
opcode inside {ADD, AND, NOT, LD, LDR, LDI, LEA, ST, STI, STR, BR, JMP};
else
opcode inside {ADD, AND, NOT};
{N,Z,P} inside {[3'b001:3'b111]};
pcOffset9 inside {[0:999]};
pcOffset6 inside {[0:100]};
baseR inside {[0:999]};

} ) begin
count--;
if( instMemEntry.isMem() || instMemEntry.isCtrl() ) count = 8;
@@ -58,31 +50,23 @@ class RandomBrStoreLoadTest extends Test;

// Populates env's instruct mem
virtual function void sequenceInstr();
//integer numTrans = 8 + 100 + 100; // R0-7 + warmup + test
integer numTrans = 100*9 + 1000;
integer numTrans = 8 + 1000000;
integer ctrl = 0, mem = 0;
integer instCnt = 0;
Instruction instMemEntry = new;
env.instMem = new [numTrans];

// Warmup 0-100 addresses
// Between all stores, initialize all regs to 0
// Warmup R0-R8
// Memory is already pre-warmed up
// AND R0, R0, #0
for( int i = 0; i < 100; i++ ) begin
instMemEntry.create(STR, 0, 0, 0, 0, 0, 0, i, 0, 0, 0, 0);
for( int i = 0; i < 8; i++ ) begin
instMemEntry.create(AND, i, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
pushInst(instMemEntry);
for( int j = 0; j < 8; j++ ) begin
instMemEntry.create(AND, j, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0);
pushInst(instMemEntry);
end
end

for( int i = 0; i < numTrans - 100*9; i++ ) begin
int position = i + 100*9;
for( int i = 0; i < numTrans - 8; i++ ) begin
// Basic instructions
opcode_t opList[] = {ADD, AND, NOT};
reg [8:0] startAddr = 0;
reg [8:0] endAddr = numTrans - position - 1;

if( ctrl > `LC3_PIPE_DEPTH ) begin
integer s = opList.size();
@@ -105,8 +89,6 @@ class RandomBrStoreLoadTest extends Test;

if( instMemEntry.randomize() with {
opcode inside {opList};
pcOffset6 inside { [startAddr:endAddr] };
baseR == 0;
} ) begin
if( instMemEntry.isCtrl() ) ctrl = 0;
if( instMemEntry.isMem() ) mem = 0;
@@ -1,6 +1,5 @@
`define STALL_THRESH 1000
`define BASE_ADDR 16'h3000
`define DYN_INST_CNT 100000
`define LC3_PIPE_DEPTH 6

//`define DEBUG_ALL

0 comments on commit 246c64d

Please sign in to comment.
You can’t perform that action at this time.