⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 run_isp8.pl

📁 简单的8位CPU
💻 PL
字号:
# =============================================================================
#                           COPYRIGHT NOTICE
# Copyright 2000-2002 (c) Lattice Semiconductor Corporation
# ALL RIGHTS RESERVED
# This confidential and proprietary software may be used only as authorised by
# a licensing agreement from Lattice Semiconductor Corporation.
# The entire notice above must be reproduced on all authorized copies and
# copies may only be made to the extent permitted by a licensing agreement from
# Lattice Semiconductor Corporation.
#
# Lattice Semiconductor Corporation        TEL : 1-800-Lattice (USA and Canada)
# 5555 NE Moore Court                            408-826-6000 (other locations)
# Hillsboro, OR 97124                     web  : http:#www.latticesemi.com/
# U.S.A                                   email: techsupport@latticesemi.com
# =============================================================================
#                         FILE DETAILS         
# Project          : isp8 
# File             : run_isp8.pl
# Title            :  
# Dependencies     : 
# Description      : Simulation script to run modelsim simulator in Windows. 
# =============================================================================
#                        REVISION HISTORY
# Version          : 1.0
# Author(s)        : Umesh Ananthiah
# Mod. Date        : June 3, 2005
# Changes Made     : Initial Creation
# =============================================================================

# Use env varaibles
use Env;
use Cwd;
#==============================================================================
# USER VARIABLES
$os_used    = "WINDOWS";
$root_dir   = &root_dir($os_used);
$params_dir = "$root_dir/source/params";
$sim_dir    = "$root_dir/simulation/modelsim/rtl";
$source_dir = "$root_dir/source";
$models_dir = "$root_dir/models";
$testbench  = "$root_dir/testbench";
$tests_dir  = "$root_dir/tests";
$utils_dir  = "$root_dir/utils";
$syn_tool   = "synplicity";

#$modelsim_dir = "C:/Modeltech_5.8c/win32";
$modelsim_dir = "C:/isptools5_0/modelsim/win32loem";
 
$ncvlog_exe     = "$modelsim_dir/vlog";
$ncelab_exe     = "$modelsim_dir/velab";
$ncsim_exe      = "$modelsim_dir/vsim";
$ncverilog_exe  = "$modelsim_dir/vsim";

$run_type   = "_";
$c_sim      = "C_SIM" ;
$timescale  = "-timescale \"1ns/100ps\"";
$defines    = "+define+DEBUG=0";

#==============================================================================
# Usage 
sub usage {
    print "\n";
    print "Usage: \n";
    print "run_isp8.pl : To get Help\n";
    print "run_isp8.pl -h : To get Help\n";
    print "run_isp8.pl <test_case> : To run test_case with SignalScan dump \n";
    print "run_isp8.pl <test_case> <DEBUG> : To get additional messages \n";
    print "run_isp8.pl <test_case> <REGRESS> : For no signalscan dump \n";
    print "run_isp8.pl <test_case> <NO_C_SIM> : Required for test case tc_06 \n";
    print "\n";
}

$arg_num = @ARGV;

# assign the arguments to the list
@arg_list = @ARGV [0..($arg_num)];

if ($arg_num == 0) {
    usage;
    exit;
}

while (<@arg_list>) {
   if (/NO_C_SIM/) {
      $c_sim = "NO_C_SIM" ;
   }
   if (/DEBUG/) {
      $run_type = "DEBUG" ;
      $defines  = "+define+DEBUG=1";
   }
   if (/REGRESS/) {
      $run_type = "REGRESS" ;
      $sim_dir  = "$sim_dir/regress";
      $defines  = "+define+DEBUG=0 +define+REGRESS";
   }
}

$testcase = $ARGV[0];
#==============================================================================

@SOURCE_FILES = (  
                 "$source_dir/isp8.v"
                );

@MODEL_FILES = ( 
                "$models_dir/xp/sim/VHI.v",
                "$models_dir/xp/sim/VLO.v",
                "$models_dir/xp/sim/PUR.v",
                "$models_dir/xp/sim/GSR.v",
                "$models_dir/xp/sim/DP8KA.v",
                "$models_dir/xp/sim/SP8KA.v",
                "$models_dir/xp/sim/INV.v",
                "$models_dir/xp/sim/AND2.v",
                "$models_dir/xp/sim/AND3.v",
                "$models_dir/xp/sim/MUX21.v",
                "$models_dir/xp/sim/FADSU2.v",
                "$models_dir/xp/sim/DPR16X2B.v",
                "$models_dir/xp/sim/SPR16X2B.v",
                "$models_dir/xp/sim/dpram32x8.v",
                "$models_dir/xp/sim/dpram16x8.v",
                "$models_dir/xp/sim/spram16x9.v",
                "$models_dir/xp/sim/spram32x8.v",
                "$models_dir/xp/sim/spram16x8.v",
                "$models_dir/xp/sim/prom.v"
               );
		

@TB_FILES = (
             "$testbench/isp8_tb.v"
	    );

@INC_DIR  = (
	    "+incdir+$source_dir/config3"
	   );

$run_dir  = "$sim_dir/$testcase";

if (-d "$run_dir") {
   system "/bin/rm -rf $run_dir/INCA_libs";
   system "/bin/rm -rf $run_dir/work";
}
else {
   mkdir ("$sim_dir", 0777);
   mkdir ("$run_dir", 0777);
}
chdir ("$run_dir");

# create work directory
if (-d "$run_dir/work") {
}
else {
   mkdir ("$run_dir", 0777);
}

# Copy files 
&copy_testcase("$testcase.v");

#==============================================================================
# Generate pron init file
system "$utils_dir/isp8asm_win -ve -o $run_dir/prom_init.v $tests_dir/$testcase.s";
system "$utils_dir/isp8asm_win -vx -o $run_dir/prom_init.hex $tests_dir/$testcase.s";

if ($c_sim eq "NO_C_SIM") {
} else {
   system "$utils_dir/isp8sim_win $run_dir/prom_init.hex > isp8sim_out.txt";
}
#==============================================================================
# Map WORK directories
system ("$modelsim_dir/vlib work");
system ("$modelsim_dir/vmap work work");

# Make arguments 
$waveform_arg = "-wlf $sim_dir/$testcase/$testcase.wlf";
$log_arg      = "-l $sim_dir/$testcase/$testcase.log";

# Create sim.do file
$simdofile = "$run_dir/sim.do";
open (SIMDO, ">$simdofile");
print SIMDO "log -r /*\n";
print SIMDO "run -all\n";
print SIMDO "quit\n";
close(SIMDO);

# Make vlog and vsim commands 

$run_vlog = ("$modelsim_dir/vlog $defines @INC_DIR @TB_FILES @SOURCE_FILES @MODEL_FILES -work work");
$run_vsim = ("$modelsim_dir/vsim -t 1ps -c work.isp8_tb -L work $log_arg $waveform_arg -do $simdofile");


#==============================================================================
# Apply commands 
#print ("Executing the command:\n\t$run_vlog\t\n");
system ("$run_vlog");

#print ("Executing the command:\n\t$run_vsim\t\n");
system ("$run_vsim");

system ("rmdir /Q /S work");

# =============================================================================
# Define Sub Routines
sub root_dir 
  {
    my ($os) = @_;
    my $pwd = "";

    if ($os eq "WINDOWS") { $pwd = getcwd;}
    else { $pwd = $ENV{PWD};}
    $pwd  =~ s/\/\w+$//;
    $pwd  =~ s/\/\w+$//;
    $pwd  =~ s/\/\w+$//;
    return $pwd;
  }

sub add_dir
  {
    my ($dir, $val, $arr_files) = @_;
    my $file;
    my $i=0;
    foreach $file (@$arr_files) {
      @$arr_files[$i] = $val . $dir . $file;
      $i++;
    }
  }

 sub copy_testcase
  {
    my ($sub_cp_test_name) = @_;
    print "In copy_test $sub_cp_test_name \n";

    open (CTT_RFILE, "$tests_dir/$sub_cp_test_name") || die "Couldn't open $tests_dir/$sub_cp_test_name for reading : $!";
    open (CTT_WFILE, ">$sim_dir/$testcase/testcase.v")  || die "Couldn't open $sim_dir/$testcase/testcase.v for writing : $!";
    @lines_rfile = <CTT_RFILE>;
    print (CTT_WFILE "@lines_rfile");
    close CTT_RFILE;
    close CTT_WFILE;
  }

exit ;
# =============================================================================

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -