OpenCores
URL https://opencores.org/ocsvn/openmsp430/openmsp430/trunk

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src-c/] [dhrystone_4mcu/] [dhrystone_4mcu.v] - Blame information for rev 200

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
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 200 olivier.gi
/*                             DHRYSTONE FOR MCU                             */
25 145 olivier.gi
/*---------------------------------------------------------------------------*/
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 200 olivier.gi
 
45 145 olivier.gi
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 200 olivier.gi
      if ((`PMEM_SIZE !== 49152) || (`DMEM_SIZE !== 10240))
58 145 olivier.gi
        begin
59
           $display(" ===============================================");
60
           $display("|               SIMULATION ERROR                |");
61
           $display("|                                               |");
62
           $display("|  Core must be configured for:                 |");
63 200 olivier.gi
           $display("|               - 48kB program memory           |");
64
           $display("|               - 10kB data memory              |");
65 145 olivier.gi
           $display(" ===============================================");
66 200 olivier.gi
           $finish;
67 145 olivier.gi
        end
68
 
69 200 olivier.gi
      // Disable watchdog
70
      // (only required because RedHat/TI GCC toolchain doesn't disable watchdog properly at startup)
71
      `ifdef WATCHDOG
72
        force dut.watchdog_0.wdtcnt   = 16'h0000;
73
      `endif
74
 
75 145 olivier.gi
      //---------------------------------------
76
      // Number of benchmark iteration
77
      // (Must match the C-code value)
78
      //---------------------------------------
79
 
80
      Number_Of_Runs = 100;
81
 
82
 
83
      //---------------------------------------
84
      // Measure clock period
85
      //---------------------------------------
86
      repeat(100) @(posedge mclk);
87
      $timeformat(-9, 3, " ns", 10);
88
      @(posedge mclk);
89
      mclk_start_time = $time;
90
      @(posedge mclk);
91
      mclk_end_time = $time;
92
      @(posedge mclk);
93
      mclk_period    = mclk_end_time-mclk_start_time;
94
      mclk_frequency = 1000/mclk_period;
95
      $display("\nINFO-VERILOG: openMSP430 System clock frequency %f MHz\n", mclk_frequency);
96
 
97
      //---------------------------------------
98
      // Measure Dhrystone run time
99
      //---------------------------------------
100
 
101
      // Detect beginning of run
102
      @(posedge p3_dout[0]);
103
      dhry_start_time = $time;
104
      $timeformat(-3, 3, " ms", 10);
105
      $display("\nINFO-VERILOG: Dhrystone loop started at %t ", dhry_start_time);
106 200 olivier.gi
      $display("");
107
      $display("INFO-VERILOG: Be patient... there could be up to 13ms to simulate");
108
      $display("");
109
 
110 145 olivier.gi
      // Detect end of run
111
      @(negedge p3_dout[0]);
112
      dhry_end_time = $time;
113
      $timeformat(-3, 3, " ms", 10);
114
      $display("INFO-VERILOG: Dhrystone loop ended   at %t ",   dhry_end_time);
115 200 olivier.gi
 
116 145 olivier.gi
      // Compute results
117
      $timeformat(-9, 3, " ns", 10);
118
      dhry_per_sec      = (Number_Of_Runs*1000000000)/(dhry_end_time - dhry_start_time);
119
      dhry_mips         = dhry_per_sec / 1757;
120
      dhry_mips_per_mhz = dhry_mips / mclk_frequency;
121
 
122
      // Report results
123
      $display("\INFO-VERILOG: Dhrystone per second : %f",   dhry_per_sec);
124
      $display("\INFO-VERILOG: DMIPS                : %f",   dhry_mips);
125
      $display("\INFO-VERILOG: DMIPS/MHz            : %f\n", dhry_mips_per_mhz);
126
 
127
      //---------------------------------------
128
      // Wait for the end of C-code execution
129
      //---------------------------------------
130
      @(posedge p4_dout[0]);
131 200 olivier.gi
 
132 145 olivier.gi
      stimulus_done = 1;
133
 
134
      $display(" ===============================================");
135
      $display("|               SIMULATION DONE                 |");
136
      $display("|       (stopped through verilog stimulus)      |");
137
      $display(" ===============================================");
138
      $finish;
139
 
140
   end
141
 
142
// Display stuff from the C-program
143
always @(p2_dout[0])
144
  begin
145
     $write("%s", p1_dout);
146 200 olivier.gi
     $fflush();
147 145 olivier.gi
  end
148 200 olivier.gi
 
149
// Display some info to show simulation progress
150
initial
151
  begin
152
     @(posedge p3_dout[0]);
153
     #1000000;
154
     while (p3_dout[0])
155
       begin
156
          $display("INFO-VERILOG: Simulated time %t ", $time);
157
          #1000000;
158
       end
159
  end

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.