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 145

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
/*                                 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 coremark_start_time, coremark_end_time;
41
real coremark_per_sec;
42
real coremark_per_mhz;
43
 
44
integer Number_Of_Iterations;
45
 
46
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
      if ((`PMEM_SIZE !== 24576) || (`DMEM_SIZE !== 16384))
59
        begin
60
           $display(" ===============================================");
61
           $display("|               SIMULATION ERROR                |");
62
           $display("|                                               |");
63
           $display("|  Core must be configured for:                 |");
64
           $display("|               - 24kB program memory           |");
65
           $display("|               - 16kB data memory              |");
66
           $display(" ===============================================");
67
           $finish;
68
        end
69
 
70
      //---------------------------------------
71
      // Number of benchmark iteration
72
      // (Must match the C-code value)
73
      //---------------------------------------
74
 
75
      Number_Of_Iterations = 1;
76
 
77
 
78
      //---------------------------------------
79
      // Measure clock period
80
      //---------------------------------------
81
      repeat(100) @(posedge mclk);
82
      $timeformat(-9, 3, " ns", 10);
83
      @(posedge mclk);
84
      mclk_start_time = $time;
85
      @(posedge mclk);
86
      mclk_end_time = $time;
87
      @(posedge mclk);
88
      mclk_period    = mclk_end_time-mclk_start_time;
89
      mclk_frequency = 1000/mclk_period;
90
      $display("\nINFO-VERILOG: openMSP430 System clock frequency %f MHz", mclk_frequency);
91
 
92
      //---------------------------------------
93
      // Measure Dhrystone run time
94
      //---------------------------------------
95
 
96
      // Detect beginning of run
97
      @(posedge p2_dout[1]);
98
      coremark_start_time = $time;
99
      $timeformat(-3, 3, " ms", 10);
100
      $display("INFO-VERILOG: CoreMark loop started at %t ", coremark_start_time);
101
 
102
      // Detect end of run
103
      @(negedge p2_dout[1]);
104
      coremark_end_time = $time;
105
      $timeformat(-3, 3, " ms", 10);
106
      $display("INFO-VERILOG: Coremark loop ended   at %t ",   coremark_end_time);
107
 
108
      // Compute results
109
      $timeformat(-9, 3, " ns", 10);
110
      coremark_per_sec = coremark_end_time - coremark_start_time;
111
      coremark_per_sec = 1000000000 / coremark_per_sec;
112
      coremark_per_sec = Number_Of_Iterations*coremark_per_sec;
113
      coremark_per_mhz = coremark_per_sec / mclk_frequency;
114
 
115
      // Report results
116
      $display("\INFO-VERILOG: CoreMark ticks      : %d",     {p6_din, p5_din, p4_din, p3_din});
117
      $display("\INFO-VERILOG: CoreMark per second : %f",     coremark_per_sec);
118
      $display("\INFO-VERILOG: CoreMark per MHz    : %f\n\n", coremark_per_mhz);
119
 
120
      //---------------------------------------
121
      // Wait for the end of C-code execution
122
      //---------------------------------------
123
      @(posedge p2_dout[7]);
124
 
125
      stimulus_done = 1;
126
 
127
      $display(" ===============================================");
128
      $display("|               SIMULATION DONE                 |");
129
      $display("|       (stopped through verilog stimulus)      |");
130
      $display(" ===============================================");
131
      $finish;
132
 
133
   end
134
 
135
// Display stuff from the C-program
136
always @(p2_dout[0])
137
  begin
138
     $write("%s", p1_dout);
139
  end
140
 
141
 
142
// Time tick counter
143
always @(negedge mclk or posedge puc_rst)
144
  if (puc_rst)         {p6_din, p5_din, p4_din, p3_din} <= 32'h0000_0000;
145
  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.