112855Sgabeblack@google.com/*****************************************************************************
212855Sgabeblack@google.com
312855Sgabeblack@google.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
412855Sgabeblack@google.com  more contributor license agreements.  See the NOTICE file distributed
512855Sgabeblack@google.com  with this work for additional information regarding copyright ownership.
612855Sgabeblack@google.com  Accellera licenses this file to you under the Apache License, Version 2.0
712855Sgabeblack@google.com  (the "License"); you may not use this file except in compliance with the
812855Sgabeblack@google.com  License.  You may obtain a copy of the License at
912855Sgabeblack@google.com
1012855Sgabeblack@google.com    http://www.apache.org/licenses/LICENSE-2.0
1112855Sgabeblack@google.com
1212855Sgabeblack@google.com  Unless required by applicable law or agreed to in writing, software
1312855Sgabeblack@google.com  distributed under the License is distributed on an "AS IS" BASIS,
1412855Sgabeblack@google.com  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1512855Sgabeblack@google.com  implied.  See the License for the specific language governing
1612855Sgabeblack@google.com  permissions and limitations under the License.
1712855Sgabeblack@google.com
1812855Sgabeblack@google.com *****************************************************************************/
1912855Sgabeblack@google.com
2012855Sgabeblack@google.com/*****************************************************************************
2112855Sgabeblack@google.com
2212855Sgabeblack@google.com  stim.h --
2312855Sgabeblack@google.com
2412855Sgabeblack@google.com  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
2512855Sgabeblack@google.com
2612855Sgabeblack@google.com *****************************************************************************/
2712855Sgabeblack@google.com
2812855Sgabeblack@google.com/*****************************************************************************
2912855Sgabeblack@google.com
3012855Sgabeblack@google.com  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
3112855Sgabeblack@google.com  changes you are making here.
3212855Sgabeblack@google.com
3312855Sgabeblack@google.com      Name, Affiliation, Date:
3412855Sgabeblack@google.com  Description of Modification:
3512855Sgabeblack@google.com
3612855Sgabeblack@google.com *****************************************************************************/
3712855Sgabeblack@google.com
3812855Sgabeblack@google.com/******************************************************************************/
3912855Sgabeblack@google.com/***************************  stimulus Class Definition    ********************/
4012855Sgabeblack@google.com/******************************************************************************/
4112855Sgabeblack@google.com
4212855Sgabeblack@google.com#include "common.h"
4312855Sgabeblack@google.com
4412855Sgabeblack@google.comSC_MODULE( STIM )
4512855Sgabeblack@google.com{
4612855Sgabeblack@google.com    SC_HAS_PROCESS( STIM );
4712855Sgabeblack@google.com
4812855Sgabeblack@google.com    sc_in_clk clk;
4912855Sgabeblack@google.com
5012855Sgabeblack@google.com          sc_signal<bool>& 	reset;
5112855Sgabeblack@google.com          sc_signal<bool>&    	in_ok;
5212855Sgabeblack@google.com          sc_signal<bool>&    	out_ok;
5312855Sgabeblack@google.com    const sc_signal<bool>&     	instrb;
5412855Sgabeblack@google.com    const sc_signal<bool>&     	outstrb;
5512855Sgabeblack@google.com          signal_bool_vector    &a1,&a2,&a3,&a4,&a5,&a6,&a7,&a8;// -128 to 127
5612855Sgabeblack@google.com    const signal_bool_vector    &d1,&d2,&d3,&d4,&d5,&d6,&d7,&d8;
5712855Sgabeblack@google.com
5812855Sgabeblack@google.com
5912855Sgabeblack@google.com    STIM( 	sc_module_name  		NAME,
6012855Sgabeblack@google.com	       	      sc_clock& 		TICK_P,
6112855Sgabeblack@google.com    		      sc_signal<bool>& 		RESET,
6212855Sgabeblack@google.com    		      sc_signal<bool>& 		IN_OK,
6312855Sgabeblack@google.com    		      sc_signal<bool>& 		OUT_OK,
6412855Sgabeblack@google.com    		const sc_signal<bool>&     	INSTRB,
6512855Sgabeblack@google.com    		const sc_signal<bool>&    	OUTSTRB,
6612855Sgabeblack@google.com    		      signal_bool_vector&       A1,
6712855Sgabeblack@google.com		      signal_bool_vector&	A2,
6812855Sgabeblack@google.com		      signal_bool_vector&	A3,
6912855Sgabeblack@google.com		      signal_bool_vector&	A4,
7012855Sgabeblack@google.com		      signal_bool_vector&	A5,
7112855Sgabeblack@google.com		      signal_bool_vector&	A6,
7212855Sgabeblack@google.com		      signal_bool_vector&	A7,
7312855Sgabeblack@google.com		      signal_bool_vector&	A8,
7412855Sgabeblack@google.com    		      signal_bool_vector&       D1,
7512855Sgabeblack@google.com		      signal_bool_vector&	D2,
7612855Sgabeblack@google.com		      signal_bool_vector&	D3,
7712855Sgabeblack@google.com		      signal_bool_vector&	D4,
7812855Sgabeblack@google.com		      signal_bool_vector&	D5,
7912855Sgabeblack@google.com		      signal_bool_vector&	D6,
8012855Sgabeblack@google.com		      signal_bool_vector&	D7,
8112855Sgabeblack@google.com		      signal_bool_vector&	D8
8212855Sgabeblack@google.com              )
8312855Sgabeblack@google.com        :
8412855Sgabeblack@google.com		reset	(RESET),
8512855Sgabeblack@google.com		in_ok	(IN_OK),
8612855Sgabeblack@google.com		out_ok	(OUT_OK),
8712855Sgabeblack@google.com		instrb 	(INSTRB),
8812855Sgabeblack@google.com		outstrb (OUTSTRB),
8912855Sgabeblack@google.com		a1      (A1), a2(A2), a3(A3), a4(A4),
9012855Sgabeblack@google.com                a5      (A5), a6(A6), a7(A7), a8(A8),
9112855Sgabeblack@google.com		d1      (D1), d2(D2), d3(D3), d4(D4),
9212855Sgabeblack@google.com                d5      (D5), d6(D6), d7(D7), d8(D8)
9312855Sgabeblack@google.com    {
9412855Sgabeblack@google.com        clk(TICK_P);
9512855Sgabeblack@google.com        SC_CTHREAD( entry, clk.neg() );
9612855Sgabeblack@google.com    }
9712855Sgabeblack@google.com    void entry();
9812855Sgabeblack@google.com};
9912855Sgabeblack@google.com
10012855Sgabeblack@google.com/******************************************************************************/
10112855Sgabeblack@google.com/*************************** testbench Entry Function    **********************/
10212855Sgabeblack@google.com/******************************************************************************/
10312855Sgabeblack@google.comvoid
10412855Sgabeblack@google.comSTIM::entry()
10512855Sgabeblack@google.com{
10612855Sgabeblack@google.com
10712855Sgabeblack@google.com// INITIAL INPUT VALUES
10812855Sgabeblack@google.com
10912855Sgabeblack@google.com  a1.write(0);		// Are quotes necessary ???
11012855Sgabeblack@google.com  a2.write(0);
11112855Sgabeblack@google.com  a3.write(0);
11212855Sgabeblack@google.com  a4.write(0);
11312855Sgabeblack@google.com  a5.write(0);
11412855Sgabeblack@google.com  a6.write(0);
11512855Sgabeblack@google.com  a7.write(0);
11612855Sgabeblack@google.com  a8.write(0);
11712855Sgabeblack@google.com  in_ok.write(0);
11812855Sgabeblack@google.com  out_ok.write(0);
11912855Sgabeblack@google.com  reset.write(1);
12012855Sgabeblack@google.com  wait(2);
12112855Sgabeblack@google.com
12212855Sgabeblack@google.com// REMOVE RESET
12312855Sgabeblack@google.com
12412855Sgabeblack@google.com  reset.write(0);
12512855Sgabeblack@google.com  wait();
12612855Sgabeblack@google.com
12712855Sgabeblack@google.com// WAIT FOR REQUEST FOR INPUT
12812855Sgabeblack@google.com
12912855Sgabeblack@google.com  do { wait(); } while (instrb == 0);
13012855Sgabeblack@google.com
13112855Sgabeblack@google.com// SEND INPUT DATA TO BE SORTED
13212855Sgabeblack@google.com  a1.write(-76);
13312855Sgabeblack@google.com  a2.write(  1);
13412855Sgabeblack@google.com  a3.write( 12);
13512855Sgabeblack@google.com  a4.write( 85);
13612855Sgabeblack@google.com  a5.write( 15);
13712855Sgabeblack@google.com  a6.write(103);
13812855Sgabeblack@google.com  a7.write( -2);
13912855Sgabeblack@google.com  a8.write(  3);
14012855Sgabeblack@google.com  in_ok.write(1);
14112855Sgabeblack@google.com  wait();
14212855Sgabeblack@google.com
14312855Sgabeblack@google.com// WAIT FOR OUTPUT READY
14412855Sgabeblack@google.com
14512855Sgabeblack@google.com  do { wait(); } while (outstrb == 0);
14612855Sgabeblack@google.com
14712855Sgabeblack@google.com// READ OUTPUT & DISPLAY RESULTS
14812855Sgabeblack@google.com
14912855Sgabeblack@google.com  cout << "\n" << endl;
15012855Sgabeblack@google.com  cout << "\t\t INPUT DATA \t\t SORTED DATA" << endl;
15112855Sgabeblack@google.com  cout << "\t\t " << a1.read().to_int() << "   \t\t "
15212855Sgabeblack@google.com		  << d1.read().to_int() << endl;
15312855Sgabeblack@google.com  cout << "\t\t " << a2.read().to_int() << "   \t\t "
15412855Sgabeblack@google.com		  << d2.read().to_int() << endl;
15512855Sgabeblack@google.com  cout << "\t\t " << a3.read().to_int() << "   \t\t "
15612855Sgabeblack@google.com		  << d3.read().to_int() << endl;
15712855Sgabeblack@google.com  cout << "\t\t " << a4.read().to_int() << "   \t\t "
15812855Sgabeblack@google.com		  << d4.read().to_int() << endl;
15912855Sgabeblack@google.com  cout << "\t\t " << a5.read().to_int() << "   \t\t "
16012855Sgabeblack@google.com		  << d5.read().to_int() << endl;
16112855Sgabeblack@google.com  cout << "\t\t " << a6.read().to_int() << "   \t\t "
16212855Sgabeblack@google.com		  << d6.read().to_int() << endl;
16312855Sgabeblack@google.com  cout << "\t\t " << a7.read().to_int() << "   \t\t "
16412855Sgabeblack@google.com		  << d7.read().to_int() << endl;
16512855Sgabeblack@google.com  cout << "\t\t " << a8.read().to_int() << "   \t\t "
16612855Sgabeblack@google.com		  << d8.read().to_int() << endl;
16712855Sgabeblack@google.com  cout << "\n" << endl;
16812855Sgabeblack@google.com
16912855Sgabeblack@google.com// SEND FINISHED READING OUTPUT FLAG
17012855Sgabeblack@google.com
17112855Sgabeblack@google.com  in_ok.write(0);
17212855Sgabeblack@google.com  out_ok.write(1);
17312855Sgabeblack@google.com  wait();
17412855Sgabeblack@google.com
17512855Sgabeblack@google.com// STOP SIMULATION
17612855Sgabeblack@google.com
17712855Sgabeblack@google.com  sc_stop();
17812855Sgabeblack@google.com}
179