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

Subversion Repositories openmsp430

[/] [openmsp430/] [trunk/] [core/] [sim/] [rtl_sim/] [src-c/] [coremark_v1.0/] [coremark_v1.0.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
/*                                 COREMARK                                  */
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 coremark_start_time, coremark_end_time;
41
real coremark_per_sec;
42
real coremark_per_mhz;
43
 
44
integer Number_Of_Iterations;
45 200 olivier.gi
 
46 145 olivier.gi
initial
47
   begin
48
      $display(" ===============================================");
49
      $display("|                 START SIMULATION              |");
50
      $display(" ===============================================");
51
      repeat(5) @(posedge mclk);
52
      stimulus_done = 0;
53
 
54
      //---------------------------------------
55
      // Check CPU configuration
56
      //---------------------------------------
57
 
58 200 olivier.gi
      if ((`PMEM_SIZE !== 55296) || (`DMEM_SIZE !== 5120))
59 145 olivier.gi
        begin
60
           $display(" ===============================================");
61
           $display("|               SIMULATION ERROR                |");
62
           $display("|                                               |");
63
           $display("|  Core must be configured for:                 |");
64 200 olivier.gi
           $display("|               - 54kB program memory           |");
65
           $display("|               -  5kB data memory              |");
66 145 olivier.gi
           $display(" ===============================================");
67 200 olivier.gi
           $finish;
68 145 olivier.gi
        end
69
 
70 200 olivier.gi
      // Disable watchdog
71
      // (only required because RedHat/TI GCC toolchain doesn't disable watchdog properly at startup)
72
      `ifdef WATCHDOG
73
        force dut.watchdog_0.wdtcnt   = 16'h0000;
74
      `endif
75
 
76 145 olivier.gi
      //---------------------------------------
77
      // Number of benchmark iteration
78
      // (Must match the C-code value)
79
      //---------------------------------------
80
 
81
      Number_Of_Iterations = 1;
82
 
83
 
84
      //---------------------------------------
85
      // Measure clock period
86
      //---------------------------------------
87
      repeat(100) @(posedge mclk);
88
      $timeformat(-9, 3, " ns", 10);
89
      @(posedge mclk);
90
      mclk_start_time = $time;
91
      @(posedge mclk);
92
      mclk_end_time = $time;
93
      @(posedge mclk);
94
      mclk_period    = mclk_end_time-mclk_start_time;
95
      mclk_frequency = 1000/mclk_period;
96
      $display("\nINFO-VERILOG: openMSP430 System clock frequency %f MHz", mclk_frequency);
97
 
98
      //---------------------------------------
99 200 olivier.gi
      // Measure CoreMark run time
100 145 olivier.gi
      //---------------------------------------
101
 
102
      // Detect beginning of run
103
      @(posedge p2_dout[1]);
104
      coremark_start_time = $time;
105
      $timeformat(-3, 3, " ms", 10);
106
      $display("INFO-VERILOG: CoreMark loop started at %t ", coremark_start_time);
107 200 olivier.gi
      $display("");
108
      $display("INFO-VERILOG: Be patient... there could be up to 90ms to simulate");
109
      $display("");
110
 
111 145 olivier.gi
      // Detect end of run
112
      @(negedge p2_dout[1]);
113
      coremark_end_time = $time;
114
      $timeformat(-3, 3, " ms", 10);
115
      $display("INFO-VERILOG: Coremark loop ended   at %t ",   coremark_end_time);
116 200 olivier.gi
 
117 145 olivier.gi
      // Compute results
118
      $timeformat(-9, 3, " ns", 10);
119
      coremark_per_sec = coremark_end_time - coremark_start_time;
120
      coremark_per_sec = 1000000000 / coremark_per_sec;
121
      coremark_per_sec = Number_Of_Iterations*coremark_per_sec;
122
      coremark_per_mhz = coremark_per_sec / mclk_frequency;
123
 
124
      // Report results
125
      $display("\INFO-VERILOG: CoreMark ticks      : %d",     {p6_din, p5_din, p4_din, p3_din});
126
      $display("\INFO-VERILOG: CoreMark per second : %f",     coremark_per_sec);
127
      $display("\INFO-VERILOG: CoreMark per MHz    : %f\n\n", coremark_per_mhz);
128
 
129
      //---------------------------------------
130
      // Wait for the end of C-code execution
131
      //---------------------------------------
132
      @(posedge p2_dout[7]);
133 200 olivier.gi
 
134 145 olivier.gi
      stimulus_done = 1;
135
 
136
      $display(" ===============================================");
137
      $display("|               SIMULATION DONE                 |");
138
      $display("|       (stopped through verilog stimulus)      |");
139
      $display(" ===============================================");
140
      $finish;
141
 
142
   end
143
 
144
// Display stuff from the C-program
145
always @(p2_dout[0])
146
  begin
147
     $write("%s", p1_dout);
148 200 olivier.gi
     $fflush();
149 145 olivier.gi
  end
150
 
151 200 olivier.gi
// Display some info to show simulation progress
152
initial
153
  begin
154
     @(posedge p2_dout[1]);
155
     #1000000;
156
     while (p2_dout[1])
157
       begin
158
          $display("INFO-VERILOG: Simulated time %t ", $time);
159
          #1000000;
160
       end
161
  end
162 145 olivier.gi
 
163 200 olivier.gi
 
164 145 olivier.gi
// Time tick counter
165
always @(negedge mclk or posedge puc_rst)
166
  if (puc_rst)         {p6_din, p5_din, p4_din, p3_din} <= 32'h0000_0000;
167
  else if (p2_dout[1]) {p6_din, p5_din, p4_din, p3_din} <= {p6_din, p5_din, p4_din, p3_din} + 32'h1;

powered by: WebSVN 2.1.0

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