quick.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

   

space.gif

   

space.gif

  ../../images/main/bulllet_4dots_orange.gif UART Scoreboard
   

space.gif


  1 <'
  2 struct uart_sb {
  3    ! tx : list of byte;
  4    ! rx : list of byte;
  5 
  6   txAdd(data : byte) is {
  7     tx.push(data);
  8   };
  9 
 10   rxAdd(data : byte) is {
 11     rx.push(data);
 12   };
 13 
 14   txCompare(data : byte) is {
 15     var org_data : byte = tx.pop0();
 16     if (data  ! = org_data) {
 17       outf("%dns : txCompare : Error : Expected data %x, Got %x\n",
 18        sys.time, org_data, data); 
 19     };
 20   };
 21 
 22   rxCompare(data : byte) is {
 23     var org_data : byte = rx.pop0();
 24     if (data  ! = org_data) {
 25       outf("%dns : rxCompare : Error : Expected data %x, Got %x\n",
 26         sys.time, org_data, data); 
 27     };
 28   };
 29 
 30 };
 31 '>
You could download file specman_examples here
   

space.gif

  ../../images/main/bulllet_4dots_orange.gif UART Transcation Generator
   

space.gif


   1 <'
   2 struct uart_txgen {
   3    sb : uart_sb;
   4 
   5     ! tx_done      : bit;
   6     ! rx_done      : bit;
   7 
   8    // Connects the transmitter output to recevier input
   9    loopback     : bit;
  10      keep loopback == 0;
  11    // Number of frames to send to transmitter
  12    no_tx_cmds   : uint;
  13      keep no_tx_cmds == 1;
  14    // Number of frames to send to receiver
  15    no_rx_cmds   : uint;
  16      keep no_rx_cmds == 1;
  17    // Delay the reading of data from receiver
  18    rx_over_flow : bit;
  19      keep rx_over_flow == 0;
  20    // Send frame to transmitter before it has sent out last frame
  21    tx_over_flow : bit;
  22      keep tx_over_flow == 0;
  23    // Insert framming error (stop bit) in frame sent to receiver
  24    rx_frame_err : bit;
  25      keep rx_frame_err == 0;
  26   
  27    // Main method, which starts rest of methods 
  28    goTxgen()@sys.any is {
  29      tx_done = 0;
  30      rx_done = 0;
  31      assertReset();
  32      start txDriver();
  33      start rxDriver();
  34      start txMonitor();
  35      start rxMonitor();
  36    };
  37    // This method asserts method
  38    assertReset()@sys.rxclk is {
  39       wait cycle;
  40       'top.reset' = 1;
  41       outf("%dns : Asserting reset to Uart\n",sys.time);
  42       wait [5]*cycle;
  43       'top.reset' = 0;
  44    };
  45 
  46    txDriver()@sys.txclk is {
  47      var tx_timeout : uint = 0;
  48      var tx_data : byte = 0;
  49      'top.tx_enable' = 1;
  50      for {var i : uint = 0; i < no_tx_cmds; i = i + 1} do {
  51        gen tx_data;
  52        sb.txAdd(tx_data);
  53        if (loopback == 1) {
  54          sb.rxAdd(tx_data);
  55        };
  56        // Check if uart is ready to accept data for transmission
  57        while ('top.tx_empty' == 0) {
  58          wait cycle;
  59          tx_timeout =+ 1 ;
  60          if (tx_timeout > 10) {
  61            outf("%dns : txDriver : Warning : tx_empty is 0 for more then 10 clocks\n",
  62              sys.time);
  63          };
  64        };
  65        tx_timeout = 0;
  66        // Drive the data in UART for transmitting
  67        wait cycle;
  68        'top.ld_tx_data' = 1;
  69        'top.tx_data'    = tx_data;
  70        outf("%dns : txDriver : Transmitting data %x\n",sys.time, tx_data);
  71        wait cycle;
  72        'top.ld_tx_data' = 0;
  73        'top.tx_data'    = 0;
  74        while ('top.tx_empty' == 1) {
  75          wait cycle;
  76          tx_timeout =+ 1 ;
  77          if (tx_timeout > 10) {
  78            outf("%dns : txDriver : Warning : tx_empty is 1 for more then 10 clocks\n",
  79              sys.time);
  80          };
  81        };
  82        tx_timeout = 0;
  83      };
  84      tx_done = 1;
  85    };
  86 
  87    rxDriver()@sys.txclk is {
  88      var rx_data : byte = 0;
  89      'top.rx_enable' = 1;
  90      if (loopback == 1) {
  91        'top.loopback' = 1;
  92      } else {
  93        'top.loopback' = 0;
  94        for {var i : uint = 0; i < no_rx_cmds; i = i + 1} do {
  95          gen rx_data; 
  96          sb.rxAdd(rx_data);
  97          outf("%dns : rxDriver : Transmitting data %x\n",sys.time, rx_data);
  98          wait cycle;
  99          'top.rx_in' = 0;
 100          for {var j : uint = 0; j < 8; j = j + 1} do {
 101            wait cycle;
 102            'top.rx_in' = rx_data[j:j];
 103          };
 104          wait cycle;
 105          'top.rx_in' = 1;
 106          wait cycle;
 107        };
 108      };
 109      rx_done = 1;
 110    };
 111 
 112    txMonitor()@sys.txclk is {
 113      var tx_data : byte = 0;
 114      while (TRUE) {
 115        wait cycle;
 116        if ('top.tx_out' == 0) {
 117           outf("%dns : txMonitor : Found start of frame\n",sys.time);
 118           for {var i : uint = 0; i < 8; i = i + 1} do {
 119             wait cycle;
 120             tx_data[i:i] = 'top.tx_out';
 121           };
 122           wait cycle;
 123           if ('top.tx_out' == 0) {
 124             outf("%dns : txMonitor Error : Framing error detecting\n",sys.time);
 125             sb.txCompare(8'b0);
 126           } else {
 127             outf("%dns : txMonitor : Sampled data %x\n",sys.time, tx_data);
 128             sb.txCompare(tx_data);
 129           };
 130        };
 131      };
 132    };
 133 
 134    rxMonitor()@sys.rxclk is {
 135      var rx_data : byte = 0;
 136      while (TRUE) {
 137        wait cycle;
 138        if ('top.rx_empty' == 0) {
 139          'top.uld_rx_data' = 1;
 140          wait cycle;
 141          rx_data = 'top.rx_data';
 142          'top.uld_rx_data' = 0;
 143          outf("%dns : rxMonitor : Sampled data %x\n",sys.time, rx_data);
 144          sb.rxCompare(rx_data);
 145          wait cycle;
 146        };
 147      };
 148    };
 149    
 150    isDone() : bool is {
 151      var status : bool = FALSE;
 152      if (tx_done == 1 && rx_done == 1) {
 153        status =  TRUE;
 154      };
 155      return status;
 156    };
 157 };
 158 '>
You could download file specman_examples here
   

space.gif

   

space.gif

   

space.gif

   

space.gif

space2.gif

space2.gif

space2.gif

space2.gif

space2.gif

  

Copyright © 1998-2014

Deepak Kumar Tala - All rights reserved

Do you have any Comment? mail me at:deepak@asic-world.com