1
0
mirror of https://github.com/gryf/tagbar.git synced 2026-02-15 13:35:52 +01:00

Add tests to repository

This commit is contained in:
Jan Larres
2013-03-28 00:16:03 +13:00
parent b6f47e4020
commit db9404ca1a
128 changed files with 54624 additions and 0 deletions

6
tests/vera/arb.if.vri Normal file
View File

@@ -0,0 +1,6 @@
interface arb {
input clk CLOCK ;
output reset PHOLD #1 ;
output [1:0] request PHOLD #1 ;
input [1:0] grant PSAMPLE #-1 ;
} // end of interface arb

6
tests/vera/class_a.vr Normal file
View File

@@ -0,0 +1,6 @@
// Below code can be in another file
class A {
task print () {
printf("I am in seprate file\n");
}
}

View File

@@ -0,0 +1,99 @@
// Virtual class for body of any driver
virtual class verif {
// This starts all the threads
virtual task startSim();
// This stops all the threads
virtual task stopSim();
// This prints all the stats
virtual task printStats();
// This check if driver is done or not
virtual function bit isDone () {
isDone = 0;
}
// set the driver config
virtual task setConfig(integer item, integer value);
virtual function integer getConfig(integer item) {
getConfig = 32'hDEAD_BEAF;
}
}
// ethernet inherits verif
class ethernet extends verif {
integer min_frame_size;
integer max_frame_size;
task new() {
min_frame_size = 32'h40;
max_frame_size = 32'h200;
}
task startSim() {
printf("Starting Simulation\n");
}
task stopSim() {
printf("Stopping Simulation\n");
}
task printStats() {
printf("Sent normal frames %d\n",100);
printf("Sent runt frames %d\n",1);
printf("Sent oversize frames %d\n",1);
}
function bit isDone() {
isDone = 1;
}
task setConfig(integer item, integer value) {
case(item) {
0 : min_frame_size = value;
1 : max_frame_size = value;
}
}
function integer getConfig(integer item) {
case(item) {
0 : getConfig = min_frame_size;
1 : getConfig = max_frame_size;
default : {
printf("Calling super.setConfig\n");
getConfig = super.getConfig(item);
}
}
}
}
class ethernet2 extends ethernet {
integer min_ipg;
task new() {
min_ipg = 32'hc;
}
task setConfig(integer item, integer value) {
case(item) {
2 : min_ipg = value;
default : {
printf("Calling super.setConfig\n");
super.setConfig(item,value);
}
}
}
function integer getConfig(integer item) {
case(item) {
2 : getConfig = min_ipg;
default : {
printf("Calling super.setConfig\n");
getConfig = super.getConfig(item);
}
}
}
}
program class_extension {
ethernet2 eth = new();
eth.setConfig(0,32'h100);
eth.setConfig(2,32'h24);
printf ("Value of min_frame is %0x\n", eth.getConfig(0));
printf ("Value of max_frame is %0x\n", eth.getConfig(1));
printf ("Value of min_ipg is %0x\n", eth.getConfig(2));
printf ("Value of unknown is %0x\n", eth.getConfig(3));
eth.startSim();
while (eth.isDone() == 0) {
delay(1);
}
eth.stopSim();
eth.printStats();
}

29
tests/vera/copy_object.vr Normal file
View File

@@ -0,0 +1,29 @@
class A{
integer j;
task new(){
j = 100;
}
}
class B {
integer i;
A a;
task new() {
i = 200;
}
}
program copy_object {
B b1 = new(); // Create an object of class B
B b2; //Create a null variable of class B
b1.a = new; //Create an object of class A
b2 = new b1; // Create an object that is a copy of b1,
//but only copies the handle a, not the object referenced by a.
b2.i = 300; // i is changed in b2, but not b1
printf("i in b2 = %0d\n", b2.i);// i equals 10
printf("i in b1 = %0d\n", b1.i);// i equals 1
//where as:
b2.a.j = 400; // Change j in the object referenced
// by a. j is shared by both b1 and b2
printf("j is %0d in b1 and %0d in b2\n", b1.a.j, b2.a.j);
}

13
tests/vera/enum_t.vr Normal file
View File

@@ -0,0 +1,13 @@
enum pkt_size {NORMAL, RUNT, OVERSIZE};
enum pkt_type {UNICAST=11,MULTICAST,BROADCAST};
program enum_t {
pkt_size size = NORMAL;
pkt_type type = MULTICAST;
// Print the enum value
printf("Packet size is %d\n", size);
printf("Packet type is %d\n", type);
// Print the enum name
printf("Packet size is %s\n", size);
printf("Packet type is %s\n", type);
}

60
tests/vera/properties.vr Normal file
View File

@@ -0,0 +1,60 @@
class A {
public integer data;
local integer addr;
protected integer cmd;
static integer credits;
task new() {
data = 100;
addr = 200;
cmd = 1;
credits = 10;
}
task printA() {
printf ("value of data %0d in A\n", data);
printf ("value of addr %0d in A\n", addr);
printf ("value of cmd %0d in A\n", cmd);
}
}
class B extends A {
task printB() {
printf ("value of data %0d in B\n", data);
// Below line will give compile error
//printf ("value of addr %0d in B\n", addr);
printf ("value of cmd %0d in B\n", cmd);
}
}
class C {
A a;
B b;
task new() {
a = new();
b = new();
b.data = 2;
}
task printC() {
printf ("value of data %0d in C\n", a.data);
printf ("value of data %0d in C\n", b.data);
// Below line will give compile error
//printf ("value of addr %0d in C\n", a.addr);
//printf ("value of cmd %0d in C\n", a.cmd);
//printf ("value of addr %0d in C\n", b.addr);
//printf ("value of cmd %0d in C\n", b.cmd);
}
}
program properties {
C c = new();
c.a.printA();
c.b.printB();
c.printC();
printf("value of credits is %0d\n",c.a.credits);
printf("value of credits is %0d\n",c.b.credits);
c.a.credits ++;
printf("value of credits is %0d\n",c.a.credits);
printf("value of credits is %0d\n",c.b.credits);
c.b.credits ++;
printf("value of credits is %0d\n",c.a.credits);
printf("value of credits is %0d\n",c.b.credits);
}

14
tests/vera/this_ex.vr Normal file
View File

@@ -0,0 +1,14 @@
class A {
integer i;
task set_i(integer value) {
this.i = value;
}
}
program this_ex {
A a = new();
printf("value of i is %0d\n",a.i);
a.set_i(100);
printf("value of i is %0d\n",a.i);
}

View File

@@ -0,0 +1,45 @@
#include "vera_defines.vrh"
// Port Declaration
port count_p {
clock;
reset;
enable;
cout;
}
// This is what connects with HDL
interface count_if0 {
input clock CLOCK;
output reset PHOLD#1;
output enable PHOLD#1;
input [3:0] cout PSAMPLE #-1;
}
// Now bind interface with Port
bind count_p count_bind {
clock count_if0.clock;
reset count_if0.reset;
enable count_if0.enable;
cout count_if0.cout;
}
// Top level program
program virtual_port {
count_p count = count_bind;
// Start the actual test here
@ (posedge count.$clock);
printf("Asserting Reset\n");
count.$reset = 1;
count.$enable = 0;
@ (posedge count.$clock);
printf("Deasserting Reset\n");
count.$reset = 0;
@ (posedge count.$clock);
printf("Asserting Enable\n");
count.$enable = 1;
repeat(10) {
@ (posedge count.$clock);
printf("Counter value %x\n",count.$cout);
}
@ (posedge count.$clock);
printf("Deasserting Enable\n");
count.$enable = 0;
}