test02.cpp revision 12855:588919e0e4aa
1955SN/A/*****************************************************************************
2955SN/A
37816Ssteve.reinhardt@amd.com  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
45871Snate@binkert.org  more contributor license agreements.  See the NOTICE file distributed
51762SN/A  with this work for additional information regarding copyright ownership.
6955SN/A  Accellera licenses this file to you under the Apache License, Version 2.0
7955SN/A  (the "License"); you may not use this file except in compliance with the
8955SN/A  License.  You may obtain a copy of the License at
9955SN/A
10955SN/A    http://www.apache.org/licenses/LICENSE-2.0
11955SN/A
12955SN/A  Unless required by applicable law or agreed to in writing, software
13955SN/A  distributed under the License is distributed on an "AS IS" BASIS,
14955SN/A  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15955SN/A  implied.  See the License for the specific language governing
16955SN/A  permissions and limitations under the License.
17955SN/A
18955SN/A *****************************************************************************/
19955SN/A
20955SN/A/*****************************************************************************
21955SN/A
22955SN/A  test02.cpp --
23955SN/A
24955SN/A  Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15
25955SN/A
26955SN/A *****************************************************************************/
27955SN/A
28955SN/A/*****************************************************************************
29955SN/A
302665Ssaidi@eecs.umich.edu  MODIFICATION LOG - modifiers, enter your name, affiliation, date and
312665Ssaidi@eecs.umich.edu  changes you are making here.
325863Snate@binkert.org
33955SN/A      Name, Affiliation, Date:
34955SN/A  Description of Modification:
35955SN/A
36955SN/A *****************************************************************************/
37955SN/A
388878Ssteve.reinhardt@amd.com// test of assigning sc_lv_base to the integer types
392632Sstever@eecs.umich.edu
408878Ssteve.reinhardt@amd.com#include "systemc.h"
412632Sstever@eecs.umich.edu
42955SN/Avoid
438878Ssteve.reinhardt@amd.comtest_smaller( const sc_lv<4>& lv_one, const sc_lv<4>& lv_two )
442632Sstever@eecs.umich.edu{
452761Sstever@eecs.umich.edu    cout << "*** smaller ***" << endl;
462632Sstever@eecs.umich.edu    {
472632Sstever@eecs.umich.edu        sc_int<8> a( lv_one );
482632Sstever@eecs.umich.edu        sc_int<8> b( lv_two );
492761Sstever@eecs.umich.edu        sc_int<8> c;
502761Sstever@eecs.umich.edu        sc_int<8> d;
512761Sstever@eecs.umich.edu        c = lv_one;
528878Ssteve.reinhardt@amd.com        d = lv_two;
538878Ssteve.reinhardt@amd.com        cout << a << endl;
542761Sstever@eecs.umich.edu        cout << b << endl;
552761Sstever@eecs.umich.edu        cout << c << endl;
562761Sstever@eecs.umich.edu        cout << d << endl;
572761Sstever@eecs.umich.edu    }
582761Sstever@eecs.umich.edu    cout << endl;
598878Ssteve.reinhardt@amd.com    {
608878Ssteve.reinhardt@amd.com        sc_uint<8> a( lv_one );
612632Sstever@eecs.umich.edu        sc_uint<8> b( lv_two );
622632Sstever@eecs.umich.edu        sc_uint<8> c;
638878Ssteve.reinhardt@amd.com        sc_uint<8> d;
648878Ssteve.reinhardt@amd.com        c = lv_one;
652632Sstever@eecs.umich.edu        d = lv_two;
66955SN/A        cout << a << endl;
67955SN/A        cout << b << endl;
68955SN/A        cout << c << endl;
695863Snate@binkert.org        cout << d << endl;
705863Snate@binkert.org    }
715863Snate@binkert.org    cout << endl;
725863Snate@binkert.org    {
735863Snate@binkert.org        sc_bigint<8> a( lv_one );
745863Snate@binkert.org        sc_bigint<8> b( lv_two );
755863Snate@binkert.org        sc_bigint<8> c;
765863Snate@binkert.org        sc_bigint<8> d;
775863Snate@binkert.org        c = lv_one;
785863Snate@binkert.org        d = lv_two;
795863Snate@binkert.org        cout << a << endl;
808878Ssteve.reinhardt@amd.com        cout << b << endl;
815863Snate@binkert.org        cout << c << endl;
825863Snate@binkert.org        cout << d << endl;
835863Snate@binkert.org    }
845863Snate@binkert.org    cout << endl;
855863Snate@binkert.org    {
865863Snate@binkert.org        sc_biguint<8> a( lv_one );
875863Snate@binkert.org        sc_biguint<8> b( lv_two );
885863Snate@binkert.org        sc_biguint<8> c;
895863Snate@binkert.org        sc_biguint<8> d;
905863Snate@binkert.org        c = lv_one;
915863Snate@binkert.org        d = lv_two;
925863Snate@binkert.org        cout << a << endl;
935863Snate@binkert.org        cout << b << endl;
945863Snate@binkert.org        cout << c << endl;
955863Snate@binkert.org        cout << d << endl;
968878Ssteve.reinhardt@amd.com    }
975863Snate@binkert.org}
985863Snate@binkert.org
995863Snate@binkert.orgvoid
1006654Snate@binkert.orgtest_equal( const sc_lv<4>& lv_one, const sc_lv<4>& lv_two )
101955SN/A{
1025396Ssaidi@eecs.umich.edu    cout << "*** equal ***" << endl;
1035863Snate@binkert.org    {
1045863Snate@binkert.org        sc_int<4> a( lv_one );
1054202Sbinkertn@umich.edu        sc_int<4> b( lv_two );
1065863Snate@binkert.org        sc_int<4> c;
1075863Snate@binkert.org        sc_int<4> d;
1085863Snate@binkert.org        c = lv_one;
1095863Snate@binkert.org        d = lv_two;
110955SN/A        cout << a << endl;
1116654Snate@binkert.org        cout << b << endl;
1125273Sstever@gmail.com        cout << c << endl;
1135871Snate@binkert.org        cout << d << endl;
1145273Sstever@gmail.com    }
1156655Snate@binkert.org    cout << endl;
1168878Ssteve.reinhardt@amd.com    {
1176655Snate@binkert.org        sc_uint<4> a( lv_one );
1186655Snate@binkert.org        sc_uint<4> b( lv_two );
1196655Snate@binkert.org        sc_uint<4> c;
1206655Snate@binkert.org        sc_uint<4> d;
1215871Snate@binkert.org        c = lv_one;
1226654Snate@binkert.org        d = lv_two;
1235396Ssaidi@eecs.umich.edu        cout << a << endl;
1248120Sgblack@eecs.umich.edu        cout << b << endl;
1258120Sgblack@eecs.umich.edu        cout << c << endl;
1268120Sgblack@eecs.umich.edu        cout << d << endl;
1278120Sgblack@eecs.umich.edu    }
1288120Sgblack@eecs.umich.edu    cout << endl;
1298120Sgblack@eecs.umich.edu    {
1308120Sgblack@eecs.umich.edu        sc_bigint<4> a( lv_one );
1318120Sgblack@eecs.umich.edu        sc_bigint<4> b( lv_two );
1328879Ssteve.reinhardt@amd.com        sc_bigint<4> c;
1338879Ssteve.reinhardt@amd.com        sc_bigint<4> d;
1348879Ssteve.reinhardt@amd.com        c = lv_one;
1358879Ssteve.reinhardt@amd.com        d = lv_two;
1368879Ssteve.reinhardt@amd.com        cout << a << endl;
1378879Ssteve.reinhardt@amd.com        cout << b << endl;
1388879Ssteve.reinhardt@amd.com        cout << c << endl;
1398879Ssteve.reinhardt@amd.com        cout << d << endl;
1408879Ssteve.reinhardt@amd.com    }
1418879Ssteve.reinhardt@amd.com    cout << endl;
1428879Ssteve.reinhardt@amd.com    {
1438879Ssteve.reinhardt@amd.com        sc_biguint<4> a( lv_one );
1448879Ssteve.reinhardt@amd.com        sc_biguint<4> b( lv_two );
1458120Sgblack@eecs.umich.edu        sc_biguint<4> c;
1468120Sgblack@eecs.umich.edu        sc_biguint<4> d;
1478120Sgblack@eecs.umich.edu        c = lv_one;
1488120Sgblack@eecs.umich.edu        d = lv_two;
1498120Sgblack@eecs.umich.edu        cout << a << endl;
1508120Sgblack@eecs.umich.edu        cout << b << endl;
1518120Sgblack@eecs.umich.edu        cout << c << endl;
1528120Sgblack@eecs.umich.edu        cout << d << endl;
1538120Sgblack@eecs.umich.edu    }
1548120Sgblack@eecs.umich.edu}
1558120Sgblack@eecs.umich.edu
1568120Sgblack@eecs.umich.eduvoid
1578120Sgblack@eecs.umich.edutest_larger( const sc_lv<4>& lv_one, const sc_lv<4>& lv_two )
1588120Sgblack@eecs.umich.edu{
1598879Ssteve.reinhardt@amd.com    cout << "*** larger ***" << endl;
1608879Ssteve.reinhardt@amd.com    {
1618879Ssteve.reinhardt@amd.com        sc_int<2> a( lv_one );
1628879Ssteve.reinhardt@amd.com        sc_int<2> b( lv_two );
1638879Ssteve.reinhardt@amd.com        sc_int<2> c;
1648879Ssteve.reinhardt@amd.com        sc_int<2> d;
1658879Ssteve.reinhardt@amd.com        c = lv_one;
1668879Ssteve.reinhardt@amd.com        d = lv_two;
1678879Ssteve.reinhardt@amd.com        cout << a << endl;
1688879Ssteve.reinhardt@amd.com        cout << b << endl;
1698879Ssteve.reinhardt@amd.com        cout << c << endl;
1708879Ssteve.reinhardt@amd.com        cout << d << endl;
1718120Sgblack@eecs.umich.edu    }
1727816Ssteve.reinhardt@amd.com    cout << endl;
1737816Ssteve.reinhardt@amd.com    {
1747816Ssteve.reinhardt@amd.com        sc_uint<2> a( lv_one );
1757816Ssteve.reinhardt@amd.com        sc_uint<2> b( lv_two );
1767816Ssteve.reinhardt@amd.com        sc_uint<2> c;
1777816Ssteve.reinhardt@amd.com        sc_uint<2> d;
1787816Ssteve.reinhardt@amd.com        c = lv_one;
1797816Ssteve.reinhardt@amd.com        d = lv_two;
1807816Ssteve.reinhardt@amd.com        cout << a << endl;
1815871Snate@binkert.org        cout << b << endl;
1825871Snate@binkert.org        cout << c << endl;
1836121Snate@binkert.org        cout << d << endl;
1845871Snate@binkert.org    }
1855871Snate@binkert.org    cout << endl;
1866003Snate@binkert.org    {
1876655Snate@binkert.org        sc_bigint<2> a( lv_one );
188955SN/A        sc_bigint<2> b( lv_two );
1895871Snate@binkert.org        sc_bigint<2> c;
1905871Snate@binkert.org        sc_bigint<2> d;
1915871Snate@binkert.org        c = lv_one;
1925871Snate@binkert.org        d = lv_two;
193955SN/A        cout << a << endl;
1946121Snate@binkert.org        cout << b << endl;
1956121Snate@binkert.org        cout << c << endl;
1966121Snate@binkert.org        cout << d << endl;
1971533SN/A    }
1986655Snate@binkert.org    cout << endl;
1996655Snate@binkert.org    {
2006655Snate@binkert.org        sc_biguint<2> a( lv_one );
2016655Snate@binkert.org        sc_biguint<2> b( lv_two );
2025871Snate@binkert.org        sc_biguint<2> c;
2035871Snate@binkert.org        sc_biguint<2> d;
2045863Snate@binkert.org        c = lv_one;
2055871Snate@binkert.org        d = lv_two;
2068878Ssteve.reinhardt@amd.com        cout << a << endl;
2075871Snate@binkert.org        cout << b << endl;
2085871Snate@binkert.org        cout << c << endl;
2095871Snate@binkert.org        cout << d << endl;
2105863Snate@binkert.org    }
2116121Snate@binkert.org}
2125863Snate@binkert.org
2135871Snate@binkert.orgint
2148336Ssteve.reinhardt@amd.comsc_main( int, char*[] )
2158336Ssteve.reinhardt@amd.com{
2168336Ssteve.reinhardt@amd.com    sc_lv<4> lv_one( "0101" );
2178336Ssteve.reinhardt@amd.com    sc_lv<4> lv_two( "1010" );
2184678Snate@binkert.org
2198336Ssteve.reinhardt@amd.com    test_smaller( lv_one, lv_two );
2208336Ssteve.reinhardt@amd.com    test_equal( lv_one, lv_two );
2218336Ssteve.reinhardt@amd.com    test_larger( lv_one, lv_two );
2224678Snate@binkert.org
2234678Snate@binkert.org    return 0;
2244678Snate@binkert.org}
2254678Snate@binkert.org