/*===========================================================================*/
|
/*===========================================================================*/
|
/* Copyright (C) 2001 Authors */
|
/* Copyright (C) 2001 Authors */
|
/* */
|
/* */
|
/* This source file may be used and distributed without restriction provided */
|
/* This source file may be used and distributed without restriction provided */
|
/* that this copyright statement is not removed from the file and that any */
|
/* that this copyright statement is not removed from the file and that any */
|
/* derivative work contains the original copyright notice and the associated */
|
/* derivative work contains the original copyright notice and the associated */
|
/* disclaimer. */
|
/* disclaimer. */
|
/* */
|
/* */
|
/* This source file is free software; you can redistribute it and/or modify */
|
/* This source file is free software; you can redistribute it and/or modify */
|
/* it under the terms of the GNU Lesser General Public License as published */
|
/* it under the terms of the GNU Lesser General Public License as published */
|
/* by the Free Software Foundation; either version 2.1 of the License, or */
|
/* by the Free Software Foundation; either version 2.1 of the License, or */
|
/* (at your option) any later version. */
|
/* (at your option) any later version. */
|
/* */
|
/* */
|
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
|
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
|
/* License for more details. */
|
/* License for more details. */
|
/* */
|
/* */
|
/* You should have received a copy of the GNU Lesser General Public License */
|
/* You should have received a copy of the GNU Lesser General Public License */
|
/* along with this source; if not, write to the Free Software Foundation, */
|
/* along with this source; if not, write to the Free Software Foundation, */
|
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
/* */
|
/* */
|
/*===========================================================================*/
|
/*===========================================================================*/
|
/* DHRYSTONE FOR MCU */
|
/* DHRYSTONE FOR MCU */
|
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
/* */
|
/* */
|
/* Author(s): */
|
/* Author(s): */
|
/* - Olivier Girard, olgirard@gmail.com */
|
/* - Olivier Girard, olgirard@gmail.com */
|
/* */
|
/* */
|
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
/* $Rev: 19 $ */
|
/* $Rev: 19 $ */
|
/* $LastChangedBy: olivier.girard $ */
|
/* $LastChangedBy: olivier.girard $ */
|
/* $LastChangedDate: 2009-08-04 23:47:15 +0200 (Tue, 04 Aug 2009) $ */
|
/* $LastChangedDate: 2009-08-04 23:47:15 +0200 (Tue, 04 Aug 2009) $ */
|
/*===========================================================================*/
|
/*===========================================================================*/
|
`define NO_TIMEOUT
|
`define NO_TIMEOUT
|
|
|
time mclk_start_time, mclk_end_time;
|
time mclk_start_time, mclk_end_time;
|
real mclk_period, mclk_frequency;
|
real mclk_period, mclk_frequency;
|
|
|
time dhry_start_time, dhry_end_time;
|
time dhry_start_time, dhry_end_time;
|
real dhry_per_sec, dhry_mips, dhry_mips_per_mhz;
|
real dhry_per_sec, dhry_mips, dhry_mips_per_mhz;
|
|
|
integer Number_Of_Runs;
|
integer Number_Of_Runs;
|
|
|
initial
|
initial
|
begin
|
begin
|
$display(" ===============================================");
|
$display(" ===============================================");
|
$display("| START SIMULATION |");
|
$display("| START SIMULATION |");
|
$display(" ===============================================");
|
$display(" ===============================================");
|
|
// Disable automatic DMA verification
|
|
#10;
|
|
dma_verif_on = 0;
|
|
|
repeat(5) @(posedge mclk);
|
repeat(5) @(posedge mclk);
|
stimulus_done = 0;
|
stimulus_done = 0;
|
|
|
//---------------------------------------
|
//---------------------------------------
|
// Check CPU configuration
|
// Check CPU configuration
|
//---------------------------------------
|
//---------------------------------------
|
|
|
if ((`PMEM_SIZE !== 49152) || (`DMEM_SIZE !== 10240))
|
if ((`PMEM_SIZE !== 49152) || (`DMEM_SIZE !== 10240))
|
begin
|
begin
|
$display(" ===============================================");
|
$display(" ===============================================");
|
$display("| SIMULATION ERROR |");
|
$display("| SIMULATION ERROR |");
|
$display("| |");
|
$display("| |");
|
$display("| Core must be configured for: |");
|
$display("| Core must be configured for: |");
|
$display("| - 48kB program memory |");
|
$display("| - 48kB program memory |");
|
$display("| - 10kB data memory |");
|
$display("| - 10kB data memory |");
|
$display(" ===============================================");
|
$display(" ===============================================");
|
$finish;
|
$finish;
|
end
|
end
|
|
|
// Disable watchdog
|
// Disable watchdog
|
// (only required because RedHat/TI GCC toolchain doesn't disable watchdog properly at startup)
|
// (only required because RedHat/TI GCC toolchain doesn't disable watchdog properly at startup)
|
`ifdef WATCHDOG
|
`ifdef WATCHDOG
|
force dut.watchdog_0.wdtcnt = 16'h0000;
|
force dut.watchdog_0.wdtcnt = 16'h0000;
|
`endif
|
`endif
|
|
|
//---------------------------------------
|
//---------------------------------------
|
// Number of benchmark iteration
|
// Number of benchmark iteration
|
// (Must match the C-code value)
|
// (Must match the C-code value)
|
//---------------------------------------
|
//---------------------------------------
|
|
|
Number_Of_Runs = 100;
|
Number_Of_Runs = 100;
|
|
|
|
|
//---------------------------------------
|
//---------------------------------------
|
// Measure clock period
|
// Measure clock period
|
//---------------------------------------
|
//---------------------------------------
|
repeat(100) @(posedge mclk);
|
repeat(100) @(posedge mclk);
|
$timeformat(-9, 3, " ns", 10);
|
$timeformat(-9, 3, " ns", 10);
|
@(posedge mclk);
|
@(posedge mclk);
|
mclk_start_time = $time;
|
mclk_start_time = $time;
|
@(posedge mclk);
|
@(posedge mclk);
|
mclk_end_time = $time;
|
mclk_end_time = $time;
|
@(posedge mclk);
|
@(posedge mclk);
|
mclk_period = mclk_end_time-mclk_start_time;
|
mclk_period = mclk_end_time-mclk_start_time;
|
mclk_frequency = 1000/mclk_period;
|
mclk_frequency = 1000/mclk_period;
|
$display("\nINFO-VERILOG: openMSP430 System clock frequency %f MHz\n", mclk_frequency);
|
$display("\nINFO-VERILOG: openMSP430 System clock frequency %f MHz\n", mclk_frequency);
|
|
|
//---------------------------------------
|
//---------------------------------------
|
// Measure Dhrystone run time
|
// Measure Dhrystone run time
|
//---------------------------------------
|
//---------------------------------------
|
|
|
// Detect beginning of run
|
// Detect beginning of run
|
@(posedge p3_dout[0]);
|
@(posedge p3_dout[0]);
|
dhry_start_time = $time;
|
dhry_start_time = $time;
|
$timeformat(-3, 3, " ms", 10);
|
$timeformat(-3, 3, " ms", 10);
|
$display("\nINFO-VERILOG: Dhrystone loop started at %t ", dhry_start_time);
|
$display("\nINFO-VERILOG: Dhrystone loop started at %t ", dhry_start_time);
|
$display("");
|
$display("");
|
$display("INFO-VERILOG: Be patient... there could be up to 13ms to simulate");
|
$display("INFO-VERILOG: Be patient... there could be up to 13ms to simulate");
|
$display("");
|
$display("");
|
|
|
// Detect end of run
|
// Detect end of run
|
@(negedge p3_dout[0]);
|
@(negedge p3_dout[0]);
|
dhry_end_time = $time;
|
dhry_end_time = $time;
|
$timeformat(-3, 3, " ms", 10);
|
$timeformat(-3, 3, " ms", 10);
|
$display("INFO-VERILOG: Dhrystone loop ended at %t ", dhry_end_time);
|
$display("INFO-VERILOG: Dhrystone loop ended at %t ", dhry_end_time);
|
|
|
// Compute results
|
// Compute results
|
$timeformat(-9, 3, " ns", 10);
|
$timeformat(-9, 3, " ns", 10);
|
dhry_per_sec = (Number_Of_Runs*1000000000)/(dhry_end_time - dhry_start_time);
|
dhry_per_sec = (Number_Of_Runs*1000000000)/(dhry_end_time - dhry_start_time);
|
dhry_mips = dhry_per_sec / 1757;
|
dhry_mips = dhry_per_sec / 1757;
|
dhry_mips_per_mhz = dhry_mips / mclk_frequency;
|
dhry_mips_per_mhz = dhry_mips / mclk_frequency;
|
|
|
// Report results
|
// Report results
|
$display("\INFO-VERILOG: Dhrystone per second : %f", dhry_per_sec);
|
$display("\INFO-VERILOG: Dhrystone per second : %f", dhry_per_sec);
|
$display("\INFO-VERILOG: DMIPS : %f", dhry_mips);
|
$display("\INFO-VERILOG: DMIPS : %f", dhry_mips);
|
$display("\INFO-VERILOG: DMIPS/MHz : %f\n", dhry_mips_per_mhz);
|
$display("\INFO-VERILOG: DMIPS/MHz : %f\n", dhry_mips_per_mhz);
|
|
|
//---------------------------------------
|
//---------------------------------------
|
// Wait for the end of C-code execution
|
// Wait for the end of C-code execution
|
//---------------------------------------
|
//---------------------------------------
|
@(posedge p4_dout[0]);
|
@(posedge p4_dout[0]);
|
|
|
stimulus_done = 1;
|
stimulus_done = 1;
|
|
|
$display(" ===============================================");
|
$display(" ===============================================");
|
$display("| SIMULATION DONE |");
|
$display("| SIMULATION DONE |");
|
$display("| (stopped through verilog stimulus) |");
|
$display("| (stopped through verilog stimulus) |");
|
$display(" ===============================================");
|
$display(" ===============================================");
|
$finish;
|
$finish;
|
|
|
end
|
end
|
|
|
// Display stuff from the C-program
|
// Display stuff from the C-program
|
always @(p2_dout[0])
|
always @(p2_dout[0])
|
begin
|
begin
|
$write("%s", p1_dout);
|
$write("%s", p1_dout);
|
$fflush();
|
$fflush();
|
end
|
end
|
|
|
// Display some info to show simulation progress
|
// Display some info to show simulation progress
|
initial
|
initial
|
begin
|
begin
|
@(posedge p3_dout[0]);
|
@(posedge p3_dout[0]);
|
#1000000;
|
#1000000;
|
while (p3_dout[0])
|
while (p3_dout[0])
|
begin
|
begin
|
$display("INFO-VERILOG: Simulated time %t ", $time);
|
$display("INFO-VERILOG: Simulated time %t ", $time);
|
#1000000;
|
#1000000;
|
end
|
end
|
end
|
end
|
|
|