cloudFPGA (cF) API  1.0
The documentation of the source code of cloudFPGA (cF)

FPGA Management Core (FMC). The FMC is the core of the cloudFPGA Shell-Role-Architecture. The FMC controls the FPGA and exposes the management functionality via a RESTful HTTP API. Its tasks and responsibilities are sometimes complex and depend on the current situation and environment. In order to unbundle all these dependencies and to allow future extensions easily, the FMC contains a small Instruction-Set-Architecture (ISA). A detailed documentation of the FMC can be found at https://pages.github.ibm.com/cloudFPGA/Doc/pages/cfdk.html#fpga-management-core-fmc . More...

Collaboration diagram for FMC:

Files

file  fmc.cpp
 :
 
file  fmc.hpp
 :
 
file  fmc_hw_flags.hpp
 :
 
file  fmc_sim_flags.hpp
 :
 
file  http.cpp
 :
 
file  http.hpp
 : The HTTP parsing functions for the FMC.
 
file  tb_fmc.cpp
 :
 

Macros

#define WFV_V_SHIFT   8
 
#define DONE_SHIFT   1
 
#define WEMPTY_SHIFT   2
 
#define DECOUP_SHIFT   19
 
#define CMD_SHIFT   3
 
#define ASW1_SHIFT   20
 
#define TCP_OPERATION_SHIFT   18
 
#define ASW2_SHIFT   0
 
#define ASW3_SHIFT   8
 
#define ASW4_SHIFT   16
 
#define NOT_TO_SWAP_SHIFT   24
 
#define RCNT_SHIFT   24
 
#define MSG_SHIFT   0
 
#define ANSWER_LENGTH_SHIFT   0
 
#define HTTP_STATE_SHIFT   4
 
#define WRITE_ERROR_CNT_SHIFT   8
 
#define EMPTY_FIFO_CNT_SHIFT   16
 
#define GLOBAL_STATE_SHIFT   24
 
#define RANK_SHIFT   0
 
#define SIZE_SHIFT   8
 
#define LAST_PAGE_WRITE_CNT_SHIFT   16
 
#define PYRO_SEND_REQUEST_SHIFT   23
 
#define RX_SESS_STATE_SHIFT   0
 
#define RX_DATA_STATE_SHIFT   4
 
#define TX_SESS_STATE_SHIFT   8
 
#define TX_DATA_STATE_SHIFT   12
 
#define TCP_ITER_COUNT_SHIFT   16
 
#define DETECTED_HTTPNL_SHIFT   24
 
#define TCP_RX_CNT_SHIFT   0
 
#define BUFFER_IN_MAX_SHIFT   0
 
#define FULL_FIFO_CNT_SHIFT   16
 
#define ICAP_FSM_SHIFT   24
 
#define WS   4
 
#define SR_OFFSET   (0x110/WS)
 
#define ISR_OFFSET   (0x20/WS)
 
#define WFV_OFFSET   (0x114/WS)
 
#define ASR_OFFSET   (0x11C/WS)
 
#define CR_OFFSET   (0x10C/WS)
 
#define RFO_OFFSET   (0x118/WS)
 
#define WF_OFFSET   (0x100/WS)
 
#define DECOUP_CMD_SHIFT   0
 
#define RST_SHIFT   1
 
#define DSEL_SHIFT   28
 
#define START_SHIFT   12
 
#define SWAP_N_SHIFT   16
 
#define CHECK_PATTERN_SHIFT   13
 
#define PARSE_HTTP_SHIFT   14
 
#define SOFT_RST_SHIFT   2
 
#define PYRO_MODE_SHIFT   15
 
#define PYRO_READ_REQUEST_SHIFT   3
 
#define ENABLE_TCP_MODE_SHIFT   4
 
#define ENABLE_FAKE_HWICAP_SHIFT   5
 
#define LAST_PAGE_CNT_SHIFT   17
 
#define LINES_PER_PAGE   32
 
#define MAX_PAGES   16
 
#define XMEM_SIZE   (LINES_PER_PAGE * MAX_PAGES)
 
#define BYTES_PER_PAGE   (LINES_PER_PAGE*4)
 
#define PAYLOAD_BYTES_PER_PAGE   (BYTES_PER_PAGE - 2)
 
#define IN_BUFFER_SIZE   4096
 
#define OUT_BUFFER_SIZE   1024
 
#define XMEM_ANSWER_START   (1*LINES_PER_PAGE)
 
#define CR_ABORT   0x10
 
#define CR_SWRST   0x8
 
#define CR_FICLR   0x4
 
#define CR_READ   0x2
 
#define CR_WRITE   0x1
 
#define HWICAP_FIFO_DEPTH   1023
 
#define MAX_HWICAP_DATA_CHUNK_BYTES   ((4*HWICAP_FIFO_DEPTH) - 24)
 
#define HWICAP_FIFO_NEARLY_FULL_TRIGGER   4
 
#define MAX_CLUSTER_SIZE   (MAX_MRT_SIZE)
 
#define MIN_ROUTING_TABLE_LINE   (1+1+4+1)
 
#define HTTP_IDLE   0
 
#define HTTP_PARSE_HEADER   1
 
#define HTTP_HEADER_PARSED   2
 
#define HTTP_READ_PAYLOAD   3
 
#define HTTP_REQUEST_COMPLETE   4
 
#define HTTP_SEND_RESPONSE   5
 
#define HTTP_INVALID_REQUEST   6
 
#define HTTP_DONE   7
 
#define HttpState   uint8_t
 
#define GLOBAL_IDLE   0
 
#define GLOBAL_XMEM_CHECK_PATTERN   1
 
#define GLOBAL_XMEM_TO_HWICAP   2
 
#define GLOBAL_XMEM_HTTP   3
 
#define GLOBAL_TCP_HTTP   4
 
#define GLOBAL_PYROLINK_RECV   5
 
#define GLOBAL_PYROLINK_TRANS   6
 
#define GLOBAL_MANUAL_DECOUPLING   7
 
#define GlobalState   uint8_t
 
#define OprvType   uint8_t
 
#define OPRV_OK   0x1
 
#define OPRV_FAIL   0x2
 
#define OPRV_SKIPPED   0x4
 
#define OPRV_NOT_COMPLETE   0x8
 
#define OPRV_PARTIAL_COMPLETE   0x10
 
#define OPRV_DONE   0x20
 
#define OPRV_USER   0x40
 
#define MASK_ALWAYS   0xFF
 
#define TCP_FSM_RESET   0
 
#define TCP_FSM_IDLE   1
 
#define TCP_FSM_W84_START   2
 
#define TCP_FSM_PROCESS_DATA   3
 
#define TCP_FSM_DONE   4
 
#define TCP_FSM_ERROR   5
 
#define TcpFsmState   uint8_t
 
#define ICAP_FSM_RESET   0
 
#define ICAP_FSM_IDLE   1
 
#define ICAP_FSM_WRITE   2
 
#define ICAP_FSM_DONE   3
 
#define ICAP_FSM_ERROR   4
 
#define ICAP_FSM_DRAIN   5
 
#define IcapFsmState   uint8_t
 
#define ICAP_FIFO_POISON_PILL   0x0a0b1c2d
 
#define ICAP_FIFO_POISON_PILL_REVERSE   0x2d1c0b0a
 
#define NUMBER_FPGA_STATE_REGISTERS   8
 
#define FPGA_STATE_LAYER_4   0
 
#define FPGA_STATE_LAYER_6   1
 
#define FPGA_STATE_LAYER_7   2
 
#define FPGA_STATE_CONFIG_UPDATE   3
 
#define FPGA_STATE_MRT_UPDATE   4
 
#define FPGA_STATE_NTS_READY   5
 
#define CHECK_CTRL_LINK_INTERVAL_SECONDS   2
 
#define CHECK_HWICAP_INTERVAL_SECONDS   2
 
#define LINKFSM_IDLE   0
 
#define LINKFSM_WAIT   1
 
#define LINKFSM_UPDATE_MRT   2
 
#define LINKFSM_UPDATE_CONFIG   3
 
#define LINKFSM_UPDATE_STATE   4
 
#define LINKFSM_UPDATE_SAVED_STATE   5
 
#define LinkFsmStateType   uint8_t
 
#define OpcodeType   uint8_t
 
#define OP_NOP   0
 
#define OP_ENABLE_XMEM_CHECK_PATTERN   1
 
#define OP_XMEM_COPY_DATA   2
 
#define OP_FILL_BUFFER_TCP   3
 
#define OP_HANDLE_HTTP   4
 
#define OP_CHECK_HTTP_EOR   5
 
#define OP_CHECK_HTTP_EOP   6
 
#define OP_BUFFER_TO_HWICAP   7
 
#define OP_BUFFER_TO_PYROLINK   8
 
#define OP_BUFFER_TO_ROUTING   9
 
#define OP_SEND_BUFFER_TCP   10
 
#define OP_SEND_BUFFER_XMEM   11
 
#define OP_CLEAR_IN_BUFFER   12
 
#define OP_CLEAR_OUT_BUFFER   13
 
#define OP_DONE   14
 
#define OP_DISABLE_XMEM_CHECK_PATTERN   15
 
#define OP_ACTIVATE_DECOUP   16
 
#define OP_DEACTIVATE_DECOUP   17
 
#define OP_ABORT_HWICAP   18
 
#define OP_FAIL   19
 
#define OP_UPDATE_HTTP_STATE   20
 
#define OP_COPY_REQTYPE_TO_RETURN   21
 
#define OP_EXIT   22
 
#define OP_ENABLE_SILENT_SKIP   23
 
#define OP_DISABLE_SILENT_SKIP   24
 
#define OP_OK   25
 
#define OP_PYROLINK_TO_OUTBUFFER   26
 
#define OP_WAIT_FOR_TCP_SESS   27
 
#define OP_SEND_TCP_SESS   28
 
#define OP_SET_NOT_TO_SWAP   29
 
#define OP_UNSET_NOT_TO_SWAP   30
 
#define OP_ACTIVATE_CONT_TCP   31
 
#define OP_DEACTIVATE_CONT_TCP   32
 
#define OP_TCP_RX_STOP_ON_EOR   33
 
#define OP_TCP_RX_STOP_ON_EOP   34
 
#define OP_TCP_CNT_RESET   35
 
#define OP_FIFO_TO_HWICAP   36
 
#define OP_CLEAR_ROUTING_TABLE   37
 
#define MAX_PROGRAM_LENGTH   64
 
#define GLOBAL_MAX_WAIT_COUNT   (5 * 1024)
 
#define CHECK_CTRL_LINK_TICKS   1000
 
#define CHECK_CTRL_LINK_TICKS   0
 
#define REQ_INVALID   0x01
 
#define POST_CONFIG   0x02
 
#define GET_STATUS   0x40
 
#define PUT_RANK   0x08
 
#define PUT_SIZE   0x10
 
#define POST_ROUTING   0x20
 
#define CUSTOM_API   0x80
 
#define RequestType   uint8_t
 
#define DEBUG
 
#define HWICAP_SEQ_SIZE   ((16*IN_BUFFER_SIZE + 512)/4)
 
#define HWICAP_SEQ_START_ADDRESS   1024
 

Functions

stream< uint8_t > internal_icap_fifo ("sInternalIcapFifo")
 
stream< uint8_t > icap_hangover_fifo ("sIcapHangoverFifo")
 
uint8_t bytesToPages (int len, bool update_global_variables)
 
void copyOutBuffer (ap_uint< 4 > numberOfPages, ap_uint< 32 > xmem[(32 *16)])
 
void emptyInBuffer ()
 
void emptyOutBuffer ()
 
uint32_t writeDisplaysToOutBuffer ()
 
void setRank (ap_uint< 32 > newRank)
 
void setSize (ap_uint< 32 > newSize)
 
ap_uint< 4 > copyAndCheckBurst (ap_uint< 32 > xmem[(32 *16)], ap_uint< 4 > ExpCnt, ap_uint< 7 > lastPageCnt_in)
 
void fmc (ap_uint< 32 > *MMIO_in, ap_uint< 32 > *MMIO_out, ap_uint< 1 > *layer_4_enabled, ap_uint< 1 > *layer_6_enabled, ap_uint< 1 > *layer_7_enabled, ap_uint< 1 > *nts_ready, ap_uint< 32 > *in_time_seconds, ap_uint< 32 > *in_time_minutes, ap_uint< 32 > *in_time_hours, ap_uint< 16 > *role_mmio_in, ap_uint< 16 > *uoe_drop_cnt_in, ap_uint< 8 > *toe_notif_drop_cnt_in, ap_uint< 8 > *toe_meta_drop_cnt_in, ap_uint< 8 > *toe_data_drop_cnt_in, ap_uint< 8 > *toe_crc_drop_cnt_in, ap_uint< 8 > *toe_sess_drop_cnt_in, ap_uint< 8 > *toe_ooo_drop_cnt_in, ap_uint< 32 > *HWICAP, ap_uint< 1 > decoupStatus, ap_uint< 1 > *setDecoup, ap_uint< 1 > *setSoftReset, ap_uint< 32 > xmem[(32 *16)], ap_uint< 32 > nalCtrl[(0x3ff/4)], ap_uint< 1 > *disable_ctrl_link, stream< TcpWord > &siNAL_Tcp_data, stream< AppMeta > &siNAL_Tcp_SessId, stream< TcpWord > &soNAL_Tcp_data, stream< AppMeta > &soNAL_Tcp_SessId, ap_uint< 32 > *role_rank, ap_uint< 32 > *cluster_size)
 
int my_strlen (char *s)
 
int my_wordlen (char *s)
 
int writeString (char *s)
 
void strrev (char *str)
 
int writeUnsignedLong (unsigned long num, uint8_t base)
 
void my_itoa (unsigned long num, char *arr, unsigned char base)
 
int my_atoi (char *str, int strlen)
 
int8_t writeHttpStatus (int status, uint16_t content_length)
 
int my_strcmp (char *tmp1, volatile uint8_t tmp2[4096], int max_length)
 
int request_len (ap_uint< 16 > offset, int maxLength)
 
int8_t extract_path (bool rx_done)
 
void parseHttpInput (bool transferErr, ap_uint< 1 > wasAbort, bool invalidPayload, bool rx_done)
 
stream< Axis< 8 > > FMC_Debug_Pyrolink ("FMC_Debug_Pyrolink")
 
stream< Axis< 8 > > Debug_FMC_Pyrolink ("Debug_FMC_Pyrolink")
 
stream< TcpWordsFMC_NAL_Tcp_data ("sFMC_Nal_Tcp_data")
 
stream< AppMetasFMC_NAL_Tcp_sessId ("sFMC_Nal_Tcp_sessId")
 
stream< TcpWordsNAL_FMC_Tcp_data ("sNAL_FMC_Tcp_data")
 
stream< AppMetasNAL_FMC_Tcp_sessId ("sNAL_FMC_Tcp_sessId")
 
ap_uint< 32 > reverse_byte_order (ap_uint< 32 > input)
 
bool checkResult (ap_uint< 32 > MMIO, ap_uint< 32 > expected)
 
void printBuffer (volatile uint8_t *buffer_int, char *msg, int max_pages)
 
void printBuffer32 (ap_uint< 32 > buffer_int[(32 *16)], char *msg, int max_pages)
 
bool checkSeqHwicap (uint32_t *true_buffer, ap_uint< 32 > *out_buffer, uint32_t start_address, uint32_t end_address, bool not_to_swap)
 
void initBuffer (ap_uint< 4 > cnt, ap_uint< 32 > xmem[(32 *16)], bool lastPage, bool withPattern)
 
ap_uint< 64 > initStream (ap_uint< 4 > cnt, stream< NetworkWord > &tcp_data, int nr_words, bool with_pattern, bool inverse_upper, bool insert_tlast)
 
void copyBufferToXmem (char *buffer_int, ap_uint< 32 > xmem[(32 *16)])
 
void copyBufferToStream (char *buffer_int, stream< NetworkWord > &tcp_data, int content_len)
 
void drainStream (stream< NetworkWord > &tcp_data)
 
int main ()
 

Variables

ap_uint< 8 > writeErrCnt = 0
 
ap_uint< 8 > fifoEmptyCnt = 0
 
ap_uint< 8 > fifoFullCnt = 0
 
ap_uint< 4 > xmem_page_trans_cnt = 0xF
 
uint8_t fsmHwicap = 0
 
bool fifo_operation_in_progress = false
 
uint8_t fifo_overflow_buffer [8]
 
bool process_fifo_overflow_buffer = false
 
uint8_t fifo_overflow_buffer_length = 8
 
uint8_t bufferIn [4096]
 
uint32_t bufferInPtrWrite = 0x0
 
uint32_t bufferInPtrMaxWrite = 0x0
 
uint32_t lastSeenBufferInPtrMaxWrite = 0x0
 
uint32_t bufferInPtrNextRead = 0x0
 
bool tcp_write_only_fifo = false
 
uint8_t bufferOut [1024]
 
uint16_t bufferOutPtrWrite = 0x0
 
uint16_t bufferOutContentLength = 0x0
 
uint16_t bufferOutPtrNextRead = 0x0
 
uint16_t lastSeenBufferOutPtrNextRead = 0x0
 
bool use_sequential_hwicap = false
 
uint32_t sequential_hwicap_address = 0
 
uint8_t httpState = 0
 
ap_uint< 32 > Display1 = 0
 
ap_uint< 32 > Display2 = 0
 
ap_uint< 32 > Display3 = 0
 
ap_uint< 32 > Display4 = 0
 
ap_uint< 32 > Display5 = 0
 
ap_uint< 32 > Display6 = 0
 
ap_uint< 32 > Display7 = 0
 
ap_uint< 32 > Display8 = 0
 
ap_uint< 32 > Display9 = 0
 
ap_uint< 28 > wordsWrittenToIcapCnt = 0
 
ap_uint< 28 > tcp_words_received = 0
 
ap_uint< 32 > nodeRank = 0
 
ap_uint< 32 > clusterSize = 0
 
ap_uint< 1 > toDecoup_persistent = 0
 
ap_uint< 8 > nal_status_request_cnt = 0
 
ap_uint< 32 > nal_status [16]
 
bool nal_status_disabled = false
 
ap_uint< 8 > fpga_status [8]
 
ap_uint< 32 > ctrl_link_next_check_seconds = 0
 
ap_uint< 32 > mrt_copy_index = 0
 
ap_uint< 16 > current_role_mmio = 0
 
ap_uint< 32 > fpga_time_seconds = 0
 
ap_uint< 32 > fpga_time_minutes = 0
 
ap_uint< 32 > fpga_time_hours = 0
 
ap_uint< 16 > nts_udp_drop_cnt = 0
 
ap_uint< 8 > nts_tcp_notif_drop_cnt = 0
 
ap_uint< 8 > nts_tcp_meta_drop_cnt = 0
 
ap_uint< 8 > nts_tcp_data_drop_cnt = 0
 
ap_uint< 8 > nts_tcp_crc_drop_cnt = 0
 
ap_uint< 8 > nts_tcp_sess_drop_cnt = 0
 
ap_uint< 8 > nts_tcp_ooo_drop_cnt = 0
 
ap_uint< 7 > lastResponsePageCnt = 0
 
ap_uint< 4 > responePageCnt = 0
 
uint8_t currentGlobalOperation = 0
 
bool streaming_mode_persistent = false
 
bool transferError_persistent = false
 
bool invalidPayload_persistent = false
 
bool globalOperationDone_persistent = false
 
bool axi_wasnot_ready_persistent = false
 
ap_uint< 32 > global_state_wait_counter_persistent = 0
 
AppMeta currentTcpSessId = 0
 
bool TcpSessId_updated_persistent = false
 
ap_uint< 1 > tcpModeEnabled = 0
 
uint8_t tcp_iteration_count = 0
 
ap_uint< 1 > flag_check_xmem_pattern = 0
 
ap_uint< 1 > flag_silent_skip = 0
 
ap_uint< 1 > last_xmem_page_received_persistent = 0
 
ap_uint< 1 > flag_continuous_tcp_rx = 0
 
ap_uint< 1 > flag_enable_fake_hwicap = 0
 
uint8_t fsmTcpSessId_RX = 0
 
uint8_t fsmTcpSessId_TX = 0
 
uint8_t fsmTcpData_RX = 0
 
uint8_t fsmTcpData_TX = 0
 
bool run_nested_loop_helper = false
 
bool goto_done_if_idle_tcp_rx = false
 
ap_uint< 4 > received_TCP_SessIds_cnt = 0
 
uint8_t last_3_chars [3]
 
ap_uint< 2 > detected_http_nl_cnt = 0
 
ap_uint< 2 > target_http_nl_cnt = 0
 
uint32_t positions_of_detected_http_nl [4]
 
uint8_t buffer_hangover_bytes [3]
 
bool hwicap_hangover_present = true
 
uint8_t hwicap_hangover_size = 0
 
bool tables_initialized = false
 
ap_uint< 32 > current_MRT [64]
 
ap_uint< 32 > current_nrc_config [16]
 
ap_uint< 32 > current_nrc_mrt_version = 0
 
bool need_to_update_nrc_mrt = false
 
bool need_to_update_nrc_config = false
 
uint8_t linkCtrlFSM = 1
 
ap_uint< 32 > max_discovered_node_id = 0
 
uint8_t bufferIn [4096]
 
uint8_t bufferOut [1024]
 
uint32_t bufferInPtrWrite
 
uint32_t bufferInPtrNextRead
 
uint16_t bufferOutPtrWrite
 
uint16_t bufferOutContentLength
 
bool use_sequential_hwicap
 
uint32_t sequential_hwicap_address
 
uint8_t httpState
 
uint8_t reqType = 0x01
 
uint8_t reqType
 
ap_uint< 32 > MMIO_in = 0x0
 
ap_uint< 32 > MMIO
 
ap_uint< 32 > MMIO_in_BE
 
ap_uint< 32 > MMIO_out_BE
 
ap_uint< 1 > layer_4_enabled = 0b1
 
ap_uint< 1 > layer_6_enabled = 0b0
 
ap_uint< 1 > layer_7_enabled = 0b0
 
ap_uint< 1 > nts_ready = 0b1
 
ap_uint< 16 > role_mmio = 0x1DEA
 
ap_uint< 16 > uoe_drop_cnt = 0x0
 
ap_uint< 8 > toe_notif_drop_cnt = 0
 
ap_uint< 8 > toe_meta_drop_cnt = 0
 
ap_uint< 8 > toe_data_drop_cnt = 0
 
ap_uint< 8 > toe_crc_drop_cnt = 0
 
ap_uint< 8 > toe_sess_drop_cnt = 0
 
ap_uint< 8 > toe_ooo_drop_cnt = 0
 
ap_uint< 32 > sim_fpga_time_seconds = 0
 
ap_uint< 32 > sim_fpga_time_minutes = 0
 
ap_uint< 32 > sim_fpga_time_hours = 0
 
ap_uint< 1 > decoupActive = 0b0
 
ap_uint< 1 > decoupStatus = 0b0
 
ap_uint< 1 > softReset = 0b0
 
ap_uint< 32 > nodeRank_out
 
ap_uint< 32 > clusterSize_out
 
ap_uint< 32 > HWICAP [512]
 
uint8_t HWICAP_seq_IN [((16 *4096+512)/4) *4]
 
ap_uint< 32 > HWICAP_seq_OUT [((16 *4096+512)/4)]
 
ap_uint< 32 > xmem [(32 *16)]
 
ap_uint< 32 > nalCtrl [(0x3ff/4)]
 
ap_uint< 1 > disable_ctrl_link = 0b0
 
ap_uint< 1 > disable_pyro_link = 0b0
 
int simCnt
 

Detailed Description

FPGA Management Core (FMC). The FMC is the core of the cloudFPGA Shell-Role-Architecture. The FMC controls the FPGA and exposes the management functionality via a RESTful HTTP API. Its tasks and responsibilities are sometimes complex and depend on the current situation and environment. In order to unbundle all these dependencies and to allow future extensions easily, the FMC contains a small Instruction-Set-Architecture (ISA). A detailed documentation of the FMC can be found at https://pages.github.ibm.com/cloudFPGA/Doc/pages/cfdk.html#fpga-management-core-fmc .

cFDK / ShellLib : Submodules

Macro Definition Documentation

◆ ANSWER_LENGTH_SHIFT

#define ANSWER_LENGTH_SHIFT   0

Definition at line 64 of file fmc.hpp.

◆ ASR_OFFSET

#define ASR_OFFSET   (0x11C/WS)

Definition at line 97 of file fmc.hpp.

◆ ASW1_SHIFT

#define ASW1_SHIFT   20

Definition at line 50 of file fmc.hpp.

◆ ASW2_SHIFT

#define ASW2_SHIFT   0

Definition at line 54 of file fmc.hpp.

◆ ASW3_SHIFT

#define ASW3_SHIFT   8

Definition at line 55 of file fmc.hpp.

◆ ASW4_SHIFT

#define ASW4_SHIFT   16

Definition at line 56 of file fmc.hpp.

◆ BUFFER_IN_MAX_SHIFT

#define BUFFER_IN_MAX_SHIFT   0

Definition at line 88 of file fmc.hpp.

◆ BYTES_PER_PAGE

#define BYTES_PER_PAGE   (LINES_PER_PAGE*4)

Definition at line 125 of file fmc.hpp.

◆ CHECK_CTRL_LINK_INTERVAL_SECONDS

#define CHECK_CTRL_LINK_INTERVAL_SECONDS   2

Definition at line 223 of file fmc.hpp.

◆ CHECK_CTRL_LINK_TICKS [1/2]

#define CHECK_CTRL_LINK_TICKS   1000

Definition at line 34 of file fmc_hw_flags.hpp.

◆ CHECK_CTRL_LINK_TICKS [2/2]

#define CHECK_CTRL_LINK_TICKS   0

Definition at line 34 of file fmc_sim_flags.hpp.

◆ CHECK_HWICAP_INTERVAL_SECONDS

#define CHECK_HWICAP_INTERVAL_SECONDS   2

Definition at line 224 of file fmc.hpp.

◆ CHECK_PATTERN_SHIFT

#define CHECK_PATTERN_SHIFT   13

Definition at line 112 of file fmc.hpp.

◆ CMD_SHIFT

#define CMD_SHIFT   3

Definition at line 49 of file fmc.hpp.

◆ CR_ABORT

#define CR_ABORT   0x10

Definition at line 137 of file fmc.hpp.

◆ CR_FICLR

#define CR_FICLR   0x4

Definition at line 139 of file fmc.hpp.

◆ CR_OFFSET

#define CR_OFFSET   (0x10C/WS)

Definition at line 98 of file fmc.hpp.

◆ CR_READ

#define CR_READ   0x2

Definition at line 140 of file fmc.hpp.

◆ CR_SWRST

#define CR_SWRST   0x8

Definition at line 138 of file fmc.hpp.

◆ CR_WRITE

#define CR_WRITE   0x1

Definition at line 141 of file fmc.hpp.

◆ CUSTOM_API

#define CUSTOM_API   0x80

Definition at line 45 of file http.hpp.

◆ DEBUG

#define DEBUG

Definition at line 30 of file tb_fmc.cpp.

◆ DECOUP_CMD_SHIFT

#define DECOUP_CMD_SHIFT   0

Definition at line 106 of file fmc.hpp.

◆ DECOUP_SHIFT

#define DECOUP_SHIFT   19

Definition at line 48 of file fmc.hpp.

◆ DETECTED_HTTPNL_SHIFT

#define DETECTED_HTTPNL_SHIFT   24

Definition at line 82 of file fmc.hpp.

◆ DONE_SHIFT

#define DONE_SHIFT   1

Definition at line 46 of file fmc.hpp.

◆ DSEL_SHIFT

#define DSEL_SHIFT   28

Definition at line 108 of file fmc.hpp.

◆ EMPTY_FIFO_CNT_SHIFT

#define EMPTY_FIFO_CNT_SHIFT   16

Definition at line 67 of file fmc.hpp.

◆ ENABLE_FAKE_HWICAP_SHIFT

#define ENABLE_FAKE_HWICAP_SHIFT   5

Definition at line 118 of file fmc.hpp.

◆ ENABLE_TCP_MODE_SHIFT

#define ENABLE_TCP_MODE_SHIFT   4

Definition at line 117 of file fmc.hpp.

◆ FPGA_STATE_CONFIG_UPDATE

#define FPGA_STATE_CONFIG_UPDATE   3

Definition at line 218 of file fmc.hpp.

◆ FPGA_STATE_LAYER_4

#define FPGA_STATE_LAYER_4   0

Definition at line 215 of file fmc.hpp.

◆ FPGA_STATE_LAYER_6

#define FPGA_STATE_LAYER_6   1

Definition at line 216 of file fmc.hpp.

◆ FPGA_STATE_LAYER_7

#define FPGA_STATE_LAYER_7   2

Definition at line 217 of file fmc.hpp.

◆ FPGA_STATE_MRT_UPDATE

#define FPGA_STATE_MRT_UPDATE   4

Definition at line 219 of file fmc.hpp.

◆ FPGA_STATE_NTS_READY

#define FPGA_STATE_NTS_READY   5

Definition at line 220 of file fmc.hpp.

◆ FULL_FIFO_CNT_SHIFT

#define FULL_FIFO_CNT_SHIFT   16

Definition at line 89 of file fmc.hpp.

◆ GET_STATUS

#define GET_STATUS   0x40

Definition at line 41 of file http.hpp.

◆ GLOBAL_IDLE

#define GLOBAL_IDLE   0

Definition at line 169 of file fmc.hpp.

◆ GLOBAL_MANUAL_DECOUPLING

#define GLOBAL_MANUAL_DECOUPLING   7

Definition at line 176 of file fmc.hpp.

◆ GLOBAL_MAX_WAIT_COUNT

#define GLOBAL_MAX_WAIT_COUNT   (5 * 1024)

Definition at line 282 of file fmc.hpp.

◆ GLOBAL_PYROLINK_RECV

#define GLOBAL_PYROLINK_RECV   5

Definition at line 174 of file fmc.hpp.

◆ GLOBAL_PYROLINK_TRANS

#define GLOBAL_PYROLINK_TRANS   6

Definition at line 175 of file fmc.hpp.

◆ GLOBAL_STATE_SHIFT

#define GLOBAL_STATE_SHIFT   24

Definition at line 68 of file fmc.hpp.

◆ GLOBAL_TCP_HTTP

#define GLOBAL_TCP_HTTP   4

Definition at line 173 of file fmc.hpp.

◆ GLOBAL_XMEM_CHECK_PATTERN

#define GLOBAL_XMEM_CHECK_PATTERN   1

Definition at line 170 of file fmc.hpp.

◆ GLOBAL_XMEM_HTTP

#define GLOBAL_XMEM_HTTP   3

Definition at line 172 of file fmc.hpp.

◆ GLOBAL_XMEM_TO_HWICAP

#define GLOBAL_XMEM_TO_HWICAP   2

Definition at line 171 of file fmc.hpp.

◆ GlobalState

#define GlobalState   uint8_t

Definition at line 178 of file fmc.hpp.

◆ HTTP_DONE

#define HTTP_DONE   7

Definition at line 165 of file fmc.hpp.

◆ HTTP_HEADER_PARSED

#define HTTP_HEADER_PARSED   2

Definition at line 160 of file fmc.hpp.

◆ HTTP_IDLE

#define HTTP_IDLE   0

Definition at line 158 of file fmc.hpp.

◆ HTTP_INVALID_REQUEST

#define HTTP_INVALID_REQUEST   6

Definition at line 164 of file fmc.hpp.

◆ HTTP_PARSE_HEADER

#define HTTP_PARSE_HEADER   1

Definition at line 159 of file fmc.hpp.

◆ HTTP_READ_PAYLOAD

#define HTTP_READ_PAYLOAD   3

Definition at line 161 of file fmc.hpp.

◆ HTTP_REQUEST_COMPLETE

#define HTTP_REQUEST_COMPLETE   4

Definition at line 162 of file fmc.hpp.

◆ HTTP_SEND_RESPONSE

#define HTTP_SEND_RESPONSE   5

Definition at line 163 of file fmc.hpp.

◆ HTTP_STATE_SHIFT

#define HTTP_STATE_SHIFT   4

Definition at line 65 of file fmc.hpp.

◆ HttpState

#define HttpState   uint8_t

Definition at line 166 of file fmc.hpp.

◆ HWICAP_FIFO_DEPTH

#define HWICAP_FIFO_DEPTH   1023

Definition at line 143 of file fmc.hpp.

◆ HWICAP_FIFO_NEARLY_FULL_TRIGGER

#define HWICAP_FIFO_NEARLY_FULL_TRIGGER   4

Definition at line 145 of file fmc.hpp.

◆ HWICAP_SEQ_SIZE

#define HWICAP_SEQ_SIZE   ((16*IN_BUFFER_SIZE + 512)/4)

Definition at line 54 of file tb_fmc.cpp.

◆ HWICAP_SEQ_START_ADDRESS

#define HWICAP_SEQ_START_ADDRESS   1024

Definition at line 58 of file tb_fmc.cpp.

◆ ICAP_FIFO_POISON_PILL

#define ICAP_FIFO_POISON_PILL   0x0a0b1c2d

Definition at line 209 of file fmc.hpp.

◆ ICAP_FIFO_POISON_PILL_REVERSE

#define ICAP_FIFO_POISON_PILL_REVERSE   0x2d1c0b0a

Definition at line 210 of file fmc.hpp.

◆ ICAP_FSM_DONE

#define ICAP_FSM_DONE   3

Definition at line 205 of file fmc.hpp.

◆ ICAP_FSM_DRAIN

#define ICAP_FSM_DRAIN   5

Definition at line 207 of file fmc.hpp.

◆ ICAP_FSM_ERROR

#define ICAP_FSM_ERROR   4

Definition at line 206 of file fmc.hpp.

◆ ICAP_FSM_IDLE

#define ICAP_FSM_IDLE   1

Definition at line 203 of file fmc.hpp.

◆ ICAP_FSM_RESET

#define ICAP_FSM_RESET   0

Definition at line 202 of file fmc.hpp.

◆ ICAP_FSM_SHIFT

#define ICAP_FSM_SHIFT   24

Definition at line 90 of file fmc.hpp.

◆ ICAP_FSM_WRITE

#define ICAP_FSM_WRITE   2

Definition at line 204 of file fmc.hpp.

◆ IcapFsmState

#define IcapFsmState   uint8_t

Definition at line 208 of file fmc.hpp.

◆ IN_BUFFER_SIZE

#define IN_BUFFER_SIZE   4096

Definition at line 131 of file fmc.hpp.

◆ ISR_OFFSET

#define ISR_OFFSET   (0x20/WS)

Definition at line 95 of file fmc.hpp.

◆ LAST_PAGE_CNT_SHIFT

#define LAST_PAGE_CNT_SHIFT   17

Definition at line 119 of file fmc.hpp.

◆ LAST_PAGE_WRITE_CNT_SHIFT

#define LAST_PAGE_WRITE_CNT_SHIFT   16

Definition at line 73 of file fmc.hpp.

◆ LINES_PER_PAGE

#define LINES_PER_PAGE   32

Definition at line 122 of file fmc.hpp.

◆ LINKFSM_IDLE

#define LINKFSM_IDLE   0

Definition at line 226 of file fmc.hpp.

◆ LINKFSM_UPDATE_CONFIG

#define LINKFSM_UPDATE_CONFIG   3

Definition at line 229 of file fmc.hpp.

◆ LINKFSM_UPDATE_MRT

#define LINKFSM_UPDATE_MRT   2

Definition at line 228 of file fmc.hpp.

◆ LINKFSM_UPDATE_SAVED_STATE

#define LINKFSM_UPDATE_SAVED_STATE   5

Definition at line 231 of file fmc.hpp.

◆ LINKFSM_UPDATE_STATE

#define LINKFSM_UPDATE_STATE   4

Definition at line 230 of file fmc.hpp.

◆ LINKFSM_WAIT

#define LINKFSM_WAIT   1

Definition at line 227 of file fmc.hpp.

◆ LinkFsmStateType

#define LinkFsmStateType   uint8_t

Definition at line 232 of file fmc.hpp.

◆ MASK_ALWAYS

#define MASK_ALWAYS   0xFF

Definition at line 189 of file fmc.hpp.

◆ MAX_CLUSTER_SIZE

#define MAX_CLUSTER_SIZE   (MAX_MRT_SIZE)

Definition at line 151 of file fmc.hpp.

◆ MAX_HWICAP_DATA_CHUNK_BYTES

#define MAX_HWICAP_DATA_CHUNK_BYTES   ((4*HWICAP_FIFO_DEPTH) - 24)

Definition at line 144 of file fmc.hpp.

◆ MAX_PAGES

#define MAX_PAGES   16

Definition at line 123 of file fmc.hpp.

◆ MAX_PROGRAM_LENGTH

#define MAX_PROGRAM_LENGTH   64

Definition at line 278 of file fmc.hpp.

◆ MIN_ROUTING_TABLE_LINE

#define MIN_ROUTING_TABLE_LINE   (1+1+4+1)

Definition at line 154 of file fmc.hpp.

◆ MSG_SHIFT

#define MSG_SHIFT   0

Definition at line 61 of file fmc.hpp.

◆ NOT_TO_SWAP_SHIFT

#define NOT_TO_SWAP_SHIFT   24

Definition at line 57 of file fmc.hpp.

◆ NUMBER_FPGA_STATE_REGISTERS

#define NUMBER_FPGA_STATE_REGISTERS   8

Definition at line 214 of file fmc.hpp.

◆ OP_ABORT_HWICAP

#define OP_ABORT_HWICAP   18

Definition at line 256 of file fmc.hpp.

◆ OP_ACTIVATE_CONT_TCP

#define OP_ACTIVATE_CONT_TCP   31

Definition at line 269 of file fmc.hpp.

◆ OP_ACTIVATE_DECOUP

#define OP_ACTIVATE_DECOUP   16

Definition at line 254 of file fmc.hpp.

◆ OP_BUFFER_TO_HWICAP

#define OP_BUFFER_TO_HWICAP   7

Definition at line 245 of file fmc.hpp.

◆ OP_BUFFER_TO_PYROLINK

#define OP_BUFFER_TO_PYROLINK   8

Definition at line 246 of file fmc.hpp.

◆ OP_BUFFER_TO_ROUTING

#define OP_BUFFER_TO_ROUTING   9

Definition at line 247 of file fmc.hpp.

◆ OP_CHECK_HTTP_EOP

#define OP_CHECK_HTTP_EOP   6

Definition at line 244 of file fmc.hpp.

◆ OP_CHECK_HTTP_EOR

#define OP_CHECK_HTTP_EOR   5

Definition at line 243 of file fmc.hpp.

◆ OP_CLEAR_IN_BUFFER

#define OP_CLEAR_IN_BUFFER   12

Definition at line 250 of file fmc.hpp.

◆ OP_CLEAR_OUT_BUFFER

#define OP_CLEAR_OUT_BUFFER   13

Definition at line 251 of file fmc.hpp.

◆ OP_CLEAR_ROUTING_TABLE

#define OP_CLEAR_ROUTING_TABLE   37

Definition at line 275 of file fmc.hpp.

◆ OP_COPY_REQTYPE_TO_RETURN

#define OP_COPY_REQTYPE_TO_RETURN   21

Definition at line 259 of file fmc.hpp.

◆ OP_DEACTIVATE_CONT_TCP

#define OP_DEACTIVATE_CONT_TCP   32

Definition at line 270 of file fmc.hpp.

◆ OP_DEACTIVATE_DECOUP

#define OP_DEACTIVATE_DECOUP   17

Definition at line 255 of file fmc.hpp.

◆ OP_DISABLE_SILENT_SKIP

#define OP_DISABLE_SILENT_SKIP   24

Definition at line 262 of file fmc.hpp.

◆ OP_DISABLE_XMEM_CHECK_PATTERN

#define OP_DISABLE_XMEM_CHECK_PATTERN   15

Definition at line 253 of file fmc.hpp.

◆ OP_DONE

#define OP_DONE   14

Definition at line 252 of file fmc.hpp.

◆ OP_ENABLE_SILENT_SKIP

#define OP_ENABLE_SILENT_SKIP   23

Definition at line 261 of file fmc.hpp.

◆ OP_ENABLE_XMEM_CHECK_PATTERN

#define OP_ENABLE_XMEM_CHECK_PATTERN   1

Definition at line 239 of file fmc.hpp.

◆ OP_EXIT

#define OP_EXIT   22

Definition at line 260 of file fmc.hpp.

◆ OP_FAIL

#define OP_FAIL   19

Definition at line 257 of file fmc.hpp.

◆ OP_FIFO_TO_HWICAP

#define OP_FIFO_TO_HWICAP   36

Definition at line 274 of file fmc.hpp.

◆ OP_FILL_BUFFER_TCP

#define OP_FILL_BUFFER_TCP   3

Definition at line 241 of file fmc.hpp.

◆ OP_HANDLE_HTTP

#define OP_HANDLE_HTTP   4

Definition at line 242 of file fmc.hpp.

◆ OP_NOP

#define OP_NOP   0

Definition at line 238 of file fmc.hpp.

◆ OP_OK

#define OP_OK   25

Definition at line 263 of file fmc.hpp.

◆ OP_PYROLINK_TO_OUTBUFFER

#define OP_PYROLINK_TO_OUTBUFFER   26

Definition at line 264 of file fmc.hpp.

◆ OP_SEND_BUFFER_TCP

#define OP_SEND_BUFFER_TCP   10

Definition at line 248 of file fmc.hpp.

◆ OP_SEND_BUFFER_XMEM

#define OP_SEND_BUFFER_XMEM   11

Definition at line 249 of file fmc.hpp.

◆ OP_SEND_TCP_SESS

#define OP_SEND_TCP_SESS   28

Definition at line 266 of file fmc.hpp.

◆ OP_SET_NOT_TO_SWAP

#define OP_SET_NOT_TO_SWAP   29

Definition at line 267 of file fmc.hpp.

◆ OP_TCP_CNT_RESET

#define OP_TCP_CNT_RESET   35

Definition at line 273 of file fmc.hpp.

◆ OP_TCP_RX_STOP_ON_EOP

#define OP_TCP_RX_STOP_ON_EOP   34

Definition at line 272 of file fmc.hpp.

◆ OP_TCP_RX_STOP_ON_EOR

#define OP_TCP_RX_STOP_ON_EOR   33

Definition at line 271 of file fmc.hpp.

◆ OP_UNSET_NOT_TO_SWAP

#define OP_UNSET_NOT_TO_SWAP   30

Definition at line 268 of file fmc.hpp.

◆ OP_UPDATE_HTTP_STATE

#define OP_UPDATE_HTTP_STATE   20

Definition at line 258 of file fmc.hpp.

◆ OP_WAIT_FOR_TCP_SESS

#define OP_WAIT_FOR_TCP_SESS   27

Definition at line 265 of file fmc.hpp.

◆ OP_XMEM_COPY_DATA

#define OP_XMEM_COPY_DATA   2

Definition at line 240 of file fmc.hpp.

◆ OpcodeType

#define OpcodeType   uint8_t

Definition at line 237 of file fmc.hpp.

◆ OPRV_DONE

#define OPRV_DONE   0x20

Definition at line 187 of file fmc.hpp.

◆ OPRV_FAIL

#define OPRV_FAIL   0x2

Definition at line 183 of file fmc.hpp.

◆ OPRV_NOT_COMPLETE

#define OPRV_NOT_COMPLETE   0x8

Definition at line 185 of file fmc.hpp.

◆ OPRV_OK

#define OPRV_OK   0x1

Definition at line 182 of file fmc.hpp.

◆ OPRV_PARTIAL_COMPLETE

#define OPRV_PARTIAL_COMPLETE   0x10

Definition at line 186 of file fmc.hpp.

◆ OPRV_SKIPPED

#define OPRV_SKIPPED   0x4

Definition at line 184 of file fmc.hpp.

◆ OPRV_USER

#define OPRV_USER   0x40

Definition at line 188 of file fmc.hpp.

◆ OprvType

#define OprvType   uint8_t

Definition at line 181 of file fmc.hpp.

◆ OUT_BUFFER_SIZE

#define OUT_BUFFER_SIZE   1024

Definition at line 133 of file fmc.hpp.

◆ PARSE_HTTP_SHIFT

#define PARSE_HTTP_SHIFT   14

Definition at line 113 of file fmc.hpp.

◆ PAYLOAD_BYTES_PER_PAGE

#define PAYLOAD_BYTES_PER_PAGE   (BYTES_PER_PAGE - 2)

Definition at line 126 of file fmc.hpp.

◆ POST_CONFIG

#define POST_CONFIG   0x02

Definition at line 40 of file http.hpp.

◆ POST_ROUTING

#define POST_ROUTING   0x20

Definition at line 44 of file http.hpp.

◆ PUT_RANK

#define PUT_RANK   0x08

Definition at line 42 of file http.hpp.

◆ PUT_SIZE

#define PUT_SIZE   0x10

Definition at line 43 of file http.hpp.

◆ PYRO_MODE_SHIFT

#define PYRO_MODE_SHIFT   15

Definition at line 115 of file fmc.hpp.

◆ PYRO_READ_REQUEST_SHIFT

#define PYRO_READ_REQUEST_SHIFT   3

Definition at line 116 of file fmc.hpp.

◆ PYRO_SEND_REQUEST_SHIFT

#define PYRO_SEND_REQUEST_SHIFT   23

Definition at line 74 of file fmc.hpp.

◆ RANK_SHIFT

#define RANK_SHIFT   0

Definition at line 71 of file fmc.hpp.

◆ RCNT_SHIFT

#define RCNT_SHIFT   24

Definition at line 60 of file fmc.hpp.

◆ REQ_INVALID

#define REQ_INVALID   0x01

Definition at line 39 of file http.hpp.

◆ RequestType

#define RequestType   uint8_t

Definition at line 46 of file http.hpp.

◆ RFO_OFFSET

#define RFO_OFFSET   (0x118/WS)

Definition at line 99 of file fmc.hpp.

◆ RST_SHIFT

#define RST_SHIFT   1

Definition at line 107 of file fmc.hpp.

◆ RX_DATA_STATE_SHIFT

#define RX_DATA_STATE_SHIFT   4

Definition at line 78 of file fmc.hpp.

◆ RX_SESS_STATE_SHIFT

#define RX_SESS_STATE_SHIFT   0

Definition at line 77 of file fmc.hpp.

◆ SIZE_SHIFT

#define SIZE_SHIFT   8

Definition at line 72 of file fmc.hpp.

◆ SOFT_RST_SHIFT

#define SOFT_RST_SHIFT   2

Definition at line 114 of file fmc.hpp.

◆ SR_OFFSET

#define SR_OFFSET   (0x110/WS)

Definition at line 94 of file fmc.hpp.

◆ START_SHIFT

#define START_SHIFT   12

Definition at line 110 of file fmc.hpp.

◆ SWAP_N_SHIFT

#define SWAP_N_SHIFT   16

Definition at line 111 of file fmc.hpp.

◆ TCP_FSM_DONE

#define TCP_FSM_DONE   4

Definition at line 196 of file fmc.hpp.

◆ TCP_FSM_ERROR

#define TCP_FSM_ERROR   5

Definition at line 197 of file fmc.hpp.

◆ TCP_FSM_IDLE

#define TCP_FSM_IDLE   1

Definition at line 193 of file fmc.hpp.

◆ TCP_FSM_PROCESS_DATA

#define TCP_FSM_PROCESS_DATA   3

Definition at line 195 of file fmc.hpp.

◆ TCP_FSM_RESET

#define TCP_FSM_RESET   0

Definition at line 192 of file fmc.hpp.

◆ TCP_FSM_W84_START

#define TCP_FSM_W84_START   2

Definition at line 194 of file fmc.hpp.

◆ TCP_ITER_COUNT_SHIFT

#define TCP_ITER_COUNT_SHIFT   16

Definition at line 81 of file fmc.hpp.

◆ TCP_OPERATION_SHIFT

#define TCP_OPERATION_SHIFT   18

Definition at line 51 of file fmc.hpp.

◆ TCP_RX_CNT_SHIFT

#define TCP_RX_CNT_SHIFT   0

Definition at line 85 of file fmc.hpp.

◆ TcpFsmState

#define TcpFsmState   uint8_t

Definition at line 199 of file fmc.hpp.

◆ TX_DATA_STATE_SHIFT

#define TX_DATA_STATE_SHIFT   12

Definition at line 80 of file fmc.hpp.

◆ TX_SESS_STATE_SHIFT

#define TX_SESS_STATE_SHIFT   8

Definition at line 79 of file fmc.hpp.

◆ WEMPTY_SHIFT

#define WEMPTY_SHIFT   2

Definition at line 47 of file fmc.hpp.

◆ WF_OFFSET

#define WF_OFFSET   (0x100/WS)

Definition at line 100 of file fmc.hpp.

◆ WFV_OFFSET

#define WFV_OFFSET   (0x114/WS)

Definition at line 96 of file fmc.hpp.

◆ WFV_V_SHIFT

#define WFV_V_SHIFT   8

Definition at line 45 of file fmc.hpp.

◆ WRITE_ERROR_CNT_SHIFT

#define WRITE_ERROR_CNT_SHIFT   8

Definition at line 66 of file fmc.hpp.

◆ WS

#define WS   4

Definition at line 93 of file fmc.hpp.

◆ XMEM_ANSWER_START

#define XMEM_ANSWER_START   (1*LINES_PER_PAGE)

Definition at line 134 of file fmc.hpp.

◆ XMEM_SIZE

#define XMEM_SIZE   (LINES_PER_PAGE * MAX_PAGES)

Definition at line 124 of file fmc.hpp.

Function Documentation

◆ bytesToPages()

uint8_t bytesToPages ( int  len,
bool  update_global_variables 
)

Definition at line 169 of file fmc.cpp.

170 {
171  printf("bytesToPages: len %d\n",len);
172 
173  uint8_t pageCnt = len/BYTES_PER_PAGE;
174 
175  if(update_global_variables)
176  {
178  printf("lastResponsePageCnt: %d\n", (int) lastResponsePageCnt);
179  }
180 
181  //we need to ceil the page count (if lastResponsePageCnt != 0....)
182  if(len % BYTES_PER_PAGE > 0)
183  {
184  pageCnt++;
185  }
186 
187  if(update_global_variables)
188  { // for Display4
189  responePageCnt = pageCnt;
190  printf("responePageCnt: %d\n", (int) responePageCnt);
191  }
192 
193  assert(pageCnt <= MAX_PAGES);
194 
195  return pageCnt;
196 
197 }
#define BYTES_PER_PAGE
Definition: fmc.hpp:125
#define MAX_PAGES
Definition: fmc.hpp:123
ap_uint< 4 > responePageCnt
Definition: fmc.cpp:108
ap_uint< 7 > lastResponsePageCnt
Definition: fmc.cpp:107
Here is the caller graph for this function:

◆ checkResult()

bool checkResult ( ap_uint< 32 >  MMIO,
ap_uint< 32 >  expected 
)

Definition at line 144 of file tb_fmc.cpp.

145 {
146  if (MMIO == expected)
147  {
148  printf("expected result: %#010x\n", (int) MMIO);
149  return true;
150  }
151 
152  printf("[%4.4d] ERROR: Got %#010x instead of %#010x\n", simCnt, (int) MMIO, (int) expected);
153  //return false;
154  exit(-1);
155 }
ap_uint< 32 > MMIO
Definition: tb_fmc.cpp:64
int simCnt
Definition: tb_fmc.cpp:113
Here is the caller graph for this function:

◆ checkSeqHwicap()

bool checkSeqHwicap ( uint32_t *  true_buffer,
ap_uint< 32 > *  out_buffer,
uint32_t  start_address,
uint32_t  end_address,
bool  not_to_swap 
)

Definition at line 189 of file tb_fmc.cpp.

190 {
191  uint32_t max_address = end_address;
192  if(max_address > HWICAP_SEQ_SIZE)
193  {
194  max_address = HWICAP_SEQ_SIZE;
195  printf("set max verify address to %d.\n",max_address);
196  }
197  for(int i = start_address; i<max_address; i++)
198  {
199  ap_uint<32> true_buffer_BE = 0x0;
200  if(not_to_swap)
201  {
202  true_buffer_BE = true_buffer[i];
203  } else {
204  true_buffer_BE = (ap_uint<32>) ((true_buffer[i] >> 24) & 0xFF);
205  true_buffer_BE |= (ap_uint<32>) ((true_buffer[i] >> 8) & 0xFF00);
206  true_buffer_BE |= (ap_uint<32>) ((true_buffer[i] << 8) & 0xFF0000);
207  true_buffer_BE |= (ap_uint<32>) ((true_buffer[i] << 24) & 0xFF000000);
208  }
209  if(true_buffer_BE != out_buffer[i])
210  {
211  printf("HWICAP OUT is different at position %d: should be %#010x, but is %#010x\n", i, (int) true_buffer_BE, (int) out_buffer[i]);
212  printf("relative position: %d; end address: %d\n",(int) (i - start_address), max_address);
213  printf("Context:\n\tShould:\n");
214  for(int j = i-3; j<i+3; j++)
215  {
216  ap_uint<32> true_buffer_BE_2 = 0x0;
217  if(not_to_swap)
218  {
219  true_buffer_BE_2 = true_buffer[j];
220  } else {
221  true_buffer_BE_2 = (ap_uint<32>) ((true_buffer[j] >> 24) & 0xFF);
222  true_buffer_BE_2 |= (ap_uint<32>) ((true_buffer[j] >> 8) & 0xFF00);
223  true_buffer_BE_2 |= (ap_uint<32>) ((true_buffer[j] << 8) & 0xFF0000);
224  true_buffer_BE_2 |= (ap_uint<32>) ((true_buffer[j] << 24) & 0xFF000000);
225  }
226  printf("\t%4.4d: %#010x\n",j,(int) true_buffer_BE_2);
227  }
228  printf("\tIs:\n");
229  for(int j = i-3; j<i+3; j++)
230  {
231  printf("\t%4.4d: %#010x\n",j,(int) out_buffer[j]);
232  }
233  printf("\n");
234  return false;
235  }
236  }
237  printf("[HWICAP OUT is valid from address %d to %d]\n",start_address, max_address);
238  return true;
239 }
#define HWICAP_SEQ_SIZE
Definition: tb_fmc.cpp:54
Here is the caller graph for this function:

◆ copyAndCheckBurst()

ap_uint<4> copyAndCheckBurst ( ap_uint< 32 >  xmem[(32 * 16)],
ap_uint< 4 >  ExpCnt,
ap_uint< 7 >  lastPageCnt_in 
)

Definition at line 464 of file fmc.cpp.

465 {
466 
467  ap_uint<8> curHeader = 0;
468  ap_uint<8> curFooter = 0;
469 
470  ap_int<16> buff_pointer = 0-1;
471 
472 
473  for(int i = 0; i<LINES_PER_PAGE; i++)
474  {
475  ap_uint<32> tmp = 0;
476  tmp = xmem[i];
477 
478  if ( i == 0 )
479  {
480  curHeader = tmp & 0xff;
481  } else {
482  buff_pointer++;
483  bufferIn[bufferInPtrWrite + buff_pointer] = (tmp & 0xff);
484  }
485 
486  buff_pointer++;
487  bufferIn[bufferInPtrWrite + buff_pointer] = (tmp >> 8) & 0xff;
488  buff_pointer++;
489  bufferIn[bufferInPtrWrite + buff_pointer] = (tmp >> 16 ) & 0xff;
490 
491  if ( i == LINES_PER_PAGE-1)
492  {
493  curFooter = (tmp >> 24) & 0xff;
494  } else {
495  buff_pointer++;
496  bufferIn[bufferInPtrWrite + buff_pointer] = (tmp >> 24) & 0xff;
497  }
498  }
499 
500 
501  ap_uint<4> curCnt = curHeader & 0xf;
502 
503 
504  if ( curHeader != curFooter)
505  {//we are in the middle of a transfer!
506  return 1;
507  }
508 
509  if(curCnt == xmem_page_trans_cnt)
510  {//page was already transfered
511  return 0;
512  }
513 
514  if (curCnt != ExpCnt)
515  {//we must missed something
516  return 2;
517  }
518 
519  bool lastPage = (curHeader & 0xf0) == 0xf0;
520 
521  //now we have a clean transfer
522  if(lastPage && flag_check_xmem_pattern == 0)
523  { //we didn't received a full page;
524  bufferInPtrWrite += (lastPageCnt_in -1); //-1, because the address is 0 based!
525  printf("lastPageCnt_in %d\n", (int) lastPageCnt_in);
526  } else {
527  bufferInPtrWrite += buff_pointer;// +1;
528  }
531 
533  {
534  bufferInPtrWrite = 0;
535  }
536 
537  if(flag_check_xmem_pattern == 1)
538  {
539  ap_uint<8> ctrlByte = (((ap_uint<8>) ExpCnt) << 4) | ExpCnt;
540 
541  //printf("ctrlByte: %#010x\n",(int) ctrlByte);
542 
543  //for simplicity check only lines in between and skip potentiall hangover
544  for(int i = 3; i< PAYLOAD_BYTES_PER_PAGE -3; i++)
545  {
546  if(bufferIn[bufferInPtrNextRead + i] != ctrlByte)
547  {//data is corrupt
548  //printf("corrupt at %d with %#010x\n",i, (int) bufferIn[bufferInPtrWrite + i]);
549  return 3;
550  }
551  }
552  bufferInPtrNextRead = bufferInPtrWrite; //only for check pattern case
553  }
554 
555  if (lastPage)
556  {
557  return 4;
558  }
559 
560  return 5;
561 }
ap_uint< 1 > flag_check_xmem_pattern
Definition: fmc.cpp:129
#define LINES_PER_PAGE
Definition: fmc.hpp:122
uint32_t bufferInPtrWrite
Definition: fmc.cpp:53
ap_uint< 32 > xmem[(32 *16)]
Definition: tb_fmc.cpp:89
#define PAYLOAD_BYTES_PER_PAGE
Definition: fmc.hpp:126
#define IN_BUFFER_SIZE
Definition: fmc.hpp:131
ap_uint< 4 > xmem_page_trans_cnt
Definition: fmc.cpp:42
uint32_t bufferInPtrMaxWrite
Definition: fmc.cpp:54
uint32_t bufferInPtrNextRead
Definition: fmc.cpp:56
uint8_t bufferIn[4096]
Definition: fmc.cpp:52
Here is the caller graph for this function:

◆ copyBufferToStream()

void copyBufferToStream ( char *  buffer_int,
stream< NetworkWord > &  tcp_data,
int  content_len 
)

Definition at line 330 of file tb_fmc.cpp.

331 {
332  printf("Writing %d bytes to Stream: (in hex)\n", content_len);
333  for(int i = 0; i<content_len; i+=8)
334  {
335  ap_uint<64> new_word = 0;
336  ap_uint<8> tkeep = 0;
337  for(int j = 0; j<8; j++)
338  {
339  if(i+j < content_len)
340  {
341  new_word |= ((ap_uint<64>) ((uint8_t) buffer_int[i+j])) << (j*8);
342  tkeep |= ((ap_uint<8>) 1) << j;
343  } else {
344  new_word |= ((ap_uint<64>) ((uint8_t) 0 ))<< (j*8);
345  tkeep |= ((ap_uint<8>) 0) << j;
346  }
347  }
348  //printf("Writing to Stream: 0x%llx\n",(unsigned long long) new_word);
349  //printf("%016llx\n",(unsigned long long) new_word);
350 
352  tmp.tdata = new_word;
353  tmp.tkeep = tkeep;
354  if(i >= (content_len - 8))
355  {
356  tmp.tlast = 1;
357  } else {
358  tmp.tlast = 0;
359  }
360 
361  printf("%016llx | %02x | %d \n",(unsigned long long) new_word, (int) tkeep, (int) tmp.tlast);
362  tcp_data.write(tmp);
363 
364  }
365 
366 }
Here is the caller graph for this function:

◆ copyBufferToXmem()

void copyBufferToXmem ( char *  buffer_int,
ap_uint< 32 >  xmem[(32 * 16)] 
)

Definition at line 317 of file tb_fmc.cpp.

318 {
319  for(int i = 0; i<LINES_PER_PAGE; i++)
320  {
321  ap_uint<32> tmp = 0;
322  tmp = ((ap_uint<32>) (uint8_t) buffer_int[i*4 + 0]);
323  tmp |= ((ap_uint<32>)(uint8_t) buffer_int[i*4 + 1]) << 8;
324  tmp |= ((ap_uint<32>)(uint8_t) buffer_int[i*4 + 2]) << 16;
325  tmp |= ((ap_uint<32>)(uint8_t) buffer_int[i*4 + 3]) << 24;
326  xmem[i] = tmp;;
327  }
328 }
Here is the caller graph for this function:

◆ copyOutBuffer()

void copyOutBuffer ( ap_uint< 4 >  numberOfPages,
ap_uint< 32 >  xmem[(32 * 16)] 
)

Definition at line 201 of file fmc.cpp.

202 {
203  for(int i = 0; i < numberOfPages*LINES_PER_PAGE; i++)
204  {
205  ap_uint<32> tmp = 0;
206 
207  tmp = ((ap_uint<32>) bufferOut[i*4 + 0]);
208  tmp |= ((ap_uint<32>) bufferOut[i*4 + 1]) << 8;
209  tmp |= ((ap_uint<32>) bufferOut[i*4 + 2]) << 16;
210  tmp |= ((ap_uint<32>) bufferOut[i*4 + 3]) << 24;
211  xmem[XMEM_ANSWER_START + i] = tmp;
212  }
213 
214 }
uint8_t bufferOut[1024]
Definition: fmc.cpp:59
#define XMEM_ANSWER_START
Definition: fmc.hpp:134
Here is the caller graph for this function:

◆ Debug_FMC_Pyrolink()

stream<Axis<8> > Debug_FMC_Pyrolink ( "Debug_FMC_Pyrolink"  )
Here is the caller graph for this function:

◆ drainStream()

void drainStream ( stream< NetworkWord > &  tcp_data)

Definition at line 368 of file tb_fmc.cpp.

369 {
370  printf("Draining NetworkStream: (in hex)\n");
371 
372  while(!tcp_data.empty())
373  {
374  NetworkWord tmp = tcp_data.read();
375  printf("%016llx\n",(unsigned long long) tmp.tdata);
376  }
377 
378 }
Here is the caller graph for this function:

◆ emptyInBuffer()

void emptyInBuffer ( )

Definition at line 217 of file fmc.cpp.

218 {
219  for(int i = 0; i < IN_BUFFER_SIZE; i++)
220  {
221 //#pragma HLS unroll
222  bufferIn[i] = 0x0;
223  }
224  bufferInPtrWrite = 0x0;
225  bufferInPtrNextRead = 0x0;
226  bufferInPtrMaxWrite = 0x0;
228  hwicap_hangover_present = false;
230  for(int i = 0; i < 3; i++)
231  {
232 #pragma HLS unroll
233  buffer_hangover_bytes[i] = 0x0;
234  }
235  while(!internal_icap_fifo.empty())
236  {
237  internal_icap_fifo.read();
238  }
239  while(!icap_hangover_fifo.empty())
240  {
241  icap_hangover_fifo.read();
242  }
243  tcp_write_only_fifo = false;
246  for(int i = 0; i<8; i++)
247  {
248  fifo_overflow_buffer[i] = 0x0;
249  }
252  printf("\t inBuffer cleaned\n");
253 }
bool process_fifo_overflow_buffer
Definition: fmc.cpp:49
uint8_t buffer_hangover_bytes[3]
Definition: fmc.cpp:151
#define ICAP_FSM_IDLE
Definition: fmc.hpp:203
uint8_t fsmHwicap
Definition: fmc.cpp:46
stream< uint8_t > icap_hangover_fifo("sIcapHangoverFifo")
bool tcp_write_only_fifo
Definition: fmc.cpp:57
bool fifo_operation_in_progress
Definition: fmc.cpp:47
stream< uint8_t > internal_icap_fifo("sInternalIcapFifo")
uint8_t hwicap_hangover_size
Definition: fmc.cpp:153
uint8_t fifo_overflow_buffer[8]
Definition: fmc.cpp:48
uint32_t lastSeenBufferInPtrMaxWrite
Definition: fmc.cpp:55
uint8_t fifo_overflow_buffer_length
Definition: fmc.cpp:50
bool hwicap_hangover_present
Definition: fmc.cpp:152
Here is the call graph for this function:
Here is the caller graph for this function:

◆ emptyOutBuffer()

void emptyOutBuffer ( )

Definition at line 255 of file fmc.cpp.

256 {
257  for(int i = 0; i < OUT_BUFFER_SIZE; i++)
258  {
259 //#pragma HLS unroll
260  bufferOut[i] = 0x0;
261  }
262  bufferOutPtrWrite = 0x0;
264  bufferOutPtrNextRead = 0x0;
266  printf("\t outBuffer cleaned\n");
267 }
#define OUT_BUFFER_SIZE
Definition: fmc.hpp:133
uint16_t bufferOutContentLength
Definition: fmc.cpp:61
uint16_t lastSeenBufferOutPtrNextRead
Definition: fmc.cpp:63
uint16_t bufferOutPtrWrite
Definition: fmc.cpp:60
uint16_t bufferOutPtrNextRead
Definition: fmc.cpp:62
Here is the caller graph for this function:

◆ extract_path()

int8_t extract_path ( bool  rx_done)

Definition at line 321 of file http.cpp.

322 {
323  int stringlen = my_strlen((char*) (uint8_t*) bufferIn);
324  // strlen works, because after the request is the buffer 00ed
325  // and we see single pages --> not the complete transfer at once
326 
327  printf("stringlen: %d\n",(int) stringlen);
328 
329  if (stringlen == 0)
330  {
331  return 0;
332  }
333 
334 
335  int requestLen = request_len(0, stringlen);
336  printf("requestLen: %d\n",(int) requestLen);
337 
338 
339  //from here it looks like a valid header
340 
341  reqType = REQ_INVALID; //reset
342 
343  if(requestLen <= 0)
344  {//not a valid header
345  if (stringlen == PAYLOAD_BYTES_PER_PAGE || !rx_done)
346  {//not yet complete
347  return -1;
348  }
349  return -2;
350  }
351 
352  if (my_strcmp(statusPath, bufferIn, my_strlen(statusPath)) == 0 )
353  {
354  //printf("strlen status: %d\n", my_strlen(statusPath));
356  return 1;
357  } else if (my_strcmp(configurePath, bufferIn, my_strlen(configurePath)) == 0 )
358  {
359  bufferInPtrNextRead = requestLen + 4;
361  return 2;
362  } else if(my_strcmp(putRank, bufferIn, my_strlen(putRank)) == 0 )
363  {
364  reqType = PUT_RANK;
365  char* intStart = (char*) &bufferIn[my_strlen(putRank)];
366  int intLen = my_wordlen(intStart);
367 
368  ap_uint<32> newRank = (unsigned int) my_atoi(intStart, intLen);
369  if(newRank >= MAX_CLUSTER_SIZE)
370  {//invalid
371  return -2;
372  }
373  setRank(newRank);
374  return 3;
375  } else if(my_strcmp(putSize, bufferIn, my_strlen(putSize)) == 0 )
376  {
377  reqType = PUT_SIZE;
378  char* intStart = (char*) &bufferIn[my_strlen(putSize)];
379  int intLen = my_wordlen(intStart);
380 
381  ap_uint<32> newSize = (unsigned int) my_atoi(intStart, intLen);
382  if(newSize >= MAX_CLUSTER_SIZE)
383  {//invalid
384  return -2;
385  }
386  setSize(newSize);
387  return 4;
388  } else if(my_strcmp(postRouting, bufferIn, my_strlen(postRouting)) == 0 )
389  {
391  bufferInPtrNextRead = requestLen + 4;
392 
393  return 5;
394  } else {
395  //Invalid / Not Found
396  return -3;
397  }
398 }
int my_wordlen(char *s)
Definition: http.cpp:63
uint8_t reqType
Definition: http.cpp:284
#define POST_ROUTING
Definition: http.hpp:44
#define REQ_INVALID
Definition: http.hpp:39
int my_atoi(char *str, int strlen)
Definition: http.cpp:177
void setRank(ap_uint< 32 > newRank)
Definition: fmc.cpp:451
int my_strlen(char *s)
Definition: http.cpp:52
#define POST_CONFIG
Definition: http.hpp:40
int my_strcmp(char *tmp1, volatile uint8_t tmp2[4096], int max_length)
Definition: http.cpp:246
#define PUT_SIZE
Definition: http.hpp:43
int request_len(ap_uint< 16 > offset, int maxLength)
Definition: http.cpp:286
#define MAX_CLUSTER_SIZE
Definition: fmc.hpp:151
void setSize(ap_uint< 32 > newSize)
Definition: fmc.cpp:458
#define GET_STATUS
Definition: http.hpp:41
#define PUT_RANK
Definition: http.hpp:42
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fmc()

void fmc ( ap_uint< 32 > *  MMIO_in,
ap_uint< 32 > *  MMIO_out,
ap_uint< 1 > *  layer_4_enabled,
ap_uint< 1 > *  layer_6_enabled,
ap_uint< 1 > *  layer_7_enabled,
ap_uint< 1 > *  nts_ready,
ap_uint< 32 > *  in_time_seconds,
ap_uint< 32 > *  in_time_minutes,
ap_uint< 32 > *  in_time_hours,
ap_uint< 16 > *  role_mmio_in,
ap_uint< 16 > *  uoe_drop_cnt_in,
ap_uint< 8 > *  toe_notif_drop_cnt_in,
ap_uint< 8 > *  toe_meta_drop_cnt_in,
ap_uint< 8 > *  toe_data_drop_cnt_in,
ap_uint< 8 > *  toe_crc_drop_cnt_in,
ap_uint< 8 > *  toe_sess_drop_cnt_in,
ap_uint< 8 > *  toe_ooo_drop_cnt_in,
ap_uint< 32 > *  HWICAP,
ap_uint< 1 >  decoupStatus,
ap_uint< 1 > *  setDecoup,
ap_uint< 1 > *  setSoftReset,
ap_uint< 32 >  xmem[(32 *16)],
ap_uint< 32 >  nalCtrl[(0x3ff/4)],
ap_uint< 1 > *  disable_ctrl_link,
stream< TcpWord > &  siNAL_Tcp_data,
stream< AppMeta > &  siNAL_Tcp_SessId,
stream< TcpWord > &  soNAL_Tcp_data,
stream< AppMeta > &  soNAL_Tcp_SessId,
ap_uint< 32 > *  role_rank,
ap_uint< 32 > *  cluster_size 
)

Definition at line 564 of file fmc.cpp.

608 {
609 //#pragma HLS RESOURCE variable=bufferIn core=RAM_2P_BRAM
610 //#pragma HLS RESOURCE variable=bufferIn core=RAM_S2P_LUTRAM
611 //#pragma HLS RESOURCE variable=bufferOut core=RAM_2P_BRAM
612 #pragma HLS RESOURCE variable=xmem core=RAM_1P_BRAM
613 #pragma HLS INTERFACE m_axi depth=512 port=HWICAP bundle=boHWICAP
614 #pragma HLS INTERFACE ap_ovld register port=MMIO_out name=poMMIO
615 #pragma HLS INTERFACE ap_vld register port=MMIO_in name=piMMIO
616 #pragma HLS INTERFACE ap_vld register port=layer_4_enabled name=piLayer4enabled
617 #pragma HLS INTERFACE ap_vld register port=layer_6_enabled name=piLayer6enabled
618 #pragma HLS INTERFACE ap_vld register port=layer_7_enabled name=piLayer7enabled
619 #pragma HLS INTERFACE ap_vld register port=nts_ready name=piNTS_ready
620 #pragma HLS INTERFACE ap_vld register port=in_time_seconds name=piTime_seconds
621 #pragma HLS INTERFACE ap_vld register port=in_time_minutes name=piTime_minutes
622 #pragma HLS INTERFACE ap_vld register port=in_time_hours name=piTime_hours
623 #pragma HLS INTERFACE ap_vld register port=role_mmio_in name=piRole_mmio
624 #pragma HLS INTERFACE ap_vld register port=uoe_drop_cnt_in name=piUOE_drop_cnt
625 #pragma HLS INTERFACE ap_vld register port=toe_notif_drop_cnt_in name=piTOE_notif_drop_cnt
626 #pragma HLS INTERFACE ap_vld register port=toe_meta_drop_cnt_in name=piTOE_meta_drop_cnt
627 #pragma HLS INTERFACE ap_vld register port=toe_data_drop_cnt_in name=piTOE_data_drop_cnt
628 #pragma HLS INTERFACE ap_vld register port=toe_crc_drop_cnt_in name=piTOE_crc_drop_cnt
629 #pragma HLS INTERFACE ap_vld register port=toe_sess_drop_cnt_in name=piTOE_sess_drop_cnt
630 #pragma HLS INTERFACE ap_vld register port=toe_ooo_drop_cnt_in name=piTOE_ooo_drop_cnt
631 #pragma HLS INTERFACE ap_stable register port=decoupStatus name=piDECOUP_status
632 #pragma HLS INTERFACE ap_ovld register port=setDecoup name=poDECOUP_activate
633 #pragma HLS INTERFACE ap_ovld register port=role_rank name=poROLE_rank
634 #pragma HLS INTERFACE ap_ovld register port=cluster_size name=poROLE_size
635 #pragma HLS INTERFACE m_axi depth=16383 port=nalCtrl bundle=boNAL_ctrlLink
636  //max_read_burst_length=1 max_write_burst_length=1 //0x3fff - 0x2000
637 #pragma HLS INTERFACE ap_stable register port=disable_ctrl_link name=piDisableCtrlLink
638 #pragma HLS INTERFACE ap_ovld register port=setSoftReset name=poSoftReset
639 
640 #ifdef INCLUDE_PYROLINK
641 #pragma HLS INTERFACE ap_fifo register both port=soPYROLINK
642 #pragma HLS INTERFACE ap_fifo register both port=siPYROLINK
643 #pragma HLS INTERFACE ap_stable register port=disable_pyro_link name=piDisablePyroLink
644 #endif
645 
646 #pragma HLS INTERFACE ap_fifo port=siNAL_Tcp_data
647 #pragma HLS INTERFACE ap_fifo port=soNAL_Tcp_data
648 #pragma HLS INTERFACE ap_fifo port=siNAL_Tcp_SessId
649 #pragma HLS INTERFACE ap_fifo port=soNAL_Tcp_SessId
650 //ap_ctrl is default (i.e. ap_hs)
651 //#pragma HLS DATAFLOW TODO: crashes Vivado..
652 
653 #pragma HLS STREAM variable=internal_icap_fifo depth=4096
654 #pragma HLS STREAM variable=icap_hangover_fifo depth=3
655 
656 #pragma HLS reset variable=nal_status_request_cnt
657 #pragma HLS reset variable=httpState
658 #pragma HLS reset variable=bufferInPtrWrite
659 #pragma HLS reset variable=bufferInPtrMaxWrite
660 #pragma HLS reset variable=lastSeenBufferInPtrMaxWrite
661 #pragma HLS reset variable=bufferInPtrNextRead
662 #pragma HLS reset variable=tcp_write_only_fifo
663 #pragma HLS reset variable=bufferOutPtrWrite
664 #pragma HLS reset variable=bufferOutContentLength
665 #pragma HLS reset variable=bufferOutPtrNextRead
666 #pragma HLS reset variable=lastSeenBufferOutPtrNextRead
667 #pragma HLS reset variable=writeErrCnt
668 #pragma HLS reset variable=fifoEmptyCnt
669 #pragma HLS reset variable=fifoFullCnt
670 #pragma HLS reset variable=wordsWrittenToIcapCnt
671 #pragma HLS reset variable=fsmHwicap
672 #pragma HLS reset variable=fifo_operation_in_progress
673 #pragma HLS reset variable=tcp_words_received
674 #pragma HLS reset variable=fifo_overflow_buffer_length
675 #pragma HLS reset variable=process_fifo_overflow_buffer
676 #pragma HLS reset variable=globalOperationDone_persistent
677 #pragma HLS reset variable=transferError_persistent
678 #pragma HLS reset variable=invalidPayload_persistent
679 #pragma HLS reset variable=flag_check_xmem_pattern
680 #pragma HLS reset variable=flag_silent_skip
681 #pragma HLS reset variable=toDecoup_persistent
682 #pragma HLS reset variable=lastResponsePageCnt
683 #pragma HLS reset variable=responePageCnt
684 #pragma HLS reset variable=xmem_page_trans_cnt
685 #pragma HLS reset variable=last_xmem_page_received_persistent
686 #pragma HLS reset variable=flag_continuous_tcp_rx
687 #pragma HLS reset variable=axi_wasnot_ready_persistent
688 #pragma HLS reset variable=global_state_wait_counter_persistent
689 #pragma HLS reset variable=currentTcpSessId
690 #pragma HLS reset variable=TcpSessId_updated_persistent
691 #pragma HLS reset variable=tcpModeEnabled
692 #pragma HLS reset variable=tcp_iteration_count
693 #pragma HLS reset variable=fsmTcpSessId_TX
694 #pragma HLS reset variable=fsmTcpSessId_RX
695 #pragma HLS reset variable=fsmTcpData_TX
696 #pragma HLS reset variable=fsmTcpData_RX
697 #pragma HLS reset variable=run_nested_loop_helper
698 #pragma HLS reset variable=goto_done_if_idle_tcp_rx
699 #pragma HLS reset variable=received_TCP_SessIds_cnt
700 
701 #pragma HLS reset variable=current_nrc_mrt_version
702 #pragma HLS reset variable=current_MRT
703 #pragma HLS reset variable=current_nrc_config
704 #pragma HLS reset variable=nodeRank
705 #pragma HLS reset variable=clusterSize
706 #pragma HLS reset variable=tables_initialized
707 #pragma HLS reset variable=nal_status_disabled
708 #pragma HLS reset variable=need_to_update_nrc_mrt
709 #pragma HLS reset variable=need_to_update_nrc_config
710 #pragma HLS reset variable=ctrl_link_next_check_seconds
711 #pragma HLS reset variable=mrt_copy_index
712 //#pragma HLS reset variable=ctrl_link_transfer_ongoing
713 #pragma HLS reset variable=linkCtrlFSM
714 #pragma HLS reset variable=max_discovered_node_id
715 #pragma HLS reset variable=detected_http_nl_cnt
716 #pragma HLS reset variable=target_http_nl_cnt
717 #pragma HLS reset variable=hwicap_hangover_present
718 #pragma HLS reset variable=hwicap_hangover_size
719 #pragma HLS reset variable=flag_enable_fake_hwicap
720 
721 
722 
723 
724  //===========================================================
725  // Core-wide variables
726  ap_uint<32> SR = 0, HWICAP_Done = 0, EOS = 0, CR = 0, CR_value = 0, ASR = 0;
727  ap_uint<8> ASW1 = 0, ASW2 = 0, ASW3 = 0, ASW4= 0;
728 
729  ap_uint<32> ISR = 0, WFV = 0; // RFO = 0;
730  ap_uint<32> WFV_value = 0, WEMPTY = 0;
731 
732  ap_uint<4> expCnt = 0;
733  ap_uint<4> copyRet = 0;
734 
735 
736  ap_uint<1> pyroSendRequestBit = 0;
737  char msg_buf[4] = {0x49,0x44,0x4C,'\n'}; //IDL
738  char *msg = &msg_buf[0];
739 
740  OprvType lastReturnValue = 0x0;
741  uint8_t currentProgramLength = 0;
742  OpcodeType opcodeProgram[MAX_PROGRAM_LENGTH];
743  OprvType programMask[MAX_PROGRAM_LENGTH];
744 
745  if(!tables_initialized)
746  {
747  for(int i = 0; i < MAX_MRT_SIZE; i++)
748  {
749 //#pragma HLS unroll
750  current_MRT[i] = 0x0;
751  }
752  for(int i = 0; i < NUMBER_CONFIG_WORDS; i++)
753  {
754 //#pragma HLS unroll
755  current_nrc_config[i] = 0x0;
756  }
757  for(int i = 0; i < NUMBER_FPGA_STATE_REGISTERS; i++)
758  {
759 //#pragma HLS unroll
760  fpga_status[i] = 0x0;
761  }
762  for(int i = 0; i < 2; i++)
763  {
764 //#pragma HLS unroll
765  last_3_chars[i] = 0x0;
766  }
767  for(int i = 0; i < 3; i++)
768  {
769 //#pragma HLS unroll
770  buffer_hangover_bytes[i] = 0x0;
772  }
773  tables_initialized = true;
774  }
775 
776  // ++++++++++++++++++ evaluate outside world ++++++++++++++++
777  //===========================================================
778  // Connection to HWICAP
779  // essential data (ask every time)
780  SR = HWICAP[SR_OFFSET];
781  CR = HWICAP[CR_OFFSET];
782  ASR = HWICAP[ASR_OFFSET];
783  ASW1 = ASR & 0xFF;
784  ASW2 = (ASR & 0xFF00) >> 8;
785  ASW3 = (ASR & 0xFF0000) >> 16;
786  ASW4 = (ASR & 0xFF000000) >> 24;
787 
788  HWICAP_Done = SR & 0x1;
789  EOS = (SR & 0x4) >> 2;
790  CR_value = CR & 0x1F;
791 
792  ISR = HWICAP[ISR_OFFSET];
793  WFV = HWICAP[WFV_OFFSET];
794 
795  //RFO = HWICAP[RFO_OFFSET];
796  WEMPTY = (ISR & 0x4) >> 2;
797  WFV_value = WFV & 0x7FF;
798 
799 
800  ap_uint<1> wasAbort = (CR_value & CR_ABORT) >> 4;
801  //Maybe CR_ABORT is not set
802  if( ASW1 != 0x00)
803  {
804  wasAbort = 1;
805  }
806 
807 
808  //MMIO commands
809  ap_uint<32> MMIO_in_LE = 0x0;
810  MMIO_in_LE = (ap_uint<32>) ((*MMIO_in >> 24) & 0xFF);
811  MMIO_in_LE |= (ap_uint<32>) ((*MMIO_in >> 8) & 0xFF00);
812  MMIO_in_LE |= (ap_uint<32>) ((*MMIO_in << 8) & 0xFF0000);
813  MMIO_in_LE |= (ap_uint<32>) ((*MMIO_in << 24) & 0xFF000000);
814 
815  ap_uint<1> checkPattern = (MMIO_in_LE >> CHECK_PATTERN_SHIFT ) & 0b1;
816 
817  ap_uint<1> parseHTTP = (MMIO_in_LE >> PARSE_HTTP_SHIFT) & 0b1;
818 
819  ap_uint<1> notToSwap = (MMIO_in_LE >> SWAP_N_SHIFT) & 0b1;
820  //Turns out: we need to swap => active low
821 
822  ap_uint<1> startXmemTrans = (MMIO_in_LE >> START_SHIFT) & 0b1;
823 
824 
825  ap_uint<1> pyroReadReq = (MMIO_in_LE >> PYRO_READ_REQUEST_SHIFT) & 0b1;
826 
827  ap_uint<1> tcpModeStart = (MMIO_in_LE >> ENABLE_TCP_MODE_SHIFT) & 0b1;
828 
829  ap_uint<1> pyroRecvMode = (MMIO_in_LE >> PYRO_MODE_SHIFT) & 0b1;
830 
831  ap_uint<7> lastPageCnt_in = (MMIO_in_LE >> LAST_PAGE_CNT_SHIFT) & 0x7F;
832 
833  ap_uint<1> manuallyToDecoup = (MMIO_in_LE >> DECOUP_CMD_SHIFT) & 0b1;
834 
835  ap_uint<1> CR_isWriting = CR_value & CR_WRITE;
836 
837  ap_uint<1> reset_from_psoc = (MMIO_in_LE >> RST_SHIFT) & 0b1;
838 
839  ap_uint<1> flag_enable_fake_hwicap = (MMIO_in_LE >> ENABLE_FAKE_HWICAP_SHIFT) & 0b1;
840 
841 #ifdef INCLUDE_PYROLINK
842  if(*disable_pyro_link == 0)
843  {
844  pyroSendRequestBit = siPYROLINK.empty()? 0 : 1;
845  }
846 #else
847  pyroSendRequestBit = 0;
848 #endif
849 
856 
857  fpga_time_seconds = *in_time_seconds;
858  fpga_time_minutes = *in_time_minutes;
859  fpga_time_hours = *in_time_hours;
860 
861  current_role_mmio = *role_mmio_in;
862 
863  nts_udp_drop_cnt = *uoe_drop_cnt_in;
864  nts_tcp_notif_drop_cnt = *toe_notif_drop_cnt_in;
865  nts_tcp_meta_drop_cnt = *toe_meta_drop_cnt_in;
866  nts_tcp_data_drop_cnt = *toe_data_drop_cnt_in;
867  nts_tcp_crc_drop_cnt = *toe_crc_drop_cnt_in;
868  nts_tcp_sess_drop_cnt = *toe_sess_drop_cnt_in;
869  nts_tcp_ooo_drop_cnt = *toe_ooo_drop_cnt_in;
870 
871 
872  // ++++++++++++++++++ IMMEDIATE ACTIONS +++++++++++++++++++
873  //===========================================================
874 
875  // ++++++++++++++++++ MAKE THE PLAN +++++++++++++++++++
876  //===========================================================
877 
878 
879  bool iterate_again = true;
880  while(iterate_again)
881  {
882  iterate_again = false;
883  switch(currentGlobalOperation)
884  {
885  default: //no break, just for default
886  case GLOBAL_IDLE:
887  //general stuff before a new global operation
889  transferError_persistent = false;
894  tcpModeEnabled = 0;
896  if(reset_from_psoc == 1)
897  {
898  printf("[FMC] reset from PSOC!\n");
900  //tcp_rx_blocked_by_processing = false;
901  writeErrCnt = 0;
902  fifoEmptyCnt = 0;
903  fifoFullCnt = 0;
904  //wordsWrittenToIcapCnt = 0;
905  iterate_again = false;
906  //hwicap_waiting_for_tcp = false;
907  break;
908  }
909  //ongoingTransfer_persistent = false;
910  currentProgramLength = 0;
911  //looking for a new job...but with priorities
912  if(tcpModeStart == 1 && parseHTTP == 1)
913  {
916 
918  //reset TX TCP FSMs
921 
922  currentTcpSessId = 0;
924  iterate_again = true;
928 
929  opcodeProgram[0] = OP_CLEAR_IN_BUFFER;
930  programMask[0] = MASK_ALWAYS;
931  opcodeProgram[1] = OP_CLEAR_OUT_BUFFER;
932  programMask[1] = MASK_ALWAYS;
933  opcodeProgram[2] = OP_TCP_CNT_RESET;
934  programMask[2] = MASK_ALWAYS;
935  currentProgramLength = 3;
936  }
937  else if(tcpModeStart == 1)
938  {
939  //This was GLOBAL_TCP_TO_HWICAP, but is now NOP
941  } else if(parseHTTP == 1 && startXmemTrans == 1)
942  {
945  xmem_page_trans_cnt = 0xf;
947 
949  opcodeProgram[0] = OP_CLEAR_IN_BUFFER;
950  programMask[0] = MASK_ALWAYS;
951  opcodeProgram[1] = OP_CLEAR_OUT_BUFFER;
952  programMask[1] = MASK_ALWAYS;
953  currentProgramLength = 2;
954  iterate_again = true;
955  } else if(checkPattern == 1 && startXmemTrans == 1)
956  {
957  xmem_page_trans_cnt = 0xf;
958 
960  //only in the beginning!
961  opcodeProgram[0] = OP_CLEAR_IN_BUFFER;
962  programMask[0] = MASK_ALWAYS;
963  currentProgramLength = 1;
964  iterate_again = true;
965  } else if(startXmemTrans == 1)
966  {
967  xmem_page_trans_cnt = 0xf;
969 
971  opcodeProgram[0] = OP_CLEAR_IN_BUFFER;
972  programMask[0] = MASK_ALWAYS;
973  currentProgramLength = 1;
974  iterate_again = true;
975 #ifdef INCLUDE_PYROLINK
976  } else if(pyroRecvMode == 1 && *disable_pyro_link == 0)
977  {
978  currentGlobalOperation = GLOBAL_PYROLINK_RECV; //i.e. Coaxium to FPGA
979  xmem_page_trans_cnt = 0xf;
980 
981  opcodeProgram[0] = OP_CLEAR_IN_BUFFER;
982  programMask[0] = MASK_ALWAYS;
983  currentProgramLength = 1;
984  iterate_again = true;
985 
986  } else if(pyroReadReq == 1 && *disable_pyro_link == 0)
987  {
988  currentGlobalOperation = GLOBAL_PYROLINK_TRANS; //i.e. FPGA to Coaxium
989 
990  opcodeProgram[0] = OP_CLEAR_OUT_BUFFER;
991  programMask[0] = MASK_ALWAYS;
992  currentProgramLength = 1;
993  iterate_again = true;
994 #endif
995  } else if(manuallyToDecoup == 1)
996  {
998  iterate_again = true;
999  } else {
1000  //else...we just do the daily jobs...
1001  //currentProgramLength = 0;
1002  msg = "BOR"; //BOR..ING
1003  }
1004  //need to break to reevaluate switch-case
1005  break;
1006 
1008  if(reset_from_psoc == 1)
1009  { //reset form counter etc. are done in GLOBAL_IDLE;
1011  //do nothing
1012  currentProgramLength = 0;
1013  //to trigger all resets
1014  iterate_again = true;
1015  break;
1016  }
1018  { // means, we have this operation done and wait for status change
1019  if(startXmemTrans == 0)
1020  {
1022  }
1023  //do nothing
1024  msg="SUC"; //maintain SUC message (for XMEM transfer)
1025  currentProgramLength = 0;
1026  break;
1027  }
1029  {
1030  //do not change state?
1031  msg="ERR";
1032  currentProgramLength=0;
1033  break;
1034  }
1035 
1036  opcodeProgram[currentProgramLength] = OP_ENABLE_XMEM_CHECK_PATTERN;
1037  programMask[currentProgramLength] = MASK_ALWAYS;
1038  currentProgramLength++;
1039  opcodeProgram[currentProgramLength] = OP_XMEM_COPY_DATA;
1040  programMask[currentProgramLength] = MASK_ALWAYS;
1041  currentProgramLength++;
1042 
1043  //execute multiple times if not OPRV_DONE
1044  for(uint8_t i = 0; i<15; i++)
1045  {
1046  opcodeProgram[currentProgramLength] = OP_XMEM_COPY_DATA;
1047  programMask[currentProgramLength] = OPRV_OK | OPRV_PARTIAL_COMPLETE | OPRV_NOT_COMPLETE;
1048  currentProgramLength++;
1049  }
1050 
1051  //to switch from skipped to done
1052  //we skip for FAIL or DONE --> in both cases we won't continue and msg is set accordingly
1053  opcodeProgram[currentProgramLength] = OP_DONE;
1054  programMask[currentProgramLength] = OPRV_SKIPPED;
1055  currentProgramLength++;
1056 
1057  break;
1058 
1059  case GLOBAL_XMEM_TO_HWICAP:
1060  if(reset_from_psoc == 1)
1061  { //reset form counter etc. are done in GLOBAL_IDLE;
1063  //do nothing
1064  currentProgramLength = 0;
1065  //to trigger all resets
1066  iterate_again = true;
1067  break;
1068  }
1070  { // means, we have this operation done and wait for status change
1071  if(startXmemTrans == 0)
1072  {
1074  }
1075  //do nothing else
1076  currentProgramLength=0;
1077  msg="SUC"; //maintain SUC message (for XMEM transfer)
1078  break;
1079  }
1080  if(wasAbort == 1)
1081  {
1082  //do not change state?
1083  msg="ABR";
1084  currentProgramLength=0;
1085  break;
1086  }
1088  {
1089  //do not change state?
1090  msg="ERR";
1091  currentProgramLength=0;
1092  break;
1093  }
1094 
1095  opcodeProgram[currentProgramLength] = OP_ACTIVATE_DECOUP;
1096  programMask[currentProgramLength] = MASK_ALWAYS;
1097  currentProgramLength++;
1098  opcodeProgram[currentProgramLength] = OP_XMEM_COPY_DATA;
1099  programMask[currentProgramLength] = MASK_ALWAYS;
1100  currentProgramLength++;
1101  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1102  programMask[currentProgramLength] = MASK_ALWAYS;
1103  currentProgramLength++;
1104  opcodeProgram[currentProgramLength] = OP_BUFFER_TO_HWICAP;
1105  programMask[currentProgramLength] = OPRV_DONE | OPRV_OK;
1106  currentProgramLength++;
1107  //done for now
1108  opcodeProgram[currentProgramLength] = OP_EXIT;
1109  programMask[currentProgramLength] = OPRV_OK | OPRV_NOT_COMPLETE;
1110  currentProgramLength++;
1111  //done at all or fail (?)
1112  opcodeProgram[currentProgramLength] = OP_DEACTIVATE_DECOUP;
1113  programMask[currentProgramLength] = OPRV_DONE;
1114  currentProgramLength++;
1115  opcodeProgram[currentProgramLength] = OP_CLEAR_ROUTING_TABLE;
1116  programMask[currentProgramLength] = OPRV_DONE;
1117  currentProgramLength++;
1118  opcodeProgram[currentProgramLength] = OP_EXIT;
1119  programMask[currentProgramLength] = OPRV_DONE;
1120  currentProgramLength++;
1121  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1122  programMask[currentProgramLength] = MASK_ALWAYS;
1123  currentProgramLength++;
1124  opcodeProgram[currentProgramLength] = OP_ABORT_HWICAP;
1125  programMask[currentProgramLength] = OPRV_FAIL;
1126  currentProgramLength++;
1127  opcodeProgram[currentProgramLength] = OP_FAIL;
1128  programMask[currentProgramLength] = OPRV_OK;
1129  currentProgramLength++;
1130  opcodeProgram[currentProgramLength] = OP_EXIT;
1131  programMask[currentProgramLength] = OPRV_FAIL;
1132  currentProgramLength++;
1133 
1134  break;
1135 
1136  case GLOBAL_XMEM_HTTP:
1137  if(reset_from_psoc == 1)
1138  { //reset form counter etc. are done in GLOBAL_IDLE;
1140  //do nothing
1141  currentProgramLength = 0;
1142  //to trigger all resets
1143  iterate_again = true;
1144  break;
1145  }
1147  { // means, we have this operation done and wait for status change
1148  if(startXmemTrans == 0)
1149  {
1151  }
1152  //do nothing
1153  currentProgramLength = 0;
1154  msg="SUC"; //maintain SUC message (for XMEM transfer)
1155  break;
1156  }
1157  if(wasAbort == 1)
1158  {
1159  //do not change state?
1160  msg="ABR";
1161  currentProgramLength=0;
1162  break;
1163  }
1165  {
1166  //do not change state?
1167  msg="ERR";
1168  currentProgramLength=0;
1169  break;
1170  }
1171 
1172  if(reqType == POST_ROUTING)
1173  {
1174  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1175  programMask[currentProgramLength] = MASK_ALWAYS;
1176  currentProgramLength++;
1177  opcodeProgram[currentProgramLength] = OP_XMEM_COPY_DATA;
1178  programMask[currentProgramLength] = MASK_ALWAYS;
1179  currentProgramLength++;
1180  opcodeProgram[currentProgramLength] = OP_EXIT; //wait for data or fatal failure
1181  programMask[currentProgramLength] = OPRV_NOT_COMPLETE | OPRV_PARTIAL_COMPLETE | OPRV_FAIL;
1182  currentProgramLength++;
1183  opcodeProgram[currentProgramLength] = OP_BUFFER_TO_ROUTING;
1184  programMask[currentProgramLength] = OPRV_DONE | OPRV_OK;
1185  currentProgramLength++;
1186  opcodeProgram[currentProgramLength] = OP_EXIT;
1187  programMask[currentProgramLength] = OPRV_NOT_COMPLETE;
1188  currentProgramLength++;
1189  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1190  programMask[currentProgramLength] = OPRV_DONE | OPRV_FAIL;
1191  currentProgramLength++;
1192  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1193  programMask[currentProgramLength] = MASK_ALWAYS;
1194  currentProgramLength++;
1195  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1196  programMask[currentProgramLength] = OPRV_OK;
1197  currentProgramLength++;
1198  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_XMEM;
1199  programMask[currentProgramLength] = OPRV_DONE;
1200  currentProgramLength++;
1201  break;
1202  }
1203  if(reqType == POST_CONFIG)
1204  {//decoup already activated
1205  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1206  programMask[currentProgramLength] = MASK_ALWAYS;
1207  currentProgramLength++;
1208  opcodeProgram[currentProgramLength] = OP_XMEM_COPY_DATA;
1209  programMask[currentProgramLength] = MASK_ALWAYS;
1210  currentProgramLength++;
1211  opcodeProgram[currentProgramLength] = OP_EXIT; //wait for data of fatal failure
1212  programMask[currentProgramLength] = OPRV_NOT_COMPLETE | OPRV_PARTIAL_COMPLETE | OPRV_FAIL;
1213  currentProgramLength++;
1214  opcodeProgram[currentProgramLength] = OP_BUFFER_TO_HWICAP;
1215  programMask[currentProgramLength] = OPRV_DONE | OPRV_OK;
1216  currentProgramLength++;
1217  //wait for next junk
1218  opcodeProgram[currentProgramLength] = OP_EXIT;
1219  programMask[currentProgramLength] = OPRV_OK | OPRV_NOT_COMPLETE;
1220  currentProgramLength++;
1221  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1222  programMask[currentProgramLength] = MASK_ALWAYS;
1223  currentProgramLength++;
1224  //failed?
1225  opcodeProgram[currentProgramLength] = OP_ABORT_HWICAP;
1226  programMask[currentProgramLength] = OPRV_FAIL;
1227  currentProgramLength++;
1228  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1229  programMask[currentProgramLength] = OPRV_OK;
1230  currentProgramLength++;
1231  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1232  programMask[currentProgramLength] = OPRV_OK;
1233  currentProgramLength++;
1234  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_XMEM;
1235  programMask[currentProgramLength] = OPRV_DONE;
1236  currentProgramLength++;
1237  //restore RV
1238  opcodeProgram[currentProgramLength] = OP_FAIL;
1239  programMask[currentProgramLength] = OPRV_OK;
1240  currentProgramLength++;
1241  opcodeProgram[currentProgramLength] = OP_EXIT;
1242  programMask[currentProgramLength] = OPRV_FAIL;
1243  currentProgramLength++;
1244  //Reconfiguration done
1245  opcodeProgram[currentProgramLength] = OP_DEACTIVATE_DECOUP;
1246  programMask[currentProgramLength] = OPRV_SKIPPED;
1247  currentProgramLength++;
1248  opcodeProgram[currentProgramLength] = OP_CLEAR_ROUTING_TABLE;
1249  programMask[currentProgramLength] = OPRV_OK;
1250  currentProgramLength++;
1251  opcodeProgram[currentProgramLength] = OP_DONE;
1252  programMask[currentProgramLength] = OPRV_OK;
1253  currentProgramLength++;
1254  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1255  programMask[currentProgramLength] = OPRV_DONE;
1256  currentProgramLength++;
1257  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1258  programMask[currentProgramLength] = OPRV_OK;
1259  currentProgramLength++;
1260  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_XMEM;
1261  programMask[currentProgramLength] = OPRV_DONE;
1262  currentProgramLength++;
1263  break;
1264  }
1265 
1266  //else...first run?
1267  opcodeProgram[currentProgramLength] = OP_XMEM_COPY_DATA;
1268  programMask[currentProgramLength] = MASK_ALWAYS;
1269  currentProgramLength++;
1270  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1271  programMask[currentProgramLength] = MASK_ALWAYS;
1272  currentProgramLength++;
1273  opcodeProgram[currentProgramLength] = OP_EXIT; //wait for data or fatal failure
1274  programMask[currentProgramLength] = OPRV_NOT_COMPLETE | OPRV_PARTIAL_COMPLETE | OPRV_FAIL;
1275  currentProgramLength++;
1276  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1277  programMask[currentProgramLength] = OPRV_DONE | OPRV_OK;
1278  currentProgramLength++;
1279  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP; //If we just need to create a response
1280  programMask[currentProgramLength] = OPRV_USER;
1281  currentProgramLength++;
1282  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_XMEM; //send if necessary
1283  programMask[currentProgramLength] = OPRV_DONE;
1284  currentProgramLength++;
1285  opcodeProgram[currentProgramLength] = OP_EXIT; //exit after send
1286  programMask[currentProgramLength] = OPRV_DONE;
1287  currentProgramLength++;
1288  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1289  programMask[currentProgramLength] = MASK_ALWAYS;
1290  currentProgramLength++;
1291  opcodeProgram[currentProgramLength] = OP_COPY_REQTYPE_TO_RETURN;
1292  programMask[currentProgramLength] = OPRV_PARTIAL_COMPLETE;
1293  currentProgramLength++;
1294  //if skipped --> OK or not complete --> more data, also exit
1295  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1296  programMask[currentProgramLength] = MASK_ALWAYS;
1297  currentProgramLength++;
1298  opcodeProgram[currentProgramLength] = OP_EXIT;
1299  programMask[currentProgramLength] = OPRV_SKIPPED;
1300  currentProgramLength++;
1301  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1302  programMask[currentProgramLength] = MASK_ALWAYS;
1303  currentProgramLength++;
1304  //not exit --> RV is request type, only POST_CONFIG or POST_ROUTING remains
1305  opcodeProgram[currentProgramLength] = OP_BUFFER_TO_ROUTING;
1306  programMask[currentProgramLength] = POST_ROUTING;
1307  currentProgramLength++;
1308  //if done --> send reply
1309  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1310  programMask[currentProgramLength] = OPRV_DONE | OPRV_FAIL;
1311  currentProgramLength++;
1312  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1313  programMask[currentProgramLength] = OPRV_OK;
1314  currentProgramLength++;
1315  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_XMEM;
1316  programMask[currentProgramLength] = OPRV_DONE;
1317  currentProgramLength++;
1318  opcodeProgram[currentProgramLength] = OP_EXIT;
1319  programMask[currentProgramLength] = OPRV_DONE;
1320  currentProgramLength++;
1321  //here neither routing not complete or post config
1322  opcodeProgram[currentProgramLength] = OP_COPY_REQTYPE_TO_RETURN;
1323  programMask[currentProgramLength] = OPRV_SKIPPED;
1324  currentProgramLength++;
1325  //if routing --> we need more data (and erase the RV)
1326  opcodeProgram[currentProgramLength] = OP_OK;
1327  programMask[currentProgramLength] = POST_ROUTING;
1328  currentProgramLength++;
1329  opcodeProgram[currentProgramLength] = OP_EXIT;
1330  programMask[currentProgramLength] = OPRV_OK;
1331  currentProgramLength++;
1332  //now, it is POST configure
1333  opcodeProgram[currentProgramLength] = OP_ACTIVATE_DECOUP;
1334  programMask[currentProgramLength] = OPRV_SKIPPED;
1335  currentProgramLength++;
1336  // we lost the information of DONE in the RV, but it is also stored in last_xmem_page_received_persistent
1337  opcodeProgram[currentProgramLength] = OP_BUFFER_TO_HWICAP;
1338  programMask[currentProgramLength] = OPRV_OK;
1339  currentProgramLength++;
1340  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1341  programMask[currentProgramLength] = MASK_ALWAYS;
1342  currentProgramLength++;
1343  //wait for next junk
1344  opcodeProgram[currentProgramLength] = OP_EXIT;
1345  programMask[currentProgramLength] = OPRV_OK | OPRV_NOT_COMPLETE;
1346  currentProgramLength++;
1347  //Reconfiguration done
1348  opcodeProgram[currentProgramLength] = OP_DEACTIVATE_DECOUP;
1349  programMask[currentProgramLength] = OPRV_DONE;
1350  currentProgramLength++;
1351  opcodeProgram[currentProgramLength] = OP_CLEAR_ROUTING_TABLE;
1352  programMask[currentProgramLength] = OPRV_DONE;
1353  currentProgramLength++;
1354  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1355  programMask[currentProgramLength] = OPRV_DONE;
1356  currentProgramLength++;
1357  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1358  programMask[currentProgramLength] = OPRV_OK;
1359  currentProgramLength++;
1360  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_XMEM;
1361  programMask[currentProgramLength] = OPRV_DONE;
1362  currentProgramLength++;
1363  opcodeProgram[currentProgramLength] = OP_EXIT;
1364  programMask[currentProgramLength] = OPRV_DONE;
1365  currentProgramLength++;
1366  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1367  programMask[currentProgramLength] = MASK_ALWAYS;
1368  currentProgramLength++;
1369  //if fail --> abort
1370  opcodeProgram[currentProgramLength] = OP_ABORT_HWICAP;
1371  programMask[currentProgramLength] = OPRV_FAIL;
1372  currentProgramLength++;
1373  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1374  programMask[currentProgramLength] = OPRV_OK;
1375  currentProgramLength++;
1376  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1377  programMask[currentProgramLength] = OPRV_OK;
1378  currentProgramLength++;
1379  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_XMEM;
1380  programMask[currentProgramLength] = OPRV_DONE;
1381  currentProgramLength++;
1382  //restore RV
1383  opcodeProgram[currentProgramLength] = OP_FAIL;
1384  programMask[currentProgramLength] = OPRV_DONE;
1385  currentProgramLength++;
1386  opcodeProgram[currentProgramLength] = OP_EXIT;
1387  programMask[currentProgramLength] = OPRV_FAIL;
1388  currentProgramLength++;
1389  opcodeProgram[currentProgramLength] = OP_OK;
1390  programMask[currentProgramLength] = OPRV_SKIPPED;
1391  currentProgramLength++;
1392 
1393  break;
1394 
1395  case GLOBAL_TCP_HTTP:
1396  if(reset_from_psoc == 1)
1397  { //reset form counter etc. are done in GLOBAL_IDLE;
1399  //do nothing
1400  currentProgramLength = 0;
1401  tcp_iteration_count = 0;
1402  //to trigger all resets
1403  iterate_again = true;
1404  break;
1405  }
1406  //TODO: implement timeout for NOT complete requests
1407  tcpModeEnabled = 1;
1408  msg="TCP";
1409 
1411  {
1412  //"self reset" --> start over
1413  //but wait until TX TCP FSMs have finished
1416  {
1418  iterate_again = true;
1419  msg="SUC"; //maintain SUC message
1420  //do nothing else
1421  currentProgramLength=0;
1422  } else {
1423  printf("\t\t\tWaiting for TCP FSMs to finish...\n");
1424  msg="WFF"; //Wait for FSM
1425 
1426  //give the FSM the option to update Flags
1427  currentProgramLength=0;
1428  opcodeProgram[currentProgramLength] = OP_SEND_TCP_SESS;
1429  programMask[currentProgramLength] = MASK_ALWAYS;
1430  currentProgramLength++;
1431  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_TCP;
1432  programMask[currentProgramLength] = MASK_ALWAYS;
1433  currentProgramLength++;
1434  }
1435  break;
1436  }
1437  if(wasAbort == 1)
1438  {
1439  //do not change state?
1440  msg="ABR";
1441  currentProgramLength=0;
1442  break;
1443  }
1445  {
1446  //TODO: self reset?
1447  //do not change state?
1448  msg="ERR";
1449  currentProgramLength=0;
1450  break;
1451  }
1452  printf("GLOBAL_TCP_HTTP: make a plan with REQUEST_TYPE: %d\n", (int) reqType);
1453 
1455  {
1456  opcodeProgram[currentProgramLength] = OP_WAIT_FOR_TCP_SESS;
1457  programMask[currentProgramLength] = MASK_ALWAYS;
1458  currentProgramLength++;
1459  opcodeProgram[currentProgramLength] = OP_EXIT;
1460  programMask[currentProgramLength] = OPRV_NOT_COMPLETE;
1461  currentProgramLength++;
1462  //clearing the buffers is done by the "self reset" above
1463  }
1464 
1465  if(reqType == POST_ROUTING)
1466  {//cont tcp already activated
1467  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1468  programMask[currentProgramLength] = MASK_ALWAYS;
1469  currentProgramLength++;
1470  opcodeProgram[currentProgramLength] = OP_FILL_BUFFER_TCP;
1471  programMask[currentProgramLength] = MASK_ALWAYS;
1472  currentProgramLength++;
1473  opcodeProgram[currentProgramLength] = OP_EXIT; //wait for data or fatal failure
1474  programMask[currentProgramLength] = OPRV_NOT_COMPLETE | OPRV_PARTIAL_COMPLETE | OPRV_FAIL;
1475  currentProgramLength++;
1476  opcodeProgram[currentProgramLength] = OP_BUFFER_TO_ROUTING;
1477  programMask[currentProgramLength] = OPRV_DONE | OPRV_OK;
1478  currentProgramLength++;
1479  opcodeProgram[currentProgramLength] = OP_EXIT;
1480  programMask[currentProgramLength] = OPRV_NOT_COMPLETE;
1481  currentProgramLength++;
1482  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1483  programMask[currentProgramLength] = OPRV_DONE | OPRV_FAIL;
1484  currentProgramLength++;
1485  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1486  programMask[currentProgramLength] = MASK_ALWAYS;
1487  currentProgramLength++;
1488  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1489  programMask[currentProgramLength] = OPRV_OK;
1490  currentProgramLength++;
1491  opcodeProgram[currentProgramLength] = OP_SEND_TCP_SESS;
1492  programMask[currentProgramLength] = OPRV_DONE;
1493  currentProgramLength++;
1494  opcodeProgram[currentProgramLength] = OP_DEACTIVATE_CONT_TCP;
1495  programMask[currentProgramLength] = OPRV_DONE;
1496  currentProgramLength++;
1497  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_TCP;
1498  programMask[currentProgramLength] = OPRV_DONE;
1499  currentProgramLength++;
1500  break;
1501  }
1502  if(reqType == POST_CONFIG)
1503  {//decoup already activated
1504  //cont tcp already activated
1505  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1506  programMask[currentProgramLength] = MASK_ALWAYS;
1507  currentProgramLength++;
1508  opcodeProgram[currentProgramLength] = OP_FIFO_TO_HWICAP;
1509  programMask[currentProgramLength] = MASK_ALWAYS;
1510  currentProgramLength++;
1511  opcodeProgram[currentProgramLength] = OP_EXIT; //we have smth left to do
1512  programMask[currentProgramLength] = OPRV_OK | OPRV_NOT_COMPLETE;
1513  currentProgramLength++;
1514  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1515  programMask[currentProgramLength] = MASK_ALWAYS;
1516  currentProgramLength++;
1517  //failed?
1518  opcodeProgram[currentProgramLength] = OP_ABORT_HWICAP;
1519  programMask[currentProgramLength] = OPRV_FAIL;
1520  currentProgramLength++;
1521  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1522  programMask[currentProgramLength] = OPRV_OK;
1523  currentProgramLength++;
1524  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1525  programMask[currentProgramLength] = OPRV_OK;
1526  currentProgramLength++;
1527  opcodeProgram[currentProgramLength] = OP_SEND_TCP_SESS;
1528  programMask[currentProgramLength] = OPRV_DONE;
1529  currentProgramLength++;
1530  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_TCP;
1531  programMask[currentProgramLength] = OPRV_DONE;
1532  currentProgramLength++;
1533  //restore RV
1534  opcodeProgram[currentProgramLength] = OP_FAIL;
1535  programMask[currentProgramLength] = OPRV_OK;
1536  currentProgramLength++;
1537  opcodeProgram[currentProgramLength] = OP_EXIT;
1538  programMask[currentProgramLength] = OPRV_FAIL;
1539  currentProgramLength++;
1540  //Reconfiguration done
1541  opcodeProgram[currentProgramLength] = OP_DEACTIVATE_DECOUP;
1542  programMask[currentProgramLength] = OPRV_SKIPPED;
1543  currentProgramLength++;
1544  opcodeProgram[currentProgramLength] = OP_CLEAR_ROUTING_TABLE;
1545  programMask[currentProgramLength] = OPRV_OK;
1546  currentProgramLength++;
1547  opcodeProgram[currentProgramLength] = OP_DONE;
1548  programMask[currentProgramLength] = OPRV_OK;
1549  currentProgramLength++;
1550  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1551  programMask[currentProgramLength] = OPRV_DONE;
1552  currentProgramLength++;
1553  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1554  programMask[currentProgramLength] = OPRV_OK;
1555  currentProgramLength++;
1556  opcodeProgram[currentProgramLength] = OP_SEND_TCP_SESS;
1557  programMask[currentProgramLength] = OPRV_DONE;
1558  currentProgramLength++;
1559  opcodeProgram[currentProgramLength] = OP_DEACTIVATE_CONT_TCP;
1560  programMask[currentProgramLength] = OPRV_DONE;
1561  currentProgramLength++;
1562  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_TCP;
1563  programMask[currentProgramLength] = OPRV_DONE;
1564  currentProgramLength++;
1565  opcodeProgram[currentProgramLength] = OP_EXIT;
1566  programMask[currentProgramLength] = OPRV_DONE;
1567  currentProgramLength++;
1568  break;
1569  }
1570 
1571  //else...first run?
1572  opcodeProgram[currentProgramLength] = OP_FILL_BUFFER_TCP;
1573  programMask[currentProgramLength] = MASK_ALWAYS;
1574  currentProgramLength++;
1575  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1576  programMask[currentProgramLength] = MASK_ALWAYS;
1577  currentProgramLength++;
1578  opcodeProgram[currentProgramLength] = OP_EXIT; //wait for data or fatal failure
1579  programMask[currentProgramLength] = OPRV_NOT_COMPLETE | OPRV_PARTIAL_COMPLETE | OPRV_FAIL;
1580  currentProgramLength++;
1581  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1582  programMask[currentProgramLength] = OPRV_DONE | OPRV_OK;
1583  currentProgramLength++;
1584  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP; //If we just need to create a response
1585  programMask[currentProgramLength] = OPRV_USER;
1586  currentProgramLength++;
1587  opcodeProgram[currentProgramLength] = OP_SEND_TCP_SESS;
1588  programMask[currentProgramLength] = OPRV_DONE;
1589  currentProgramLength++;
1590  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_TCP; //send if necessary
1591  programMask[currentProgramLength] = OPRV_DONE;
1592  currentProgramLength++;
1593  opcodeProgram[currentProgramLength] = OP_EXIT; //exit after send
1594  programMask[currentProgramLength] = OPRV_DONE;
1595  currentProgramLength++;
1596  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1597  programMask[currentProgramLength] = MASK_ALWAYS;
1598  currentProgramLength++;
1599  opcodeProgram[currentProgramLength] = OP_COPY_REQTYPE_TO_RETURN;
1600  programMask[currentProgramLength] = OPRV_PARTIAL_COMPLETE;
1601  currentProgramLength++;
1602  //if skipped --> OK or not complete --> more data, also exit
1603  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1604  programMask[currentProgramLength] = MASK_ALWAYS;
1605  currentProgramLength++;
1606  opcodeProgram[currentProgramLength] = OP_EXIT;
1607  programMask[currentProgramLength] = OPRV_SKIPPED;
1608  currentProgramLength++;
1609  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1610  programMask[currentProgramLength] = MASK_ALWAYS;
1611  currentProgramLength++;
1612  //not exit --> RV is request type, only POST_CONFIG or POST_ROUTING remains
1613  opcodeProgram[currentProgramLength] = OP_BUFFER_TO_ROUTING;
1614  programMask[currentProgramLength] = POST_ROUTING;
1615  currentProgramLength++;
1616  //if done --> send reply
1617  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1618  programMask[currentProgramLength] = OPRV_DONE | OPRV_FAIL;
1619  currentProgramLength++;
1620  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1621  programMask[currentProgramLength] = OPRV_OK;
1622  currentProgramLength++;
1623  opcodeProgram[currentProgramLength] = OP_SEND_TCP_SESS;
1624  programMask[currentProgramLength] = OPRV_DONE;
1625  currentProgramLength++;
1626  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_TCP;
1627  programMask[currentProgramLength] = OPRV_DONE;
1628  currentProgramLength++;
1629  opcodeProgram[currentProgramLength] = OP_EXIT;
1630  programMask[currentProgramLength] = OPRV_DONE;
1631  currentProgramLength++;
1632  //here neither routing not complete or post config
1633  //in all cases: we need continuous TCP and expect a payload
1634  opcodeProgram[currentProgramLength] = OP_ACTIVATE_CONT_TCP;
1635  programMask[currentProgramLength] = MASK_ALWAYS;
1636  currentProgramLength++;
1637  opcodeProgram[currentProgramLength] = OP_TCP_RX_STOP_ON_EOP;
1638  programMask[currentProgramLength] = MASK_ALWAYS;
1639  currentProgramLength++;
1640  opcodeProgram[currentProgramLength] = OP_COPY_REQTYPE_TO_RETURN;
1641  programMask[currentProgramLength] = OPRV_SKIPPED;
1642  currentProgramLength++;
1643  //if routing --> we need more data (and erase the RV)
1644  opcodeProgram[currentProgramLength] = OP_OK;
1645  programMask[currentProgramLength] = POST_ROUTING;
1646  currentProgramLength++;
1647  opcodeProgram[currentProgramLength] = OP_EXIT;
1648  programMask[currentProgramLength] = OPRV_OK;
1649  currentProgramLength++;
1650  //now, it is POST configure
1651  opcodeProgram[currentProgramLength] = OP_ACTIVATE_DECOUP;
1652  programMask[currentProgramLength] = OPRV_SKIPPED;
1653  currentProgramLength++;
1654  // we lost the information of DONE in the RV, but it is also stored in last_xmem_page_received_persistent or in detected_http_nl_cnt
1655  opcodeProgram[currentProgramLength] = OP_FIFO_TO_HWICAP;
1656  programMask[currentProgramLength] = OPRV_OK;
1657  currentProgramLength++;
1658  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1659  programMask[currentProgramLength] = MASK_ALWAYS;
1660  currentProgramLength++;
1661  opcodeProgram[currentProgramLength] = OP_EXIT; //we have smth left to do
1662  programMask[currentProgramLength] = OPRV_OK | OPRV_NOT_COMPLETE;
1663  currentProgramLength++;
1664  //Reconfiguration done
1665  opcodeProgram[currentProgramLength] = OP_DEACTIVATE_DECOUP;
1666  programMask[currentProgramLength] = OPRV_DONE;
1667  currentProgramLength++;
1668  opcodeProgram[currentProgramLength] = OP_CLEAR_ROUTING_TABLE;
1669  programMask[currentProgramLength] = OPRV_DONE;
1670  currentProgramLength++;
1671  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1672  programMask[currentProgramLength] = OPRV_DONE;
1673  currentProgramLength++;
1674  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1675  programMask[currentProgramLength] = OPRV_OK;
1676  currentProgramLength++;
1677  opcodeProgram[currentProgramLength] = OP_SEND_TCP_SESS;
1678  programMask[currentProgramLength] = OPRV_DONE;
1679  currentProgramLength++;
1680  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_TCP;
1681  programMask[currentProgramLength] = OPRV_DONE;
1682  currentProgramLength++;
1683  opcodeProgram[currentProgramLength] = OP_DEACTIVATE_CONT_TCP;
1684  programMask[currentProgramLength] = OPRV_DONE;
1685  currentProgramLength++;
1686  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1687  programMask[currentProgramLength] = OPRV_DONE;
1688  currentProgramLength++;
1689  opcodeProgram[currentProgramLength] = OP_EXIT;
1690  programMask[currentProgramLength] = OPRV_DONE;
1691  currentProgramLength++;
1692  opcodeProgram[currentProgramLength] = OP_DISABLE_SILENT_SKIP;
1693  programMask[currentProgramLength] = MASK_ALWAYS;
1694  currentProgramLength++;
1695  //if fail --> abort
1696  opcodeProgram[currentProgramLength] = OP_ABORT_HWICAP;
1697  programMask[currentProgramLength] = OPRV_FAIL;
1698  currentProgramLength++;
1699  opcodeProgram[currentProgramLength] = OP_UPDATE_HTTP_STATE;
1700  programMask[currentProgramLength] = OPRV_OK;
1701  currentProgramLength++;
1702  opcodeProgram[currentProgramLength] = OP_HANDLE_HTTP;
1703  programMask[currentProgramLength] = OPRV_OK;
1704  currentProgramLength++;
1705  opcodeProgram[currentProgramLength] = OP_SEND_TCP_SESS;
1706  programMask[currentProgramLength] = OPRV_DONE;
1707  currentProgramLength++;
1708  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_TCP;
1709  programMask[currentProgramLength] = OPRV_DONE;
1710  currentProgramLength++;
1711  opcodeProgram[currentProgramLength] = OP_DEACTIVATE_CONT_TCP;
1712  programMask[currentProgramLength] = OPRV_DONE;
1713  currentProgramLength++;
1714  //restore RV
1715  opcodeProgram[currentProgramLength] = OP_FAIL;
1716  programMask[currentProgramLength] = OPRV_DONE;
1717  currentProgramLength++;
1718  opcodeProgram[currentProgramLength] = OP_EXIT;
1719  programMask[currentProgramLength] = OPRV_FAIL;
1720  currentProgramLength++;
1721  //in all other cases: we need to wait for data
1722  opcodeProgram[currentProgramLength] = OP_OK;
1723  programMask[currentProgramLength] = OPRV_SKIPPED;
1724  currentProgramLength++;
1725  break;
1726 
1727  case GLOBAL_PYROLINK_RECV: //i.e. Coaxium to FPGA
1728  if(reset_from_psoc == 1)
1729  { //reset form counter etc. are done in GLOBAL_IDLE;
1731  //do nothing
1732  currentProgramLength = 0;
1733  //to trigger all resets
1734  iterate_again = true;
1735  break;
1736  }
1738  { // means, we have this operation done and wait for status change
1739  if(pyroRecvMode == 0)
1740  {
1742  }
1743  //do nothing else
1744  currentProgramLength=0;
1745  msg="SUC"; //maintain SUC message (for XMEM transfer)
1746  break;
1747  }
1749  {
1750  //do not change state?
1751  msg="ERR";
1752  currentProgramLength=0;
1753  break;
1754  }
1755 
1757  {
1758  opcodeProgram[currentProgramLength] = OP_XMEM_COPY_DATA;
1759  programMask[currentProgramLength] = MASK_ALWAYS;
1760  currentProgramLength++;
1761  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1762  programMask[currentProgramLength] = MASK_ALWAYS;
1763  currentProgramLength++;
1764  //done for now
1765  opcodeProgram[currentProgramLength] = OP_EXIT;
1766  programMask[currentProgramLength] = OPRV_NOT_COMPLETE | OPRV_PARTIAL_COMPLETE;
1767  currentProgramLength++;
1768  }
1769  //we have smth to write
1770  opcodeProgram[currentProgramLength] = OP_BUFFER_TO_PYROLINK;
1771  programMask[currentProgramLength] = OPRV_DONE | OPRV_OK;
1772  currentProgramLength++;
1773  //--> if receiver not ready must be handled afterwards
1774  break;
1775 
1776  case GLOBAL_PYROLINK_TRANS: //i.e. FPGA to Coaxium
1777  if(reset_from_psoc == 1)
1778  { //reset form counter etc. are done in GLOBAL_IDLE;
1780  //do nothing
1781  currentProgramLength = 0;
1782  //to trigger all resets
1783  iterate_again = true;
1784  break;
1785  }
1787  { // means, we have this operation done and wait for status change
1788  if(pyroReadReq == 0)
1789  {
1791  }
1792  //do nothing else
1793  currentProgramLength=0;
1794  pyroSendRequestBit = 0; //signal OPRV_DONE
1795  break;
1796  }
1798  {
1800  {
1801  msg = "NOC";
1802  } else {
1803  msg="ERR";
1804  }
1805  currentProgramLength=0;
1806  break;
1807  }
1808 
1810  {//sender didn't send data, we wait for maximum cycles
1813  {
1814  transferError_persistent = true;
1815  msg="NOC";
1816  currentProgramLength = 0;
1817  break;
1818  }
1819  }
1820 
1821  opcodeProgram[currentProgramLength] = OP_PYROLINK_TO_OUTBUFFER;
1822  programMask[currentProgramLength] = MASK_ALWAYS;
1823  currentProgramLength++;
1824  opcodeProgram[currentProgramLength] = OP_ENABLE_SILENT_SKIP;
1825  programMask[currentProgramLength] = MASK_ALWAYS;
1826  currentProgramLength++;
1827  opcodeProgram[currentProgramLength] = OP_SEND_BUFFER_XMEM;
1828  programMask[currentProgramLength] = OPRV_OK | OPRV_DONE;
1829  currentProgramLength++;
1830  opcodeProgram[currentProgramLength] = OP_EXIT;
1831  programMask[currentProgramLength] = OPRV_OK | OPRV_DONE;
1832  currentProgramLength++;
1833  //something isn't done -> leaves OPRV_NOT_COMPLETE and OPRV_FAIL for handling
1834 
1835  break;
1836 
1838  //currentProgramLength = 0;
1839  //toDecoup_persistent = 1;, no, with programms...
1840 
1841  opcodeProgram[0] = OP_ACTIVATE_DECOUP;
1842  programMask[0] = MASK_ALWAYS;
1843  currentProgramLength = 1;
1844 
1845  if(manuallyToDecoup == 0)
1846  {
1848  opcodeProgram[0] = OP_DEACTIVATE_DECOUP;
1849  programMask[0] = MASK_ALWAYS;
1850  currentProgramLength = 1;
1851  }
1852  break;
1853 
1854  }
1855  }
1856 
1857  // ++++++++++++++++++ HANDLE TCP (before executing the plan) ++++++++++++++++
1858 
1859  if(tcpModeEnabled == 1)
1860  {
1861 //#pragma HLS dataflow interval=1 FIXME: causes Vivado HLS 2017.4 to crash...
1862 
1863  switch(fsmTcpSessId_RX) {
1864 
1865  default:
1866  case TCP_FSM_RESET:
1868  break;
1869  case TCP_FSM_IDLE:
1870  //just stay here
1871  break;
1872 
1873  case TCP_FSM_W84_START:
1875  //no break;
1876  case TCP_FSM_PROCESS_DATA:
1877  if(!siNAL_Tcp_SessId.empty())
1878  {
1879  //we assume that the NRC always sends a valid pair of SessId and data (because we control it)
1880  AppMeta tmp = 0x0;
1881  if(siNAL_Tcp_SessId.read_nb(tmp))
1882  {
1885  }
1886  }
1887  break;
1888  case TCP_FSM_DONE:
1889  // just stay here?
1890  break;
1891  }
1892 
1893  switch(fsmTcpSessId_TX) {
1894 
1895  default:
1896  case TCP_FSM_RESET:
1898  currentTcpSessId = 0;
1899  break;
1900  case TCP_FSM_IDLE:
1901  //just stay here
1902  break;
1903 
1904  case TCP_FSM_W84_START:
1906  //no break;
1907  case TCP_FSM_PROCESS_DATA:
1908  if(!soNAL_Tcp_SessId.full())
1909  {
1910  if(soNAL_Tcp_SessId.write_nb(currentTcpSessId))
1911  {
1913  }
1914  }
1915  break;
1916  case TCP_FSM_DONE:
1917  // just stay here?
1918  break;
1919  }
1920 
1921  switch(fsmTcpData_RX) {
1922 
1923  default:
1924  case TCP_FSM_RESET:
1926  break;
1927  case TCP_FSM_IDLE:
1928  //just stay here
1929  break;
1930 
1931  case TCP_FSM_W84_START:
1933  //no break;
1934  case TCP_FSM_PROCESS_DATA:
1935  for(int f = 0; f<IN_BUFFER_SIZE; f++)
1936  {
1937  //if ICAP is blocking, we can't do much...
1938  if( internal_icap_fifo.full() )
1939  {
1940  break;
1941  }
1943  {
1944  printf("try to empty overflow buffer\n");
1945  int new_write_index = 0;
1946  bool once_blocked = false;
1947  for(int i =0; i < fifo_overflow_buffer_length; i++)
1948  {
1949  if(once_blocked || !internal_icap_fifo.write_nb(fifo_overflow_buffer[i]) )
1950  {
1951  once_blocked = true;
1952  if(i != new_write_index)
1953  {
1954  fifo_overflow_buffer[new_write_index] = fifo_overflow_buffer[i];
1955  new_write_index++;
1956  }
1957  }
1958  }
1959  fifo_overflow_buffer_length = new_write_index;
1960  if(!once_blocked)
1961  {
1963  } else {
1964  printf("TCP RX still blocked by hwicap fifo\n");
1965  break;
1966  }
1967  }
1968  //check before we proceed...
1969  if(siNAL_Tcp_data.empty() || internal_icap_fifo.full() )
1970  {
1971  break;
1972  }
1973 
1974  NetworkWord big = NetworkWord();
1975  if(!siNAL_Tcp_data.read_nb(big))
1976  {
1977  break;
1978  }
1979 
1981  for(int i = 0; i < 8; i++)
1982  {
1983 #pragma HLS unroll factor=8
1984  if((big.tkeep >> i) == 0)
1985  {
1986  continue;
1987  }
1988  ap_uint<8> current_byte = (ap_uint<8>) (big.tdata >> i*8);
1989  if(!tcp_write_only_fifo)
1990  {
1991  bufferIn[bufferInPtrWrite] = current_byte;
1992  }
1993  if(detected_http_nl_cnt >= 1)
1994  {
1995  if(!internal_icap_fifo.write_nb(current_byte))
1996  {
2000  }
2001  tcp_words_received++; //TODO: for debugging, count words written to fifo...
2002  }
2003  if(!tcp_write_only_fifo)
2004  {
2005  if(bufferInPtrWrite >= 3)
2006  {
2007  if(bufferIn[bufferInPtrWrite] == 0xa &&
2008  bufferIn[bufferInPtrWrite -1] == 0xd &&
2009  bufferIn[bufferInPtrWrite -2] == 0xa &&
2010  bufferIn[bufferInPtrWrite -3] == 0xd )
2011  {//HTTP EOF/EOP detected
2014  printf("TCP RX: detected %d. HTTP NL at position %d\n",(int) detected_http_nl_cnt, (int) (bufferInPtrWrite - 3));
2015  }
2016  } else if (bufferInPtrMaxWrite >= 3 ) {
2017  //hangover case if _not_ just cleaned
2018  printf("bufferInPtrMaxWrite: %d\n", (int) bufferInPtrMaxWrite);
2019  uint8_t chars_to_compare[4];
2020  uint32_t position = 0;
2021  for(int j = 3; j>=0; j--)
2022  {
2023 #pragma HLS unroll factor=4
2024  int relative_buffer_in_write = ((int) bufferInPtrWrite) - j;
2025  //if( (((int) bufferInPtrWrite) -j) < 0)
2026  if(relative_buffer_in_write < 0)
2027  {
2028  assert(((3-j) >= 0) && ((j-3) < 3));
2029  chars_to_compare[3-j] = last_3_chars[3-j];
2030  } else {
2031  position = IN_BUFFER_SIZE - j + 1;
2032  //assert((bufferInPtrWrite-j) >= 0 && (bufferInPtrWrite-j) < IN_BUFFER_SIZE);
2033  assert(relative_buffer_in_write >= 0 && relative_buffer_in_write < IN_BUFFER_SIZE);
2034  assert(((3-j) >= 0) && ((j-3) < 4));
2035  //chars_to_compare[3-j] = bufferIn[bufferInPtrWrite-j];
2036  chars_to_compare[3-j] = bufferIn[relative_buffer_in_write];
2037  }
2038  }
2039  printf("chars_to_compare: 0x%02x%02x%02x%02x\n", chars_to_compare[0], chars_to_compare[1], chars_to_compare[2], chars_to_compare[3]);
2040  if(chars_to_compare[0] == 0xd && chars_to_compare[1] == 0xa &&
2041  chars_to_compare[2] == 0xd && chars_to_compare[3] == 0xa)
2042  {//HTTP EOF/EOP detected
2045  printf("TCP RX: detected %d. HTTP NL at position %d\n",(int) detected_http_nl_cnt, (int) position);
2046  }
2047  }
2048  //TODO: write explicit poison pill? or use 2nd http nl count?
2049  bufferInPtrWrite++;
2050  }
2051  } //inner for
2052 
2053  //tcp_words_received++; //TODO: for debugging, count words written to fifo...
2054  if(!tcp_write_only_fifo)
2055  {
2058  {
2059  //for hangover detection
2063  //we need to process first
2064  bufferInPtrWrite = 0; //TODO?
2065  tcp_write_only_fifo = true;
2066  printf("\tlast_3_chars: 0x%02x%02x%02x\n", last_3_chars[0], last_3_chars[1], last_3_chars[2]);
2067  break;
2068  }
2069  }
2070 
2073  {
2075  break;
2076  }
2077  } //outer loop
2078  printf("after TCP RX: bufferInPtrWrite %d; bufferInPtrMaxWrite %d;\n", (int) bufferInPtrWrite, (int) bufferInPtrMaxWrite);
2079  break;
2080  case TCP_FSM_DONE:
2081  // just stay here?
2082  break;
2083  case TCP_FSM_ERROR:
2084  //TODO
2085  break;
2086  }
2087 
2088  switch(fsmTcpData_TX) {
2089 
2090  default:
2091  case TCP_FSM_RESET:
2093  break;
2094  case TCP_FSM_IDLE:
2095  //just stay here
2096  break;
2097 
2098  case TCP_FSM_W84_START:
2100  //no break;
2101  case TCP_FSM_PROCESS_DATA:
2102  //if(!soNAL_Tcp_data.full())
2103  run_nested_loop_helper = true;
2104  while(!soNAL_Tcp_data.full() && run_nested_loop_helper)
2105  {
2106  //out = NetworkWord();
2108  out.tdata = 0;
2109  out.tlast = 0;
2110  out.tkeep = 0;
2111 
2112  for(int i = 0; i < 8; i++)
2113  {
2114 #pragma HLS unroll
2115  out.tdata |= ((ap_uint<64>) (bufferOut[bufferOutPtrNextRead + i]) )<< (i*8);
2116  out.tkeep |= (ap_uint<8>) 0x1 << i;
2117 
2119  {
2120  out.tlast = 1;
2122  break;
2123  }
2124 
2125  }
2126  if(soNAL_Tcp_data.write_nb(out))
2127  {
2128  bufferOutPtrNextRead += 8;
2129  //break while
2130  if(out.tlast == 1)
2131  {
2132  run_nested_loop_helper = false;
2133  break;
2134  }
2135  } else {
2136  run_nested_loop_helper = false;
2137  break;
2138  }
2139  } //while
2140  //else {
2141  // printf("\t ----------- soNAL_Tcp_data is full -----------");
2142  //}
2143  break;
2144  case TCP_FSM_DONE:
2145  // just stay here?
2146  break;
2147  }
2148 
2149  printf("fsmTcpSessId_RX: %d; \tfsmTcpSessId_TX %d\n", fsmTcpSessId_RX, fsmTcpSessId_TX);
2150  printf("fsmTcpData_RX: %d; \tfsmTcpData_TX %d\n", fsmTcpData_RX, fsmTcpData_TX);
2151  }
2152 
2153 
2154  // ++++++++++++++++++ HWICAP TCP FSM ++++++++++++++++++++
2155 
2156  switch(fsmHwicap)
2157  {
2158  default:
2159  case ICAP_FSM_RESET:
2161  case ICAP_FSM_IDLE:
2162  //just stay here?
2163  break;
2164 
2165  case ICAP_FSM_WRITE:
2166  {
2167  if( EOS != 1)
2168  {//HWICAP is not accessible
2170  break;
2171  }
2172  CR_isWriting = CR_value & CR_WRITE;
2173  if (CR_isWriting != 1 && flag_enable_fake_hwicap == 0)
2174  {
2176  }
2177  //get current FIFO vaccancies
2178  WFV = HWICAP[WFV_OFFSET];
2179  WFV_value = WFV & 0x7FF;
2180  uint32_t max_words_to_write = WFV_value;
2181  printf("HWICAP FSM: max_words_to_write %d\n", (int) max_words_to_write);
2182  for(int f = 0; f<IN_BUFFER_SIZE; f++)
2183  {
2184  //if(internal_icap_fifo.empty())
2185  //we can't do anything if both are empty...
2186  if(internal_icap_fifo.empty() && icap_hangover_fifo.empty() )
2187  {
2188  break;
2189  }
2190  if(max_words_to_write == 0)
2191  {
2192 #ifndef __SYNTHESIS__
2194  { //for the csim, we need to break in all cases
2195  break;
2196  }
2197 #endif
2198  if(flag_enable_fake_hwicap == 0)
2199  {
2200  //update FIFO vaccancies
2201  WFV = HWICAP[WFV_OFFSET];
2202  WFV_value = WFV & 0x7FF;
2203  }
2204  max_words_to_write = WFV_value;
2205  printf("UPDATE: max_words_to_write %d\n", (int) max_words_to_write);
2206  if(max_words_to_write == 0)
2207  {
2208  break;
2209  }
2210  }
2211  uint8_t bytes_read[4];
2212  uint8_t bytes_read_count = 0;
2213  while(!icap_hangover_fifo.empty())
2214  {
2215  uint8_t read_var = 0x0;
2216  if(icap_hangover_fifo.read_nb(read_var))
2217  {
2218  bytes_read[bytes_read_count] = read_var;
2219  bytes_read_count++;
2220  } else {
2221  break;
2222  }
2223  }
2224  while( (bytes_read_count < 4) && !internal_icap_fifo.empty() )
2225  {
2226  uint8_t read_var = 0x0;
2227  if(internal_icap_fifo.read_nb(read_var))
2228  {
2229  bytes_read[bytes_read_count] = read_var;
2230  bytes_read_count++;
2231  } else {
2232  break;
2233  }
2234  }
2235  if(bytes_read_count != 4)
2236  { //didn't read a full word
2237  printf("FIFO hangover bytes: 0x");
2238  for(int i = 0; i < bytes_read_count; i++)
2239  {
2240  icap_hangover_fifo.write(bytes_read[i]);
2241  printf("%02x ", (int) bytes_read[i]);
2242  }
2243  printf("\nFIFO hangover with size %d\n", (int) bytes_read_count);
2244  break;
2245  } else { //we have a full word
2246  ap_uint<32> tmp = 0;
2247  if (notToSwap == 1)
2248  {
2249  tmp |= (ap_uint<32>) bytes_read[0];
2250  tmp |= (((ap_uint<32>) bytes_read[1]) << 8);
2251  tmp |= (((ap_uint<32>) bytes_read[2]) << 16);
2252  tmp |= (((ap_uint<32>) bytes_read[3]) << 24);
2253  } else {
2254  //default
2255  tmp |= (ap_uint<32>) bytes_read[3];
2256  tmp |= (((ap_uint<32>) bytes_read[2]) << 8);
2257  tmp |= (((ap_uint<32>) bytes_read[1]) << 16);
2258  tmp |= (((ap_uint<32>) bytes_read[0]) << 24);
2259  }
2260 
2261  if ( tmp == 0x0d0a0d0a || tmp == 0x0a0d0a0d )
2262  { //is like a poison pill, we are done for today
2263  printf("HTTP NL received, treat it as Poison Pill...\n");
2265  {
2268  }
2270  break;
2272  { //we are done for today
2273  printf("Poison Pill received...\n");
2275  break;
2276  } else {
2277  if(flag_enable_fake_hwicap == 0)
2278  {
2279 #ifndef __SYNTHESIS__
2281  {
2284  }
2285  //TODO: decrement WFV value of testbench
2286  //for debugging reasons, we write it twice
2287  HWICAP[WF_OFFSET] = tmp;
2288 #else
2289  HWICAP[WF_OFFSET] = tmp;
2290 #endif
2291  } else {
2292  //we do NOT write it to HWICAP
2293  //but update the WFV
2294  WFV_value--;
2295  }
2297  max_words_to_write--;
2298  printf("writing to HWICAP: %#010x\n",(int) tmp);
2299  }
2300  }
2301  } //while
2302 
2303  WFV = HWICAP[WFV_OFFSET];
2304  WFV_value = WFV & 0x7FF;
2305  if (WFV_value >= HWICAP_FIFO_DEPTH && (WFV_value != max_words_to_write) )
2306  {
2307  fifoEmptyCnt++;
2308  //TODO: re-iterate again?
2309  }
2310 
2311  if(WFV_value <= HWICAP_FIFO_NEARLY_FULL_TRIGGER)
2312  {
2313  fifoFullCnt++;
2314  }
2315  }
2316  break;
2317 
2318  case ICAP_FSM_DONE:
2319  //stay here
2320  break;
2321  case ICAP_FSM_ERROR:
2322  //stay here
2323  break;
2324  case ICAP_FSM_DRAIN:
2325  while(!internal_icap_fifo.empty())
2326  {
2327  internal_icap_fifo.read();
2328  }
2329  while(!icap_hangover_fifo.empty())
2330  {
2331  icap_hangover_fifo.read();
2332  }
2334  break;
2335  }
2336  printf("fsmHwicap: %d\n", fsmHwicap);
2337  // ++++++++++++++++++ EXECUTE THE PLAN ++++++++++++++++
2338 
2339  lastReturnValue = OPRV_OK; //allow the first operation to be executed
2340 
2341  //reset flags
2343  flag_silent_skip = 0;
2344 
2345  printf("currentProgramLength: %d\n", (int) currentProgramLength);
2346  printf("currentGlobalOperation: %d\n", (int) currentGlobalOperation);
2347  assert(currentProgramLength < MAX_PROGRAM_LENGTH);
2348 
2349 
2350  //progLoop:
2351  for(uint8_t progCnt = 0; progCnt < currentProgramLength; progCnt++)
2352  {
2353  OprvType currentMask = programMask[progCnt];
2354  OpcodeType currentOpcode = opcodeProgram[progCnt];
2355  printf("PC %d, lst RV %d, opcode %d\n", (int) progCnt, (int) lastReturnValue, (int) currentOpcode);
2356 
2357  OprvType mask_result = currentMask & lastReturnValue;
2358  if(((uint8_t) mask_result) == 0)
2359  {//i.e. we skip this command
2360  if(flag_silent_skip == 0)
2361  {
2362  lastReturnValue = OPRV_SKIPPED;
2363  }
2364  printf("[%d] operation skipped (silent: %d)\n", (int) progCnt, (int) flag_silent_skip);
2365  continue;
2366  }
2367 
2368 
2369  switch(currentOpcode)
2370  {
2371 
2372  default: //NO Break
2373  case OP_NOP: //we do nothing, also leave return value untouched
2374  break;
2375 
2378  lastReturnValue = OPRV_OK;
2379  break;
2380 
2383  lastReturnValue = OPRV_OK;
2384  break;
2385 
2386  case OP_ENABLE_SILENT_SKIP:
2387  flag_silent_skip = 1;
2388  break;
2389 
2391  flag_silent_skip = 0;
2392  break;
2393 
2394  case OP_SET_NOT_TO_SWAP:
2395  notToSwap = 1;
2396  break;
2397 
2398  case OP_UNSET_NOT_TO_SWAP:
2399  notToSwap = 0; //default
2400  break;
2401 
2402  case OP_XMEM_COPY_DATA: //sensitive to FLAG check pattern
2404  //explicit overflow
2405  expCnt = xmem_page_trans_cnt + 1;
2406  if (xmem_page_trans_cnt == 0xf)
2407  {
2408  expCnt = 0;
2409  }
2410  copyRet = copyAndCheckBurst(xmem,expCnt, lastPageCnt_in);
2411 
2412  switch (copyRet) {
2413  default:
2414  case 0:
2415  msg = "UTD"; //Up To Date
2416  lastReturnValue = OPRV_NOT_COMPLETE;
2417  break;
2418  case 1:
2419  msg = "INV"; //Invalid
2420  //We are in the middle of a page transfer
2421  lastReturnValue = OPRV_PARTIAL_COMPLETE;
2422  break;
2423  case 2:
2424  msg = "CMM"; //Counter MisMatch
2425  lastReturnValue = OPRV_FAIL;
2426  break;
2427  case 3:
2428  msg = "COR"; //Corrupt pattern
2429  lastReturnValue = OPRV_FAIL;
2430  break;
2431  case 4:
2432  //we received a lastpage
2433  msg = "SUC"; //success
2434  xmem_page_trans_cnt = expCnt;
2436  lastReturnValue = OPRV_DONE;
2437  break;
2438  case 5: //we received a page, but not the last one
2439  msg= " OK";
2440  xmem_page_trans_cnt = expCnt;
2441  lastReturnValue = OPRV_OK;
2442  break;
2443  }
2444  break;
2445 
2446  case OP_TCP_CNT_RESET:
2447  goto_done_if_idle_tcp_rx = false;
2449  //we reset HTTP EOF detection
2451  target_http_nl_cnt = 0;
2452  for(int i = 0; i < 3; i++)
2453  {
2454 #pragma HLS unroll
2455  last_3_chars[i] = 0x0;
2457  }
2458  tcp_write_only_fifo = false;
2459  break;
2460 
2461  case OP_WAIT_FOR_TCP_SESS:
2463  {
2465  {
2467  lastReturnValue = OPRV_NOT_COMPLETE;
2470  {
2471  lastReturnValue = OPRV_OK;
2473  tcp_words_received = 0;
2474  } else {//we still wait
2475  lastReturnValue = OPRV_NOT_COMPLETE;
2476  }
2477  } else {
2478  lastReturnValue = OPRV_OK;
2479  }
2480  break;
2481 
2482  case OP_ACTIVATE_CONT_TCP:
2484  goto_done_if_idle_tcp_rx = false;
2486  {
2488  }
2489  break;
2490 
2493  target_http_nl_cnt = 0;
2494  goto_done_if_idle_tcp_rx = true;
2495  break;
2496 
2497  case OP_TCP_RX_STOP_ON_EOR:
2498  target_http_nl_cnt = 1;
2499  break;
2500 
2501  case OP_TCP_RX_STOP_ON_EOP:
2502  target_http_nl_cnt = 2;
2503  break;
2504 
2505  case OP_FILL_BUFFER_TCP:
2507  {
2508  goto_done_if_idle_tcp_rx = false;
2510  lastReturnValue = OPRV_NOT_COMPLETE;
2511  } else if(fsmTcpData_RX == TCP_FSM_DONE)
2512  {
2513  lastReturnValue = OPRV_DONE;
2516  && !tcp_write_only_fifo //this isn't increasing the counter
2518  )
2519  { //nothing new
2520  lastReturnValue = OPRV_NOT_COMPLETE;
2521  //printf("tcp_write_only_fifo: %d\n", (int) tcp_write_only_fifo);
2522  } else {
2523  //looks like we get something
2524  //or stuff is still left for processing
2525  lastReturnValue = OPRV_OK;
2526  }
2527  //in any case
2529  break;
2530 
2531  case OP_HANDLE_HTTP:
2532  {
2533  //TODO: break in multiple opcodes?
2534  printf("httpState bevore parseHTTP: %d\n",httpState);
2535  bool rx_done = false;
2536  if(lastReturnValue == OPRV_DONE)
2537  {
2538  rx_done = true;
2539  }
2540 
2542 
2543  printf("reqType after parseHTTP: %d\n", reqType);
2544 
2545  switch (httpState) {
2546  case HTTP_IDLE:
2547  lastReturnValue = OPRV_OK;
2548  break;
2549  case HTTP_PARSE_HEADER:
2550  lastReturnValue = OPRV_OK;
2551  break;
2552  case HTTP_HEADER_PARSED:
2553 
2555  {//corner case
2557  lastReturnValue = OPRV_NOT_COMPLETE;
2558  } else {
2559  lastReturnValue = OPRV_PARTIAL_COMPLETE;
2560  }
2561  //TODO: start of bitfile must be aligned to 4?? do in sender??
2562  break;
2563  case HTTP_READ_PAYLOAD:
2564  // Do nothing?
2565  lastReturnValue = OPRV_PARTIAL_COMPLETE;
2566  break;
2567  case HTTP_REQUEST_COMPLETE:
2569  // no break??
2570  case HTTP_SEND_RESPONSE:
2571  lastReturnValue = OPRV_USER;
2572  break;
2573  case HTTP_INVALID_REQUEST:
2574  //no break
2575  case HTTP_DONE:
2576  lastReturnValue = OPRV_DONE;
2577  break;
2578  }
2579  }
2580  break;
2581 
2582  case OP_UPDATE_HTTP_STATE:
2583  if(lastReturnValue == OPRV_FAIL)
2584  {
2586  }
2587  if(wasAbort == 1 || transferError_persistent == true || invalidPayload_persistent == true)
2588  {
2590  }
2591  if(lastReturnValue == OPRV_DONE)
2592  {
2594  }
2595  lastReturnValue = OPRV_OK;
2596  break;
2597 
2598  case OP_CHECK_HTTP_EOR:
2599  if(detected_http_nl_cnt >= 1)
2600  {
2601  lastReturnValue = OPRV_DONE;
2602  } else {
2603  lastReturnValue = OPRV_NOT_COMPLETE;
2604  }
2605  break;
2606 
2607  case OP_CHECK_HTTP_EOP:
2608  if(detected_http_nl_cnt >= 2)
2609  {
2610  lastReturnValue = OPRV_DONE;
2611  } else {
2612  lastReturnValue = OPRV_NOT_COMPLETE;
2613  }
2614  break;
2615 
2617  lastReturnValue = reqType;
2618  break;
2619 
2620  case OP_BUFFER_TO_HWICAP:
2621  {
2622  if (EOS != 1)
2623  {//HWICAP is not accessible
2624  msg = "INR";
2625  lastReturnValue = OPRV_FAIL;
2626  break;
2627  }
2628  uint32_t maxPayloadWrite = 0;
2629  if(bufferInPtrMaxWrite >= 4)
2630  {
2631  maxPayloadWrite = bufferInPtrMaxWrite - 3;
2632  }
2634  {
2635  if(detected_http_nl_cnt >= 2
2637  {
2638  maxPayloadWrite = positions_of_detected_http_nl[1] - 4; //-4, becauese we have <= in the for
2639  lastReturnValue = OPRV_DONE;
2640  printf("STOP at 2. HTTP NL\n");
2641  }
2642 
2643  }
2644  //printf("Writing Buffer to HWICAP from %d to %d (including); notToSwap = %d, max_bytes_to_write: %d, write_iteration: %d, read_iteration: %d\n", (int) bufferInPtrNextRead, (int) maxPayloadWrite,(int) notToSwap, (int) max_bytes_to_write,(int) bufferIn_write_iteration_cnt, (int) bufferIn_read_iteration_cnt);
2645  printf("Writing Buffer to HWICAP from %d to %d (including); notToSwap = %d\n", (int) bufferInPtrNextRead, (int) maxPayloadWrite,(int) notToSwap);
2646  ap_uint<32> old_bufferInPtrNextRead = bufferInPtrNextRead;
2647  ap_uint<32> old_wordsWrittenToIcapCnt = wordsWrittenToIcapCnt;
2648  //for(i = bufferInPtrNextRead; i <= maxPayloadWrite; i += 4)
2649  uint32_t i = bufferInPtrNextRead;
2650  //while(i <= maxPayloadWrite) //we have substracted -3, so <=
2651  while(i <= maxPayloadWrite && maxPayloadWrite > 0) //we have substracted -3, so <=
2652  {
2653  ap_uint<32> tmp = 0;
2654 
2656  && i == 0) //only for first iteration, if bufferInPtrNextRead = 0
2657  {
2658  for(int j = 0; j < 4; j++)
2659  {
2660 #pragma HLS unroll factor=4
2661  if( notToSwap == 1)
2662  {
2663  if(j - (((int) hwicap_hangover_size) -1) <= 0)
2664  {//from hangover bytes
2665  tmp |= (((ap_uint<32>) buffer_hangover_bytes[j]) << 8*j);
2666  } else {//from buffer
2667  tmp |= (((ap_uint<32>) bufferIn[j - hwicap_hangover_size]) << 8*j); //actually -1 + 1...
2668  }
2669  } else { //default
2670  if(j - (((int) hwicap_hangover_size) -1) <= 0)
2671  {//from hanover bytes
2672  tmp |= (((ap_uint<32>) buffer_hangover_bytes[j]) << 8*(3-j));
2673  } else {//from buffer
2674  assert((j - hwicap_hangover_size) >= 0);
2675  tmp |= (((ap_uint<32>) bufferIn[j - hwicap_hangover_size]) << 8*(3-j)); //actually -1 + 1...
2676  }
2677  }
2678  }
2679  hwicap_hangover_present = false;
2680  i += 4 - hwicap_hangover_size;
2681  printf("hangover of size %d inserted.\n", (int) hwicap_hangover_size);
2682  } else {
2683  if (notToSwap == 1)
2684  {
2685  tmp |= (ap_uint<32>) bufferIn[i + 0];
2686  tmp |= (((ap_uint<32>) bufferIn[i + 1]) << 8);
2687  tmp |= (((ap_uint<32>) bufferIn[i + 2]) << 16);
2688  tmp |= (((ap_uint<32>) bufferIn[i + 3]) << 24);
2689  } else {
2690  //default
2691  tmp |= (ap_uint<32>) bufferIn[i + 3];
2692  tmp |= (((ap_uint<32>) bufferIn[i + 2]) << 8);
2693  tmp |= (((ap_uint<32>) bufferIn[i + 1]) << 16);
2694  tmp |= (((ap_uint<32>) bufferIn[i + 0]) << 24);
2695  }
2696  i += 4;
2697  }
2698 
2699  if ( tmp == 0x0d0a0d0a || tmp == 0x0a0d0a0d )
2700  { //in theory, should never happen...
2701  printf("Error: Tried to write 0d0a0d0a.\n");
2702  writeErrCnt++;
2703  //continue;
2704  } else {
2705 #ifndef __SYNTHESIS__
2707  {
2710  }
2711  //for debugging reasons, we write it twice
2712  HWICAP[WF_OFFSET] = tmp;
2713 #else
2714  HWICAP[WF_OFFSET] = tmp;
2715 #endif
2717  printf("writing to HWICAP: %#010x\n",(int) tmp);
2718  }
2719  } //while
2720 
2721  // printf("bufferInPtrMaxWrite: %d\n", (int) bufferInPtrMaxWrite);
2722  // printf("bufferInPtrNextRead: %d\n", (int) bufferInPtrNextRead);
2723  // printf("wordsWrittenToIcapCnt: %d\n", (int) wordsWrittenToIcapCnt);
2724 
2725  CR_isWriting = CR_value & CR_WRITE;
2726  if (CR_isWriting != 1)
2727  {
2729  }
2730 
2731 
2732  bufferInPtrNextRead = i; //no +4, since it is done as last step in the loop
2733  printf("bufferInPtrNextRead: %d\n", (int) bufferInPtrNextRead);
2734  printf("bufferInPtrMaxWrite: %d\n", (int) bufferInPtrMaxWrite);
2735  //printf("bufferInPtrMaxWrite_old_iteration: %d\n", (int) bufferInPtrMaxWrite_old_iteration);
2736  printf("bufferInPtrWrite: %d\n", (int) bufferInPtrWrite);
2737 
2738  WFV = HWICAP[WFV_OFFSET];
2739  WFV_value = WFV & 0x7FF;
2740  //if (WFV_value == 0x7FF)
2741  if (WFV_value >= HWICAP_FIFO_DEPTH && (bufferInPtrNextRead > old_bufferInPtrNextRead))
2742  {
2743  //printf("FIFO is unexpected empty\n");
2744  fifoEmptyCnt++;
2745  }
2746 
2747  if(WFV_value <= HWICAP_FIFO_NEARLY_FULL_TRIGGER)
2748  {
2749  fifoFullCnt++;
2750  }
2751 
2752 
2754  {
2756  {//should always hit even pages....
2757  if (parseHTTP == 1)
2758  {
2759  ap_int<5> telomere = bufferInPtrMaxWrite - bufferInPtrNextRead + 1; //+1 because MaxWrite is already filled (not next write)
2760  printf("telomere: %d\n", (int) telomere);
2761 
2762  if (telomere != 0)
2763  {
2764  for(int j = 0; j<telomere; j++)
2765  {
2767  }
2768  bufferInPtrWrite = telomere;
2769  }
2770  if (telomere < 0)
2771  {
2772  printf("ERROR negativ telomere!\n");
2773  writeErrCnt++;
2774  }
2775  }
2776 
2777  bufferInPtrNextRead = 0;
2778  }
2779  }
2780 
2782  {
2783  //check for hangover
2785  {
2786  ap_int<5> telomere = bufferInPtrMaxWrite - bufferInPtrNextRead + 1; //+1 because MaxWrite is already filled (not next write)
2787  printf("telomere: %d\n", (int) telomere);
2788  assert(telomere >= 0 && telomere < 4);
2790  if(telomere > 0 && telomere < 4)
2791  {
2792  printf("hangover bytes: 0x");
2793  for(int j = 0; j<telomere; j++)
2794  {
2796  printf("%02x ",(int) buffer_hangover_bytes[j]);
2797  }
2798  hwicap_hangover_present = true;
2799  hwicap_hangover_size = telomere;
2800  printf("\nBuffer hangover with size %d\n", (int) hwicap_hangover_size);
2801  } else if(telomere != 0)
2802  { //in theory, should never happen
2803  printf("invalid telomere count!\n");
2804  writeErrCnt++;
2805  }
2806  //in all cases
2807  bufferInPtrNextRead = 0;
2808  }
2809  }
2810  printf("after UPDATE bufferInPtrNextRead: %d\n", (int) bufferInPtrNextRead);
2811 
2812  if(lastReturnValue == OPRV_DONE || last_xmem_page_received_persistent == 1)
2813  { //pass done
2814  lastReturnValue = OPRV_DONE;
2815  } else if(bufferInPtrNextRead == old_bufferInPtrNextRead)
2816  {
2817  lastReturnValue = OPRV_NOT_COMPLETE;
2818  } else {
2819  lastReturnValue = OPRV_OK;
2820  }
2821  }
2822  break;
2823 
2824  case OP_FIFO_TO_HWICAP:
2825  if(fsmHwicap == ICAP_FSM_IDLE)
2826  {
2829  lastReturnValue = OPRV_NOT_COMPLETE;
2830  printf("started HWICAP FIFO FSM");
2831  } else if(fsmHwicap == ICAP_FSM_DONE)
2832  {
2833  //now, wait for HWICAP
2834  CR = HWICAP[CR_OFFSET];
2835  CR_value = CR & 0x1F;
2836  CR_isWriting = CR_value & CR_WRITE;
2837  WFV = HWICAP[WFV_OFFSET];
2838  WFV_value = WFV & 0x7FF;
2839  if(WFV_value < 0x3FF && CR_isWriting != 1 && flag_enable_fake_hwicap == 0)
2840  {
2841  lastReturnValue = OPRV_NOT_COMPLETE;
2843  } else {
2844  lastReturnValue = OPRV_DONE;
2847  }
2848  } else if(fsmHwicap == ICAP_FSM_ERROR || fsmHwicap == ICAP_FSM_DRAIN)
2849  {
2850  lastReturnValue = OPRV_FAIL;
2853  } else {
2854  //we are doing smth
2855  lastReturnValue = OPRV_OK;
2856  }
2857  break;
2858 
2859  case OP_BUFFER_TO_PYROLINK:
2860 #ifdef INCLUDE_PYROLINK
2861  //TODO handle swapping / Big Endiannes?
2862 
2863  if(*disable_pyro_link == 0) //to avoid blocking...
2864  {
2865  if(lastReturnValue == OPRV_DONE || last_xmem_page_received_persistent == 1)
2866  { //pass done
2867  lastReturnValue = OPRV_DONE;
2868  } else {
2869  lastReturnValue = OPRV_OK; //overwrite later if necessary
2870  }
2871 
2872  //printf("OP_BUFFER_TO_PYROLINK: bufferInPtrNextRead %d, bufferInPtrMaxWrite %d\n", (int) bufferInPtrNextRead, (int) bufferInPtrMaxWrite);
2873  uint32_t i = 0;
2874  for(i = bufferInPtrNextRead; i <= bufferInPtrMaxWrite; i++)
2875  {
2876  if(!soPYROLINK.full())
2877  {
2878  Axis<8> tmp = Axis<8>(bufferIn[i]);
2879  tmp.tkeep = 1;
2880  if( last_xmem_page_received_persistent == 1 && i == bufferInPtrMaxWrite ) //not -1, because both is 0 based
2881  {
2882  tmp.tlast = 1;
2883  //no break necessary, this should anyway be the last rount
2884  } else {
2885  tmp.tlast = 0;
2886  }
2887 
2888  soPYROLINK.write(tmp);
2889 
2890  } else {
2891  lastReturnValue = OPRV_NOT_COMPLETE;
2892  //TODO: must we i--?
2893  break;
2894  }
2895  }
2896  bufferInPtrNextRead = i;
2897  } else {
2898  lastReturnValue = OPRV_FAIL;
2899  }
2900 #endif
2901  break;
2902 
2903  case OP_BUFFER_TO_ROUTING:
2904  if (*disable_ctrl_link == 0)
2905  {
2907 
2908  int i = bufferInPtrNextRead;
2910 
2911  need_to_update_nrc_mrt = true;
2912 
2913  if(bodyLen > 0)
2914  { //body is complete here
2915  maxWhile = bufferInPtrNextRead + bodyLen; //bodyLen is WITHOUT the actual footer
2916  lastReturnValue = OPRV_DONE;
2918  } else {
2919  lastReturnValue = OPRV_NOT_COMPLETE;
2920  }
2921 
2922  printf("nextRead: %d, maxWhile %d, notToSwap %d\n", i, maxWhile, (int) notToSwap);
2923 
2924  while(i<maxWhile)
2925  {
2926  char* intStart = (char*) &bufferIn[i];
2927  int intLen = my_wordlen(intStart);
2928  if(i + intLen + 1 + 4 + 1> bufferInPtrMaxWrite) //1: space, 4: IPv4 address 1: \n (now we know the actual length)
2929  {
2930  //TODO
2931  break;
2932  }
2933  //looks like complete line is here
2934  ap_uint<32> rankID = (unsigned int) my_atoi(intStart, intLen);
2935  printf("intLen: %d, rankdID: %d\n", intLen, (unsigned int) rankID);
2936  i += intLen;
2937  i++; //space
2938  ap_uint<32> tmp = 0;
2939 
2940  if ( notToSwap == 1)
2941  {
2942  tmp |= (ap_uint<32>) bufferIn[i + 0];
2943  tmp |= (((ap_uint<32>) bufferIn[i + 1]) << 8);
2944  tmp |= (((ap_uint<32>) bufferIn[i + 2]) << 16);
2945  tmp |= (((ap_uint<32>) bufferIn[i + 3]) << 24);
2946  } else {
2947  //default
2948  tmp |= (ap_uint<32>) bufferIn[i + 3];
2949  tmp |= (((ap_uint<32>) bufferIn[i + 2]) << 8);
2950  tmp |= (((ap_uint<32>) bufferIn[i + 1]) << 16);
2951  tmp |= (((ap_uint<32>) bufferIn[i + 0]) << 24);
2952  }
2953  i+= 4;
2954 
2955  i++; //newline
2956 
2957  if(rankID >= MAX_CLUSTER_SIZE)
2958  { //ignore and return 422
2960  lastReturnValue = OPRV_DONE;
2961  need_to_update_nrc_mrt = false;
2963  printf("invalid routing table detected.\n");
2964  break;
2965  }
2966  //dont' check for current cluster size!
2967  //it could be that the CFRM want's to override the entries of removed nodes
2968 
2969  //transfer to NRC:
2970  current_MRT[rankID] = tmp;
2971  if(rankID > max_discovered_node_id)
2972  {
2973  max_discovered_node_id = rankID;
2974  printf("max_discovered_node_id: %d\n", (int) max_discovered_node_id);
2975  }
2976  //lastaddressWrittenToNRC = tmp;
2977  //lastNIDWrittentoNRC = rankID;
2978  printf("writing on address %d to NRC: %#010x\n",(unsigned int) rankID, (int) tmp);
2979  }
2980 
2981  bufferInPtrNextRead = i; //NOT i + x, because that is already done by the for loop!
2982  //return value already set!
2983  } else {
2984  lastReturnValue = OPRV_FAIL;
2985  transferError_persistent = true;
2986  }
2987  break;
2988 
2990  need_to_update_nrc_mrt = true;
2992  for(int i = 0; i < max_discovered_node_id; i++)
2993  {
2994  current_MRT[i] = 0x0;
2995  }
2996  //lastReturnValue unchanged
2997  break;
2998 
3000 #ifdef INCLUDE_PYROLINK
3001  if(*disable_pyro_link == 0)
3002  {
3003  int i = 0;
3004  if(!siPYROLINK.empty())
3005  {
3006  lastReturnValue = OPRV_OK; //overwrite if necessary
3007 
3008  //printf("bufferOutPtrWrite: %d\n", (int) bufferOutPtrWrite);
3009 
3010  for(i = bufferOutPtrWrite; i<IN_BUFFER_SIZE; i++)
3011  {
3012  if(!siPYROLINK.empty())
3013  {
3014  Axis<8> tmp = siPYROLINK.read();
3015  if (tmp.tkeep != 1)
3016  {//skip it
3017  i--;
3018  continue;
3019  }
3020  bufferOut[bufferOutPtrWrite + i] = tmp.tdata;
3021  if(tmp.tlast == 1)
3022  {
3023  lastReturnValue = OPRV_DONE;
3024  break;
3025  }
3026  }
3027  }
3028  bufferOutPtrWrite += i + 1; //where to write NEXT
3029  bufferOutContentLength = bufferOutPtrWrite; //still plus 1, because it's a length
3030  } else {
3031  //we didn't receive anything
3032  lastReturnValue = OPRV_NOT_COMPLETE;
3033  }
3034 
3035  } else {
3036  lastReturnValue = OPRV_FAIL;
3037  }
3038 #endif
3039  break;
3040 
3041  case OP_SEND_TCP_SESS:
3042  //if we are in an OPRV_DONE "state": we just start the TX FSM and then go to "success"
3043  //the global state will wait until all TCP FSMs are done before it starts over
3044  //The TX FSMs block on sending, after the FMC ISA finished...so this OP-code is for triggering the FSM to start to work
3046  {
3048  {
3050  if(lastReturnValue != OPRV_DONE)
3051  {
3052  lastReturnValue = OPRV_NOT_COMPLETE;
3053  }
3054  } else if(fsmTcpSessId_TX == TCP_FSM_DONE)
3055  {
3056  if(lastReturnValue != OPRV_DONE)
3057  {
3058  lastReturnValue = OPRV_OK;
3059  }
3063  } else {//we still wait
3064  if(lastReturnValue != OPRV_DONE)
3065  {
3066  lastReturnValue = OPRV_NOT_COMPLETE;
3067  }
3068  }
3069  } else {
3070  if(lastReturnValue != OPRV_DONE)
3071  {
3072  lastReturnValue = OPRV_OK;
3073  }
3074  }
3075  break;
3076 
3077  case OP_SEND_BUFFER_TCP:
3078  //if we are in an OPRV_DONE "state": we just start the TX FSM and then go to "success"
3079  //the global state will wait until all TCP FSMs are done before it starts over
3080  //The TX FSMs block on sending, after the FMC ISA finished...so this OP-code is for triggering the FSM to start to work
3082  {
3084  if(lastReturnValue != OPRV_DONE)
3085  {
3086  lastReturnValue = OPRV_NOT_COMPLETE;
3087  }
3088  } else if(fsmTcpData_TX == TCP_FSM_DONE)
3089  {
3091  lastReturnValue = OPRV_DONE;
3093  {//looks like there are no news
3094  if(lastReturnValue != OPRV_DONE)
3095  {
3096  lastReturnValue = OPRV_NOT_COMPLETE;
3097  }
3098  } else {
3099  if(lastReturnValue != OPRV_DONE)
3100  {
3101  lastReturnValue = OPRV_OK;
3102  }
3103  }
3105  break;
3106 
3107  case OP_SEND_BUFFER_XMEM:
3108  {
3109  uint8_t pageCnt = bytesToPages(bufferOutContentLength, true);
3110  copyOutBuffer(pageCnt,xmem);
3111 
3112  if(lastReturnValue == OPRV_DONE)
3113  { //pass done
3114  lastReturnValue = OPRV_DONE;
3115  } else {
3116  lastReturnValue = OPRV_OK;
3117  }
3118  }
3119  break;
3120 
3121  case OP_CLEAR_IN_BUFFER:
3122  emptyInBuffer();
3123  lastReturnValue = OPRV_OK;
3124  break;
3125 
3126  case OP_CLEAR_OUT_BUFFER:
3127  emptyOutBuffer();
3128  lastReturnValue = OPRV_OK;
3129  break;
3130 
3131  case OP_ACTIVATE_DECOUP:
3132  toDecoup_persistent = 1;
3133  lastReturnValue = OPRV_OK;
3134  break;
3135 
3136  case OP_DEACTIVATE_DECOUP:
3137  toDecoup_persistent = 0;
3138  if(lastReturnValue == OPRV_DONE)
3139  { //pass done
3140  lastReturnValue = OPRV_DONE;
3141  } else {
3142  lastReturnValue = OPRV_OK;
3143  }
3144  break;
3145 
3146  case OP_ABORT_HWICAP:
3148  transferError_persistent = true;
3149  wasAbort = 1;
3150  lastReturnValue = OPRV_OK;
3151  break;
3152 
3153  case OP_FAIL:
3154  lastReturnValue = OPRV_FAIL;
3155  break;
3156 
3157  case OP_DONE:
3158  lastReturnValue = OPRV_DONE;
3159  //break progLoop; //does this work?
3160  break;
3161 
3162  case OP_OK:
3163  lastReturnValue = OPRV_OK;
3164  break;
3165 
3166  case OP_EXIT:
3167  //lastReturnValue unchanged
3168  progCnt = MAX_PROGRAM_LENGTH;
3169  break;
3170 
3171  } //switch
3172  } //prog loop
3173 
3174 
3175  // ++++++++++++++++++ UPDATE OPERATIONS ++++++++++++++++
3176 
3177  switch(currentGlobalOperation)
3178  {
3179  default: //no break, just for default
3180  case GLOBAL_IDLE:
3181  //nothing to do
3182  break;
3183 
3185  //OPRV_NOT_COMPLETE, OPRV_PARTIAL_COMPLETE --> continue
3186  if(lastReturnValue == OPRV_DONE)
3187  {//received last page
3188  //Displays are set in daily task
3189  //ATTENTION: we only change state if input changes
3191  } else if(lastReturnValue == OPRV_FAIL)
3192  {
3193  transferError_persistent = true;
3194  }
3195  break;
3196 
3197  case GLOBAL_XMEM_TO_HWICAP:
3198  if(lastReturnValue == OPRV_DONE)
3199  {//looks like we are done
3200  //Displays are set in daily task
3202  }
3203  if(lastReturnValue == OPRV_FAIL)
3204  {
3205  transferError_persistent = true;
3206  }
3207  break;
3208 
3209  case GLOBAL_XMEM_HTTP:
3210  if(lastReturnValue == OPRV_DONE)
3211  {//looks like we are done
3212  //Displays are set in daily taksk
3214  }
3215  if(lastReturnValue == OPRV_FAIL)
3216  {
3217  transferError_persistent = true;
3218  }
3219  break;
3220 
3221  case GLOBAL_TCP_HTTP:
3222  // continue in this mode when HTTP_IDLE and environment not changed
3223  if(lastReturnValue == OPRV_DONE)
3224  {//looks like we are done
3225  //Displays are set in daily taksk
3227  msg="SUC";
3228  }
3229  if(lastReturnValue == OPRV_FAIL)
3230  {
3231  transferError_persistent = true;
3232  msg="ERR";
3233  }
3234  if(lastReturnValue == OPRV_NOT_COMPLETE)
3235  {
3236  msg="WAT";
3237  }
3238  if(globalOperationDone_persistent && (lastReturnValue != OPRV_DONE))
3239  {//we wait for the TCP FSM's to finish..
3240  msg="WFF";
3241  }
3242  break;
3243 
3244  case GLOBAL_PYROLINK_RECV: //i.e. Coaxium to FPGA
3245  if(lastReturnValue == OPRV_DONE)
3246  {//looks like we are done
3247  //Displays are set in daily tasks
3249  }
3250  if(lastReturnValue == OPRV_FAIL)
3251  {
3252  transferError_persistent = true;
3253  }
3254  if(lastReturnValue == OPRV_NOT_COMPLETE)
3255  {
3257  } else {
3259  }
3260  break;
3261 
3262  case GLOBAL_PYROLINK_TRANS: //i.e. FPGA to Coaxium
3263  if(lastReturnValue == OPRV_DONE)
3264  {//looks like we are done
3265  //Displays are set in daily tasks
3267  pyroSendRequestBit = 0;
3268  }
3269  if(lastReturnValue == OPRV_FAIL)
3270  {
3271  transferError_persistent = true;
3272  }
3273  if(lastReturnValue == OPRV_NOT_COMPLETE)
3274  {
3276  } else {
3278  }
3279  //OPRV_OK --> we need another round
3280  break;
3281 
3283  //nothing to do
3284  break;
3285  }
3286 
3287 
3288  // ++++++++++++++++++ EVERY-DAY JOBS ++++++++++++++++++++
3289 
3290  if( wasAbort == 1)
3291  { //Abort occured in previous cycle
3292  msg = "ABR";
3293  }
3294 
3295  // SOFT RESET
3296  *setSoftReset = (MMIO_in_LE >> SOFT_RST_SHIFT) & 0b1;
3297 
3298  //===========================================================
3299  // Decoupling
3300 
3301  if ( toDecoup_persistent == 1 || wasAbort == 1)
3302  {
3303  *setDecoup = 0b1;
3304 } else {
3305  *setDecoup = 0b0;
3306 }
3307 
3308 //===========================================================
3309 // Set RANK and SIZE
3310 
3311 *role_rank = nodeRank;
3313 
3314 
3315 //===========================================================
3316 // connection to NRC
3317 
3318 //to not overwrite NRC updates
3319 if((*disable_ctrl_link == 0) && (*layer_4_enabled == 0) && tables_initialized )
3320 {
3321  //reset of NTS closes ports
3325  need_to_update_nrc_config = false; //the NRC know this too
3326 }
3327 
3328 if((*disable_ctrl_link == 0) && (*layer_6_enabled == 1) && tables_initialized //to avoid blocking...
3329  && !fifo_operation_in_progress //to avoid delays of PR
3330  )
3331 { //and we need valid tables
3332 
3333  nal_status_disabled = false;
3334 
3335  switch (linkCtrlFSM)
3336  {
3337  case LINKFSM_IDLE:
3340  {
3342  }
3344  break;
3345 
3346  case LINKFSM_WAIT:
3348  {
3350  }
3351  else if(need_to_update_nrc_mrt)
3352  {
3353  mrt_copy_index = 0;
3355  }
3357  {
3360  }
3361  break;
3362 
3363  case LINKFSM_UPDATE_CONFIG:
3364  //e.g. to recover from a reset
3369  need_to_update_nrc_config = false;
3371  break;
3372 
3373  case LINKFSM_UPDATE_MRT:
3374  printf("linkFSM: updating entry %d with value 0x%08x; max_discovered_node_id: %d\n",(int) mrt_copy_index, (int) current_MRT[mrt_copy_index], (int) max_discovered_node_id);
3376  mrt_copy_index++;
3377 
3379  {
3381  need_to_update_nrc_mrt = false;
3383  }
3384  break;
3385 
3386  case LINKFSM_UPDATE_STATE:
3390  {
3392  {
3393  need_to_update_nrc_mrt = true;
3394  need_to_update_nrc_config = true; //better to do both
3396  }
3398  {
3401  } else {
3403  }
3404  }
3405  break;
3407  //indicies don't match: need to to manually
3412  break;
3413  }
3414  printf("ctrlLINK FSM: %d\n", linkCtrlFSM);
3415 
3416  } else {
3417  //ctrlLink disabled
3418  //hex for "DISABLED"
3419  nal_status_disabled = true;
3420  nal_status[0] = 0x44495341;
3421  nal_status[1] = 0x424c4544;
3422  }
3423 
3424 
3425  //===========================================================
3426  // putting displays together
3427 
3428 
3429  ap_uint<4> Dsel = 0;
3430 
3431  Dsel = (MMIO_in_LE >> DSEL_SHIFT) & 0xF;
3432 
3433  Display1 = (WEMPTY << WEMPTY_SHIFT) | (HWICAP_Done << DONE_SHIFT) | EOS;
3434  Display1 |= WFV_value << WFV_V_SHIFT;
3435  Display1 |= ((ap_uint<32>) decoupStatus) << DECOUP_SHIFT;
3436  Display1 |= ((ap_uint<32>) tcpModeEnabled) << TCP_OPERATION_SHIFT;
3437  Display1 |= ((ap_uint<32>) ASW1) << ASW1_SHIFT;
3438  Display1 |= ((ap_uint<32>) CR_value) << CMD_SHIFT;
3439 
3440  Display2 = ((ap_uint<32>) ASW2) << ASW2_SHIFT;
3441  Display2 |= ((ap_uint<32>) ASW3) << ASW3_SHIFT;
3442  Display2 |= ((ap_uint<32>) ASW4) << ASW4_SHIFT;
3443  Display2 |= ((ap_uint<32>) notToSwap) << NOT_TO_SWAP_SHIFT;
3444 
3445  Display3 = ((ap_uint<32>) xmem_page_trans_cnt) << RCNT_SHIFT;
3446  Display3 |= ((ap_uint<32>) msg[0]) << MSG_SHIFT + 16;
3447  Display3 |= ((ap_uint<32>) msg[1]) << MSG_SHIFT + 8;
3448  Display3 |= ((ap_uint<32>) msg[2]) << MSG_SHIFT + 0;
3449 
3450  Display4 = ((ap_uint<32>) responePageCnt) << ANSWER_LENGTH_SHIFT;
3452  Display4 |= ((ap_uint<32>) writeErrCnt) << WRITE_ERROR_CNT_SHIFT;
3453  Display4 |= ((ap_uint<32>) fifoEmptyCnt) << EMPTY_FIFO_CNT_SHIFT;
3454  Display4 |= ((ap_uint<32>) currentGlobalOperation) << GLOBAL_STATE_SHIFT;
3455 
3456  Display5 = (ap_uint<32>) wordsWrittenToIcapCnt;
3457 
3461  Display6 |= ((ap_uint<32>) pyroSendRequestBit) << PYRO_SEND_REQUEST_SHIFT;
3462 
3463  Display7 = ((ap_uint<32>) fsmTcpSessId_RX) << RX_SESS_STATE_SHIFT;
3464  Display7 |= ((ap_uint<32>) fsmTcpData_RX) << RX_DATA_STATE_SHIFT;
3465  Display7 |= ((ap_uint<32>) fsmTcpSessId_TX) << TX_SESS_STATE_SHIFT;
3466  Display7 |= ((ap_uint<32>) fsmTcpData_TX) << TX_DATA_STATE_SHIFT;
3467  Display7 |= ((ap_uint<32>) tcp_iteration_count) << TCP_ITER_COUNT_SHIFT;
3468  Display7 |= ((ap_uint<32>) detected_http_nl_cnt) << DETECTED_HTTPNL_SHIFT;
3469 
3470  Display8 = (ap_uint<32>) tcp_words_received;
3471 
3472  Display9 = (bufferInPtrMaxWrite & 0x000FFFFF) << BUFFER_IN_MAX_SHIFT;
3473  Display9 |= ((ap_uint<32>) fifoFullCnt) << FULL_FIFO_CNT_SHIFT;
3474  Display9 |= ((ap_uint<32>) fsmHwicap) << ICAP_FSM_SHIFT;
3475 
3476  ap_uint<32> MMIO_out_LE = 0x0;
3477 
3478  switch (Dsel) {
3479  case 1:
3480  MMIO_out_LE = (0x1 << DSEL_SHIFT) | Display1;
3481  break;
3482  case 2:
3483  MMIO_out_LE = (0x2 << DSEL_SHIFT) | Display2;
3484  break;
3485  case 3:
3486  MMIO_out_LE = (0x3 << DSEL_SHIFT) | Display3;
3487  break;
3488  case 4:
3489  MMIO_out_LE = (0x4 << DSEL_SHIFT) | Display4;
3490  break;
3491  case 5:
3492  MMIO_out_LE = (0x5 << DSEL_SHIFT) | Display5;
3493  break;
3494  case 6:
3495  MMIO_out_LE = (0x6 << DSEL_SHIFT) | Display6;
3496  break;
3497  case 7:
3498  MMIO_out_LE = (0x7 << DSEL_SHIFT) | Display7;
3499  break;
3500  case 8:
3501  MMIO_out_LE = (0x8 << DSEL_SHIFT) | Display8;
3502  break;
3503  case 9:
3504  MMIO_out_LE = (0x9 << DSEL_SHIFT) | Display9;
3505  break;
3506  default:
3507  MMIO_out_LE = 0xBEBAFECA;
3508  break;
3509  }
3510 
3511  ap_uint<32> MMIO_out_BE = 0x0;
3512  MMIO_out_BE = (ap_uint<32>) ((MMIO_out_LE >> 24) & 0xFF);
3513  MMIO_out_BE |= (ap_uint<32>) ((MMIO_out_LE >> 8) & 0xFF00);
3514  MMIO_out_BE |= (ap_uint<32>) ((MMIO_out_LE << 8) & 0xFF0000);
3515  MMIO_out_BE |= (ap_uint<32>) ((MMIO_out_LE << 24) & 0xFF000000);
3516 
3517  *MMIO_out = MMIO_out_BE;
3518 
3519  return;
3520 }
#define SIZE_SHIFT
Definition: fmc.hpp:72
#define RST_SHIFT
Definition: fmc.hpp:107
#define OPRV_USER
Definition: fmc.hpp:188
#define DECOUP_SHIFT
Definition: fmc.hpp:48
ap_uint< 1 > nts_ready
Definition: tb_fmc.cpp:69
#define DONE_SHIFT
Definition: fmc.hpp:46
uint8_t fsmTcpSessId_TX
Definition: fmc.cpp:137
#define LAST_PAGE_WRITE_CNT_SHIFT
Definition: fmc.hpp:73
#define FPGA_STATE_LAYER_4
Definition: fmc.hpp:215
uint8_t currentGlobalOperation
Definition: fmc.cpp:111
#define PYRO_MODE_SHIFT
Definition: fmc.hpp:115
ap_uint< 8 > writeErrCnt
Definition: fmc.cpp:39
#define RANK_SHIFT
Definition: fmc.hpp:71
#define DETECTED_HTTPNL_SHIFT
Definition: fmc.hpp:82
#define LAST_PAGE_CNT_SHIFT
Definition: fmc.hpp:119
uint32_t positions_of_detected_http_nl[4]
Definition: fmc.cpp:148
ap_uint< 4 > received_TCP_SessIds_cnt
Definition: fmc.cpp:142
bool run_nested_loop_helper
Definition: fmc.cpp:140
AppMeta currentTcpSessId
Definition: fmc.cpp:122
#define OP_CLEAR_OUT_BUFFER
Definition: fmc.hpp:251
ap_uint< 1 > layer_7_enabled
Definition: tb_fmc.cpp:68
#define RX_SESS_STATE_SHIFT
Definition: fmc.hpp:77
void copyOutBuffer(ap_uint< 4 > numberOfPages, ap_uint< 32 > xmem[(32 *16)])
Definition: fmc.cpp:201
ap_uint< 1 > disable_pyro_link
Definition: tb_fmc.cpp:92
ap_uint< 28 > tcp_words_received
Definition: fmc.cpp:76
#define PARSE_HTTP_SHIFT
Definition: fmc.hpp:113
ap_uint< 8 > nts_tcp_crc_drop_cnt
Definition: fmc.cpp:103
#define OP_HANDLE_HTTP
Definition: fmc.hpp:242
#define OP_BUFFER_TO_PYROLINK
Definition: fmc.hpp:246
#define OP_TCP_RX_STOP_ON_EOP
Definition: fmc.hpp:272
ap_uint< 1 > last_xmem_page_received_persistent
Definition: fmc.cpp:131
#define TX_SESS_STATE_SHIFT
Definition: fmc.hpp:79
#define OP_BUFFER_TO_ROUTING
Definition: fmc.hpp:247
ap_uint< 4 > copyAndCheckBurst(ap_uint< 32 > xmem[(32 *16)], ap_uint< 4 > ExpCnt, ap_uint< 7 > lastPageCnt_in)
Definition: fmc.cpp:464
#define HTTP_REQUEST_COMPLETE
Definition: fmc.hpp:162
#define OP_DISABLE_XMEM_CHECK_PATTERN
Definition: fmc.hpp:253
ap_uint< 8 > nts_tcp_notif_drop_cnt
Definition: fmc.cpp:100
#define OP_COPY_REQTYPE_TO_RETURN
Definition: fmc.hpp:259
bool nal_status_disabled
Definition: fmc.cpp:85
#define OP_DONE
Definition: fmc.hpp:252
uint8_t linkCtrlFSM
Definition: fmc.cpp:162
uint8_t fsmTcpData_RX
Definition: fmc.cpp:138
#define CHECK_CTRL_LINK_INTERVAL_SECONDS
Definition: fmc.hpp:223
#define OP_DEACTIVATE_DECOUP
Definition: fmc.hpp:255
#define OprvType
Definition: fmc.hpp:181
#define CR_WRITE
Definition: fmc.hpp:141
ap_uint< 8 > nts_tcp_meta_drop_cnt
Definition: fmc.cpp:101
#define OP_SEND_BUFFER_XMEM
Definition: fmc.hpp:249
ap_uint< 32 > clusterSize
Definition: fmc.cpp:79
#define OP_ACTIVATE_CONT_TCP
Definition: fmc.hpp:269
#define OP_BUFFER_TO_HWICAP
Definition: fmc.hpp:245
#define HTTP_HEADER_PARSED
Definition: fmc.hpp:160
#define TCP_ITER_COUNT_SHIFT
Definition: fmc.hpp:81
ap_uint< 8 > fifoFullCnt
Definition: fmc.cpp:41
ap_uint< 32 > Display7
Definition: fmc.cpp:74
#define OP_ENABLE_XMEM_CHECK_PATTERN
Definition: fmc.hpp:239
#define OP_TCP_CNT_RESET
Definition: fmc.hpp:273
#define OP_NOP
Definition: fmc.hpp:238
ap_uint< 32 > Display1
Definition: fmc.cpp:74
#define OP_CLEAR_ROUTING_TABLE
Definition: fmc.hpp:275
#define GLOBAL_XMEM_CHECK_PATTERN
Definition: fmc.hpp:170
ap_uint< 1 > flag_silent_skip
Definition: fmc.cpp:130
#define GLOBAL_XMEM_TO_HWICAP
Definition: fmc.hpp:171
#define FULL_FIFO_CNT_SHIFT
Definition: fmc.hpp:89
#define OP_WAIT_FOR_TCP_SESS
Definition: fmc.hpp:265
ap_uint< 32 > max_discovered_node_id
Definition: fmc.cpp:163
#define ENABLE_TCP_MODE_SHIFT
Definition: fmc.hpp:117
#define FPGA_STATE_CONFIG_UPDATE
Definition: fmc.hpp:218
ap_uint< 1 > disable_ctrl_link
Definition: tb_fmc.cpp:91
#define HTTP_IDLE
Definition: fmc.hpp:158
ap_uint< 32 > nal_status[16]
Definition: fmc.cpp:84
ap_uint< 32 > mrt_copy_index
Definition: fmc.cpp:90
#define OP_DEACTIVATE_CONT_TCP
Definition: fmc.hpp:270
#define GLOBAL_PYROLINK_RECV
Definition: fmc.hpp:174
#define OP_SEND_TCP_SESS
Definition: fmc.hpp:266
ap_uint< 16 > current_role_mmio
Definition: fmc.cpp:93
#define FPGA_STATE_MRT_UPDATE
Definition: fmc.hpp:219
ap_uint< 32 > ctrl_link_next_check_seconds
Definition: fmc.cpp:88
#define ICAP_FSM_DONE
Definition: fmc.hpp:205
#define SOFT_RST_SHIFT
Definition: fmc.hpp:114
void emptyInBuffer()
Definition: fmc.cpp:217
#define HTTP_SEND_RESPONSE
Definition: fmc.hpp:163
#define RCNT_SHIFT
Definition: fmc.hpp:60
#define PYRO_READ_REQUEST_SHIFT
Definition: fmc.hpp:116
#define HWICAP_FIFO_NEARLY_FULL_TRIGGER
Definition: fmc.hpp:145
ap_uint< 8 > nts_tcp_ooo_drop_cnt
Definition: fmc.cpp:105
#define OP_ABORT_HWICAP
Definition: fmc.hpp:256
#define CMD_SHIFT
Definition: fmc.hpp:49
ap_uint< 8 > nts_tcp_data_drop_cnt
Definition: fmc.cpp:102
#define WFV_OFFSET
Definition: fmc.hpp:96
#define WF_OFFSET
Definition: fmc.hpp:100
bool transferError_persistent
Definition: fmc.cpp:114
#define ASW3_SHIFT
Definition: fmc.hpp:55
bool TcpSessId_updated_persistent
Definition: fmc.cpp:123
#define ISR_OFFSET
Definition: fmc.hpp:95
ap_uint< 1 > flag_enable_fake_hwicap
Definition: fmc.cpp:133
uint8_t fsmTcpSessId_RX
Definition: fmc.cpp:136
#define SWAP_N_SHIFT
Definition: fmc.hpp:111
#define ASW4_SHIFT
Definition: fmc.hpp:56
#define ICAP_FSM_RESET
Definition: fmc.hpp:202
#define MASK_ALWAYS
Definition: fmc.hpp:189
ap_uint< 32 > MMIO_out_BE
Definition: tb_fmc.cpp:65
ap_uint< 32 > Display6
Definition: fmc.cpp:74
#define TCP_FSM_ERROR
Definition: fmc.hpp:197
void parseHttpInput(bool transferErr, ap_uint< 1 > wasAbort, bool invalidPayload, bool rx_done)
Definition: http.cpp:401
#define BUFFER_IN_MAX_SHIFT
Definition: fmc.hpp:88
#define CHECK_PATTERN_SHIFT
Definition: fmc.hpp:112
ap_uint< 8 > fpga_status[8]
Definition: fmc.cpp:87
#define LINKFSM_UPDATE_MRT
Definition: fmc.hpp:228
#define OP_EXIT
Definition: fmc.hpp:260
ap_uint< 8 > fifoEmptyCnt
Definition: fmc.cpp:40
#define GLOBAL_MANUAL_DECOUPLING
Definition: fmc.hpp:176
#define GLOBAL_STATE_SHIFT
Definition: fmc.hpp:68
ap_uint< 1 > flag_continuous_tcp_rx
Definition: fmc.cpp:132
uint8_t httpState
Definition: fmc.cpp:72
ap_uint< 8 > nal_status_request_cnt
Definition: fmc.cpp:83
ap_uint< 32 > fpga_time_hours
Definition: fmc.cpp:97
#define ICAP_FIFO_POISON_PILL
Definition: fmc.hpp:209
#define GLOBAL_TCP_HTTP
Definition: fmc.hpp:173
#define OP_XMEM_COPY_DATA
Definition: fmc.hpp:240
#define TCP_FSM_PROCESS_DATA
Definition: fmc.hpp:195
#define OP_FILL_BUFFER_TCP
Definition: fmc.hpp:241
#define TX_DATA_STATE_SHIFT
Definition: fmc.hpp:80
#define HWICAP_FIFO_DEPTH
Definition: fmc.hpp:143
#define OP_ACTIVATE_DECOUP
Definition: fmc.hpp:254
ap_uint< 32 > current_nrc_config[16]
Definition: fmc.cpp:158
#define LINKFSM_UPDATE_SAVED_STATE
Definition: fmc.hpp:231
ap_uint< 1 > layer_4_enabled
Definition: tb_fmc.cpp:66
#define OPRV_OK
Definition: fmc.hpp:182
#define ICAP_FSM_DRAIN
Definition: fmc.hpp:207
#define TCP_FSM_RESET
Definition: fmc.hpp:192
#define MAX_PROGRAM_LENGTH
Definition: fmc.hpp:278
#define HTTP_PARSE_HEADER
Definition: fmc.hpp:159
ap_uint< 32 > Display4
Definition: fmc.cpp:74
#define OP_SET_NOT_TO_SWAP
Definition: fmc.hpp:267
#define MSG_SHIFT
Definition: fmc.hpp:61
#define ASW2_SHIFT
Definition: fmc.hpp:54
#define ENABLE_FAKE_HWICAP_SHIFT
Definition: fmc.hpp:118
#define OPRV_DONE
Definition: fmc.hpp:187
#define TCP_FSM_W84_START
Definition: fmc.hpp:194
#define LINKFSM_UPDATE_CONFIG
Definition: fmc.hpp:229
#define ICAP_FSM_SHIFT
Definition: fmc.hpp:90
#define LINKFSM_WAIT
Definition: fmc.hpp:227
ap_uint< 32 > current_nrc_mrt_version
Definition: fmc.cpp:159
#define OP_TCP_RX_STOP_ON_EOR
Definition: fmc.hpp:271
ap_uint< 1 > tcpModeEnabled
Definition: fmc.cpp:124
ap_uint< 32 > global_state_wait_counter_persistent
Definition: fmc.cpp:120
#define LINKFSM_UPDATE_STATE
Definition: fmc.hpp:230
uint32_t sequential_hwicap_address
Definition: fmc.cpp:68
#define OPRV_NOT_COMPLETE
Definition: fmc.hpp:185
bool need_to_update_nrc_config
Definition: fmc.cpp:161
#define OP_UPDATE_HTTP_STATE
Definition: fmc.hpp:258
ap_uint< 1 > layer_6_enabled
Definition: tb_fmc.cpp:67
#define GLOBAL_IDLE
Definition: fmc.hpp:169
#define GLOBAL_XMEM_HTTP
Definition: fmc.hpp:172
#define EMPTY_FIFO_CNT_SHIFT
Definition: fmc.hpp:67
ap_uint< 32 > Display3
Definition: fmc.cpp:74
#define ANSWER_LENGTH_SHIFT
Definition: fmc.hpp:64
bool axi_wasnot_ready_persistent
Definition: fmc.cpp:119
#define OP_SEND_BUFFER_TCP
Definition: fmc.hpp:248
#define CR_ABORT
Definition: fmc.hpp:137
bool invalidPayload_persistent
Definition: fmc.cpp:115
#define ASR_OFFSET
Definition: fmc.hpp:97
#define LINKFSM_IDLE
Definition: fmc.hpp:226
#define OPRV_FAIL
Definition: fmc.hpp:183
#define OP_CHECK_HTTP_EOR
Definition: fmc.hpp:243
ap_uint< 16 > nts_udp_drop_cnt
Definition: fmc.cpp:99
ap_uint< 32 > current_MRT[64]
Definition: fmc.cpp:157
#define OPRV_PARTIAL_COMPLETE
Definition: fmc.hpp:186
bool tables_initialized
Definition: fmc.cpp:156
#define PYRO_SEND_REQUEST_SHIFT
Definition: fmc.hpp:74
#define TCP_FSM_IDLE
Definition: fmc.hpp:193
ap_uint< 32 > nodeRank
Definition: fmc.cpp:78
#define FPGA_STATE_LAYER_7
Definition: fmc.hpp:217
#define OP_UNSET_NOT_TO_SWAP
Definition: fmc.hpp:268
ap_uint< 1 > decoupStatus
Definition: tb_fmc.cpp:82
#define DSEL_SHIFT
Definition: fmc.hpp:108
ap_uint< 28 > wordsWrittenToIcapCnt
Definition: fmc.cpp:75
#define OP_PYROLINK_TO_OUTBUFFER
Definition: fmc.hpp:264
#define WFV_V_SHIFT
Definition: fmc.hpp:45
ap_uint< 1 > toDecoup_persistent
Definition: fmc.cpp:81
ap_uint< 32 > fpga_time_seconds
Definition: fmc.cpp:95
#define ICAP_FIFO_POISON_PILL_REVERSE
Definition: fmc.hpp:210
bool globalOperationDone_persistent
Definition: fmc.cpp:118
ap_uint< 32 > MMIO_in
Definition: tb_fmc.cpp:63
uint8_t fsmTcpData_TX
Definition: fmc.cpp:139
#define WRITE_ERROR_CNT_SHIFT
Definition: fmc.hpp:66
bool need_to_update_nrc_mrt
Definition: fmc.cpp:160
#define WEMPTY_SHIFT
Definition: fmc.hpp:47
#define OPRV_SKIPPED
Definition: fmc.hpp:184
uint8_t bytesToPages(int len, bool update_global_variables)
Definition: fmc.cpp:169
ap_uint< 32 > HWICAP[512]
Definition: tb_fmc.cpp:86
ap_uint< 32 > fpga_time_minutes
Definition: fmc.cpp:96
ap_uint< 32 > Display8
Definition: fmc.cpp:74
#define OP_FAIL
Definition: fmc.hpp:257
#define START_SHIFT
Definition: fmc.hpp:110
#define OP_CHECK_HTTP_EOP
Definition: fmc.hpp:244
#define DECOUP_CMD_SHIFT
Definition: fmc.hpp:106
#define OP_CLEAR_IN_BUFFER
Definition: fmc.hpp:250
#define OP_OK
Definition: fmc.hpp:263
#define ICAP_FSM_ERROR
Definition: fmc.hpp:206
void emptyOutBuffer()
Definition: fmc.cpp:255
ap_uint< 2 > detected_http_nl_cnt
Definition: fmc.cpp:146
#define FPGA_STATE_NTS_READY
Definition: fmc.hpp:220
bool goto_done_if_idle_tcp_rx
Definition: fmc.cpp:141
#define OP_ENABLE_SILENT_SKIP
Definition: fmc.hpp:261
#define HTTP_READ_PAYLOAD
Definition: fmc.hpp:161
#define GLOBAL_MAX_WAIT_COUNT
Definition: fmc.hpp:282
uint8_t tcp_iteration_count
Definition: fmc.cpp:125
#define OpcodeType
Definition: fmc.hpp:237
#define HTTP_DONE
Definition: fmc.hpp:165
#define NUMBER_FPGA_STATE_REGISTERS
Definition: fmc.hpp:214
#define TCP_FSM_DONE
Definition: fmc.hpp:196
ap_uint< 32 > Display9
Definition: fmc.cpp:74
#define SR_OFFSET
Definition: fmc.hpp:94
#define GLOBAL_PYROLINK_TRANS
Definition: fmc.hpp:175
#define HTTP_STATE_SHIFT
Definition: fmc.hpp:65
#define OP_FIFO_TO_HWICAP
Definition: fmc.hpp:274
#define OP_DISABLE_SILENT_SKIP
Definition: fmc.hpp:262
#define FPGA_STATE_LAYER_6
Definition: fmc.hpp:216
#define ICAP_FSM_WRITE
Definition: fmc.hpp:204
ap_uint< 32 > Display2
Definition: fmc.cpp:74
#define NOT_TO_SWAP_SHIFT
Definition: fmc.hpp:57
ap_uint< 8 > nts_tcp_sess_drop_cnt
Definition: fmc.cpp:104
uint8_t last_3_chars[3]
Definition: fmc.cpp:145
#define ASW1_SHIFT
Definition: fmc.hpp:50
ap_uint< 32 > nalCtrl[(0x3ff/4)]
Definition: tb_fmc.cpp:90
#define CR_OFFSET
Definition: fmc.hpp:98
ap_uint< 32 > Display5
Definition: fmc.cpp:74
#define MIN_ROUTING_TABLE_LINE
Definition: fmc.hpp:154
ap_uint< 2 > target_http_nl_cnt
Definition: fmc.cpp:147
#define HTTP_INVALID_REQUEST
Definition: fmc.hpp:164
#define RX_DATA_STATE_SHIFT
Definition: fmc.hpp:78
#define TCP_OPERATION_SHIFT
Definition: fmc.hpp:51
bool use_sequential_hwicap
Definition: fmc.cpp:67
ap_uint< 32 > cluster_size
#define NUMBER_CONFIG_WORDS
Definition: nal.hpp:191
#define NAL_CTRL_LINK_STATUS_START_ADDR
Definition: nal.hpp:85
#define NAL_STATUS_FMC_PORT_PROCESSED
Definition: nal.hpp:224
#define NAL_CONFIG_SAVED_FMC_PORTS
Definition: nal.hpp:219
#define NAL_CONFIG_SAVED_TCP_PORTS
Definition: nal.hpp:218
#define NAL_CTRL_LINK_MRT_START_ADDR
Definition: nal.hpp:87
#define NAL_STATUS_MRT_VERSION
Definition: nal.hpp:221
#define MAX_MRT_SIZE
Definition: nal.hpp:94
#define NAL_CTRL_LINK_CONFIG_START_ADDR
Definition: nal.hpp:83
#define NAL_CONFIG_SAVED_UDP_PORTS
Definition: nal.hpp:217
#define NAL_NUMBER_STATUS_WORDS
Definition: nal.hpp:194
#define NAL_STATUS_OWN_RANK
Definition: nal.hpp:225
#define NAL_CONFIG_MRT_VERSION
Definition: nal.hpp:216
#define NAL_CONFIG_OWN_RANK
Definition: nal.hpp:215
#define NAL_STATUS_OPEN_TCP_PORTS
Definition: nal.hpp:223
#define NAL_STATUS_OPEN_UDP_PORTS
Definition: nal.hpp:222
out
Definition: test.py:12
#define NETWORK_WORD_BYTE_WIDTH
Definition: network.hpp:45
TcpSessId AppMeta
ap_uint< 64 > tdata
Definition: network.hpp:49
ap_uint< 8 > tkeep
Definition: network.hpp:50
ap_uint< 1 > tlast
Definition: network.hpp:51
Here is the call graph for this function:
Here is the caller graph for this function:

◆ FMC_Debug_Pyrolink()

stream<Axis<8> > FMC_Debug_Pyrolink ( "FMC_Debug_Pyrolink"  )
Here is the caller graph for this function:

◆ icap_hangover_fifo()

stream<uint8_t> icap_hangover_fifo ( "sIcapHangoverFifo"  )
Here is the caller graph for this function:

◆ initBuffer()

void initBuffer ( ap_uint< 4 >  cnt,
ap_uint< 32 >  xmem[(32 * 16)],
bool  lastPage,
bool  withPattern 
)

Definition at line 241 of file tb_fmc.cpp.

242 {
243  ap_uint<32> ctrlWord = 0;
244  for(int i = 0; i<8; i++)
245  {
246  ctrlWord |= ((ap_uint<32>) cnt) << (i*4);
247  }
248 
249  for(int i = 0; i<LINES_PER_PAGE; i++)
250  {
251  if (withPattern)
252  {
253  xmem[i] = ctrlWord;
254  } else {
255  //xmem[i] = ctrlWord+i;
256  // xmem[i] = (ctrlWord << 16) + (rand() % 65536);
257  xmem[i] = (((ap_uint<32>) cnt) << 24) | 0x0A0B00 | ((ap_uint<32>) i);
258  }
259  }
260  //printf("CtrlWord: %#010x\n",(int) ctrlWord);
261 
262  //Set Header and Footer
263  ap_uint<8> header = (ap_uint<8>) cnt;
264  if (lastPage)
265  {
266  header |= 0xf0;
267  }
268  //ap_uint<32> headerLine = header | (ctrlWord & 0xFFFFFF00);
269  ap_uint<32> headerLine = header | (xmem[0] & 0xFFFFFF00);
270  //ap_uint<32> footerLine = (((ap_uint<32>) header) << 24) | (ctrlWord & 0x00FFFFFF);
271  ap_uint<32> footerLine = (((ap_uint<32>) header) << 24) | (xmem[LINES_PER_PAGE-1] & 0x00FFFFFF);
272  xmem[0] = headerLine;
273  xmem[LINES_PER_PAGE-1] = footerLine;
274 
275 }
Here is the caller graph for this function:

◆ initStream()

ap_uint<64> initStream ( ap_uint< 4 >  cnt,
stream< NetworkWord > &  tcp_data,
int  nr_words,
bool  with_pattern,
bool  inverse_upper,
bool  insert_tlast 
)

Definition at line 277 of file tb_fmc.cpp.

278 {
279  ap_uint<32> ctrlWord = 0;
280  for(int i = 0; i<8; i++)
281  {
282  if(with_pattern)
283  {
284  ctrlWord |= ((ap_uint<32>) ++cnt) << (i*4);
285  } else {
286  ctrlWord |= ((ap_uint<32>) cnt) << (i*4);
287  }
288  }
289 
290  ap_uint<64> data_word = 0;
291  if(inverse_upper)
292  {
293  data_word = (((ap_uint<64>) ~ctrlWord) << 32) | ctrlWord;
294  } else {
295  data_word = ((ap_uint<64>) ctrlWord << 32) | ctrlWord;
296  }
297 
298  printf("Writing to Stream: 0x%llx\n",(unsigned long long) data_word);
299 
300  for(int i = 0; i<nr_words; i++)
301  {
303  tmp.tdata = data_word;
304  tmp.tkeep = 0xFF;
305  if(i == nr_words -1 && insert_tlast)
306  {
307  tmp.tlast = 1;
308  } else {
309  tmp.tlast = 0;
310  }
311  tcp_data.write(tmp);
312  }
313 
314  return data_word;
315 }

◆ internal_icap_fifo()

stream<uint8_t> internal_icap_fifo ( "sInternalIcapFifo"  )
Here is the caller graph for this function:

◆ main()

int main ( )

Definition at line 380 of file tb_fmc.cpp.

380  {
381 
382  ap_uint<32> SR;
383  ap_uint<32> ISR;
384  ap_uint<32> WFV;
385 
386  SR=0x5;
387  ISR=0x4;
388  WFV=0x7FF;
389 
390  HWICAP[SR_OFFSET] = SR;
391  HWICAP[ISR_OFFSET] = ISR;
392  HWICAP[WFV_OFFSET] = WFV;
393  HWICAP[ASR_OFFSET] = 0;
394  HWICAP[CR_OFFSET] = 0;
395  //HWICAP[RFO_OFFSET] = 0x3FF;
396 
397  bool succeded = true;
398 
399  decoupStatus = 0b1;
400  stepDut();
401  printf("%#010x\n", (int) MMIO);
402  succeded = (MMIO == 0xBEBAFECA) && succeded;
403 
404 //===========================================================
405 //Test Displays
406  MMIO_in = 0x1 << DSEL_SHIFT;
407  decoupStatus = 0b0;
408  stepDut();
409  printf("%#010x\n", (int) MMIO);
410  succeded = (MMIO == 0x1007FF07) && succeded && (decoupActive == 0);
411 
412  MMIO_in = 0x2 << DSEL_SHIFT;
413  stepDut();
414  printf("%#010x\n", (int) MMIO);
415  succeded = (MMIO == 0x20000000) && succeded && (decoupActive == 0);
416 
417  MMIO_in = 0x1 << DSEL_SHIFT | 0b1 << DECOUP_CMD_SHIFT;
418  decoupStatus = 0b1;
419  stepDut();
420  printf("%#010x\n", (int) MMIO);
421  succeded = (MMIO == 0x100FFF07) && succeded && (decoupActive == 1);
422 
423  MMIO_in = 0x3 << DSEL_SHIFT | 0b1 << DECOUP_CMD_SHIFT;
424  stepDut();
425  printf("%#010x\n", (int) MMIO);
426  succeded = (MMIO == 0x3f49444C) && succeded && (decoupActive == 1);
427 
428  MMIO_in = 0x1 << DSEL_SHIFT;
429  stepDut();
430  printf("%#010x\n", (int) MMIO);
431  succeded = (MMIO == 0x100FFF07) && succeded && (decoupActive == 0);
432  assert(succeded);
433  printf("== Display and Decoup Test passed == \n");
434 
435 //===========================================================
436 //Test Counter & Xmem
437  printf("===== XMEM =====\n");
438 
439  int cnt = 0;
440  MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT);
441  initBuffer((ap_uint<4>) cnt, xmem, false, false);
442  decoupStatus = 0b0;
443  stepDut(); //simCnt 7
444  succeded &= checkResult(MMIO, 0x30204F4B);
445 
446  cnt = 1;
447  //MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT);
448  initBuffer((ap_uint<4>) cnt, xmem, false, false);
449  stepDut();
450  succeded &= checkResult(MMIO, 0x31204F4B);
451 
452  cnt = 2;
453  stepDut();
454  succeded &= checkResult(MMIO, 0x31555444);
455 
456  initBuffer((ap_uint<4>) cnt, xmem, false, false);
457  stepDut();
458  succeded &= checkResult(MMIO, 0x32204F4B);
459 
460  cnt = 3;
461  initBuffer((ap_uint<4>) cnt, xmem, false, false);
462  xmem[2] = 42;
463  stepDut();
464  succeded &= checkResult(MMIO, 0x33204F4B);
465 
466  //RST
467  MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << RST_SHIFT);
468  stepDut(); //12
469  succeded &= checkResult(MMIO, 0x3349444C);
470 
471  cnt = 0;
472  MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT);
473  initBuffer((ap_uint<4>) cnt, xmem, false, false);
474  stepDut();
475  succeded &= checkResult(MMIO, 0x30204F4B);
476 
477  cnt = 1;
478  initBuffer((ap_uint<4>) cnt, xmem, false, false);
479  xmem[0] = 42;
480  stepDut();
481  succeded &= checkResult(MMIO, 0x30494E56);
482 
483  //Test RST
484  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
485  stepDut();
486  succeded &= checkResult(MMIO, 0x3049444C);
487 
488  //Test ABR
489  cnt = 0;
490  MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT);
491  initBuffer((ap_uint<4>) cnt, xmem, false, false);
492  //HWICAP[CR_OFFSET] = CR_ABORT;
493  HWICAP[ASR_OFFSET] = 0x42;
494  stepDut();
495  succeded &= checkResult(MMIO, 0x3f414252);
496 
497  HWICAP[ASR_OFFSET] = 0x0;
498  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
499  stepDut();
500  succeded &= checkResult(MMIO, 0x3f49444C);
501  assert(succeded);
502 
503  //RST again (BOR)
504  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
505  stepDut(); //18
506  //succeded &= checkResult(MMIO, 0x3f424f52);
507  succeded &= checkResult(MMIO & 0xFF000000, 0x3f000000);
508 
509  HWICAP[CR_OFFSET] = 0x0;
510  //one complete transfer with overflow
511  //LOOP
512  MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT);
513  //MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT) | ( 1 << CHECK_PATTERN_SHIFT);
514  for(int i = 0; i<0xf; i++)
515  {
516  cnt = i;
517  initBuffer((ap_uint<4>) cnt, xmem, false, false);
518  stepDut();
519  assert(decoupActive == 1);
520 
521  //printBuffer(bufferIn, "bufferIn", 7);
522  //printBuffer32(xmem,"Xmem",1);
523  //printf("currentBufferInPtr: %#010x\n",(int) currentBufferInPtr);
524  printf("WF: %#010x\n",(int) HWICAP[WF_OFFSET]);
525  //printf("xmem: %#010x\n",(int) xmem[LINES_PER_PAGE-1]);
526  int WF_should = 0;
527  if ( i % 2 == 0)
528  {
529  WF_should = (((xmem[LINES_PER_PAGE-2] & 0xff00) >>8) << 24);
530  WF_should |= (xmem[LINES_PER_PAGE-2] & 0xff0000);
531  WF_should |= ((xmem[LINES_PER_PAGE-2] & 0xff000000) >> 16); //24-8
532  WF_should |= (xmem[LINES_PER_PAGE-1] & 0xff);
533  } else {
534  WF_should = (xmem[LINES_PER_PAGE-2] & 0xff000000);
535  WF_should |= (xmem[LINES_PER_PAGE-1] & 0xff) << 16;
536  WF_should |= (xmem[LINES_PER_PAGE-1] & 0xff00);
537  WF_should |= ((xmem[LINES_PER_PAGE-1] & 0xff0000) >> 16);
538  }
539  printf("WF_should: %#010x\n", WF_should);
540  assert((int) HWICAP[WF_OFFSET] == WF_should);
541 
542  }
543 
544  printBuffer(bufferIn, "buffer after 0xf transfers:",8);
545 
546  printf("CR: %#010x\n", CR_OFFSET);
547  assert(HWICAP[CR_OFFSET] == CR_WRITE);
548 
549  cnt = 0xf;
550  initBuffer((ap_uint<4>) cnt, xmem, false, false);
551  stepDut(); //34
552  succeded &= checkResult(MMIO, 0x3f204f4b);
553  //printBuffer32(xmem, "Xmem:");
554 
555 // MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT) | ( 1 << CHECK_PATTERN_SHIFT);
556  cnt = 0x0;
557  initBuffer((ap_uint<4>) cnt, xmem, false, false);
558  HWICAP[WF_OFFSET] = 42;
559  HWICAP[CR_OFFSET] = 0;
560  stepDut();
561  //succeded &= checkResult(MMIO, 0x30204F4B) && (HWICAP[WF_OFFSET] == 42);
562  succeded &= checkResult(MMIO, 0x30204F4B);
563  assert(HWICAP[WF_OFFSET] != 42);
564  assert(HWICAP[CR_OFFSET] == CR_WRITE);
565 
566  MMIO_in = 0x3 << DSEL_SHIFT |(126 << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT);
567  cnt = 0x1;
568  initBuffer((ap_uint<4>) cnt, xmem, true, false);
569  stepDut();
570  succeded &= checkResult(MMIO, 0x31535543);
571  assert(HWICAP[CR_OFFSET] == CR_WRITE);
572 
573  //Check CR_WRITE
574  HWICAP[CR_OFFSET] = 0;
575  stepDut(); //37
576  succeded &= checkResult(MMIO, 0x31535543);
577  assert(HWICAP[CR_OFFSET] == 0);
578 
579  //RST
580  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
581  stepDut();
582  succeded &= checkResult(MMIO, 0x3149444C);
583  assert(decoupActive == 0);
584 
585  //one complete transfer with overflow and Memcheck
586  //LOOP
587  //MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT) | (1 << SWAP_SHIFT);
588  //MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT);
589  MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT) | ( 1 << CHECK_PATTERN_SHIFT);
590 
591  xmem[0] = 0xAABBCC00;
592  xmem[4] = 0x12121212;
593  xmem[127] = 0xAABBCCFF;
594  stepDut();
595  assert(checkResult(MMIO, 0x3f494e56));
596  assert(decoupActive == 0);
597 
598  for(int i = 0; i<0xf; i++)
599  {
600  cnt = i;
601  initBuffer((ap_uint<4>) cnt, xmem, false, true);
602  stepDut();
603 
604  //printBuffer(bufferIn, "bufferIn", 7);
605  //printBuffer32(xmem,"Xmem",1);
606  printf("MMIO out: %#010x\n", (int) MMIO);
607  //assert((MMIO & 0xf0ffffff) == 0x30204F4B);
608  //msg could also be UTD instead of OK
609  //assert((MMIO & 0xf0ffffff) == (0x30204F4B | 0x30555444));
610  assert(decoupActive == 0);
611  }
612 
613  cnt = 0xf;
614  initBuffer((ap_uint<4>) cnt, xmem, false, true);
615  stepDut(); //55
616  assert(checkResult(MMIO & 0xf0ffffff, 0x30555444));
617 
618  printBuffer(bufferIn, "buffer after 16 check pattern transfers:",8);
619 
620  printf("== XMEM Test passed == \n");
621 //===========================================================
622 //Test HTTP
623 
624  printf("===== HTTP =====\n");
625 
626  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
627  stepDut();
628  succeded &= checkResult(MMIO, 0x3f49444C);
629 
630  // GET TEST
631  char *httpBuffer = new char[1024];
632  char* getStatus = "GET /status HTTP/1.1\r\nHost: localhost:8080\r\nUser-Agent: curl/7.47.0\r\nAccept: */*\r\n\r\n";
633  httpBuffer[0] = 0xF0;
634  strcpy(&httpBuffer[1],getStatus);
635  httpBuffer[strlen(getStatus)+1] = 0x0;
636  httpBuffer[127] = 0xF0;
637  //printBuffer((ap_uint<8>*)(uint8_t*) httpBuffer, "httpBuffer");
638  copyBufferToXmem(httpBuffer,xmem );
639  xmem[XMEM_ANSWER_START] = 42;
640  int lastPageBytes = strlen(getStatus) % 126;
641  MMIO_in = 0x3 << DSEL_SHIFT |(lastPageBytes << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
642  stepDut();
643  succeded &= checkResult(MMIO, 0x30535543);
644  assert(decoupActive == 0);
645  //printBuffer(bufferIn, "buffer after GET transfers:",2);
646  MMIO_in = 0x4 << DSEL_SHIFT | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
647  stepDut(); //58
648  succeded &= checkResult(MMIO & 0xFF00FFF0, 0x43000070);
649  assert(decoupActive == 0);
650  printBuffer(bufferOut, "Valid HTTP GET: BufferOut:",4);
651  printf("XMEM_ANSWER_START: %#010x\n",(int) xmem[XMEM_ANSWER_START]);
652  //printBuffer32(xmem, "Xmem:");
653  assert(xmem[XMEM_ANSWER_START] == 0x50545448);
654 
655 
656  //RST
657  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
658  stepDut();
659  succeded &= checkResult(MMIO & 0xf0ffffff, 0x3049444C);
660  assert(decoupActive == 0);
661 
662  // INVALID TEST
663  getStatus = "GET /theWorldAndEveryghing HTTP/1.1\r\nHost: localhost:8080\r\nUser-Agent: curl/7.47.0\r\nAccept: */*\r\n\r\n";
664  httpBuffer[0] = 0xF0;
665  strcpy(&httpBuffer[1],getStatus);
666  httpBuffer[strlen(getStatus)+1] = 0x0;
667  httpBuffer[127] = 0xF0;
668  //printBuffer((ap_uint<8>*)(uint8_t*) httpBuffer, "httpBuffer");
669  copyBufferToXmem(httpBuffer,xmem );
670  xmem[XMEM_ANSWER_START] = 42;
671  lastPageBytes = strlen(getStatus) % 126;
672  MMIO_in = 0x3 << DSEL_SHIFT |(lastPageBytes << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
673  stepDut(); //60
674  succeded &= checkResult(MMIO, 0x30535543);
675  assert(decoupActive == 0);
676  //printBuffer(bufferIn, "buffer after Invalid GET transfers:",2);
677 
678  MMIO_in = 0x4 << DSEL_SHIFT | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
679  stepDut();
680  succeded &= checkResult(MMIO, 0x43000061);
681  assert(decoupActive == 0);
682 
683  printBuffer(bufferOut, "INVALID REQUEST; BufferOut:",2);
684  // printf("XMEM_ANSWER_START: %#010x\n",(int) xmem[XMEM_ANSWER_START]);
685  //printBuffer32(xmem, "Xmem:");
686  assert(xmem[XMEM_ANSWER_START] == 0x50545448);
687 
688  HWICAP[WFV_OFFSET] = 0x710;
689 
690  //RST
691  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
692  stepDut();
693  succeded &= checkResult(MMIO & 0xf0ffffff, 0x3049444C);
694  assert(decoupActive == 0);
695 
696  // INVALID TEST 2
697  getStatus = "GET /theWorldAndEveryghing HTTP/1.1\r\nHost: localhost:8080\r\nUser-Agent: curl/7.47.0\r\nAccept: */*\r\n"; //i.e. missing second \r\n
698  httpBuffer[0] = 0xF0;
699  strcpy(&httpBuffer[1],getStatus);
700  httpBuffer[strlen(getStatus)+1] = 0x0;
701  httpBuffer[127] = 0xF0;
702  //printBuffer((ap_uint<8>*)(uint8_t*) httpBuffer, "httpBuffer");
703  copyBufferToXmem(httpBuffer,xmem );
704  xmem[XMEM_ANSWER_START] = 42;
705  lastPageBytes = strlen(getStatus) % 126;
706  MMIO_in = 0x3 << DSEL_SHIFT |(lastPageBytes << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
707  stepDut();
708  succeded &= checkResult(MMIO, 0x30535543);
709  assert(decoupActive == 0);
710  //printBuffer(bufferIn, "buffer after 2. Invalid GET transfers:",2);
711 
712  MMIO_in = 0x4 << DSEL_SHIFT | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
713  stepDut();
714  succeded &= checkResult(MMIO, 0x43000061);
715  assert(decoupActive == 0);
716 
717  //printBuffer(bufferOut, "BufferOut:",2);
718  //printf("XMEM_ANSWER_START: %#010x\n",(int) xmem[XMEM_ANSWER_START]);
719  //printBuffer32(xmem, "Xmem:");
720  assert(xmem[XMEM_ANSWER_START] == 0x50545448);
721 
722  HWICAP[WFV_OFFSET] = 0x710;
723 
724 
725  //RST
726  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
727  stepDut(); //65
728  succeded &= checkResult(MMIO & 0xf0ffffff, 0x3049444C);
729 
730  // POST TEST
731  getStatus = "POST /configure HTTP/1.1\r\nHost: localhost:8080\r\nUser-Agent: curl/7.47.0\r\nContent-Length: 1607\r\n \
732 Content-Type: application/x-www-form-urlencodedAB\r\n\r\nffffffffffbb11220044ffffffffffffffffaa99556620000000200000002000";
733  printf("%s\n",getStatus);
734  httpBuffer[0] = 0x00;
735  strcpy(&httpBuffer[1],getStatus);
736  httpBuffer[strlen(getStatus)+1] = 0x0;
737  httpBuffer[127] = 0x00; //this will damage some payload, but should be ok here
738  httpBuffer[128] = 0xF1;
739  httpBuffer[255] = 0XF1;
740  //printBuffer((ap_uint<8>*)(uint8_t*) httpBuffer, "POST httpBuffer", 3);
741  copyBufferToXmem(httpBuffer,xmem );
742  xmem[XMEM_ANSWER_START] = 42;
743  HWICAP[WF_OFFSET] = 0x42;
744  HWICAP[WFV_OFFSET] = 0x1FE; //to not trigger the "empty FIFO" counter
745  //printBuffer32(xmem, "Xmem:",2);
746  lastPageBytes = strlen(getStatus) % 126;
747  MMIO_in = 0x3 << DSEL_SHIFT |(lastPageBytes << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
748  stepDut();
749  succeded &= checkResult(MMIO, 0x30204F4B);
750  printBuffer(bufferIn, "buffer IN after POST 1/2:",3);
751  copyBufferToXmem(&httpBuffer[128],xmem );
752  // printBuffer32(xmem, "Xmem:",2);
753  stepDut();
754  succeded &= checkResult(MMIO, 0x31535543);
755  printBuffer(bufferIn, "buffer IN after POST 2/2:",3);
756  MMIO_in = 0x4 << DSEL_SHIFT | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
757  stepDut();
758  printBuffer(bufferOut, "POST TEST 1; BufferOut:",2);
759  succeded &= checkResult(MMIO, 0x43000072);
760  printf("XMEM_ANSWER_START: %#010x\n",(int) xmem[XMEM_ANSWER_START]);
761  printf("WF: %#010x\n",(int) HWICAP[WF_OFFSET]);
762  //printBuffer32(xmem, "Xmem:");
763  assert(decoupActive == 0);
764  assert(xmem[XMEM_ANSWER_START] == 0x50545448);
765  //assert(HWICAP[WF_OFFSET] == 0x32303030);
766 
767  //RST
768  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
769  stepDut(); //69
770  succeded &= checkResult(MMIO & 0xf0ffffff, 0x3049444C);
771 
772  // POST TEST 2
773  //getStatus = "POST /configure HTTP/1.1\r\nHost: localhost:8080\r\nUser-Agent: curl/7.47.0\r\nContent-Length: 1607\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\nffff000000bb11220044ffffffffffffffffaa995566200000002000000020000000200000002000000020000000200000002000000020000000200000002000000020000000200000002000000000200000002000000020000000200000002000";
774  getStatus = "POST /configure HTTP/1.1\r\nUser-Agent: curl/7.47.0\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\nffff000000bb11220044ffffffffffffffffaa995566200000002000000020000000200000002000000020000000200000002000000020000000200000002000000020000000200000002000000000200000002000000020000000200000002000";
775 
776  printf("%s\n",getStatus);
777 
778  httpBuffer[0] = 0x00;
779  strcpy(&httpBuffer[1],getStatus);
780  httpBuffer[strlen(getStatus)+1] = 0x0;
781  httpBuffer[127] = 0x00; //this will damage some payload, but should be ok here
782  httpBuffer[128] = 0x01;
783  httpBuffer[255] = 0X01;
784  httpBuffer[256] = 0xF2;
785  httpBuffer[383] = 0xF2;
786  //printBuffer((ap_uint<8>*)(uint8_t*) httpBuffer, "POST httpBuffer", 3);
787  copyBufferToXmem(httpBuffer,xmem );
788  xmem[XMEM_ANSWER_START] = 42;
789  HWICAP[WF_OFFSET] = 0x42;
790  //printBuffer32(xmem, "Xmem:",2);
791  lastPageBytes = strlen(getStatus) % 126;
792  MMIO_in = 0x3 << DSEL_SHIFT |(lastPageBytes << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
793  stepDut(); //70
794  succeded &= checkResult(MMIO, 0x30204F4B);
795  printBuffer(bufferIn, "buffer IN after POST 1/3:",3);
796  copyBufferToXmem(&httpBuffer[128],xmem );
797  //printBuffer32(xmem, "Xmem:",2);
798  stepDut();
799  succeded &= checkResult(MMIO, 0x31204F4B);
800  assert(decoupActive == 1);
801 
802  printBuffer(bufferIn, "buffer IN after POST 2/3:",3);
803  printf("WF: %#010x\n",(int) HWICAP[WF_OFFSET]);
804 
805  for(int i = 2; i<0x1f; i++)
806  {
807  cnt = i;
808  initBuffer((ap_uint<4>) cnt, xmem, false, false);
809  HWICAP[CR_OFFSET] = 0;
810  //printBuffer32(xmem,"Xmem",1);
811  stepDut();
812  //test double call --> nothing should change
813  for(int j = 0; j< 4; j++)
814  {
815  stepDut();
816  }
817 
818  assert(decoupActive == 1);
819  assert(HWICAP[CR_OFFSET] == CR_WRITE);
820 
821 
822  }
823  cnt = 0xf;
824  initBuffer((ap_uint<4>) cnt, xmem, true, false);
825  stepDut(); //217
826  succeded &= checkResult(MMIO, 0x3f535543);
827 
828  stepDut();
829  int WF_should = 0;
830  WF_should = (xmem[LINES_PER_PAGE-3] & 0xff000000);
831  WF_should |= (xmem[LINES_PER_PAGE-2] & 0xff) << 16;
832  WF_should |= (xmem[LINES_PER_PAGE-2] & 0xff00);
833  WF_should |= ((xmem[LINES_PER_PAGE-2] & 0xff0000) >> 16);
834  //printf("WF_should: %#010x\n", WF_should);
835 
836  // printBuffer32(xmem,"Xmem",1);
837  stepDut();
838  printBuffer(bufferIn, "bufferIn after 15 HTTP transfer", 8);
839 
840  //Check CR_WRITE
841  HWICAP[CR_OFFSET] = 0;
842  stepDut(); //220
843  succeded &= checkResult(MMIO, 0x3f535543);
844  assert(HWICAP[CR_OFFSET] == 0);
845 
846 
847  MMIO_in = 0x4 << DSEL_SHIFT;
848  stepDut();
849  succeded &= checkResult(MMIO, 0x40000072);
850  assert(decoupActive == 0);
851 
852  printBuffer(bufferOut, "BufferOut:",2);
853  printf("XMEM_ANSWER_START: %#010x\n",(int) xmem[XMEM_ANSWER_START]);
854  printf("WF: %#010x\n",(int) HWICAP[WF_OFFSET]);
855 
856  //printBuffer32(xmem, "Xmem:");
857  assert(xmem[XMEM_ANSWER_START] == 0x50545448);
858 
859  //RST
860  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
861  stepDut();
862  //succeded &= checkResult(MMIO & 0xf0ffffff, 0x30424f52); //FMC is already boring
863  succeded &= checkResult(MMIO & 0xFF000000, 0x3f000000);
864  assert(decoupActive == 0);
865 
866  // PUT RANK TEST
867  getStatus = "PUT /rank/42 HTTP/1.1\r\nUser-Agent: curl/7.47.0\r\nAccept: */*\r\n\r\n";
868  httpBuffer[0] = 0xF0;
869  strcpy(&httpBuffer[1],getStatus);
870  httpBuffer[strlen(getStatus)+1] = 0x0;
871  httpBuffer[127] = 0xF0;
872  //printBuffer((ap_uint<8>*)(uint8_t*) httpBuffer, "httpBuffer");
873  copyBufferToXmem(httpBuffer,xmem );
874  xmem[XMEM_ANSWER_START] = 42;
875  lastPageBytes = strlen(getStatus) % 126;
876  MMIO_in = 0x3 << DSEL_SHIFT |(lastPageBytes << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
877  stepDut();
878  succeded &= checkResult(MMIO, 0x30535543);
879  assert(decoupActive == 0);
880  //printBuffer(bufferIn, "buffer after PUT RANK transfers:",2);
881  MMIO_in = 0x4 << DSEL_SHIFT | ( 1 << PARSE_HTTP_SHIFT);
882  stepDut();
883  succeded &= checkResult(MMIO, 0x40000071);
884  assert(decoupActive == 0);
885  printBuffer(bufferOut, "PUT RANK: BufferOut:",2);
886  //printf("XMEM_ANSWER_START: %#010x\n",(int) xmem[XMEM_ANSWER_START]);
887  //printBuffer32(xmem, "Xmem:");
888  assert(xmem[XMEM_ANSWER_START] == 0x50545448);
889  assert(nodeRank_out == 42);
890 
891  //RST
892  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
893  stepDut(); //225
894  //succeded &= checkResult(MMIO & 0xf0ffffff, 0x30424f52);
895  succeded &= checkResult(MMIO & 0xFF000000, 0x30000000);
896  assert(decoupActive == 0);
897 
898  // PUT RANK INVALID TEST
899  getStatus = "PUT /rank/abc HTTP/1.1\r\nUser-Agent: curl/7.47.0\r\nAccept: */*\r\n\r\n";
900  httpBuffer[0] = 0xF0;
901  strcpy(&httpBuffer[1],getStatus);
902  httpBuffer[strlen(getStatus)+1] = 0x0;
903  httpBuffer[127] = 0xF0;
904  //printBuffer((ap_uint<8>*)(uint8_t*) httpBuffer, "httpBuffer");
905  copyBufferToXmem(httpBuffer,xmem );
906  xmem[XMEM_ANSWER_START] = 42;
907  lastPageBytes = strlen(getStatus) % 126;
908  MMIO_in = 0x3 << DSEL_SHIFT |(lastPageBytes << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
909  stepDut();
910  succeded &= checkResult(MMIO, 0x30535543);
911  assert(decoupActive == 0);
912  // printBuffer(bufferIn, "buffer after PUT RANK transfers:",2);
913  MMIO_in = 0x4 << DSEL_SHIFT | ( 1 << PARSE_HTTP_SHIFT);
914  stepDut();
915  succeded &= checkResult(MMIO, 0x40000061);
916  assert(decoupActive == 0);
917  printBuffer(bufferOut, "PUT RANK INVALID: BufferOut:",2);
918  //printf("XMEM_ANSWER_START: %#010x\n",(int) xmem[XMEM_ANSWER_START]);
919  //printBuffer32(xmem, "Xmem:");
920  assert(xmem[XMEM_ANSWER_START] == 0x50545448);
921  //assert(nodeRank_out == 0);
922 
923 
924  //RST
925  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
926  stepDut();
927  succeded &= checkResult(MMIO & 0xFF000000, 0x30000000);
928  assert(decoupActive == 0);
929 
930  // PUT SIZE TEST
931  getStatus = "PUT /size/5 HTTP/1.1\r\nUser-Agent: curl/7.47.0\r\nAccept: */*\r\n\r\n";
932  httpBuffer[0] = 0xF0;
933  strcpy(&httpBuffer[1],getStatus);
934  httpBuffer[strlen(getStatus)+1] = 0x0;
935  httpBuffer[127] = 0xF0;
936  //printBuffer((ap_uint<8>*)(uint8_t*) httpBuffer, "httpBuffer");
937  copyBufferToXmem(httpBuffer,xmem );
938  xmem[XMEM_ANSWER_START] = 42;
939  lastPageBytes = strlen(getStatus) % 126;
940  MMIO_in = 0x3 << DSEL_SHIFT |(lastPageBytes << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
941  stepDut();
942  succeded &= checkResult(MMIO, 0x30535543);
943  assert(decoupActive == 0);
944  //printBuffer(bufferIn, "buffer after PUT SIZE transfers:",2);
945  MMIO_in = 0x4 << DSEL_SHIFT | ( 1 << PARSE_HTTP_SHIFT);
946  stepDut();
947  succeded &= checkResult(MMIO, 0x40000071);
948  assert(decoupActive == 0);
949  printBuffer(bufferOut, "PUT SIZE: BufferOut:",2);
950  //printf("XMEM_ANSWER_START: %#010x\n",(int) xmem[XMEM_ANSWER_START]);
951  //printBuffer32(xmem, "Xmem:");
952  assert(xmem[XMEM_ANSWER_START] == 0x50545448);
953  assert(clusterSize_out == 5);
954 
955  printf("== HTTP Test passed == \n");
956 
957 //===========================================================
958 //Test PYROLINK
959 #ifdef INCLUDE_PYROLINK
960 
961  assert(succeded);
962  printf("===== PYROLINK TEST =====\n");
963 
964  //RST ...BOR
965  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
966  stepDut(); //231
967  succeded &= checkResult(MMIO & 0xf0ffffff, 0x30424f52); //TODO: msg filed may have changed
968 
969  MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << PYRO_MODE_SHIFT) | 10 << LAST_PAGE_CNT_SHIFT;
970 
971  for(int i = 0; i<0xf; i++)
972  {
973  cnt = i;
974  initBuffer((ap_uint<4>) cnt, xmem, false, true);
975  stepDut();
976 
977  ap_uint<8> ctrlByte = ((cnt & 0xf) << 4) | (cnt & 0xf);
978  for(int j = 0; j <126; j++)
979  {
980  assert(!FMC_Debug_Pyrolink.empty());
981  Axis<8> tmp = FMC_Debug_Pyrolink.read();
982  assert(tmp.tdata == ctrlByte);
983  }
984 
985  }
986 
987  assert(decoupActive == 0);
988  cnt = 0xf;
989  initBuffer((ap_uint<4>) cnt, xmem, true, true);
990  stepDut();
991  assert(checkResult(MMIO & 0xf0ffffff, 0x30535543));
992 
993  //10 Byte only on the last page
994  ap_uint<8> ctrlByte = ((cnt & 0xf) << 4) | (cnt & 0xf);
995  for(int j = 0; j <10; j++)
996  {
997  assert(!FMC_Debug_Pyrolink.empty());
998  Axis<8> tmp = FMC_Debug_Pyrolink.read();
999  //printf("last page byte %d: .tdata: %d .tkeep: %d .tlast: %d\n",j, (int) tmp.tdata, (int) tmp.tkeep, (int) tmp.tlast);
1000 
1001  assert(tmp.tdata == ctrlByte);
1002  if(j == 9)
1003  {
1004  assert(tmp.tlast == 1);
1005  }
1006  }
1007  //assert nothing left
1008  assert(FMC_Debug_Pyrolink.empty());
1009 
1010  //RST
1011  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
1012  stepDut(); //248
1013  succeded &= checkResult(MMIO & 0xf0ffffff, 0x3049444C);
1014 
1015  for(int j = 0; j<(3*128 + 14); j++)
1016  {
1017  Axis<8> tmp = Axis<8>();
1018  tmp.tkeep = 1;
1019  tmp.tlast = 0;
1020  tmp.tdata = j;
1021  Debug_FMC_Pyrolink.write(tmp);
1022  }
1023 
1024  Axis<8> tmp = Axis<8>();
1025  tmp.tkeep = 1;
1026  tmp.tlast = 1;
1027  tmp.tdata = 3*128 + 15;
1028  Debug_FMC_Pyrolink.write(tmp);
1029 
1030  //test read request
1031  MMIO_in = 0x6 << DSEL_SHIFT;
1032  stepDut();
1033  succeded &= checkResult(MMIO & 0xf0800000, 0x60800000); //we are only interested in the pyro send request bit
1034 
1035  MMIO_in = 0x6 << DSEL_SHIFT | (1 << PYRO_READ_REQUEST_SHIFT);
1036  stepDut(); //250
1037  succeded &= checkResult(MMIO & 0xf0ff0000, 0x600F0000);
1038 
1039  printBuffer(bufferOut, "buffer OUT after Pyrolink READ:",4);
1040  assert(bufferOut[3*128+15 - 1] == (3*128 + 15) % 256);
1041 
1042  printf("== PYROLINK Test passed == \n");
1043 #else
1044  printf("-- Skipping PYROLINK Test (+20 stepDut) -- \n");
1045  simCnt += 20;
1046 #endif
1047 
1048 //===========================================================
1049 //Test NAL
1050 
1051  printf("===== NAL =====\n");
1052  layer_6_enabled = 0b1;
1054 
1055  //RST
1056  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
1057  stepDut(); //251
1058  succeded &= checkResult(MMIO & 0xf0f0f000, (0x3049444C | 0x30424f52) & 0xf0f0f000); //FMC is somehow bored
1059  assert(decoupActive == 0);
1060 
1061  //POST ROUTING TABLE
1062  getStatus = "POST /routing HTTP/1.1\r\nUser-Agent: curl/7.47.0\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n";
1063 
1064  printf("%s\n",getStatus);
1065 
1066  httpBuffer[0] = 0x00;
1067  strcpy(&httpBuffer[1],getStatus);
1068  int startTable = strlen(getStatus);
1069  int routingTable[25] = {0x30,0x20, 0x0a, 0x0b, 0x0c, 0x01, 0x0a, 0x31,0x20, 0x0a, 0x0b, 0x0c, 0x02, 0x0a, 0x32,0x20, 0x0a, 0x0b, 0x0c, 0x05, 0x0a, 0x0d, 0x0a, 0x0d, 0x0a};
1070  {
1071  int j = startTable + 1;
1072  int i = 0;
1073  while(i<25)
1074  {
1075  if(j == 127)
1076  {
1077  httpBuffer[j] = 0x00;
1078  httpBuffer[j + 1] = 0xF1;
1079  j += 2;
1080  continue;
1081  }
1082 
1083  httpBuffer[j] = routingTable[i];
1084  i++;
1085  j++;
1086 
1087  }
1088  //to be sure
1089  httpBuffer[127] = 0x00;
1090  httpBuffer[128] = 0xF1;
1091  httpBuffer[255] = 0xF1;
1092  }
1093  printBuffer((uint8_t*) httpBuffer, "POST ROUTING httpBuffer", 3);
1094  copyBufferToXmem(httpBuffer,xmem );
1095  xmem[XMEM_ANSWER_START] = 42;
1096  lastPageBytes = (strlen(getStatus) + 25) % 126;
1097 
1099 
1100  //MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
1101  MMIO_in = 0x3 << DSEL_SHIFT |(lastPageBytes << LAST_PAGE_CNT_SHIFT) | ( 1 << START_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
1102  stepDut();
1103  succeded &= checkResult(MMIO, 0x30204F4B);
1104  copyBufferToXmem(&httpBuffer[128],xmem );
1105  stepDut();
1106  succeded &= checkResult(MMIO, 0x30535543);
1107  assert(decoupActive == 0);
1108 
1109  MMIO_in = 0x4 << DSEL_SHIFT | ( 1 << PARSE_HTTP_SHIFT);
1110  stepDut();
1111  succeded &= checkResult(MMIO, 0x40000071);
1112  assert(decoupActive == 0);
1113  printBuffer(bufferIn, "POST_ROUTING: BufferIn:",3);
1114  printBuffer(bufferOut, "POST_ROUTING: BufferOut:",2);
1115  assert(xmem[XMEM_ANSWER_START] == 0x50545448);
1116 
1117  stepDut(); //255 //for coping MRT
1118  stepDut();
1119  stepDut(); //257
1120  assert(nalCtrl[NAL_CTRL_LINK_MRT_START_ADDR + 0] == 0x0a0b0c01);
1121  assert(nalCtrl[NAL_CTRL_LINK_MRT_START_ADDR + 1] == 0x0a0b0c02);
1122  assert(nalCtrl[NAL_CTRL_LINK_MRT_START_ADDR + 2] == 0x0a0b0c05);
1123 
1124  printf("== NAL Test passed == \n");
1125 //===========================================================
1126 //Test TCP
1127 
1128  printf("===== TCP =====\n");
1129 
1130 
1131 //RST again (BOR)
1132  MMIO_in = 0x3 << DSEL_SHIFT | (1 << RST_SHIFT);
1133  stepDut(); //258
1134  succeded &= checkResult(MMIO & 0xFF000000, 0x30000000);
1135 
1136  HWICAP[CR_OFFSET] = 0x0;
1137  ap_uint<32> WF_ctrl = 0;
1138 
1139  getStatus = "GET /status HTTP/1.1\r\nHost: localhost:8080\r\nUser-Agent: curl/7.47.0\r\nAccept: */*\r\n\r\n";
1140  strcpy(&httpBuffer[0],getStatus);
1141  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus));
1142 
1143  Axis<16> sessId = Axis<16>(43);
1144  sessId.setTLast(1);
1145  //sNAL_FMC_Tcp_sessId.write(sessId);
1146  sNAL_FMC_Tcp_sessId.write(sessId.getTData());
1147 
1148  MMIO_in = 0x3 << DSEL_SHIFT | ( 1 << ENABLE_TCP_MODE_SHIFT) | ( 1 << PARSE_HTTP_SHIFT);
1149 
1150  //new TCP FSM: should take only 4 cycles
1151  stepDut();
1152  stepDut(); //260
1153  stepDut();
1154  stepDut();
1155  printBuffer(bufferIn, "Valid HTTP GET: BufferIn:",2);
1156  printBuffer(bufferOut, "Valid HTTP GET: BufferOut:",4);
1157 
1158  Axis<16> sessId_back = sFMC_NAL_Tcp_sessId.read();
1159  assert(sessId.getTData() == sessId_back.getTData());
1161  assert(sFMC_NAL_Tcp_data.empty());
1162 
1163  //"self reset"
1164  stepDut();
1165  stepDut();
1166 
1167  // POST TEST via TCP
1168  // first chunk
1169  getStatus = "POST /configure HTTP/1.1\r\nUser-Agent: curl/7.47.0\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\nffff000000bb11220044ffffffffffffffffaa9955662000000021000000220000002300000024000000250000002600000027000000280abcd";
1170 
1171  printf("%s\n",getStatus);
1172 
1173  strcpy(&httpBuffer[0],getStatus);
1174  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus));
1175 
1176  sessId = Axis<16>(45);
1177  sessId.setTLast(1);
1178  sNAL_FMC_Tcp_sessId.write(sessId.getTData());
1179 
1180  HWICAP[WFV_OFFSET] = 0x3FF;
1181  HWICAP[WF_OFFSET] = 0x42;
1182  HWICAP[CR_OFFSET] = 0;
1183  stepDut(); //265
1184  stepDut();
1185  stepDut();
1186  assert(decoupActive == 1); //should be there immediately
1187  assert(HWICAP[CR_OFFSET] == CR_WRITE);
1188  //printBuffer(bufferIn, "bufferIn after TCP HTTP transfer", 2);
1189 
1190  //second chunk
1191  getStatus = "e290000002000000021000000220000002300000000240000002500000026000002700123456789AB\r\n\r\n";
1192  // -> 196 payload bytes
1193 
1194  printf("%s\n",getStatus);
1195 
1196  strcpy(&httpBuffer[0],getStatus);
1197  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus));
1198 
1199  //check telomere (should NOT be used)
1200  assert(bufferInPtrNextRead > 0);
1201  stepDut();
1202  printBuffer(bufferIn, "bufferIn after TCP HTTP transfer", 4);
1203 
1204  //process remaining
1205  //HWICAP[WFV_OFFSET] = 0x1DE;
1206  for(int j = 0; j< 3; j++)
1207  {
1208  stepDut();
1209  }
1210 
1211  //printBuffer(bufferOut, "Valid HTTP POST: BufferOut:",4);
1212 
1213  assert(decoupActive == 0);
1214  printf("WF: %#010x\n",(int) HWICAP[WF_OFFSET]);
1215  //WF_should = 0;
1216  //WF_should = 0x00002000;
1217  WF_should = 0x38394142; //we test in Ascii...
1218  printf("WF_should: %#010x\n", WF_should);
1219  assert((int) HWICAP[WF_OFFSET] == WF_should);
1220 
1221  //Check CR_WRITE
1222  HWICAP[CR_OFFSET] = 0;
1223  stepDut(); //271
1224  succeded &= checkResult(MMIO, 0x30574154); //WAT
1225  assert(decoupActive == 0);
1226  assert(HWICAP[CR_OFFSET] == 0);
1227 
1228  sessId_back = sFMC_NAL_Tcp_sessId.read();
1229  assert(sessId.getTData() == sessId_back.getTData());
1231  assert(sFMC_NAL_Tcp_data.empty());
1232  assert(sFMC_NAL_Tcp_sessId.empty());
1233 
1234  //"self reset"
1235  stepDut(); //272
1236  stepDut();
1237 
1238  //POST ROUTING via TCP
1239  getStatus = "POST /routing HTTP/1.1\r\nUser-Agent: curl/7.47.0\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\n";
1240 
1241  printf("%s\n",getStatus);
1242 
1243  strcpy(&httpBuffer[0],getStatus);
1244  startTable = strlen(getStatus);
1245  //int routingTable[25] = {0x30,0x20, 0x0a, 0x0b, 0x0c, 0x01, 0x0a, 0x31,0x20, 0x0a, 0x0b, 0x0c, 0x02, 0x0a, 0x32,0x20, 0x0a, 0x0b, 0x0c, 0x05, 0x0a, 0x0d, 0x0a, 0x0d, 0x0a};
1246  //reuse routing table
1247  {
1248  int j = startTable;
1249  int i = 0;
1250  while(i<25)
1251  {
1252  httpBuffer[j] = routingTable[i];
1253  i++;
1254  j++;
1255  }
1256  }
1257  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus) + 25);
1258 
1262 
1263  sessId = Axis<16>(46);
1264  sessId.setTLast(1);
1265  sNAL_FMC_Tcp_sessId.write(sessId.getTData());
1266 
1267  stepDut(); //three step only for TCP
1268  stepDut(); //275
1269  stepDut();
1270  stepDut();
1271  //sim_fpga_time_seconds += 4;
1272 
1273  printBuffer(bufferIn, "bufferIn after TCP HTTP POST /routing", 2);
1274 
1275  sessId_back = sFMC_NAL_Tcp_sessId.read();
1276  assert(sessId.getTData() == sessId_back.getTData());
1278  assert(sFMC_NAL_Tcp_data.empty());
1279  assert(decoupActive == 0);
1280 
1281  //some for updating MRT
1282  for(int j = 0; j< 2; j++)
1283  {
1284  stepDut();
1285  }
1286 
1287  assert(nalCtrl[NAL_CTRL_LINK_MRT_START_ADDR + 0] == 0x0a0b0c01);
1288  assert(nalCtrl[NAL_CTRL_LINK_MRT_START_ADDR + 1] == 0x0a0b0c02);
1289  assert(nalCtrl[NAL_CTRL_LINK_MRT_START_ADDR + 2] == 0x0a0b0c05);
1290 
1291  //"self reset"
1292  stepDut(); //279
1293  stepDut();
1294 
1295  //INVALID POST ROUTING via TCP
1296  getStatus = "POST /routing HTTP/1.1\r\nUser-Agent: curl/7.47.0\r\nContent-Type: application/x-www-form-urlencoded\r\nbla\r\n\r\n";
1297 
1298  printf("%s\n",getStatus);
1299 
1300  strcpy(&httpBuffer[0],getStatus);
1301  startTable = strlen(getStatus);
1302  //int routingTable[25] = {0x30,0x20, 0x0a, 0x0b, 0x0c, 0x01, 0x0a, 0x31,0x20, 0x0a, 0x0b, 0x0c, 0x02, 0x0a, 0x32,0x20, 0x0a, 0x0b, 0x0c, 0x05, 0x0a, 0x0d, 0x0a, 0x0d, 0x0a};
1303  //reuse routing table
1304  {
1305  int j = startTable + 3;//this should be enought to become invalid
1306  int i = 0;
1307  while(i<25)
1308  {
1309  httpBuffer[j] = routingTable[i];
1310  i++;
1311  j++;
1312  }
1313  }
1314  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus) + 25 + 3);
1315 
1319 
1320  sessId = Axis<16>(47);
1321  sessId.setTLast(1);
1322  sNAL_FMC_Tcp_sessId.write(sessId.getTData());
1323 
1324  stepDut(); //three step only for TCP
1325  stepDut();
1326  stepDut(); //283
1327 
1328  //printBuffer(bufferIn, "bufferIn after TCP HTTP POST /routing", 2);
1329 
1330  sessId_back = sFMC_NAL_Tcp_sessId.read();
1331  assert(sessId.getTData() == sessId_back.getTData());
1332 
1333  //check 422
1334  printf("Check stream:\n0x312e312f50545448\n0x706e552032323420\n0x6261737365636f72\n0x7469746e4520656c\n0x65686361430a0d79\n");
1335  assert(sFMC_NAL_Tcp_data.read().tdata == 0x312e312f50545448);
1336  assert(sFMC_NAL_Tcp_data.read().tdata == 0x706e552032323420);
1337  assert(sFMC_NAL_Tcp_data.read().tdata == 0x6261737365636f72);
1338  assert(sFMC_NAL_Tcp_data.read().tdata == 0x7469746e4520656c);
1339  assert(sFMC_NAL_Tcp_data.read().tdata == 0x65686361430a0d79);
1340  //drain remaining
1341  printf("Partial ");
1343  assert(sFMC_NAL_Tcp_data.empty());
1344 
1345  //nothing should have happened
1346  assert(decoupActive == 0);
1347  assert(nalCtrl[NAL_CTRL_LINK_MRT_START_ADDR + 0] == 0x0);
1348  assert(nalCtrl[NAL_CTRL_LINK_MRT_START_ADDR + 1] == 0x0);
1349  assert(nalCtrl[NAL_CTRL_LINK_MRT_START_ADDR + 2] == 0x0);
1350 
1351  //"self reset"
1352  stepDut();
1353  stepDut(); //285
1354 
1355  // POST config via TCP with hangover
1356  use_sequential_hwicap = true;
1358  uint32_t hwicap_in_address = HWICAP_SEQ_START_ADDRESS*4;
1359 
1360  // first chunk
1361  getStatus = "POST /configure HTTP/1.1\r\nUser-Agent: curl/7.47.01\r\nContent-Type: application/x-www-form-urlencoded\r\n\r\nffff000000bb11220044ffffffffffffffffaa9955662000000021000000220000002300000024000000250000002600000027000000280abcd";
1362 
1363  strcpy((char*) &HWICAP_seq_IN[hwicap_in_address],"ffff000000bb11220044ffffffffffffffffaa9955662000000021000000220000002300000024000000250000002600000027000000280abcd");
1364  hwicap_in_address += strlen("ffff000000bb11220044ffffffffffffffffaa9955662000000021000000220000002300000024000000250000002600000027000000280abcd");
1365 
1366  printf("%s\n",getStatus);
1367  printf("\t....with large payload\n\n");
1368 
1369  strcpy(&httpBuffer[0],getStatus);
1370  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus));
1371  int message_size = strlen(getStatus);
1372 
1373  sessId = Axis<16>(73);
1374  sessId.setTLast(1);
1375  sNAL_FMC_Tcp_sessId.write(sessId.getTData());
1376 
1377  HWICAP_seq_OUT[SR_OFFSET] = SR;
1378  HWICAP_seq_OUT[WF_OFFSET] = 0x42;
1380  //HWICAP_seq_OUT[WFV_OFFSET] = 0x1DE;
1381  HWICAP_seq_OUT[WFV_OFFSET] = 0x3FF;
1382  stepDut();
1383  stepDut();
1384  stepDut();
1385  assert(decoupActive == 1); //should be there immediately
1386  assert(HWICAP_seq_OUT[CR_OFFSET] == CR_WRITE);
1387 
1388  //second chunk
1389  getStatus = "e2900000020000000210000002200000023000000002400000025000000260002700123456789AB";
1390  // -> 194 payload bytes (first and second)
1391 
1392  //printf("%s\n",getStatus);
1393 
1394  strcpy(&httpBuffer[0],getStatus);
1395  strcpy((char*) &HWICAP_seq_IN[hwicap_in_address],getStatus);
1396  hwicap_in_address += strlen(getStatus);
1397  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus));
1398  message_size += strlen(getStatus);
1399 
1400  stepDut();
1401  printBuffer(bufferIn, "bufferIn after TCP HTTP transfer", 4);
1402 
1403  for(int j = 0; j< 3; j++)
1404  {
1405  stepDut();
1406  }
1407 
1408  //printBuffer(bufferOut, "Valid HTTP POST: BufferOut:",4);
1409 
1410  assert(decoupActive == 1);
1411  printf("WF: %#010x\n",(int) HWICAP_seq_OUT[WF_OFFSET]);
1412  WF_should = 0x36373839;
1413  printf("WF_should: %#010x\n", WF_should);
1414  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1415 
1417 
1418  //HWICAP_seq_OUT[WFV_OFFSET] = 0x2DE;
1419  //now, we post more than BUFFER_SIZE
1420  bool overflow_happened = false;
1421  while(message_size < IN_BUFFER_SIZE + 20)
1422  {
1423  //next chunk
1424  //getStatus = "abcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789AB";
1425  // -> 80 payload bytes
1426  getStatus = "abcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789AB";
1427  // --> 460 payload bytes
1428 
1429  strcpy((char*) &HWICAP_seq_IN[hwicap_in_address],getStatus);
1430  hwicap_in_address += strlen(getStatus);
1431 
1432  strcpy(&httpBuffer[0],getStatus);
1433  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus));
1434  message_size += strlen(getStatus);
1435  //printf("------- message size %d ------------\n", (int) message_size);
1436 
1437  stepDut();
1438  assert(decoupActive == 1);
1439  //printf("WF: %#010x\n",(int) HWICAP_seq_OUT[WF_OFFSET]);
1440  //WF_should = 0x38394142;
1441  WF_should = 0x36373839;
1442  //printf("WF_should: %#010x\n", WF_should);
1443  if(!(message_size > IN_BUFFER_SIZE) && !overflow_happened)
1444  {
1445  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1446  } else {
1447  overflow_happened = true;
1448  }
1449  }
1450 
1451  //write what's left
1452  stepDut();
1453  //to activate and see context, add +1 for the end address
1455 
1456  //test WFV feedback
1457  HWICAP_seq_OUT[WFV_OFFSET] = 0x3;
1458  //next chunk
1459  getStatus = "abcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789AB";
1460  // -> 80 payload bytes
1461 
1462  strcpy((char*) &HWICAP_seq_IN[hwicap_in_address],getStatus);
1463  hwicap_in_address += strlen(getStatus);
1464 
1465  strcpy(&httpBuffer[0],getStatus);
1466  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus));
1467  message_size += strlen(getStatus);
1468 
1469  stepDut();
1470  assert(decoupActive == 1);
1471  printf("WF: %#010x\n",(int) HWICAP_seq_OUT[WF_OFFSET]);
1472  WF_should = 0x67683230; //only 3 words
1473  printf("WF_should: %#010x\n", WF_should);
1474  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1475 
1476 
1477  //now, we set HWICAP to blocking and wait until an overflow
1478  HWICAP_seq_OUT[WFV_OFFSET] = 0x0;
1479  overflow_happened = false;
1480  message_size = 0;
1481  while(message_size < IN_BUFFER_SIZE + 300)
1482  {
1483  //next chunk
1484  //getStatus = "abcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789AB";
1485  // -> 240 payload bytes
1486 
1487  getStatus = "abcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789AB";
1488  // --> 460 payload bytes
1489 
1490  strcpy((char*) &HWICAP_seq_IN[hwicap_in_address],getStatus);
1491  hwicap_in_address += strlen(getStatus);
1492 
1493  strcpy(&httpBuffer[0],getStatus);
1494  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus));
1495  message_size += strlen(getStatus);
1496  //printf("------- message size %d ------------\n", (int) message_size);
1497 
1498  stepDut();
1499  assert(decoupActive == 1);
1500  printf("WF: %#010x\n",(int) HWICAP_seq_OUT[WF_OFFSET]);
1501  //WF_should = 0x36373839;
1502  WF_should = 0x67683230; //nothing should change
1503  printf("WF_should: %#010x\n", WF_should);
1504  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1505  }
1506 
1507  //one word only
1508  HWICAP_seq_OUT[WFV_OFFSET] = 0x1;
1509  stepDut();
1510  assert(decoupActive == 1);
1511  WF_should = 0x30303030;
1512  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1513 
1514  stepDut();
1515  assert(decoupActive == 1);
1516  WF_should = 0x30303231;
1517  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1518 
1519  //hangover test
1520  HWICAP_seq_OUT[WFV_OFFSET] = 0x1E1;
1521  stepDut();
1522  assert(decoupActive == 1);
1523  WF_should = 0x30303030;
1524  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1525  //one word only
1526  HWICAP_seq_OUT[WFV_OFFSET] = 0x1;
1527  stepDut();
1528  assert(decoupActive == 1);
1529  WF_should = 0x30303232;
1530  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1531 
1532  //now, we let it go
1533  HWICAP_seq_OUT[WFV_OFFSET] = 0x3FF;
1534  stepDut();
1535  stepDut();
1536  stepDut();
1537  stepDut();
1538  assert(decoupActive == 1);
1539  //printf("WF: %#010x\n",(int) HWICAP_seq_OUT[WF_OFFSET]);
1540  WF_should = 0x36373839; //everything should be processed
1541  //printf("WF_should: %#010x\n", WF_should);
1542  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1543 
1544  //to activate and see context, add +1 for the end address
1546 
1547 #ifndef COSIM
1548  //test random pattern
1549  printf("----------- Random Test -----------\n");
1550  HWICAP_seq_OUT[WFV_OFFSET] = 0x3FF;
1551  message_size = 0;
1552  char stringBuffer[512];
1553  uint32_t max_message_size = 5*IN_BUFFER_SIZE + 300;
1554  bool correction_done = false;
1555  struct timeval now;
1556  gettimeofday(&now, NULL);
1557  uint32_t random_seed = now.tv_sec + now.tv_usec;
1558  printf("\tSeed %d\n", random_seed);
1559  srand(random_seed);
1560  while(message_size < max_message_size)
1561  {
1562  //next chunk
1563  //getStatus = "abcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789AB";
1564  // -> 240 payload bytes
1565 
1566  getStatus = "abcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789ABabcdefgh20000000210000002200000023000000002400000025abcdef26ghijk2700123456789AB";
1567  // --> 460 payload bytes
1568 
1569  strcpy(stringBuffer,getStatus);
1570 
1571  //to check every packet size
1572  if(message_size > 1024 && message_size < (max_message_size - 1024) )
1573  {
1574  uint16_t stop_byte = rand() % (strlen(getStatus) - 1);
1575  //if(stop_byte < 2*NETWORK_WORD_BYTE_WIDTH)
1576  //{
1577  // stop_byte += 2*NETWORK_WORD_BYTE_WIDTH;
1578  //}
1579  if(stop_byte < 3)
1580  {
1581  stop_byte += 3;
1582  }
1583  printf("cutting payload at %d\n", stop_byte);
1584  stringBuffer[stop_byte] = '\0';
1585  } else if( (message_size > (max_message_size - 1024)) && !correction_done)
1586  {
1587  correction_done = true;
1588  uint16_t stop_byte = 32 + ( 4 - (message_size % 4));
1589  printf("correcting payload with length %d\n", stop_byte);
1590  stringBuffer[stop_byte] = '\0';
1591  }
1592 
1593  strcpy((char*) &HWICAP_seq_IN[hwicap_in_address],stringBuffer);
1594  hwicap_in_address += strlen(stringBuffer);
1595 
1596  strcpy(&httpBuffer[0],stringBuffer);
1597  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(stringBuffer));
1598  message_size += strlen(stringBuffer);
1599  //printf("------- message size %d ------------\n", (int) message_size);
1600 
1601  stepDut();
1602 
1603  uint8_t multiple_iterations = rand() % 8;
1604  for(int k = 0; k < multiple_iterations; k++)
1605  {
1606  printf("multiple FMC calls with no input %d.\n",multiple_iterations);
1607  stepDut();
1608  }
1609  assert(decoupActive == 1);
1610  //we cant test the last word, but we can test the total
1612  }
1613 
1614  //to write all remaining stuff (including possible wrap around)
1615  stepDut();
1616  stepDut();
1617  assert(decoupActive == 1);
1618 #endif
1619 
1620  //last chunk
1621  //HWICAP_seq_OUT[WFV_OFFSET] = 0x710;
1622  getStatus = "0012345678abcdefgh\r\n\r\n";
1623  // -> 18 payload bytes
1624 
1625  strcpy((char*) &HWICAP_seq_IN[hwicap_in_address],"0012345678abcdefgh");
1626  hwicap_in_address += strlen(getStatus);
1627 
1628  strcpy(&httpBuffer[0],getStatus);
1629  copyBufferToStream(httpBuffer,sNAL_FMC_Tcp_data,strlen(getStatus));
1630 
1631  stepDut();
1632  stepDut();
1633  //now, we are done
1634  assert(decoupActive == 0);
1635  printf("WF: %#010x\n",(int) HWICAP_seq_OUT[WF_OFFSET]);
1636  WF_should = 0x65666768;
1637  printf("WF_should: %#010x\n", WF_should);
1638  assert((int) HWICAP_seq_OUT[WF_OFFSET] == WF_should);
1639 
1640  //now, we can check the complete buffer, it should be also empty afterwards...
1642 
1643  //Check CR_WRITE
1645  stepDut(); //to finish
1646  stepDut(); //334 (if buffer = 2048)
1647  succeded &= checkResult(MMIO, 0x30574154); //WAT
1648  assert(decoupActive == 0);
1649  assert(HWICAP_seq_OUT[CR_OFFSET] == 0);
1650 
1651  sessId_back = sFMC_NAL_Tcp_sessId.read();
1652  assert(sessId.getTData() == sessId_back.getTData());
1653  printf("Check stream:\n0x312e312f50545448\n0x0d4b4f2030303220\n");
1654  assert(sFMC_NAL_Tcp_data.read().tdata == 0x312e312f50545448);
1655  assert(sFMC_NAL_Tcp_data.read().tdata == 0x0d4b4f2030303220);
1656  //drain remaining
1657  printf("Partial ");
1659  assert(sFMC_NAL_Tcp_data.empty());
1660 
1661  //TODO: test if FMC stays operational after a failed request
1662 
1663  printf("== TCP Test passed == \n");
1664 
1665 
1666 #ifndef COSIM
1667  return succeded? 0 : -1;
1668 #else
1669  //since some vectors and their timestamps shift during cosim...
1670  return 0;
1671 #endif
1672 }
ap_uint< 1 > decoupActive
Definition: tb_fmc.cpp:81
ap_uint< 32 > sim_fpga_time_seconds
Definition: tb_fmc.cpp:78
void copyBufferToXmem(char *buffer_int, ap_uint< 32 > xmem[(32 *16)])
Definition: tb_fmc.cpp:317
ap_uint< 32 > HWICAP_seq_OUT[((16 *4096+512)/4)]
Definition: tb_fmc.cpp:88
bool checkSeqHwicap(uint32_t *true_buffer, ap_uint< 32 > *out_buffer, uint32_t start_address, uint32_t end_address, bool not_to_swap)
Definition: tb_fmc.cpp:189
stream< Axis< 8 > > FMC_Debug_Pyrolink("FMC_Debug_Pyrolink")
stream< TcpWord > sFMC_NAL_Tcp_data("sFMC_Nal_Tcp_data")
uint8_t HWICAP_seq_IN[((16 *4096+512)/4) *4]
Definition: tb_fmc.cpp:87
void drainStream(stream< NetworkWord > &tcp_data)
Definition: tb_fmc.cpp:368
void initBuffer(ap_uint< 4 > cnt, ap_uint< 32 > xmem[(32 *16)], bool lastPage, bool withPattern)
Definition: tb_fmc.cpp:241
stream< AppMeta > sNAL_FMC_Tcp_sessId("sNAL_FMC_Tcp_sessId")
ap_uint< 32 > clusterSize_out
Definition: tb_fmc.cpp:85
stream< TcpWord > sNAL_FMC_Tcp_data("sNAL_FMC_Tcp_data")
bool checkResult(ap_uint< 32 > MMIO, ap_uint< 32 > expected)
Definition: tb_fmc.cpp:144
stream< AppMeta > sFMC_NAL_Tcp_sessId("sFMC_Nal_Tcp_sessId")
stream< Axis< 8 > > Debug_FMC_Pyrolink("Debug_FMC_Pyrolink")
void stepDut()
Run a single iteration of the DUT model.
Definition: tb_fmc.cpp:115
void printBuffer(volatile uint8_t *buffer_int, char *msg, int max_pages)
Definition: tb_fmc.cpp:157
#define HWICAP_SEQ_START_ADDRESS
Definition: tb_fmc.cpp:58
void copyBufferToStream(char *buffer_int, stream< NetworkWord > &tcp_data, int content_len)
Definition: tb_fmc.cpp:330
ap_uint< 32 > nodeRank_out
Definition: tb_fmc.cpp:84
ap_uint< D > getTData()
Definition: axi_utils.hpp:55
void setTLast(ap_uint< 1 > new_last)
Definition: axi_utils.hpp:70
Here is the call graph for this function:
Here is the caller graph for this function:

◆ my_atoi()

int my_atoi ( char *  str,
int  strlen 
)

Definition at line 177 of file http.cpp.

178 {
179  int res = 0;
180 
181  for (int i = 0; i < strlen; ++i)
182  {
183  res = res*10 + (str[i] - '0');
184  }
185 
186  return res;
187 }
Here is the caller graph for this function:

◆ my_itoa()

void my_itoa ( unsigned long  num,
char *  arr,
unsigned char  base 
)

Definition at line 153 of file http.cpp.

154 {
155  unsigned char i=0,rem=0;
156 
157  // Handle 0 explicitly, otherwise empty string is printed for 0
158  if (num == 0)
159  {
160  arr[i++] = '0';
161  arr[i] = '\0';
162  }
163 
164  // Process individual digits
165  while (num != 0)
166  {
167  rem = num % base;
168  arr[i++] = (rem > 9)? (rem-10) + 'A' : rem + '0';
169  num = num/base;
170  }
171  arr[i] = '\0'; // Append string terminator
172  strrev(arr); // Reverses the string
173 }
void strrev(char *str)
Definition: http.cpp:93
Here is the call graph for this function:

◆ my_strcmp()

int my_strcmp ( char *  tmp1,
volatile uint8_t  tmp2[4096],
int  max_length 
)

Definition at line 246 of file http.cpp.

247 {
248  int cnt = 0;
249  while(*tmp1 && tmp2[cnt])
250  {
251  if(*tmp1== tmp2[cnt])
252  {
253  tmp1++;
254  cnt++;
255  }
256  else
257  {
258  if(*tmp1< tmp2[cnt])
259  {
260  return -1;
261  }
262  else
263  {
264  return 1;
265  }
266  }
267  //if (cnt == max_length -1 )
268  if (cnt == max_length ) //\0 is at the end
269  {
270  return 0; //equal until max_length
271  }
272  }
273  return 0; //strings are same
274 }
Here is the caller graph for this function:

◆ my_strlen()

int my_strlen ( char *  s)

Definition at line 52 of file http.cpp.

52  {
53  int sum = 0;
54  char c = s[0];
55 
56  while(c != '\0') {
57  sum++;
58  c = s[sum];
59  }
60  return sum;
61 }
Here is the caller graph for this function:

◆ my_wordlen()

int my_wordlen ( char *  s)

Definition at line 63 of file http.cpp.

63  {
64  //word in the sense of: string to next space
65  int sum = 0;
66  char c = s[0];
67 
68  while(c != ' ') {
69  sum++;
70  c = s[sum];
71  }
72  return sum;
73 }
Here is the caller graph for this function:

◆ parseHttpInput()

void parseHttpInput ( bool  transferErr,
ap_uint< 1 >  wasAbort,
bool  invalidPayload,
bool  rx_done 
)

Definition at line 401 of file http.cpp.

402 {
403 
404  switch (httpState) {
405  case HTTP_IDLE: //both the same
406  case HTTP_PARSE_HEADER:
407  //search for HTTP
408  switch (extract_path(rx_done)) {
409  default:
410  case -3: //404
413  break;
414  case -2: //invalid content
417  break;
418  case -1: //not yet complete
420  break;
421  case 0: //not vaild until now
422  break;
423  case 1: //get status
425  break;
426  case 2: //post config
428  break;
429  case 3: //put rank
431  break;
432  case 4: //put size
434  break;
435  case 5: //post routing
437  break;
438  }
439  break;
440  case HTTP_HEADER_PARSED: //this state is valid for one core-cycle: after that the current payload should start at 0
442  //no break
443  case HTTP_READ_PAYLOAD:
444  break;
445  case HTTP_REQUEST_COMPLETE:
446  // break;
447  case HTTP_SEND_RESPONSE:
448  //emptyOutBuffer(); ensured by global state machine
449  if(wasAbort == 1) //abort always also triggers transferErr --> so check this first
450  {
452  } else if (transferErr == true || invalidPayload == true)
453  {
455  } else if(reqType == GET_STATUS)
456  {
457  //combine status
458  //length??
460  //write status
461  uint32_t contentLen = writeDisplaysToOutBuffer();
462  writeString(httpNL); //to finish body
463  if (contentLen > 0)
464  {
465  bufferOutContentLength += contentLen;
466  }
467  } else if(reqType == POST_CONFIG)
468  {
470  bufferOutContentLength += writeString("Partial reconfiguration finished successfully!\r\n\r\n");
471  //write success message
472  } else {
473  //PUT_RANK, PUT_SIZE, POST_ROUTING
475  }
477  break;
478  default:
479  break;
480  }
481 
482  printf("parseHttpInput returns with state %d\n",httpState);
483  //printf("RequestType after parseHttpInput %d\n",reqType);
484 
485 }
int8_t writeHttpStatus(int status, uint16_t content_length)
Definition: http.cpp:190
int writeString(char *s)
Definition: http.cpp:76
uint32_t writeDisplaysToOutBuffer()
Definition: fmc.cpp:270
int8_t extract_path(bool rx_done)
Definition: http.cpp:321
Here is the call graph for this function:
Here is the caller graph for this function:

◆ printBuffer()

void printBuffer ( volatile uint8_t *  buffer_int,
char *  msg,
int  max_pages 
)

Definition at line 157 of file tb_fmc.cpp.

158 {
159  printf("%s: \n",msg);
160  for( int i = 0; i < BYTES_PER_PAGE*max_pages; i++)
161  {
162  uint8_t cur_elem = (ap_uint<8>) buffer_int[i];
163  printf("%02x ", cur_elem);
164 
165  if(i % 8 == 7)
166  {
167  printf("\n");
168  }
169 
170  }
171 }
Here is the caller graph for this function:

◆ printBuffer32()

void printBuffer32 ( ap_uint< 32 >  buffer_int[(32 * 16)],
char *  msg,
int  max_pages 
)

Definition at line 173 of file tb_fmc.cpp.

174 {
175  printf("%s: \n",msg);
176  for( int i = 0; i < LINES_PER_PAGE*max_pages; i++)
177  {
178  int cur_elem = (int) buffer_int[i];
179  printf("%08x ", cur_elem);
180 
181  if(i % 8 == 7)
182  {
183  printf("\n");
184  }
185 
186  }
187 }

◆ request_len()

int request_len ( ap_uint< 16 >  offset,
int  maxLength 
)

Definition at line 286 of file http.cpp.

287 {
288 
289  if (bufferIn[offset + 0] == 0x00)
290  {//empty
291  return 0;
292  }
293 
294  int sum = 0;
295  char c1 = 0, c2 = 0, c3 = 0, c4 = 0;
296  c1 = (char) bufferIn[offset + 0 + 0];
297  c2 = (char) bufferIn[offset + 0 + 1];
298  c3 = (char) bufferIn[offset + 0 + 2];
299  c4 = (char) bufferIn[offset + 0 + 3];
300 
301  while( (c1 != '\r' || c2 != '\n' || c3 != '\r' || c4 != '\n' ) && sum < maxLength)
302  {
303  //NOT! sum += 4;
304  sum++;
305  c1 = (char) bufferIn[offset + sum + 0];
306  c2 = (char) bufferIn[offset + sum + 1];
307  c3 = (char) bufferIn[offset + sum + 2];
308  c4 = (char) bufferIn[offset + sum + 3];
309  }
310 
311 
312  if (sum >= maxLength)
313  { //not a valid end of header found --> invalid content, since we should have already the complete request in the buffer here
314  return -1;
315  }
316 
317  return sum;
318 
319 }
Here is the caller graph for this function:

◆ reverse_byte_order()

ap_uint<32> reverse_byte_order ( ap_uint< 32 >  input)

Definition at line 100 of file tb_fmc.cpp.

101 {
102  ap_uint<32> output = 0x0;
103  output = (ap_uint<32>) ((input >> 24) & 0xFF);
104  output |= (ap_uint<32>) ((input >> 8) & 0xFF00);
105  output |= (ap_uint<32>) ((input << 8) & 0xFF0000);
106  output |= (ap_uint<32>) ((input << 24) & 0xFF000000);
107  return output;
108 }
string input
Definition: test.py:9
string output
Definition: test.py:10
Here is the caller graph for this function:

◆ setRank()

void setRank ( ap_uint< 32 >  newRank)

Definition at line 451 of file fmc.cpp.

452 {
453  nodeRank = newRank;
455  //nothing else to do so far
456 }

◆ setSize()

void setSize ( ap_uint< 32 >  newSize)

Definition at line 458 of file fmc.cpp.

459 {
460  clusterSize = newSize;
461  //nothing else to do so far
462 }

◆ sFMC_NAL_Tcp_data()

stream<TcpWord> sFMC_NAL_Tcp_data ( "sFMC_Nal_Tcp_data"  )
Here is the caller graph for this function:

◆ sFMC_NAL_Tcp_sessId()

stream<AppMeta> sFMC_NAL_Tcp_sessId ( "sFMC_Nal_Tcp_sessId"  )
Here is the caller graph for this function:

◆ sNAL_FMC_Tcp_data()

stream<TcpWord> sNAL_FMC_Tcp_data ( "sNAL_FMC_Tcp_data"  )
Here is the caller graph for this function:

◆ sNAL_FMC_Tcp_sessId()

stream<AppMeta> sNAL_FMC_Tcp_sessId ( "sNAL_FMC_Tcp_sessId"  )
Here is the caller graph for this function:

◆ strrev()

void strrev ( char *  str)

Definition at line 93 of file http.cpp.

94 {
95  unsigned char temp, len=0, i=0;
96 
97  if( str == '\0' || !(*str) ) // If str is NULL or empty, do nothing
98  return;
99 
100  while(str[len] != '\0')
101  {
102  len++;
103  }
104  len=len-1;
105 
106  // Swap the characters
107  while(i < len)
108  {
109  temp = str[i];
110  str[i] = str[len];
111  str[len] = temp;
112  i++;
113  len--;
114  }
115 }
Here is the caller graph for this function:

◆ writeDisplaysToOutBuffer()

uint32_t writeDisplaysToOutBuffer ( )

Definition at line 270 of file fmc.cpp.

271 {
272  uint32_t len = 0;
273  //Display1
274  len = writeString("Status Display 1: ");
275  len += writeUnsignedLong((uint32_t) Display1, 16);
276  bufferOut[bufferOutPtrWrite + 0] = '\r';
277  bufferOut[bufferOutPtrWrite + 1] = '\n';
278  bufferOutPtrWrite += 2;
279  len += 2;
280 
281  //Display2
282  len += writeString("Status Display 2: ");
283  len += writeUnsignedLong((uint32_t) Display2, 16);
284  bufferOut[bufferOutPtrWrite + 0] = '\r';
285  bufferOut[bufferOutPtrWrite + 1] = '\n';
286  bufferOutPtrWrite += 2;
287  len += 2;
288 
289  //Display 3 & 4 is less informative outside EMIF Context
290 
291  //insert rank and size
292  len += writeString("Rank: ");
293  len += writeUnsignedLong(nodeRank, 10);
294  bufferOut[bufferOutPtrWrite + 0] = '\r';
295  bufferOut[bufferOutPtrWrite + 1] = '\n';
296  bufferOutPtrWrite += 2;
297  len += 2;
298 
299  len += writeString("Size: ");
300  len += writeUnsignedLong(clusterSize, 10);
301  bufferOut[bufferOutPtrWrite + 0] = '\r';
302  bufferOut[bufferOutPtrWrite + 1] = '\n';
303  bufferOutPtrWrite += 2;
304  len += 2;
305 
306  //NRC status
307  len += writeString("NAL Status (16 lines): \r\n"); //NAL_NUMBER_STATUS_WORDS
308 
309  for(int i = 0; i<NAL_NUMBER_STATUS_WORDS; i++)
310  {
311  if(i<=9)
312  {
313  bufferOut[bufferOutPtrWrite] = '0' + i; //poor mans ascii cast
314  } else {
317  len++;
318  bufferOut[bufferOutPtrWrite] = '0' + (i-10);
319  }
321  len++;
322  len+=writeString(": ");
323  if( nal_status_disabled )
324  {
325  bufferOut[bufferOutPtrWrite + 3] = nal_status[i] & 0xFF;
326  bufferOut[bufferOutPtrWrite + 2] = (nal_status[i] >> 8) & 0xFF;
327  bufferOut[bufferOutPtrWrite + 1] = (nal_status[i] >> 16) & 0xFF;
328  bufferOut[bufferOutPtrWrite + 0] = (nal_status[i] >> 24) & 0xFF;
329  bufferOut[bufferOutPtrWrite + 4] = '\r';
330  bufferOut[bufferOutPtrWrite + 5] = '\n';
331  bufferOutPtrWrite += 6;
332  len += 6;
333  } else {
334  len += writeUnsignedLong((uint32_t) nal_status[i], 16);
335  bufferOut[bufferOutPtrWrite + 0] = '\r';
336  bufferOut[bufferOutPtrWrite + 1] = '\n';
337  bufferOutPtrWrite += 2;
338  len += 2;
339  }
340  }
341 
342  //FPGA status
343  len += writeString("FPGA Status (8 lines): \r\n"); //NUMBER_FPGA_STATE_REGISTERS
344  for(int i = 0; i<NUMBER_FPGA_STATE_REGISTERS; i++)
345  {
346  if(i<=9)
347  {
348  bufferOut[bufferOutPtrWrite] = '0' + i; //poor mans ascii cast
349  } else {
352  len++;
353  bufferOut[bufferOutPtrWrite] = '0' + (i-10);
354  }
356  len++;
357  len+=writeString(": ");
358  //we have a bit size of 8
359  uint8_t val = fpga_status[i];
360  bufferOut[bufferOutPtrWrite] = (val > 9)? (val-10) + 'A' : val + '0'; //is only 8bit
361  bufferOut[bufferOutPtrWrite + 1] = '\r';
362  bufferOut[bufferOutPtrWrite + 2] = '\n';
363  bufferOutPtrWrite += 3;
364  len += 3;
365  }
366 
367  //print uptime
368  len += writeString("FPGA uptime: ");
369  bufferOut[bufferOutPtrWrite + 0] = '0' + (fpga_time_hours / 10);
370  bufferOut[bufferOutPtrWrite + 1] = '0' + (fpga_time_hours % 10);
371  bufferOut[bufferOutPtrWrite + 2] = ':';
372  bufferOutPtrWrite += 3;
373  len += 3;
374  bufferOut[bufferOutPtrWrite + 0] = '0' + (fpga_time_minutes / 10);
375  bufferOut[bufferOutPtrWrite + 1] = '0' + (fpga_time_minutes % 10);
376  bufferOut[bufferOutPtrWrite + 2] = ':';
377  bufferOutPtrWrite += 3;
378  len += 3;
379  bufferOut[bufferOutPtrWrite + 0] = '0' + (fpga_time_seconds / 10);
380  bufferOut[bufferOutPtrWrite + 1] = '0' + (fpga_time_seconds % 10);
381  bufferOut[bufferOutPtrWrite + 2] = '\r';
382  bufferOut[bufferOutPtrWrite + 3] = '\n';
383  bufferOutPtrWrite += 4;
384  len += 3;
385 
386  //print cFDK version
387  len += writeString("cFDK/FMC version: ");
389  bufferOut[bufferOutPtrWrite + 0] = '\r';
390  bufferOut[bufferOutPtrWrite + 1] = '\n';
391  bufferOutPtrWrite += 2;
392  len += 2;
393 
394  //print Role version vector
395  len += writeString("current ROLE version: ");
396  len += writeUnsignedLong((uint16_t) current_role_mmio, 16);
397  bufferOut[bufferOutPtrWrite + 0] = '\r';
398  bufferOut[bufferOutPtrWrite + 1] = '\n';
399  bufferOutPtrWrite += 2;
400  len += 2;
401 
402  //print NTS drop counts
403  len += writeString("UDP RX drop count: ");
404  len += writeUnsignedLong((uint16_t) nts_udp_drop_cnt, 16);
405  bufferOut[bufferOutPtrWrite + 0] = '\r';
406  bufferOut[bufferOutPtrWrite + 1] = '\n';
407  bufferOutPtrWrite += 2;
408  len += 2;
409  len += writeString("TCP RX notif drop count: ");
410  len += writeUnsignedLong((uint8_t) nts_tcp_notif_drop_cnt, 16);
411  bufferOut[bufferOutPtrWrite + 0] = '\r';
412  bufferOut[bufferOutPtrWrite + 1] = '\n';
413  bufferOutPtrWrite += 2;
414  len += 2;
415  len += writeString("TCP RX meta drop count: ");
416  len += writeUnsignedLong((uint8_t) nts_tcp_meta_drop_cnt, 16);
417  bufferOut[bufferOutPtrWrite + 0] = '\r';
418  bufferOut[bufferOutPtrWrite + 1] = '\n';
419  bufferOutPtrWrite += 2;
420  len += 2;
421  len += writeString("TCP RX data drop count: ");
422  len += writeUnsignedLong((uint8_t) nts_tcp_data_drop_cnt, 16);
423  bufferOut[bufferOutPtrWrite + 0] = '\r';
424  bufferOut[bufferOutPtrWrite + 1] = '\n';
425  bufferOutPtrWrite += 2;
426  len += 2;
427  len += writeString("TCP RX CRC drop count: ");
428  len += writeUnsignedLong((uint8_t) nts_tcp_crc_drop_cnt, 16);
429  bufferOut[bufferOutPtrWrite + 0] = '\r';
430  bufferOut[bufferOutPtrWrite + 1] = '\n';
431  bufferOutPtrWrite += 2;
432  len += 2;
433  len += writeString("TCP RX Session drop count: ");
434  len += writeUnsignedLong((uint8_t) nts_tcp_sess_drop_cnt, 16);
435  bufferOut[bufferOutPtrWrite + 0] = '\r';
436  bufferOut[bufferOutPtrWrite + 1] = '\n';
437  bufferOutPtrWrite += 2;
438  len += 2;
439  len += writeString("TCP RX Out-of-Order drop count: ");
440  len += writeUnsignedLong((uint8_t) nts_tcp_ooo_drop_cnt, 16);
441  bufferOut[bufferOutPtrWrite + 0] = '\r';
442  bufferOut[bufferOutPtrWrite + 1] = '\n';
443  bufferOutPtrWrite += 2;
444  len += 2;
445 
446 
447  len += writeString(httpNL);
448  return len;
449 }
#define CFDK_VERSION_STRING
Definition: cfdk.hpp:30
int writeUnsignedLong(unsigned long num, uint8_t base)
Definition: http.cpp:119
Here is the call graph for this function:
Here is the caller graph for this function:

◆ writeHttpStatus()

int8_t writeHttpStatus ( int  status,
uint16_t  content_length 
)

Definition at line 190 of file http.cpp.

190  {
191 
192  char* toWrite;
193 
194  switch (status) {
195  case 200:
196  toWrite = status200;
197  break;
198  case 400:
199  toWrite = status400;
200  break;
201  case 403:
202  toWrite = status403;
203  break;
204  case 404:
205  toWrite = status404;
206  break;
207  case 422:
208  toWrite = status422;
209  break;
210  default:
211  toWrite = status500;
212  break;
213  }
214 
215  //Assemble Header
216  int len = writeString(httpHeader);
217  len += writeString(toWrite);
218  len += writeString(httpNL);
219  len += writeString(generalHeaderBegin);
221  len += writeString(httpNL);
222 
223  //TODO: maybe include in future versions
224  /* if ( content_length > 0)
225  {
226  char *lengthAscii = new char[6];
227 
228  for(int i = 0; i < 6; i++)
229  {
230  lengthAscii[i] = 0x20;
231  }
232 
233  my_itoa(content_length, lengthAscii, 10);
234 
235  len += writeString(contentLengthHeader);
236  len += writeString(lengthAscii);
237  len += writeString(httpNL);
238  }
239  */
240  len += writeString(httpNL); // to finish header
241 
242  return len;
243 }
Here is the caller graph for this function:

◆ writeString()

int writeString ( char *  s)

Definition at line 76 of file http.cpp.

77 {
78  int len = 0;
79  for(int i = 0; i<OUT_BUFFER_SIZE; i++)
80  {
81  if(s[i] == '\0')
82  {
83  break;
84  }
85  bufferOut[bufferOutPtrWrite + i] = s[i];
86  len++;
87  }
88  bufferOutPtrWrite += len;
90  return len;
91 }
Here is the caller graph for this function:

◆ writeUnsignedLong()

int writeUnsignedLong ( unsigned long  num,
uint8_t  base 
)

Definition at line 119 of file http.cpp.

120 {
121  unsigned char i=0,rem=0;
122  char arr[66];
123 
124  // Handle 0 explicitly, otherwise empty string is printed for 0
125  if (num == 0)
126  {
127  arr[i++] = '0';
128  }
129  // Process individual digits
130  while (num != 0 && i<=64)
131  {
132  rem = num % base;
133  arr[i++] = (rem > 9)? (rem-10) + 'A' : rem + '0';
134  num = num/base;
135  }
136  arr[i] = '\0'; // Append string terminator
137  strrev(arr); // Reverses the string
138 
139  //now, copy to buffer out
140  //<i, because we don't want to copy \0
141  for(int p = 0; p<i; p++)
142  {
143  bufferOut[bufferOutPtrWrite + p] = arr[p];
144  }
145  bufferOutPtrWrite += i;
146  printf("written unsigned long %s of length %d with basis %d\n",arr,i, (int) base);
147 
149  return i;
150 }
Here is the call graph for this function:
Here is the caller graph for this function:

Variable Documentation

◆ axi_wasnot_ready_persistent

bool axi_wasnot_ready_persistent = false

Definition at line 119 of file fmc.cpp.

◆ buffer_hangover_bytes

uint8_t buffer_hangover_bytes[3]

Definition at line 151 of file fmc.cpp.

◆ bufferIn [1/2]

uint8_t bufferIn[4096]

Definition at line 52 of file fmc.cpp.

◆ bufferIn [2/2]

uint8_t bufferIn[4096]
extern

Definition at line 52 of file fmc.cpp.

◆ bufferInPtrMaxWrite

uint32_t bufferInPtrMaxWrite = 0x0

Definition at line 54 of file fmc.cpp.

◆ bufferInPtrNextRead [1/2]

uint32_t bufferInPtrNextRead = 0x0

Definition at line 56 of file fmc.cpp.

◆ bufferInPtrNextRead [2/2]

uint32_t bufferInPtrNextRead
extern

Definition at line 56 of file fmc.cpp.

◆ bufferInPtrWrite [1/2]

uint32_t bufferInPtrWrite = 0x0

Definition at line 53 of file fmc.cpp.

◆ bufferInPtrWrite [2/2]

uint32_t bufferInPtrWrite
extern

Definition at line 53 of file fmc.cpp.

◆ bufferOut [1/2]

uint8_t bufferOut[1024]

Definition at line 59 of file fmc.cpp.

◆ bufferOut [2/2]

uint8_t bufferOut[1024]
extern

Definition at line 59 of file fmc.cpp.

◆ bufferOutContentLength [1/2]

uint16_t bufferOutContentLength = 0x0

Definition at line 61 of file fmc.cpp.

◆ bufferOutContentLength [2/2]

uint16_t bufferOutContentLength
extern

Definition at line 61 of file fmc.cpp.

◆ bufferOutPtrNextRead

uint16_t bufferOutPtrNextRead = 0x0

Definition at line 62 of file fmc.cpp.

◆ bufferOutPtrWrite [1/2]

uint16_t bufferOutPtrWrite = 0x0

Definition at line 60 of file fmc.cpp.

◆ bufferOutPtrWrite [2/2]

uint16_t bufferOutPtrWrite
extern

Definition at line 60 of file fmc.cpp.

◆ clusterSize

ap_uint<32> clusterSize = 0

Definition at line 79 of file fmc.cpp.

◆ clusterSize_out

ap_uint<32> clusterSize_out

Definition at line 85 of file tb_fmc.cpp.

◆ ctrl_link_next_check_seconds

ap_uint<32> ctrl_link_next_check_seconds = 0

Definition at line 88 of file fmc.cpp.

◆ current_MRT

ap_uint<32> current_MRT[64]

Definition at line 157 of file fmc.cpp.

◆ current_nrc_config

ap_uint<32> current_nrc_config[16]

Definition at line 158 of file fmc.cpp.

◆ current_nrc_mrt_version

ap_uint<32> current_nrc_mrt_version = 0

Definition at line 159 of file fmc.cpp.

◆ current_role_mmio

ap_uint<16> current_role_mmio = 0

Definition at line 93 of file fmc.cpp.

◆ currentGlobalOperation

uint8_t currentGlobalOperation = 0

Definition at line 111 of file fmc.cpp.

◆ currentTcpSessId

AppMeta currentTcpSessId = 0

Definition at line 122 of file fmc.cpp.

◆ decoupActive

ap_uint<1> decoupActive = 0b0

Definition at line 81 of file tb_fmc.cpp.

◆ decoupStatus

ap_uint<1> decoupStatus = 0b0

Definition at line 82 of file tb_fmc.cpp.

◆ detected_http_nl_cnt

ap_uint<2> detected_http_nl_cnt = 0

Definition at line 146 of file fmc.cpp.

◆ disable_ctrl_link

ap_uint<1> disable_ctrl_link = 0b0

Definition at line 91 of file tb_fmc.cpp.

◆ disable_pyro_link

ap_uint<1> disable_pyro_link = 0b0

Definition at line 92 of file tb_fmc.cpp.

◆ Display1

ap_uint<32> Display1 = 0

Definition at line 74 of file fmc.cpp.

◆ Display2

ap_uint<32> Display2 = 0

Definition at line 74 of file fmc.cpp.

◆ Display3

ap_uint<32> Display3 = 0

Definition at line 74 of file fmc.cpp.

◆ Display4

ap_uint<32> Display4 = 0

Definition at line 74 of file fmc.cpp.

◆ Display5

ap_uint<32> Display5 = 0

Definition at line 74 of file fmc.cpp.

◆ Display6

ap_uint<32> Display6 = 0

Definition at line 74 of file fmc.cpp.

◆ Display7

ap_uint<32> Display7 = 0

Definition at line 74 of file fmc.cpp.

◆ Display8

ap_uint<32> Display8 = 0

Definition at line 74 of file fmc.cpp.

◆ Display9

ap_uint<32> Display9 = 0

Definition at line 74 of file fmc.cpp.

◆ fifo_operation_in_progress

bool fifo_operation_in_progress = false

Definition at line 47 of file fmc.cpp.

◆ fifo_overflow_buffer

uint8_t fifo_overflow_buffer[8]

Definition at line 48 of file fmc.cpp.

◆ fifo_overflow_buffer_length

uint8_t fifo_overflow_buffer_length = 8

Definition at line 50 of file fmc.cpp.

◆ fifoEmptyCnt

ap_uint<8> fifoEmptyCnt = 0

Definition at line 40 of file fmc.cpp.

◆ fifoFullCnt

ap_uint<8> fifoFullCnt = 0

Definition at line 41 of file fmc.cpp.

◆ flag_check_xmem_pattern

ap_uint<1> flag_check_xmem_pattern = 0

Definition at line 129 of file fmc.cpp.

◆ flag_continuous_tcp_rx

ap_uint<1> flag_continuous_tcp_rx = 0

Definition at line 132 of file fmc.cpp.

◆ flag_enable_fake_hwicap

ap_uint<1> flag_enable_fake_hwicap = 0

Definition at line 133 of file fmc.cpp.

◆ flag_silent_skip

ap_uint<1> flag_silent_skip = 0

Definition at line 130 of file fmc.cpp.

◆ fpga_status

ap_uint<8> fpga_status[8]

Definition at line 87 of file fmc.cpp.

◆ fpga_time_hours

ap_uint<32> fpga_time_hours = 0

Definition at line 97 of file fmc.cpp.

◆ fpga_time_minutes

ap_uint<32> fpga_time_minutes = 0

Definition at line 96 of file fmc.cpp.

◆ fpga_time_seconds

ap_uint<32> fpga_time_seconds = 0

Definition at line 95 of file fmc.cpp.

◆ fsmHwicap

uint8_t fsmHwicap = 0

Definition at line 46 of file fmc.cpp.

◆ fsmTcpData_RX

uint8_t fsmTcpData_RX = 0

Definition at line 138 of file fmc.cpp.

◆ fsmTcpData_TX

uint8_t fsmTcpData_TX = 0

Definition at line 139 of file fmc.cpp.

◆ fsmTcpSessId_RX

uint8_t fsmTcpSessId_RX = 0

Definition at line 136 of file fmc.cpp.

◆ fsmTcpSessId_TX

uint8_t fsmTcpSessId_TX = 0

Definition at line 137 of file fmc.cpp.

◆ global_state_wait_counter_persistent

ap_uint<32> global_state_wait_counter_persistent = 0

Definition at line 120 of file fmc.cpp.

◆ globalOperationDone_persistent

bool globalOperationDone_persistent = false

Definition at line 118 of file fmc.cpp.

◆ goto_done_if_idle_tcp_rx

bool goto_done_if_idle_tcp_rx = false

Definition at line 141 of file fmc.cpp.

◆ httpState [1/2]

uint8_t httpState = 0

Definition at line 72 of file fmc.cpp.

◆ httpState [2/2]

uint8_t httpState
extern

Definition at line 72 of file fmc.cpp.

◆ HWICAP

ap_uint<32> HWICAP[512]

Definition at line 86 of file tb_fmc.cpp.

◆ hwicap_hangover_present

bool hwicap_hangover_present = true

Definition at line 152 of file fmc.cpp.

◆ hwicap_hangover_size

uint8_t hwicap_hangover_size = 0

Definition at line 153 of file fmc.cpp.

◆ HWICAP_seq_IN

uint8_t HWICAP_seq_IN[((16 *4096+512)/4) *4]

Definition at line 87 of file tb_fmc.cpp.

◆ HWICAP_seq_OUT

ap_uint<32> HWICAP_seq_OUT[((16 *4096+512)/4)]

Definition at line 88 of file tb_fmc.cpp.

◆ invalidPayload_persistent

bool invalidPayload_persistent = false

Definition at line 115 of file fmc.cpp.

◆ last_3_chars

uint8_t last_3_chars[3]

Definition at line 145 of file fmc.cpp.

◆ last_xmem_page_received_persistent

ap_uint<1> last_xmem_page_received_persistent = 0

Definition at line 131 of file fmc.cpp.

◆ lastResponsePageCnt

ap_uint<7> lastResponsePageCnt = 0

Definition at line 107 of file fmc.cpp.

◆ lastSeenBufferInPtrMaxWrite

uint32_t lastSeenBufferInPtrMaxWrite = 0x0

Definition at line 55 of file fmc.cpp.

◆ lastSeenBufferOutPtrNextRead

uint16_t lastSeenBufferOutPtrNextRead = 0x0

Definition at line 63 of file fmc.cpp.

◆ layer_4_enabled

ap_uint<1> layer_4_enabled = 0b1

Definition at line 66 of file tb_fmc.cpp.

◆ layer_6_enabled

ap_uint<1> layer_6_enabled = 0b0

Definition at line 67 of file tb_fmc.cpp.

◆ layer_7_enabled

ap_uint<1> layer_7_enabled = 0b0

Definition at line 68 of file tb_fmc.cpp.

◆ linkCtrlFSM

uint8_t linkCtrlFSM = 1

Definition at line 162 of file fmc.cpp.

◆ max_discovered_node_id

ap_uint<32> max_discovered_node_id = 0

Definition at line 163 of file fmc.cpp.

◆ MMIO

ap_uint<32> MMIO

Definition at line 64 of file tb_fmc.cpp.

◆ MMIO_in

ap_uint<32> MMIO_in = 0x0

Definition at line 63 of file tb_fmc.cpp.

◆ MMIO_in_BE

ap_uint<32> MMIO_in_BE

Definition at line 65 of file tb_fmc.cpp.

◆ MMIO_out_BE

ap_uint<32> MMIO_out_BE

Definition at line 65 of file tb_fmc.cpp.

◆ mrt_copy_index

ap_uint<32> mrt_copy_index = 0

Definition at line 90 of file fmc.cpp.

◆ nal_status

ap_uint<32> nal_status[ 16]

Definition at line 84 of file fmc.cpp.

◆ nal_status_disabled

bool nal_status_disabled = false

Definition at line 85 of file fmc.cpp.

◆ nal_status_request_cnt

ap_uint<8> nal_status_request_cnt = 0

Definition at line 83 of file fmc.cpp.

◆ nalCtrl

ap_uint<32> nalCtrl[(0x3ff/4)]

Definition at line 90 of file tb_fmc.cpp.

◆ need_to_update_nrc_config

bool need_to_update_nrc_config = false

Definition at line 161 of file fmc.cpp.

◆ need_to_update_nrc_mrt

bool need_to_update_nrc_mrt = false

Definition at line 160 of file fmc.cpp.

◆ nodeRank

ap_uint<32> nodeRank = 0

Definition at line 78 of file fmc.cpp.

◆ nodeRank_out

ap_uint<32> nodeRank_out

Definition at line 84 of file tb_fmc.cpp.

◆ nts_ready

ap_uint<1> nts_ready = 0b1

Definition at line 69 of file tb_fmc.cpp.

◆ nts_tcp_crc_drop_cnt

ap_uint<8> nts_tcp_crc_drop_cnt = 0

Definition at line 103 of file fmc.cpp.

◆ nts_tcp_data_drop_cnt

ap_uint<8> nts_tcp_data_drop_cnt = 0

Definition at line 102 of file fmc.cpp.

◆ nts_tcp_meta_drop_cnt

ap_uint<8> nts_tcp_meta_drop_cnt = 0

Definition at line 101 of file fmc.cpp.

◆ nts_tcp_notif_drop_cnt

ap_uint<8> nts_tcp_notif_drop_cnt = 0

Definition at line 100 of file fmc.cpp.

◆ nts_tcp_ooo_drop_cnt

ap_uint<8> nts_tcp_ooo_drop_cnt = 0

Definition at line 105 of file fmc.cpp.

◆ nts_tcp_sess_drop_cnt

ap_uint<8> nts_tcp_sess_drop_cnt = 0

Definition at line 104 of file fmc.cpp.

◆ nts_udp_drop_cnt

ap_uint<16> nts_udp_drop_cnt = 0

Definition at line 99 of file fmc.cpp.

◆ positions_of_detected_http_nl

uint32_t positions_of_detected_http_nl[4]

Definition at line 148 of file fmc.cpp.

◆ process_fifo_overflow_buffer

bool process_fifo_overflow_buffer = false

Definition at line 49 of file fmc.cpp.

◆ received_TCP_SessIds_cnt

ap_uint<4> received_TCP_SessIds_cnt = 0

Definition at line 142 of file fmc.cpp.

◆ reqType [1/2]

uint8_t reqType = 0x01

Definition at line 284 of file http.cpp.

◆ reqType [2/2]

uint8_t reqType
extern

Definition at line 284 of file http.cpp.

◆ responePageCnt

ap_uint<4> responePageCnt = 0

Definition at line 108 of file fmc.cpp.

◆ role_mmio

ap_uint<16> role_mmio = 0x1DEA

Definition at line 70 of file tb_fmc.cpp.

◆ run_nested_loop_helper

bool run_nested_loop_helper = false

Definition at line 140 of file fmc.cpp.

◆ sequential_hwicap_address [1/2]

uint32_t sequential_hwicap_address = 0

Definition at line 68 of file fmc.cpp.

◆ sequential_hwicap_address [2/2]

uint32_t sequential_hwicap_address
extern

Definition at line 68 of file fmc.cpp.

◆ sim_fpga_time_hours

ap_uint<32> sim_fpga_time_hours = 0

Definition at line 80 of file tb_fmc.cpp.

◆ sim_fpga_time_minutes

ap_uint<32> sim_fpga_time_minutes = 0

Definition at line 79 of file tb_fmc.cpp.

◆ sim_fpga_time_seconds

ap_uint<32> sim_fpga_time_seconds = 0

Definition at line 78 of file tb_fmc.cpp.

◆ simCnt

int simCnt

Definition at line 113 of file tb_fmc.cpp.

◆ softReset

ap_uint<1> softReset = 0b0

Definition at line 83 of file tb_fmc.cpp.

◆ streaming_mode_persistent

bool streaming_mode_persistent = false

Definition at line 113 of file fmc.cpp.

◆ tables_initialized

bool tables_initialized = false

Definition at line 156 of file fmc.cpp.

◆ target_http_nl_cnt

ap_uint<2> target_http_nl_cnt = 0

Definition at line 147 of file fmc.cpp.

◆ tcp_iteration_count

uint8_t tcp_iteration_count = 0

Definition at line 125 of file fmc.cpp.

◆ tcp_words_received

ap_uint<28> tcp_words_received = 0

Definition at line 76 of file fmc.cpp.

◆ tcp_write_only_fifo

bool tcp_write_only_fifo = false

Definition at line 57 of file fmc.cpp.

◆ tcpModeEnabled

ap_uint<1> tcpModeEnabled = 0

Definition at line 124 of file fmc.cpp.

◆ TcpSessId_updated_persistent

bool TcpSessId_updated_persistent = false

Definition at line 123 of file fmc.cpp.

◆ toDecoup_persistent

ap_uint<1> toDecoup_persistent = 0

Definition at line 81 of file fmc.cpp.

◆ toe_crc_drop_cnt

ap_uint<8> toe_crc_drop_cnt = 0

Definition at line 75 of file tb_fmc.cpp.

◆ toe_data_drop_cnt

ap_uint<8> toe_data_drop_cnt = 0

Definition at line 74 of file tb_fmc.cpp.

◆ toe_meta_drop_cnt

ap_uint<8> toe_meta_drop_cnt = 0

Definition at line 73 of file tb_fmc.cpp.

◆ toe_notif_drop_cnt

ap_uint<8> toe_notif_drop_cnt = 0

Definition at line 72 of file tb_fmc.cpp.

◆ toe_ooo_drop_cnt

ap_uint<8> toe_ooo_drop_cnt = 0

Definition at line 77 of file tb_fmc.cpp.

◆ toe_sess_drop_cnt

ap_uint<8> toe_sess_drop_cnt = 0

Definition at line 76 of file tb_fmc.cpp.

◆ transferError_persistent

bool transferError_persistent = false

Definition at line 114 of file fmc.cpp.

◆ uoe_drop_cnt

ap_uint<16> uoe_drop_cnt = 0x0

Definition at line 71 of file tb_fmc.cpp.

◆ use_sequential_hwicap [1/2]

bool use_sequential_hwicap = false

Definition at line 67 of file fmc.cpp.

◆ use_sequential_hwicap [2/2]

bool use_sequential_hwicap
extern

Definition at line 67 of file fmc.cpp.

◆ wordsWrittenToIcapCnt

ap_uint<28> wordsWrittenToIcapCnt = 0

Definition at line 75 of file fmc.cpp.

◆ writeErrCnt

ap_uint<8> writeErrCnt = 0

Definition at line 39 of file fmc.cpp.

◆ xmem

ap_uint<32> xmem[(32 * 16)]

Definition at line 89 of file tb_fmc.cpp.

◆ xmem_page_trans_cnt

ap_uint<4> xmem_page_trans_cnt = 0xF

Definition at line 42 of file fmc.cpp.