1 |
145 |
olivier.gi |
/*===========================================================================*/
|
2 |
|
|
/* Copyright (C) 2001 Authors */
|
3 |
|
|
/* */
|
4 |
|
|
/* This source file may be used and distributed without restriction provided */
|
5 |
|
|
/* that this copyright statement is not removed from the file and that any */
|
6 |
|
|
/* derivative work contains the original copyright notice and the associated */
|
7 |
|
|
/* disclaimer. */
|
8 |
|
|
/* */
|
9 |
|
|
/* This source file is free software; you can redistribute it and/or modify */
|
10 |
|
|
/* it under the terms of the GNU Lesser General Public License as published */
|
11 |
|
|
/* by the Free Software Foundation; either version 2.1 of the License, or */
|
12 |
|
|
/* (at your option) any later version. */
|
13 |
|
|
/* */
|
14 |
|
|
/* This source is distributed in the hope that it will be useful, but WITHOUT*/
|
15 |
|
|
/* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or */
|
16 |
|
|
/* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public */
|
17 |
|
|
/* License for more details. */
|
18 |
|
|
/* */
|
19 |
|
|
/* You should have received a copy of the GNU Lesser General Public License */
|
20 |
|
|
/* along with this source; if not, write to the Free Software Foundation, */
|
21 |
|
|
/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */
|
22 |
|
|
/* */
|
23 |
|
|
/*===========================================================================*/
|
24 |
|
|
/* SANDBOX */
|
25 |
|
|
/*---------------------------------------------------------------------------*/
|
26 |
|
|
/* */
|
27 |
|
|
/* Author(s): */
|
28 |
|
|
/* - Olivier Girard, olgirard@gmail.com */
|
29 |
|
|
/* */
|
30 |
|
|
/*---------------------------------------------------------------------------*/
|
31 |
|
|
/* $Rev: 19 $ */
|
32 |
|
|
/* $LastChangedBy: olivier.girard $ */
|
33 |
|
|
/* $LastChangedDate: 2009-08-04 23:47:15 +0200 (Tue, 04 Aug 2009) $ */
|
34 |
|
|
/*===========================================================================*/
|
35 |
|
|
`define NO_TIMEOUT
|
36 |
|
|
|
37 |
|
|
time mclk_start_time, mclk_end_time;
|
38 |
|
|
real mclk_period, mclk_frequency;
|
39 |
|
|
|
40 |
|
|
time dhry_start_time, dhry_end_time;
|
41 |
|
|
real dhry_per_sec, dhry_mips, dhry_mips_per_mhz;
|
42 |
|
|
|
43 |
|
|
integer Number_Of_Runs;
|
44 |
|
|
|
45 |
|
|
initial
|
46 |
|
|
begin
|
47 |
|
|
$display(" ===============================================");
|
48 |
|
|
$display("| START SIMULATION |");
|
49 |
|
|
$display(" ===============================================");
|
50 |
|
|
repeat(5) @(posedge mclk);
|
51 |
|
|
stimulus_done = 0;
|
52 |
|
|
|
53 |
|
|
//---------------------------------------
|
54 |
|
|
// Check CPU configuration
|
55 |
|
|
//---------------------------------------
|
56 |
|
|
|
57 |
|
|
if ((`PMEM_SIZE !== 24576) || (`DMEM_SIZE !== 16384))
|
58 |
|
|
begin
|
59 |
|
|
$display(" ===============================================");
|
60 |
|
|
$display("| SIMULATION ERROR |");
|
61 |
|
|
$display("| |");
|
62 |
|
|
$display("| Core must be configured for: |");
|
63 |
|
|
$display("| - 24kB program memory |");
|
64 |
|
|
$display("| - 16kB data memory |");
|
65 |
|
|
$display(" ===============================================");
|
66 |
|
|
$finish;
|
67 |
|
|
end
|
68 |
|
|
|
69 |
|
|
//---------------------------------------
|
70 |
|
|
// Number of benchmark iteration
|
71 |
|
|
// (Must match the C-code value)
|
72 |
|
|
//---------------------------------------
|
73 |
|
|
|
74 |
|
|
Number_Of_Runs = 100;
|
75 |
|
|
|
76 |
|
|
|
77 |
|
|
//---------------------------------------
|
78 |
|
|
// Measure clock period
|
79 |
|
|
//---------------------------------------
|
80 |
|
|
repeat(100) @(posedge mclk);
|
81 |
|
|
$timeformat(-9, 3, " ns", 10);
|
82 |
|
|
@(posedge mclk);
|
83 |
|
|
mclk_start_time = $time;
|
84 |
|
|
@(posedge mclk);
|
85 |
|
|
mclk_end_time = $time;
|
86 |
|
|
@(posedge mclk);
|
87 |
|
|
mclk_period = mclk_end_time-mclk_start_time;
|
88 |
|
|
mclk_frequency = 1000/mclk_period;
|
89 |
|
|
$display("\nINFO-VERILOG: openMSP430 System clock frequency %f MHz\n", mclk_frequency);
|
90 |
|
|
|
91 |
|
|
//---------------------------------------
|
92 |
|
|
// Measure Dhrystone run time
|
93 |
|
|
//---------------------------------------
|
94 |
|
|
|
95 |
|
|
// Detect beginning of run
|
96 |
|
|
@(posedge p3_dout[0]);
|
97 |
|
|
dhry_start_time = $time;
|
98 |
|
|
$timeformat(-3, 3, " ms", 10);
|
99 |
|
|
$display("\nINFO-VERILOG: Dhrystone loop started at %t ", dhry_start_time);
|
100 |
|
|
|
101 |
|
|
// Detect end of run
|
102 |
|
|
@(negedge p3_dout[0]);
|
103 |
|
|
dhry_end_time = $time;
|
104 |
|
|
$timeformat(-3, 3, " ms", 10);
|
105 |
|
|
$display("INFO-VERILOG: Dhrystone loop ended at %t ", dhry_end_time);
|
106 |
|
|
|
107 |
|
|
// Compute results
|
108 |
|
|
$timeformat(-9, 3, " ns", 10);
|
109 |
|
|
dhry_per_sec = (Number_Of_Runs*1000000000)/(dhry_end_time - dhry_start_time);
|
110 |
|
|
dhry_mips = dhry_per_sec / 1757;
|
111 |
|
|
dhry_mips_per_mhz = dhry_mips / mclk_frequency;
|
112 |
|
|
|
113 |
|
|
// Report results
|
114 |
|
|
$display("\INFO-VERILOG: Dhrystone per second : %f", dhry_per_sec);
|
115 |
|
|
$display("\INFO-VERILOG: DMIPS : %f", dhry_mips);
|
116 |
|
|
$display("\INFO-VERILOG: DMIPS/MHz : %f\n", dhry_mips_per_mhz);
|
117 |
|
|
|
118 |
|
|
//---------------------------------------
|
119 |
|
|
// Wait for the end of C-code execution
|
120 |
|
|
//---------------------------------------
|
121 |
|
|
@(posedge p4_dout[0]);
|
122 |
|
|
|
123 |
|
|
stimulus_done = 1;
|
124 |
|
|
|
125 |
|
|
$display(" ===============================================");
|
126 |
|
|
$display("| SIMULATION DONE |");
|
127 |
|
|
$display("| (stopped through verilog stimulus) |");
|
128 |
|
|
$display(" ===============================================");
|
129 |
|
|
$finish;
|
130 |
|
|
|
131 |
|
|
end
|
132 |
|
|
|
133 |
|
|
// Display stuff from the C-program
|
134 |
|
|
always @(p2_dout[0])
|
135 |
|
|
begin
|
136 |
|
|
$write("%s", p1_dout);
|
137 |
|
|
end
|