#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include "sim_vhpi_c.h"
/* XXX Make that some parameter */
#define TCP_PORT 13245
#define MAX_PACKET 32
-#define vhpi0 2 /* forcing 0 */
-#define vhpi1 3 /* forcing 1 */
-
-static void to_std_logic_vector(unsigned long val, unsigned char *p,
- unsigned long len)
-{
- if (len > 64) {
- fprintf(stderr, "%s: invalid length %lu\n", __func__, len);
- exit(1);
- }
-
- for (unsigned long i = 0; i < len; i++) {
- if ((val >> (len-1-i) & 1))
- *p = vhpi1;
- else
- *p = vhpi0;
-
- p++;
- }
-}
-
-static uint64_t from_std_logic_vector(unsigned char *p, unsigned long len)
-{
- unsigned long ret = 0;
-
- if (len > 64) {
- fprintf(stderr, "%s: invalid length %lu\n", __func__, len);
- exit(1);
- }
-
- for (unsigned long i = 0; i < len; i++) {
- unsigned char bit;
-
- if (*p == vhpi0) {
- bit = 0;
- } else if (*p == vhpi1) {
- bit = 1;
- } else {
- fprintf(stderr, "%s: bad bit %d\n", __func__, *p);
- bit = 0;
- }
-
- ret = (ret << 1) | bit;
- p++;
- }
-
- return ret;
-}
-
static int fd = -1;
static int cfd = -1;
fprintf(stderr, "Failed to listen to debug socket !\r\n");
goto fail;
}
- fprintf(stderr, "Debug socket ready\r\n");
+ fprintf(stdout, "Debug socket ready\r\n");
return;
fail:
if (fd >= 0)
cfd = accept(fd, (struct sockaddr *)&addr, &addr_len);
if (cfd < 0)
return;
- fprintf(stderr, "Debug client connected !\r\n");
+ fprintf(stdout, "Debug client connected !\r\n");
}
void sim_jtag_read_msg(unsigned char *out_msg, unsigned char *out_size)
if (rc < 0)
fprintf(stderr, "Debug read error, assuming client disconnected !\r\n");
if (rc == 0)
- fprintf(stderr, "Debug client disconnected !\r\n");
+ fprintf(stdout, "Debug client disconnected !\r\n");
if (rc <= 0) {
close(cfd);
cfd = -1;