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 202

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

powered by: WebSVN 2.1.0

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