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 test02.cpp 2312855Sgabeblack@google.com 2412855Sgabeblack@google.com Original Author: Andy Goodrich, Forte Design Systems, 7 Apr 2005 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#include "systemc.h" 3912855Sgabeblack@google.com 4012855Sgabeblack@google.com#define GET_UNSIGNED(VALUE,OFFSET,EXPECTED) \ 4112855Sgabeblack@google.com{ \ 4212855Sgabeblack@google.com right_sc_biguint32 = 1 << OFFSET; \ 4312855Sgabeblack@google.com VALUE.concat_get_data( right_sc_biguint32.get_raw(), OFFSET); \ 4412855Sgabeblack@google.com if ( right_sc_biguint32 != ((EXPECTED)<<OFFSET) ) \ 4512855Sgabeblack@google.com cout << __FILE__ << "(" << __LINE__ << ") : " << \ 4612855Sgabeblack@google.com #VALUE << ".concat_get_data(ulong*, " << #OFFSET << ") expected " \ 4712855Sgabeblack@google.com << ((EXPECTED)<<OFFSET) << " got " << right_sc_biguint32 << endl; \ 4812855Sgabeblack@google.com} 4912855Sgabeblack@google.com 5012855Sgabeblack@google.com#define GET_UNSIGNEDS(OFFSET,EXPECTED) \ 5112855Sgabeblack@google.com{ \ 5212855Sgabeblack@google.com GET_UNSIGNED(left_sc_bigint12,OFFSET,EXPECTED); \ 5312855Sgabeblack@google.com GET_UNSIGNED(left_sc_biguint12,OFFSET,EXPECTED); \ 5412855Sgabeblack@google.com GET_UNSIGNED(left_sc_int12,OFFSET,EXPECTED); \ 5512855Sgabeblack@google.com GET_UNSIGNED(left_sc_uint12,OFFSET,EXPECTED); \ 5612855Sgabeblack@google.com GET_UNSIGNED(left_sc_int12[1],OFFSET,((EXPECTED>>1)&1)); \ 5712855Sgabeblack@google.com GET_UNSIGNED(left_sc_uint12[1],OFFSET,((EXPECTED>>1)&1)); \ 5812855Sgabeblack@google.com GET_UNSIGNED(left_sc_int12(7,2),OFFSET,((EXPECTED>>2)&0x3f)); \ 5912855Sgabeblack@google.com GET_UNSIGNED(left_sc_uint12(7,2),OFFSET,((EXPECTED>>2)&0x3f)); \ 6012855Sgabeblack@google.com} 6112855Sgabeblack@google.com 6212855Sgabeblack@google.com#define GET_UINT64(VALUE,EXPECTED) \ 6312855Sgabeblack@google.com{ \ 6412855Sgabeblack@google.com uint64 actual = VALUE.concat_get_uint64(); \ 6512855Sgabeblack@google.com if ( actual != (EXPECTED) ) \ 6612855Sgabeblack@google.com cout << __FILE__ << "(" << __LINE__ << ") : " << \ 6712855Sgabeblack@google.com #VALUE << ".const_get_uint64() expected " << (EXPECTED) << " got " \ 6812855Sgabeblack@google.com << actual << endl; \ 6912855Sgabeblack@google.com} 7012855Sgabeblack@google.com 7112855Sgabeblack@google.com#define GET_UINT64S(EXPECTED) \ 7212855Sgabeblack@google.com{ \ 7312855Sgabeblack@google.com GET_UINT64(left_sc_bigint12,EXPECTED) \ 7412855Sgabeblack@google.com GET_UINT64(left_sc_biguint12,EXPECTED) \ 7512855Sgabeblack@google.com GET_UINT64(left_sc_int12,EXPECTED) \ 7612855Sgabeblack@google.com GET_UINT64(left_sc_uint12,EXPECTED) \ 7712855Sgabeblack@google.com GET_UINT64(left_sc_int12[1], ((EXPECTED>>1)&1)) \ 7812855Sgabeblack@google.com GET_UINT64(left_sc_uint12[1], ((EXPECTED>>1)&1)) \ 7912855Sgabeblack@google.com GET_UINT64(left_sc_int12(7,2), ((EXPECTED>>2)&0x3f)) \ 8012855Sgabeblack@google.com GET_UINT64(left_sc_uint12(7,2),((EXPECTED>>2)&0x3f)) \ 8112855Sgabeblack@google.com} 8212855Sgabeblack@google.com 8312855Sgabeblack@google.com#define LENGTH(LEFT,WIDTH) \ 8412855Sgabeblack@google.com{ \ 8512855Sgabeblack@google.com int width = LEFT.concat_length(0); \ 8612855Sgabeblack@google.com if ( width != (WIDTH) ) \ 8712855Sgabeblack@google.com cout << __FILE__ << "(" << __LINE__ << ") : " \ 8812855Sgabeblack@google.com << #LEFT << ".concat_length() expected " << (WIDTH) \ 8912855Sgabeblack@google.com << " got " << width << endl; \ 9012855Sgabeblack@google.com} 9112855Sgabeblack@google.com 9212855Sgabeblack@google.com#define LENGTHS(WIDTH) \ 9312855Sgabeblack@google.com{ \ 9412855Sgabeblack@google.com LENGTH(left_sc_bigint12,WIDTH) \ 9512855Sgabeblack@google.com LENGTH(left_sc_biguint12,WIDTH) \ 9612855Sgabeblack@google.com LENGTH(left_sc_int12,WIDTH) \ 9712855Sgabeblack@google.com LENGTH(left_sc_uint12,WIDTH) \ 9812855Sgabeblack@google.com} 9912855Sgabeblack@google.com 10012855Sgabeblack@google.com#define SET(LEFT,RIGHT,VALUE,OFFSET,EXPECTED) \ 10112855Sgabeblack@google.com{ \ 10212855Sgabeblack@google.com LEFT.concat_set(RIGHT,OFFSET); \ 10312855Sgabeblack@google.com wait(); \ 10412855Sgabeblack@google.com uint64 actual = LEFT.concat_get_uint64(); \ 10512855Sgabeblack@google.com if ( actual != (EXPECTED) ) \ 10612855Sgabeblack@google.com cout << #LEFT << ".const_set_uint64(" << #RIGHT <<", " << VALUE << ") \ 10712855Sgabeblack@google.com << expected " << (EXPECTED) << " got " << actual << endl; \ 10812855Sgabeblack@google.com} 10912855Sgabeblack@google.com 11012855Sgabeblack@google.com#define SET_SIGNED(VALUE,OFFSET,EXPECTED) \ 11112855Sgabeblack@google.com{ \ 11212855Sgabeblack@google.com right_sc_bigint32 = VALUE; \ 11312855Sgabeblack@google.com SET(left_sc_bigint12,right_sc_bigint32,VALUE,OFFSET,EXPECTED); \ 11412855Sgabeblack@google.com SET(left_sc_biguint12,right_sc_bigint32,VALUE,OFFSET,EXPECTED); \ 11512855Sgabeblack@google.com SET(left_sc_int12,right_sc_bigint32,VALUE,OFFSET,EXPECTED); \ 11612855Sgabeblack@google.com SET(left_sc_uint12,right_sc_bigint32,VALUE,OFFSET,EXPECTED); \ 11712855Sgabeblack@google.com} 11812855Sgabeblack@google.com 11912855Sgabeblack@google.com#define SET_S64(VALUE,OFFSET,EXPECTED) \ 12012855Sgabeblack@google.com{ \ 12112855Sgabeblack@google.com right_s64 = VALUE; \ 12212855Sgabeblack@google.com SET(left_sc_bigint12,right_s64,VALUE,OFFSET,EXPECTED); \ 12312855Sgabeblack@google.com SET(left_sc_biguint12,right_s64,VALUE,OFFSET,EXPECTED); \ 12412855Sgabeblack@google.com SET(left_sc_int12,right_s64,VALUE,OFFSET,EXPECTED); \ 12512855Sgabeblack@google.com SET(left_sc_uint12,right_s64,VALUE,OFFSET,EXPECTED); \ 12612855Sgabeblack@google.com} 12712855Sgabeblack@google.com 12812855Sgabeblack@google.com#define SET_UNSIGNED(VALUE,OFFSET,EXPECTED) \ 12912855Sgabeblack@google.com{ \ 13012855Sgabeblack@google.com right_sc_biguint32 = VALUE; \ 13112855Sgabeblack@google.com SET(left_sc_bigint12,right_sc_biguint32,VALUE,OFFSET,EXPECTED); \ 13212855Sgabeblack@google.com SET(left_sc_biguint12,right_sc_biguint32,VALUE,OFFSET,EXPECTED); \ 13312855Sgabeblack@google.com SET(left_sc_int12,right_sc_biguint32,VALUE,OFFSET,EXPECTED); \ 13412855Sgabeblack@google.com SET(left_sc_uint12,right_sc_biguint32,VALUE,OFFSET,EXPECTED); \ 13512855Sgabeblack@google.com} 13612855Sgabeblack@google.com 13712855Sgabeblack@google.com#define SET_U64(VALUE,OFFSET,EXPECTED) \ 13812855Sgabeblack@google.com{ \ 13912855Sgabeblack@google.com right_u64 = VALUE; \ 14012855Sgabeblack@google.com SET(left_sc_bigint12,right_u64,VALUE,OFFSET,EXPECTED); \ 14112855Sgabeblack@google.com SET(left_sc_biguint12,right_u64,VALUE,OFFSET,EXPECTED); \ 14212855Sgabeblack@google.com SET(left_sc_int12,right_u64,VALUE,OFFSET,EXPECTED); \ 14312855Sgabeblack@google.com SET(left_sc_uint12,right_u64,VALUE,OFFSET,EXPECTED); \ 14412855Sgabeblack@google.com} 14512855Sgabeblack@google.com 14612855Sgabeblack@google.com#define SETS(VALUE,OFFSET,EXPECTED) \ 14712855Sgabeblack@google.com SET_S64(VALUE,OFFSET,EXPECTED) \ 14812855Sgabeblack@google.com SET_SIGNED(VALUE,OFFSET,EXPECTED) \ 14912855Sgabeblack@google.com SET_UNSIGNED(VALUE,OFFSET,EXPECTED) \ 15012855Sgabeblack@google.com SET_U64(VALUE,OFFSET,EXPECTED) 15112855Sgabeblack@google.com 15212855Sgabeblack@google.comSC_MODULE(X) 15312855Sgabeblack@google.com{ 15412855Sgabeblack@google.com SC_CTOR(X) 15512855Sgabeblack@google.com { 15612855Sgabeblack@google.com SC_CTHREAD(sync, clk.pos()); 15712855Sgabeblack@google.com } 15812855Sgabeblack@google.com void sync() 15912855Sgabeblack@google.com { 16012855Sgabeblack@google.com // for (;; ) 16112855Sgabeblack@google.com { 16212855Sgabeblack@google.com LENGTHS(12); 16312855Sgabeblack@google.com SETS(0x87654321,0,0x321); 16412855Sgabeblack@google.com SETS(0x87654321,4,0x432); 16512855Sgabeblack@google.com GET_UINT64S(0x432); 16612855Sgabeblack@google.com GET_UNSIGNEDS(0,0x432); 16712855Sgabeblack@google.com GET_UNSIGNEDS(4,0x432); 16812855Sgabeblack@google.com } 16912855Sgabeblack@google.com } 17012855Sgabeblack@google.com 17112855Sgabeblack@google.com sc_in_clk clk; 17212855Sgabeblack@google.com sc_int<12> left_sc_int12; 17312855Sgabeblack@google.com sc_bigint<12> left_sc_bigint12; 17412855Sgabeblack@google.com sc_biguint<12> left_sc_biguint12; 17512855Sgabeblack@google.com sc_uint<12> left_sc_uint12; 17612855Sgabeblack@google.com 17712855Sgabeblack@google.com sc_int<32> right_sc_int32; 17812855Sgabeblack@google.com sc_bigint<32> right_sc_bigint32; 17912855Sgabeblack@google.com sc_biguint<32> right_sc_biguint32; 18012855Sgabeblack@google.com sc_uint<32> right_sc_uint32; 18112855Sgabeblack@google.com int right_si; 18212855Sgabeblack@google.com long right_sl; 18312855Sgabeblack@google.com int64 right_s64; 18412855Sgabeblack@google.com unsigned int right_ui; 18512855Sgabeblack@google.com unsigned long right_ul; 18612855Sgabeblack@google.com uint64 right_u64; 18712855Sgabeblack@google.com}; 18812855Sgabeblack@google.com 18912855Sgabeblack@google.comint sc_main( int argc, char* argv[] ) 19012855Sgabeblack@google.com{ 19112855Sgabeblack@google.com sc_clock clock; 19212855Sgabeblack@google.com X x("x"); 19312855Sgabeblack@google.com x.clk(clock); 19412855Sgabeblack@google.com sc_start(1000, SC_NS); 19512855Sgabeblack@google.com 19613158Sgabeblack@google.com cout << "Program completed\n"; 19712855Sgabeblack@google.com return 0; 19812855Sgabeblack@google.com} 199