OpenCores
URL https://opencores.org/ocsvn/async_sdm_noc/async_sdm_noc/trunk

Subversion Repositories async_sdm_noc

[/] [async_sdm_noc/] [trunk/] [sdm/] [tb/] [ni.cpp] - Blame information for rev 45

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 31 wsong0210
/*
2
 Asynchronous SDM NoC
3
 (C)2011 Wei Song
4
 Advanced Processor Technologies Group
5
 Computer Science, the Univ. of Manchester, UK
6
 
7
 Authors:
8
 Wei Song     wsong83@gmail.com
9
 
10
 License: LGPL 3.0 or later
11
 
12
 A SystemC network adapter/interface for NoC simulation.
13
 
14
 History:
15
 23/12/2008  Initial version. <wsong83@gmail.com>
16
 30/09/2010  Use template style packet definition. <wsong83@gmail.com>
17
 16/10/2010  Support SDM. <wsong83@gmail.com>
18
 29/05/2011  CLean up for opensource. <wsong83@gmail.com>
19
 
20
*/
21
 
22
#include "ni.h"
23
 
24
Network_Adapter::Network_Adapter(
25
         sc_module_name     name            // module name
26
        ,unsigned int       x               // location x
27
        ,unsigned int       y               // location y
28
    ):
29
         sc_module(name),
30
         frame_in("FrmIn"),
31
         frame_out("FrmOut"),
32
         loc_x(x),
33
         loc_y(y)
34
{
35
  sc_spawn_options opt;
36
 
37
  for(unsigned int i=0; i<SubChN; i++) {
38
    sc_spawn(sc_bind(&Network_Adapter::ibuffer_thread, this, i), NULL, &opt);
39
    sc_spawn(sc_bind(&Network_Adapter::obuffer_thread, this, i), NULL, &opt);
40
  }
41
}
42
 
43
Network_Adapter::~Network_Adapter()
44
{
45
}
46
 
47
// read in the incoming frame
48
void Network_Adapter::ibuffer_thread(unsigned int ii){
49
  FRAME mframe;
50
  FLIT mflit;
51
 
52
  while(1){
53
    mframe.clear();
54
 
55
    while(1) {
56
      mflit = IP[ii]->read();
57
      mframe << mflit;
58
 
59
      if(mflit.ftype == F_TL)   break;
60
    }
61
 
62
    frame_out->write(mframe);
63
  }
64
}
65
 
66
// send out a frame
67
void Network_Adapter::obuffer_thread(unsigned int ii){
68
 
69
  FRAME mframe;
70
  FLIT mflit;
71
 
72
  while(1){
73
    mframe = frame_in->read();
74
 
75
    while(1) {
76
      mframe >> mflit;
77
      mflit.vcn = ii;
78
 
79
      OP[ii]->write(mflit);
80
 
81
      if(mflit.ftype == F_TL) break;
82
    }
83
  }
84
}
85
 
86
bool Network_Adapter::check_frame(const FRAME& frame)
87
{
88
    // TODO: check the integerity, dummy right noe
89
    return true;
90
}
91
 
92
 
93
 
94
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.