HierarchyFilesModulesSignalsTasksFunctionsHelp

/******************************************************************************/ 
/*                                                                            */ 
/* Copyright (c) 1999 Sun Microsystems, Inc. All rights reserved.             */ 
/*                                                                            */ 
/* The contents of this file are subject to the current version of the Sun    */ 
/* Community Source License, microSPARCII ("the License"). You may not use    */ 
/* this file except in compliance with the License.  You may obtain a copy    */ 
/* of the License by searching for "Sun Community Source License" on the      */ 
/* World Wide Web at http://www.sun.com. See the License for the rights,      */ 
/* obligations, and limitations governing use of the contents of this file.   */ 
/*                                                                            */ 
/* Sun Microsystems, Inc. has intellectual property rights relating to the    */ 
/* technology embodied in these files. In particular, and without limitation, */ 
/* these intellectual property rights may include one or more U.S. patents,   */ 
/* foreign patents, or pending applications.                                  */ 
/*                                                                            */ 
/* Sun, Sun Microsystems, the Sun logo, all Sun-based trademarks and logos,   */ 
/* Solaris, Java and all Java-based trademarks and logos are trademarks or    */ 
/* registered trademarks of Sun Microsystems, Inc. in the United States and   */ 
/* other countries. microSPARC is a trademark or registered trademark of      */ 
/* SPARC International, Inc. All SPARC trademarks are used under license and  */ 
/* are trademarks or registered trademarks of SPARC International, Inc. in    */ 
/* the United States and other countries. Products bearing SPARC trademarks   */ 
/* are based upon an architecture developed by Sun Microsystems, Inc.         */ 
/*                                                                            */ 
/******************************************************************************/ 
//Version 7.0.02 
// Changes (1) added one new task "int_to_string"  	StarID #42312
//         (2) added one new function "int_to_str"	StarID #42312

// Version 7.0.01
// Changes (1) added global status flag			StarID #42036
// Version 7.0.0

// PCI Bus Interface Models ONLY
// uncomment the following line to generate the PCI Bus Models WITHOUT PLI calls
// `define no_pli

// FOR PCI Slave Model ONLY
// uncomment the following line to enable paged memory allocation
// `define paged


// The values on timescale directive must match the values specified 
// for the lmv_timescale defined below
`timescale 100 ps / 10 ps
 
module lmcver;

// If the timescale compiler directive is modified, please refer to notes 
// below on changing the constant time_scale_multiplier.
// The <time_precision> argument must be set to a value at least 10 times
// less than the <time_unit> argument.

// The following define statement must be modified if the <time_unit> 
// argument on the `timescale directive is modified.  
//
// The value of time_scale_multiplier must always have a value equivalent
// to 1 ns (<time_unit> * time-scale_multiplier = 1 ns). Therefore, if the 
// <time_unit> argument is modified time_scale_multiplier must be adjusted
// accordingly.
//
// Example:  original: `define lmc_timescale `timescale 1 ns / 10 ps
//                     `define time_scale_multiplier 1
//           modified:  `define lmc_timescale `timescale 1 ps / 100 fs
//                     `define time_scale_multiplier 1000
//
// Exceptions:
//	ESC
//
//	The timing delay values for these models required PS precision, 
//	thus the timescale must be specified as follows:
//
//			`timescale 1 ps / 1ps
//			define time_scale_multiplier 1000
//			define time_unit 1
//
//	The above code is included in the timing.v file for each of these
//	models.
//

`define lmv_timescale  `timescale 100 ps / 10 ps
`define time_scale_multiplier 10 

// Do not edit values below this line
`define time_unit 0.1
`define time_unit_100 1

`define max_len 320
`define true 1'b1
`define TRUE 1'b1
`define false 1'b0
`define FALSE 1'b0

`define lmv_minimum 0
`define lmv_typical 1
`define lmv_maximum 2
`define lmv_gen     3

`define binary 0
`define octal 1
`define decimal 2
`define hexadecimal 3

// lmc_bm (Added on 8/3/95)

//  type ack_val_type
`define Release 0
`define unknown 1
`define ack_rsp 2
`define busy_rsp 3

//reserved id numbers
`define cb_release_id 0
`define cb_brdcst_id 1

//cb_ack constants
`define max_ack_srch 10

//target busy constants
`define max_wait_on_avail_t 1000 * `time_scale_multiplier

//  type cmd_src_type
`define embedded 0
`define cmd_memory 1

// Dispatcher declarations
`define dspch_queue_page_size 100

// Misc.
`define blanket_tvalue 1

//  type msg_level_types
`define no_msg 0
`define warnings 1
`define debug_1 2
`define debug_2 3
`define debug_3 4
`define debug_cb 5
`define debug_int 6
`define debug_cmd_mem 7

// Command codes
`define max_ctrl_immed_code 99
`define max_auto_immed_code 199
`define max_user_immed_code 299
`define max_user_cycle_code 399

`define null_cmd 0

//auto-gen non-model-specific immed commands  (controller executed)
//"ctrl_immed"
`define remote_cmd 1
`define restart_cmd 2
`define trigger_cmd 3
`define wait_on_cmd 4
`define print_msg_cmd 5
`define set_msg_level_cmd 6
`define call_cmd 7
`define open_buffer_cmd 8
`define close_buffer_cmd 9
`define func_beg_cmd 10
`define func_end_cmd 11
`define for_cmd 12
`define end_loop_cmd 13
`define sequential_cmd 14
`define wait_on_node_cmd 15
`define stop_sim_cmd 16

//auto-gen model-specific immed commands  (always just executed in normal sequence)
//"auto_immed"
`define set_cmd 101
`define get_cmd 102
`define reload_cmd 103
`define dump_cmd 104
`define rte_cmd 105

//user-gen model-specfic immed commands  (always just executed in normal sequence)
//"user_immed"
`define configure_cmd 201
`define query_cmd 202
//pcimaster
`define wakeup_cmd 203

//user-gen model-specfic non-immed commands  (always just executed in normal sequence)
//"user_cycle"
`define idle_cmd 301
`define read_cycle_cmd 302
`define read_continue_cmd 303
`define write_cycle_cmd 304
`define write_continue_cmd 305
`define read_mod_write_cmd 306
`define read_until 307
`define transfer_cmd 308
`define request_cmd 309
`define connect_cmd 310
`define detach_cmd 311

//fm special commands
 //pcimaster
`define sleep_cmd 312
 //i80386
`define start_cmd 313
`define halt_cmd 314
`define shutdown_cmd 315
 //Pentium
`define flush_cmd 316
`define writeback_cmd 317
`define branch_tr_msg_cmd 318
`define flush_ack_cmd 319


// Command String Parsing
`define token_size 128
`define max_cmd_size 256
`define max_tokens 10
`define slv_size 64

// Return Data
`define ret_slv_len `slv_size
`define ret_ary_len 50

//  type transaction_type
`define cmd_trans 0
`define status_trans 1


  function [1:1*8] int_to_str;
  input [31:0] int_val;
  begin
    case (int_val)
      0 : int_to_str = "0";
      1 : int_to_str = "1";
      2 : int_to_str = "2";
      3 : int_to_str = "3";
      4 : int_to_str = "4";
      5 : int_to_str = "5";
      6 : int_to_str = "6";
      7 : int_to_str = "7";
      8 : int_to_str = "8";
      9 : int_to_str = "9";
    endcase
  end
  endfunction // int_to_str

  task int_to_string;
  input [31:0] in_value;
  output [1:4*8] out_value;   // 4-digit number
  integer Rem, i;
  integer d [0:3]; // 4-digit number
  begin
    Rem = in_value;
    i = 3;         // 4-digit number
    begin : loop_c
    while (i >= 0) begin
          if (i == 0) begin
             d[0] = Rem;
             disable loop_c;
          end // if
          d[i] = Rem / (power(10,i));
          Rem = Rem % (power(10,i));
          if (Rem < (power(10, i-1))) begin
             d[i-1] = 0;
             i = i - 2;
          end else begin
             i = i - 1;
          end // if
    end // loop
    end // loop1
  out_value = {int_to_str(d[3]),int_to_str(d[2]),int_to_str(d[1]),int_to_str(d[0])};
  end
  endtask // int_to_string

  function [31:0] power;
    input [31:0] num1, num2;
    integer result,i;
    begin
      result = 1;
      for (i = 1; i <= num2; i = i + 1)
        result = result * num1;
      power = result;
    end
  endfunction // power

  function [20*8:1] tolower;
    input [20*8:1] version;
    reg [8:1] char, temp;
    integer i, j;
    begin 
      for (i = 20; i >= 1; i = i - 1)
        begin
        for (j = 8; j >= 1; j = j - 1)
          char[j] = version[i*8-(8-j)];
        case (char)
          "A" : temp = "a";
          "B" : temp = "b";
          "C" : temp = "c";
          "D" : temp = "d";
          "E" : temp = "e";
          "F" : temp = "f";
          "G" : temp = "g";
          "H" : temp = "h";
          "I" : temp = "i";
          "J" : temp = "j";
          "K" : temp = "k";
          "L" : temp = "l";
          "M" : temp = "m";
          "N" : temp = "n";
          "O" : temp = "o";
          "P" : temp = "p";
          "Q" : temp = "q";
          "R" : temp = "r";
          "S" : temp = "s";
          "T" : temp = "t";
          "U" : temp = "u";
          "V" : temp = "v";
          "W" : temp = "w";
          "X" : temp = "x";
          "Y" : temp = "y";
          "Z" : temp = "z";
          default temp = char;
        endcase
        for (j = 8; j >= 1; j = j - 1)
          tolower[i*8-(8-j)] = temp[j];
        end
    end
  endfunction  // tolower

  function [31:0] rem;
    input [31:0] numerator_in, denominator_in;
    integer numerator, denominator, temp;
    begin
      numerator = numerator_in;
      denominator = denominator_in;
      temp = numerator / denominator;
      rem = numerator - (temp * denominator);
      if (denominator < 0 && rem > 0)
        rem = -rem;
      else if (denominator > 0 && rem < 0)
        rem = -rem;
    end
  endfunction // rem

  task get_flags;
    output [31:0] option;
    output time_check, x_check, annotated;
    output [31:0] debug_level, vlt, tmp, DF;
    begin
      option = `lmv_maximum;
      time_check = `true;
      x_check = `true;
      annotated = `false;
      debug_level = `false;
      vlt = 5000;
      tmp = 300;
      DF = 100;
      if ($test$plusargs("maxdelays")) begin
        option = `lmv_maximum;
      end else if ($test$plusargs("mindelays")) begin
        option = `lmv_minimum;
      end else if ($test$plusargs("typdelays")) begin
        option = `lmv_typical;
      end
      if ($test$plusargs("notimecheck")) begin
        time_check = `false;
      end
      if ($test$plusargs("noxcheck")) begin
        x_check = `false;
      end
      if ($test$plusargs("annotated")) begin
        annotated = `true;
      end
      if ($test$plusargs("debug")) begin
        debug_level = 1;
      end
      if ($test$plusargs("vlt_")) begin
        $lmv_plusargs("vlt_",vlt);
      end
      if ($test$plusargs("tmp_")) begin
        $lmv_plusargs("tmp_",tmp);
      end
      if ($test$plusargs("DF_")) begin
        $lmv_plusargs("DF_",DF);
      end
    end
  endtask

  function [31:0] map;
  input value;
  begin
    case (value)
      1'b0: map = 0;
      1'b1: map = 1;
      1'bx: map = 2;
      1'bz: map = 3;
      default map = 2;
    endcase
  end
  endfunction

  /* added the delay function to replace map */
  function [31:0] delay;
  input [127:0] delay_array;
  input value;
  begin
    case (value)
      1'b0: delay = delay_array[31:0];
      1'b1: delay = delay_array[63:32];
      1'bx: delay = delay_array[95:64];
      1'bz: delay = delay_array[127:96];
      default delay = delay_array[95:64];
    endcase
  end
  endfunction

  function [1:8] bit_to_str;
  input bit;
  begin
    case (bit)
      1'b0: bit_to_str = "0";
      1'b1: bit_to_str = "1";
      1'bx: bit_to_str = "x";
      1'bz: bit_to_str = "z";
      default bit_to_str = "z";
    endcase
  end
  endfunction

  function filter;
  input bit;
  begin
    case (bit)
      1'b0: filter = 1'b0;
      1'b1: filter = 1'b1;
      default filter = 1'bx;
    endcase
  end
  endfunction
    
  function filter_up;
  input bit;
  begin
    case (bit)
      1'b0: filter_up = 1'b0;
      1'b1: filter_up = 1'b1;
      1'bz: filter_up = 1'b1;
      default filter_up = 1'bx;
    endcase
  end
  endfunction
    
  function filter_down;
  input bit;
  begin
    case (bit)
      1'b0: filter_down = 1'b0;
      1'b1: filter_down = 1'b1;
      1'bz: filter_down= 1'b0;
      default filter_down = 1'bx;
    endcase
  end
  endfunction

// Global Status Flag
reg exit_status; initial exit_status = 0;

// Control Bus Declaration

reg [1 : 2182] cb;                // control_bus_type
reg [1 : 96] cb_ack;              // cb_ack_type

initial cb = 2182'b0;

reg [31:0] flags; initial flags = 32'h0;
integer winner_id; initial winner_id = 0;

reg [31:0] flags_ack; initial flags_ack = 32'h0;
integer winner_id_ack; initial winner_id_ack = 0;

// Control Bus Resolution Tasks 

 task request_bus;
 input [31:0] my_id;
 integer i;
 reg dummy;
 begin
   flags[my_id] = 1;
   dummy = 0;
   dummy <= 1;
   @(dummy);
   begin: loop_request
//   for (i = 31; i>= 0; i=i-1) begin        // priority for higher id's
   for (i= 0; i <= 31; i=i+1) begin       // priority for lower id's
     if (flags[i] == 1) begin
       winner_id = i;
       disable loop_request;
     end // if
   end // for
   end // loop_request
 end
 endtask // request_bus

 task free_bus;
 input [31:0] my_id;
 integer i;
 begin
   flags[my_id] = 0;
   begin: loop_free
//   for (i = 31; i>= 0; i=i-1) begin         // priority for higher id's
   for (i= 0; i <= 31; i=i+1) begin        // priority for lower id's
     if (flags[i] == 1) begin
       winner_id = i;
       disable loop_free;
     end // if
   end // for
   end // loop_free
 end
 endtask // free_bus

 task wait_for_0;
 reg dummy;
 begin
   dummy = 0;
   dummy <= 1;
   @(posedge dummy);
 end
 endtask

endmodule
HierarchyFilesModulesSignalsTasksFunctionsHelp

This page: Created:Thu Aug 19 11:59:40 1999
From: ../../../sparc_v8/system/lmc/rtl/lmc_8.v

Verilog converted to html by v2html 5.0 (written by Costas Calamvokis).Help