datatypes.cpp revision 12855:588919e0e4aa
12207SN/A/*****************************************************************************
25254Sksewell@umich.edu
35254Sksewell@umich.edu  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
42207SN/A  more contributor license agreements.  See the NOTICE file distributed
55254Sksewell@umich.edu  with this work for additional information regarding copyright ownership.
65254Sksewell@umich.edu  Accellera licenses this file to you under the Apache License, Version 2.0
75254Sksewell@umich.edu  (the "License"); you may not use this file except in compliance with the
85254Sksewell@umich.edu  License.  You may obtain a copy of the License at
95254Sksewell@umich.edu
105254Sksewell@umich.edu    http://www.apache.org/licenses/LICENSE-2.0
115254Sksewell@umich.edu
125254Sksewell@umich.edu  Unless required by applicable law or agreed to in writing, software
135254Sksewell@umich.edu  distributed under the License is distributed on an "AS IS" BASIS,
145254Sksewell@umich.edu  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
152207SN/A  implied.  See the License for the specific language governing
165254Sksewell@umich.edu  permissions and limitations under the License.
175254Sksewell@umich.edu
185254Sksewell@umich.edu *****************************************************************************/
195254Sksewell@umich.edu
205254Sksewell@umich.edu/*****************************************************************************
215254Sksewell@umich.edu
225254Sksewell@umich.edu  datatypes.cpp --
235254Sksewell@umich.edu
245254Sksewell@umich.edu  Original Author: Rocco Jonack, Synopsys, Inc., 1999-07-30
255254Sksewell@umich.edu
265254Sksewell@umich.edu *****************************************************************************/
272665Ssaidi@eecs.umich.edu
285254Sksewell@umich.edu/*****************************************************************************
295254Sksewell@umich.edu
305254Sksewell@umich.edu  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
312207SN/A  changes you are making here.
322207SN/A
332474SN/A      Name, Affiliation, Date:
342207SN/A  Description of Modification:
358229Snate@binkert.org
362454SN/A *****************************************************************************/
372454SN/A
382680Sktlim@umich.edu
398232Snate@binkert.org#include "datatypes.h"
406650Sksewell@umich.edu
416650Sksewell@umich.eduvoid datatypes::entry()
426650Sksewell@umich.edu
432474SN/A{
442207SN/A  sc_bigint<8>    tmp1;
452447SN/A  sc_bigint<8>    tmp1r;
462474SN/A  sc_biguint<8>   tmp2;
472447SN/A  sc_biguint<8>   tmp2r;
485154Sgblack@eecs.umich.edu  long            tmp3;
495154Sgblack@eecs.umich.edu  long            tmp3r;
505154Sgblack@eecs.umich.edu  int             tmp4;
512474SN/A  int             tmp4r;
522686Sksewell@umich.edu  short           tmp5;
532686Sksewell@umich.edu  short           tmp5r;
542935Sksewell@umich.edu  char            tmp6;
552474SN/A  char            tmp6r;
562474SN/A  bool            tmp7;
572474SN/A  bool            tmp7r;
582474SN/A  sc_bv<4>        tmp8;
592686Sksewell@umich.edu  sc_bv<4>        tmp8r;
602686Sksewell@umich.edu  sc_lv<4>        tmp9;
6110318Sandreas.hansson@arm.com  sc_lv<4>        tmp9r;
622686Sksewell@umich.edu
636811SMatt DeVuyst// define 1 dimensional array
6411386Ssteve.reinhardt@amd.com   int  tmpa[2];
652474SN/A   char tmpb[2];
662474SN/A
672474SN/A// reset_loop
687532Ssteve.reinhardt@amd.com  if (reset.read() == true) {
692474SN/A    out_valid.write(false);
707532Ssteve.reinhardt@amd.com    out_ack.write(false);
716650Sksewell@umich.edu    wait();
7210318Sandreas.hansson@arm.com  } else wait();
732474SN/A
745958Sgblack@eecs.umich.edu//
756811SMatt DeVuyst// main loop
766650Sksewell@umich.edu//
776811SMatt DeVuyst// initialization of sc_array
786650Sksewell@umich.edu
796811SMatt DeVuyst   tmpa[0] = 12;
806811SMatt DeVuyst   tmpa[1] = 127;
8111389Sbrandon.potter@amd.com   tmpb[1] = 'G';
8211389Sbrandon.potter@amd.com
8311389Sbrandon.potter@amd.com
846650Sksewell@umich.edu while(1) {
856650Sksewell@umich.edu    while(in_valid.read()==false) wait();
866650Sksewell@umich.edu
876811SMatt DeVuyst    //reading the inputs
886811SMatt DeVuyst    tmp1 = in_value1.read();
896811SMatt DeVuyst    tmp2 = in_value2.read();
906811SMatt DeVuyst    tmp3 = in_value3.read();
916811SMatt DeVuyst    tmp4 = in_value4.read();
926811SMatt DeVuyst    tmp5 = in_value5.read();
936811SMatt DeVuyst    tmp6 = in_value6.read();
9410318Sandreas.hansson@arm.com    tmpb[0] = in_value7.read();
956811SMatt DeVuyst    tmp7 = in_value8.read();
966811SMatt DeVuyst    tmp8 = in_value9.read();
976811SMatt DeVuyst    tmp9 = in_value10.read();
986811SMatt DeVuyst
996811SMatt DeVuyst    out_ack.write(true);
1006811SMatt DeVuyst
1016811SMatt DeVuyst    //execute mixed data type not operations
1026811SMatt DeVuyst
1036811SMatt DeVuyst    // signed(8) <- ~ unsigned(8)
1046811SMatt DeVuyst    tmp1r = ~ tmp2;
1056811SMatt DeVuyst    // unsigned(8) <- ~ long
10611389Sbrandon.potter@amd.com    tmp2r = ~ tmp3;
10711389Sbrandon.potter@amd.com    // long <- ~ char
10811389Sbrandon.potter@amd.com    tmp3r = ~ tmp6;
10911389Sbrandon.potter@amd.com    // int <- ~ short
1106811SMatt DeVuyst    tmp4r = ~ tmp5;
1116811SMatt DeVuyst    // short <- ~ int
1126811SMatt DeVuyst    tmp5r = ~ tmp4;
1136811SMatt DeVuyst    // char <- ~ char_array[0]
1146811SMatt DeVuyst    // tmp6r = ~ tmp8[0];
1156811SMatt DeVuyst    tmp6r = ~ tmp8[0].to_bool();
1166811SMatt DeVuyst    // bool <- ! bool;
1176811SMatt DeVuyst    tmp7r = !tmp7;
1186811SMatt DeVuyst    // sc_bool_vector(4) <- ~ sc_logic_vector(4)
1196811SMatt DeVuyst    tmp8r = ~ tmp9;
1206650Sksewell@umich.edu    //  sc_logic_vector(4) <- ~ sc_bool_vector(4)
1216650Sksewell@umich.edu    tmp9r = ~ tmp9;
1226811SMatt DeVuyst
1236811SMatt DeVuyst    //write outputs
1246650Sksewell@umich.edu    out_value1.write(tmp1r);
1256650Sksewell@umich.edu    out_value2.write(tmp2r);
1266650Sksewell@umich.edu    out_value3.write(tmp3r);
1276650Sksewell@umich.edu    out_value4.write(tmp4r);
1286650Sksewell@umich.edu    out_value5.write(tmp5r);
1296650Sksewell@umich.edu    out_value6.write(tmp6r);
1306650Sksewell@umich.edu    out_value7.write(tmp7r);
1316650Sksewell@umich.edu    out_value8.write(tmp8r);
1326650Sksewell@umich.edu    out_value9.write(tmp9r);
1336650Sksewell@umich.edu
1346811SMatt DeVuyst    out_valid.write(true);
1356811SMatt DeVuyst    wait();
1366811SMatt DeVuyst    out_ack.write(false);
1376811SMatt DeVuyst    out_valid.write(false);
1386811SMatt DeVuyst
1396650Sksewell@umich.edu }
1406650Sksewell@umich.edu
1416650Sksewell@umich.edu} // End
1426650Sksewell@umich.edu
1436650Sksewell@umich.edu
1446650Sksewell@umich.edu