test05.cpp revision 12855:588919e0e4aa
12568SN/A/*****************************************************************************
210723Sandreas.hansson@arm.com
38668Sgeoffrey.blake@arm.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
48668Sgeoffrey.blake@arm.com  more contributor license agreements.  See the NOTICE file distributed
58668Sgeoffrey.blake@arm.com  with this work for additional information regarding copyright ownership.
68668Sgeoffrey.blake@arm.com  Accellera licenses this file to you under the Apache License, Version 2.0
78668Sgeoffrey.blake@arm.com  (the "License"); you may not use this file except in compliance with the
88668Sgeoffrey.blake@arm.com  License.  You may obtain a copy of the License at
98668Sgeoffrey.blake@arm.com
108668Sgeoffrey.blake@arm.com    http://www.apache.org/licenses/LICENSE-2.0
118668Sgeoffrey.blake@arm.com
128668Sgeoffrey.blake@arm.com  Unless required by applicable law or agreed to in writing, software
138668Sgeoffrey.blake@arm.com  distributed under the License is distributed on an "AS IS" BASIS,
142568SN/A  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
1510975Sdavid.hashe@amd.com  implied.  See the License for the specific language governing
162568SN/A  permissions and limitations under the License.
172568SN/A
182568SN/A *****************************************************************************/
192568SN/A
202568SN/A/*****************************************************************************
212568SN/A
222568SN/A  test05.cpp --
232568SN/A
242568SN/A  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
252568SN/A
262568SN/A *****************************************************************************/
272568SN/A
282568SN/A/*****************************************************************************
292568SN/A
302568SN/A  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
312568SN/A  changes you are making here.
322568SN/A
332568SN/A      Name, Affiliation, Date:
342568SN/A  Description of Modification:
352568SN/A
362568SN/A *****************************************************************************/
372568SN/A
382568SN/A#include "systemc.h"
392568SN/A
402665Ssaidi@eecs.umich.eduSC_MODULE( proc1 )
412665Ssaidi@eecs.umich.edu{
422665Ssaidi@eecs.umich.edu  SC_HAS_PROCESS( proc1 );
432568SN/A
442568SN/A  sc_in<bool> clk;
452568SN/A
462568SN/A  char obj1;
472568SN/A  short obj2;
482568SN/A  int obj3;
492568SN/A  long obj4;
503260Ssaidi@eecs.umich.edu  int64 obj5;
518229Snate@binkert.org
523260Ssaidi@eecs.umich.edu  proc1( sc_module_name NAME,
538229Snate@binkert.org	 sc_signal<bool>& CLK )
545314Sstever@gmail.com  {
552590SN/A    clk(CLK);
563348Sbinkertn@umich.edu    SC_THREAD( entry );
572568SN/A    sensitive << clk;
582568SN/A    obj1 = 0;
595735Snate@binkert.org    obj2 = 0;
605735Snate@binkert.org    obj3 = 0;
614022Sstever@eecs.umich.edu    obj4 = 0;
624022Sstever@eecs.umich.edu    obj5 = 0;
634022Sstever@eecs.umich.edu  }
644022Sstever@eecs.umich.edu
654022Sstever@eecs.umich.edu  void entry();
664022Sstever@eecs.umich.edu};
674022Sstever@eecs.umich.edu
682641Sstever@eecs.umich.eduvoid proc1::entry()
694022Sstever@eecs.umich.edu{
704022Sstever@eecs.umich.edu  wait();
712641Sstever@eecs.umich.edu  while(true) {
724022Sstever@eecs.umich.edu    obj1 = 7;
734022Sstever@eecs.umich.edu    obj2 = 31;
7410885Sandreas.hansson@arm.com    obj3 = -1023;
7510885Sandreas.hansson@arm.com    obj4 = 2047;
764022Sstever@eecs.umich.edu	obj5 = -1;
774473Sstever@eecs.umich.edu	obj5 = obj5 << 40;
784473Sstever@eecs.umich.edu    wait();
795319Sstever@gmail.com    obj1 = 1;
805319Sstever@gmail.com    obj2 = -2;
815319Sstever@gmail.com    obj3 = 1024;
824022Sstever@eecs.umich.edu    obj4 = -2048;
8311284Sandreas.hansson@arm.com	obj5 = 7;
844022Sstever@eecs.umich.edu	obj5 = obj5 << 40;
854022Sstever@eecs.umich.edu    wait();
8611287Sandreas.hansson@arm.com  }
8711199Sandreas.hansson@arm.com}
8811199Sandreas.hansson@arm.com
8911199Sandreas.hansson@arm.com
9011199Sandreas.hansson@arm.comint sc_main(int ac, char *av[])
9111199Sandreas.hansson@arm.com{
9211199Sandreas.hansson@arm.com  sc_trace_file *tf;
9311199Sandreas.hansson@arm.com  sc_signal<bool> clock;
9411199Sandreas.hansson@arm.com
9510883Sali.jafri@arm.com  proc1 P1("P1", clock);
9611199Sandreas.hansson@arm.com
974022Sstever@eecs.umich.edu  tf = sc_create_vcd_trace_file("test05");
984022Sstever@eecs.umich.edu  sc_trace(tf, P1.obj1, "Char", 4);
994022Sstever@eecs.umich.edu  sc_trace(tf, P1.obj2, "Short", 12);
1004022Sstever@eecs.umich.edu  sc_trace(tf, P1.obj3, "Int", 14);
1014022Sstever@eecs.umich.edu  sc_trace(tf, P1.obj4, "Long", 14);
1024022Sstever@eecs.umich.edu  sc_trace(tf, P1.obj5, "Int64", 44);
1034022Sstever@eecs.umich.edu  sc_trace(tf, clock, "Clock");
1044022Sstever@eecs.umich.edu
1054022Sstever@eecs.umich.edu  clock.write(0);
1064022Sstever@eecs.umich.edu  sc_start(0, SC_NS);
1074022Sstever@eecs.umich.edu  for (int i = 0; i< 10; i++) {
1084022Sstever@eecs.umich.edu    clock.write(1);
10910886Sandreas.hansson@arm.com    sc_start(10, SC_NS);
11011284Sandreas.hansson@arm.com    clock.write(0);
11110886Sandreas.hansson@arm.com    sc_start(10, SC_NS);
1124022Sstever@eecs.umich.edu  }
11311284Sandreas.hansson@arm.com  sc_close_vcd_trace_file( tf );
1144628Sstever@eecs.umich.edu  return 0;
1157465Ssteve.reinhardt@amd.com}
11611284Sandreas.hansson@arm.com