pr-207_mem.cpp revision 12855
12131SN/A/***************************************************************************** 25268Sksewell@umich.edu 35224Sksewell@umich.edu Licensed to Accellera Systems Initiative Inc. (Accellera) under one or 45224Sksewell@umich.edu more contributor license agreements. See the NOTICE file distributed 52131SN/A with this work for additional information regarding copyright ownership. 65224Sksewell@umich.edu Accellera licenses this file to you under the Apache License, Version 2.0 75224Sksewell@umich.edu (the "License"); you may not use this file except in compliance with the 85224Sksewell@umich.edu License. You may obtain a copy of the License at 95224Sksewell@umich.edu 105224Sksewell@umich.edu http://www.apache.org/licenses/LICENSE-2.0 115224Sksewell@umich.edu 125224Sksewell@umich.edu Unless required by applicable law or agreed to in writing, software 135224Sksewell@umich.edu distributed under the License is distributed on an "AS IS" BASIS, 145224Sksewell@umich.edu WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 155224Sksewell@umich.edu implied. See the License for the specific language governing 162131SN/A permissions and limitations under the License. 175224Sksewell@umich.edu 185224Sksewell@umich.edu *****************************************************************************/ 195224Sksewell@umich.edu 205224Sksewell@umich.edu/***************************************************************************** 215224Sksewell@umich.edu 225224Sksewell@umich.edu pr-207_mem.cpp -- 235224Sksewell@umich.edu 245224Sksewell@umich.edu Original Author: Martin Janssen, Synopsys, Inc., 2002-02-15 255224Sksewell@umich.edu 265224Sksewell@umich.edu *****************************************************************************/ 275224Sksewell@umich.edu 282665Ssaidi@eecs.umich.edu/***************************************************************************** 295224Sksewell@umich.edu 305224Sksewell@umich.edu MODIFICATION LOG - modifiers, enter your name, affiliation, date and 315222Sksewell@umich.edu changes you are making here. 322131SN/A 332131SN/A Name, Affiliation, Date: 342239SN/A Description of Modification: 352239SN/A 362131SN/A *****************************************************************************/ 372131SN/A 382447SN/A#include "systemc.h" 392447SN/A 402447SN/Astruct my_pair { 416378Sgblack@eecs.umich.edu char x; 422447SN/A char y; 432131SN/A}; 442239SN/A 452131SN/Atypedef sc_signal<bool> sig_bool; 462447SN/Atypedef sc_signal<char> sig_char; 472447SN/Atypedef sc_signal<unsigned char> sig_uchar; 482447SN/A 492131SN/ASC_MODULE( pr207 ) 506379Sgblack@eecs.umich.edu{ 516379Sgblack@eecs.umich.edu SC_HAS_PROCESS( pr207 ); 526379Sgblack@eecs.umich.edu 536379Sgblack@eecs.umich.edu sc_in_clk clk; 546379Sgblack@eecs.umich.edu 552447SN/A pr207(sc_module_name NAME, 567678Sgblack@eecs.umich.edu sc_clock& CLK, 577678Sgblack@eecs.umich.edu 587678Sgblack@eecs.umich.edu const sig_bool& RESET, 596378Sgblack@eecs.umich.edu const sig_bool& START, 606378Sgblack@eecs.umich.edu const sig_char& C1, 612447SN/A const sig_char& C2, 622447SN/A const sig_uchar& IDX1, 632447SN/A const sig_uchar& IDX2, 642131SN/A sig_char& D1, 652131SN/A sig_char& D2, 662447SN/A sig_bool& READY 672131SN/A ) 682447SN/A : 692447SN/A reset(RESET), 702447SN/A start(START), 712447SN/A c1(C1), 722131SN/A c2(C2), 734695Sgblack@eecs.umich.edu idx1(IDX1), 742447SN/A idx2(IDX2), 752447SN/A d1(D1), 765222Sksewell@umich.edu d2(D2), 775222Sksewell@umich.edu ready(READY) 785222Sksewell@umich.edu { 795222Sksewell@umich.edu clk(CLK); 805222Sksewell@umich.edu SC_CTHREAD( entry, clk.pos() ); 815222Sksewell@umich.edu reset_signal_is(reset,true); 825222Sksewell@umich.edu } 835222Sksewell@umich.edu void entry(); 845222Sksewell@umich.edu 855222Sksewell@umich.edu const sig_bool& reset; 865222Sksewell@umich.edu const sig_bool& start; 875222Sksewell@umich.edu const sig_char& c1; 885222Sksewell@umich.edu const sig_char& c2; 895222Sksewell@umich.edu const sig_uchar& idx1; 902447SN/A const sig_uchar& idx2; 912131SN/A sig_char& d1; 922447SN/A sig_char& d2; 932131SN/A sig_bool& ready; 942447SN/A 952447SN/A}; 962447SN/A 972447SN/Avoid 982131SN/Apr207::entry() 994695Sgblack@eecs.umich.edu{ 1002447SN/A my_pair pair_array[10]; 1012447SN/A 1025222Sksewell@umich.edu ready = true; 1032447SN/A d1 = 0; 1042131SN/A d2 = 0; 1055222Sksewell@umich.edu wait(); 1065222Sksewell@umich.edu while (true) { 1075222Sksewell@umich.edu do { wait(); } while (start == 0); 1085222Sksewell@umich.edu ready = false; 1095222Sksewell@umich.edu wait(); 1105222Sksewell@umich.edu pair_array[idx1.read()].x = c1; 1115222Sksewell@umich.edu pair_array[idx1.read()].y = c2; 1125222Sksewell@umich.edu wait(); 1135222Sksewell@umich.edu pair_array[idx2.read()] = pair_array[idx1.read()]; 1145222Sksewell@umich.edu wait(); 1155222Sksewell@umich.edu char d1_tmp = pair_array[idx2.read()].y; 1167678Sgblack@eecs.umich.edu wait(); 1177678Sgblack@eecs.umich.edu char d2_tmp = pair_array[idx2.read()].x; 1185222Sksewell@umich.edu wait(); 1195222Sksewell@umich.edu d1 = d1_tmp; 1205222Sksewell@umich.edu d2 = d2_tmp; 1216378Sgblack@eecs.umich.edu ready = true; 1225222Sksewell@umich.edu } 1235222Sksewell@umich.edu} 1245222Sksewell@umich.edu 1255222Sksewell@umich.eduint sc_main(int argc, char* argv[] ) 1265222Sksewell@umich.edu{ 1275222Sksewell@umich.edu return 0; 1285222Sksewell@umich.edu} 1295222Sksewell@umich.edu 1305222Sksewell@umich.edu