switch simplenic to struct instead of macros
This commit is contained in:
parent
197972a23b
commit
ca94d7fa20
|
@ -1 +1 @@
|
||||||
Subproject commit 12079bd518fa934dd07c546edfcb290c22653cf5
|
Subproject commit 9fafe850da8b68bbf4677fecbb40d8c9f63683ce
|
|
@ -1,3 +1,5 @@
|
||||||
|
#ifdef SIMPLENICWIDGET_struct
|
||||||
|
|
||||||
#include "simplenic.h"
|
#include "simplenic.h"
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -41,9 +43,11 @@ static void simplify_frac(int n, int d, int *nn, int *dd)
|
||||||
simplenic_t::simplenic_t(
|
simplenic_t::simplenic_t(
|
||||||
simif_t *sim, char *slotid,
|
simif_t *sim, char *slotid,
|
||||||
uint64_t mac_little_end, int netbw, int netburst, int linklatency,
|
uint64_t mac_little_end, int netbw, int netburst, int linklatency,
|
||||||
char *niclogfile, bool loopback, char *shmemportname): endpoint_t(sim)
|
char *niclogfile, bool loopback, char *shmemportname, SIMPLENICWIDGET_struct *mmio_addrs): endpoint_t(sim)
|
||||||
{
|
{
|
||||||
#ifdef SIMPLENICWIDGET_0
|
|
||||||
|
this->mmio_addrs = mmio_addrs;
|
||||||
|
|
||||||
// store link latency:
|
// store link latency:
|
||||||
LINKLATENCY = linklatency;
|
LINKLATENCY = linklatency;
|
||||||
|
|
||||||
|
@ -107,11 +111,9 @@ simplenic_t::simplenic_t(
|
||||||
pcis_write_bufs[j] = pcis_read_bufs[j];
|
pcis_write_bufs[j] = pcis_read_bufs[j];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // #ifdef SIMPLENICWIDGET_0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
simplenic_t::~simplenic_t() {
|
simplenic_t::~simplenic_t() {
|
||||||
#ifdef SIMPLENICWIDGET_0
|
|
||||||
if (this->niclog)
|
if (this->niclog)
|
||||||
fclose(this->niclog);
|
fclose(this->niclog);
|
||||||
if (loopback) {
|
if (loopback) {
|
||||||
|
@ -123,20 +125,18 @@ simplenic_t::~simplenic_t() {
|
||||||
munmap(pcis_write_bufs[j], BUFBYTES+EXTRABYTES);
|
munmap(pcis_write_bufs[j], BUFBYTES+EXTRABYTES);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif // #ifdef SIMPLENICWIDGET_0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ceil_div(n, d) (((n) - 1) / (d) + 1)
|
#define ceil_div(n, d) (((n) - 1) / (d) + 1)
|
||||||
|
|
||||||
void simplenic_t::init() {
|
void simplenic_t::init() {
|
||||||
#ifdef SIMPLENICWIDGET_0
|
write(mmio_addrs->macaddr_upper, (mac_lendian >> 32) & 0xFFFF);
|
||||||
write(SIMPLENICWIDGET_0(macaddr_upper), (mac_lendian >> 32) & 0xFFFF);
|
write(mmio_addrs->macaddr_lower, mac_lendian & 0xFFFFFFFF);
|
||||||
write(SIMPLENICWIDGET_0(macaddr_lower), mac_lendian & 0xFFFFFFFF);
|
write(mmio_addrs->rlimit_settings,
|
||||||
write(SIMPLENICWIDGET_0(rlimit_settings),
|
|
||||||
(rlimit_inc << 16) | ((rlimit_period - 1) << 8) | rlimit_size);
|
(rlimit_inc << 16) | ((rlimit_period - 1) << 8) | rlimit_size);
|
||||||
|
|
||||||
uint32_t output_tokens_available = read(SIMPLENICWIDGET_0(outgoing_count));
|
uint32_t output_tokens_available = read(mmio_addrs->outgoing_count);
|
||||||
uint32_t input_token_capacity = SIMLATENCY_BT - read(SIMPLENICWIDGET_0(incoming_count));
|
uint32_t input_token_capacity = SIMLATENCY_BT - read(mmio_addrs->incoming_count);
|
||||||
if ((input_token_capacity != SIMLATENCY_BT) || (output_tokens_available != 0)) {
|
if ((input_token_capacity != SIMLATENCY_BT) || (output_tokens_available != 0)) {
|
||||||
printf("FAIL. INCORRECT TOKENS ON BOOT. produced tokens available %d, input slots available %d\n", output_tokens_available, input_token_capacity);
|
printf("FAIL. INCORRECT TOKENS ON BOOT. produced tokens available %d, input slots available %d\n", output_tokens_available, input_token_capacity);
|
||||||
exit(1);
|
exit(1);
|
||||||
|
@ -153,7 +153,6 @@ void simplenic_t::init() {
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
#endif // ifdef SIMPLENICWIDGET_0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//#define TOKENVERIFY
|
//#define TOKENVERIFY
|
||||||
|
@ -172,7 +171,6 @@ uint64_t timeelapsed_cycles = 0;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void simplenic_t::tick() {
|
void simplenic_t::tick() {
|
||||||
#ifdef SIMPLENICWIDGET_0
|
|
||||||
struct timespec tstart, tend;
|
struct timespec tstart, tend;
|
||||||
|
|
||||||
uint32_t token_bytes_obtained_from_fpga = 0;
|
uint32_t token_bytes_obtained_from_fpga = 0;
|
||||||
|
@ -186,8 +184,8 @@ void simplenic_t::tick() {
|
||||||
|
|
||||||
uint32_t tokens_this_round = 0;
|
uint32_t tokens_this_round = 0;
|
||||||
|
|
||||||
uint32_t output_tokens_available = read(SIMPLENICWIDGET_0(outgoing_count));
|
uint32_t output_tokens_available = read(mmio_addrs->outgoing_count);
|
||||||
uint32_t input_token_capacity = SIMLATENCY_BT - read(SIMPLENICWIDGET_0(incoming_count));
|
uint32_t input_token_capacity = SIMLATENCY_BT - read(mmio_addrs->incoming_count);
|
||||||
|
|
||||||
// we will read/write the min of tokens available / token input capacity
|
// we will read/write the min of tokens available / token input capacity
|
||||||
tokens_this_round = std::min(output_tokens_available, input_token_capacity);
|
tokens_this_round = std::min(output_tokens_available, input_token_capacity);
|
||||||
|
@ -297,5 +295,7 @@ void simplenic_t::tick() {
|
||||||
nextround = (nextround + 1) % 2;
|
nextround = (nextround + 1) % 2;
|
||||||
|
|
||||||
}
|
}
|
||||||
#endif // ifdef SIMPLENICWIDGET_0
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif // #ifdef SIMPLENICWIDGET_struct
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
|
||||||
#ifndef __SIMPLENIC_H
|
#ifndef __SIMPLENIC_H
|
||||||
#define __SIMPLENIC_H
|
#define __SIMPLENIC_H
|
||||||
|
|
||||||
|
@ -12,10 +13,11 @@
|
||||||
// IMPORTANT: this must be a multiple of 7
|
// IMPORTANT: this must be a multiple of 7
|
||||||
//#define LINKLATENCY 6405
|
//#define LINKLATENCY 6405
|
||||||
|
|
||||||
|
#ifdef SIMPLENICWIDGET_struct
|
||||||
class simplenic_t: public endpoint_t
|
class simplenic_t: public endpoint_t
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
simplenic_t(simif_t* sim, char * slotid, uint64_t mac_little_end, int netbw, int netburst, int linklatency, char * niclogfile, bool loopback, char *shmemportname);
|
simplenic_t(simif_t* sim, char * slotid, uint64_t mac_little_end, int netbw, int netburst, int linklatency, char * niclogfile, bool loopback, char *shmemportname, SIMPLENICWIDGET_struct *addrs);
|
||||||
~simplenic_t();
|
~simplenic_t();
|
||||||
|
|
||||||
virtual void init();
|
virtual void init();
|
||||||
|
@ -31,7 +33,9 @@ class simplenic_t: public endpoint_t
|
||||||
int rlimit_inc, rlimit_period, rlimit_size;
|
int rlimit_inc, rlimit_period, rlimit_size;
|
||||||
int LINKLATENCY;
|
int LINKLATENCY;
|
||||||
FILE * niclog;
|
FILE * niclog;
|
||||||
bool loopback;
|
SIMPLENICWIDGET_struct *mmio_addrs;
|
||||||
|
bool loopback;
|
||||||
};
|
};
|
||||||
|
#endif // SIMPLENICWIDGET_struct
|
||||||
|
|
||||||
#endif // __SIMPLENIC_H
|
#endif // __SIMPLENIC_H
|
||||||
|
|
|
@ -118,7 +118,12 @@ firesim_top_t::firesim_top_t(int argc, char** argv)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
add_endpoint(new blockdev_t(this, args));
|
add_endpoint(new blockdev_t(this, args));
|
||||||
add_endpoint(new simplenic_t(this, slotid, mac_little_end, netbw, netburst, linklatency, niclogfile, nic_loopback, shmemportname));
|
|
||||||
|
#ifdef SIMPLENICWIDGET_struct
|
||||||
|
SIMPLENICWIDGET_0_substruct_create;
|
||||||
|
add_endpoint(new simplenic_t(this, slotid, mac_little_end, netbw, netburst, linklatency, niclogfile, nic_loopback, shmemportname, &SIMPLENICWIDGET_0_substruct));
|
||||||
|
#endif
|
||||||
|
|
||||||
add_endpoint(new tracerv_t(this, tracefile, trace_start, trace_end));
|
add_endpoint(new tracerv_t(this, tracefile, trace_start, trace_end));
|
||||||
// add more endpoints here
|
// add more endpoints here
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue