Skip to content

Commit

Permalink
Testing out PIP
Browse files Browse the repository at this point in the history
  • Loading branch information
Steve Kerrison committed Oct 11, 2012
1 parent 95d93f7 commit f87acc5
Show file tree
Hide file tree
Showing 6 changed files with 286 additions and 3 deletions.
112 changes: 112 additions & 0 deletions .cproject

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions app_swallow_etherboot/Makefile
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
# The TARGET variable determines what target system the application is
# compiled for. It either refers to an XN file in the source directories
# or a valid argument for the --target option when compiling
TARGET = Swallow-SDRAM256
TARGET = Swallow-Ethernet

# The APP_NAME variable determines the name of the final .xe file. It should
# not include the .xe postfix. If left blank the name will default to
# the project name
APP_NAME = swallow_etherboot

# The USED_MODULES variable lists other module used by the application.
USED_MODULES = swallow_comms swallow-xlinkboot base_xlinkboot module_ethernet
USED_MODULES = swallow_comms swallow-xlinkboot base_xlinkboot module_ethernet pip

# The flags passed to xcc when building the application
# You can also set the following to override flags for a particular language:
Expand All @@ -19,7 +19,7 @@ USED_MODULES = swallow_comms swallow-xlinkboot base_xlinkboot module_ethernet
ifeq "$(CONFIG)" "Debug"
XCC_FLAGS = -g -O0
else
XCC_FLAGS = -g -O3
XCC_FLAGS = -g -O3 -report -lxscope
endif

# The VERBOSE variable, if set to 1, enables verbose output from the make
Expand Down
72 changes: 72 additions & 0 deletions app_swallow_etherboot/Swallow-Ethernet.xn
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
<?xml version="1.0" encoding="UTF-8"?>
<Network xmlns="http://www.xmos.com"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.xmos.com http://www.xmos.com">
<Type>Board</Type>
<Name>Swallow 256Mbit SDRAM Board</Name>

<Declarations>
<Declaration>core stdcore[1]</Declaration>
</Declarations>

<Packages>
<Package id="0" Type="XS1-L1A-TQ128">
<Nodes>
<Node Id="0" InPackageId="0" Type="XS1-L1A" Oscillator="25MHz" ReferenceFrequency="100MHz" SystemFrequency="600MHz">

<Boot>
<Source Location="SPI:bootFlash"/>
</Boot>

<Core Number="0" Reference="stdcore[0]">
<!--<Port Location="XS1_PORT_1L" Name="L1_LED"/>--> <!-- "L1_LED on board -->

<Port Location="XS1_PORT_1A" Name="SPI_SO"/> <!-- SPI flash lines -->
<Port Location="XS1_PORT_1B" Name="SPI_SS"/>
<Port Location="XS1_PORT_1C" Name="SPI_CLK"/>
<Port Location="XS1_PORT_1D" Name="SPI_SI"/>

<Port Location="XS1_PORT_1I" Name="I2C_SDA"/> <!-- I2C data line -->
<Port Location="XS1_PORT_1J" Name="I2C_SCK"/> <!-- I2C clock line -->

<Port Location="XS1_PORT_1G" Name="PORT_ETH_RXCLK" />
<!--<Port Location="XS1_PORT_1H" Name="PORT_ETH_RXER" /> Shared port -->
<Port Location="XS1_PORT_1K" Name="PORT_ETH_RXDV" />
<Port Location="XS1_PORT_4C" Name="PORT_ETH_RXD" />
<Port Location="XS1_PORT_1F" Name="PORT_ETH_TXCLK" />
<Port Location="XS1_PORT_1L" Name="PORT_ETH_TXEN" />
<Port Location="XS1_PORT_4D" Name="PORT_ETH_TXD" />
<Port Location="XS1_PORT_1J" Name="PORT_ETH_MDC" />
<Port Location="XS1_PORT_1I" Name="PORT_ETH_MDIO" />
<!-- <Port Location="XS1_PORT_1B" Name="PORT_ETH_RST_N" /> Shared port -->
<!-- <Port Location="XS1_PORT_8B" Name="PORT_ETH_FAKE" /> Shared port -->

</Core>
</Node>
</Nodes>
</Package>
</Packages>

<Links>
<!-- XSCOPE -->
<Link Encoding="2wire" Delays="4,4" Flags="SOD">
<LinkEndpoint NodeId="0" Link="XLD"/>
<LinkEndpoint RoutingId="0x8000" Chanend="1"/>
</Link>
</Links>

<ExternalDevices>
<Device NodeId="0" Core="0" Class="SPIFlash" Name="bootFlash" Type="FL064K1F"> <!-- is AT25FS010 compatible -->
<!-- <Device NodeId="0" Core="0" Class="SPIFlash" Name="bootFlash" Type="AT25FS010"> -->
<Attribute Name="PORT_SPI_MISO" Value="SPI_SO"/>
<Attribute Name="PORT_SPI_SS" Value="SPI_SS"/>
<Attribute Name="PORT_SPI_CLK" Value="SPI_CLK"/>
<Attribute Name="PORT_SPI_MOSI" Value="SPI_SI"/>
</Device>
</ExternalDevices>

<JTAGChain>
<JTAGDevice NodeId="0"/>
</JTAGChain>

</Network>
6 changes: 6 additions & 0 deletions app_swallow_etherboot/src/ethernet_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#define ETHERNET_DEFAULT_IMPLEMENTATION lite

#define MAX_ETHERNET_PACKET_SIZE (1518)

#define MAX_ETHERNET_CLIENTS (4)

86 changes: 86 additions & 0 deletions app_swallow_etherboot/src/main.xc
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* swallow_etherboot - Boot a Swallow grid using Ethernet
*
* Copyright (C) 2012 Steve Kerrison <[email protected]>
*
* This software is freely distributable under a derivative of the
* University of Illinois/NCSA Open Source License posted in
* LICENSE.txt and at <http://github.xcore.com/>
*/

#include <platform.h>
#include <print.h>
#include <xscope.h>
#include "smi.h"
#include "mii_driver.h"
#include "mii.h"
#include "pipServer.h"
#include "tcpApplication.h"
#include "ipv4.h"
#include "udpApplication.h"

#define PORT_ETH_FAKE XS1_PORT_8C
#define PORT_ETH_RXER XS1_PORT_1H
#define PORT_ETH_RST_N XS1_PORT_1A

mii_interface_t mii =
{
XS1_CLKBLK_1,
XS1_CLKBLK_2,

PORT_ETH_RXCLK,
PORT_ETH_RXER,
PORT_ETH_RXD,
PORT_ETH_RXDV,

PORT_ETH_TXCLK,
PORT_ETH_TXEN,
PORT_ETH_TXD,

PORT_ETH_FAKE,
};

out port p_mii_resetn = PORT_ETH_RST_N;
smi_interface_t smi = { 0x1F, PORT_ETH_MDIO, PORT_ETH_MDC };

clock clk_smi = XS1_CLKBLK_5;

void udpEcho(streaming chanend ch)
{
unsigned char buffer [1500];
unsigned rip, rport;
int len;
while (1)
{
len = pipApplicationReadUDP(ch, buffer, 0, 1500, rip, rport, 1234);
pipApplicationWriteUDP(ch, buffer, 0, len, rip, 1234, rport);
}
}

void tcpEcho(streaming chanend ch)
{
unsigned char buffer [1500];
int len;
pipApplicationAccept(ch, 0);
while (1)
{
len = pipApplicationRead(ch, 0, buffer, 1500);
pipApplicationWrite(ch, 0, buffer, len);
}
}

int main(void) {
streaming chan tcpApps[1];
streaming chan udpApps[1];
char ip[] = {4,128,168,192};
xscope_register(0);
xscope_config_io(XSCOPE_IO_BASIC);
pipAssignIPv4((ip,unsigned), 0, 0);
par
{
pipServer(clk_smi, p_mii_resetn, smi, mii, tcpApps, udpApps);
//udpEcho(udpApps[0]);
tcpEcho(tcpApps[0]);
}
return 0;
}
7 changes: 7 additions & 0 deletions app_swallow_etherboot/src/pip_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#define PIP_TCP_CHANNELS 1 // At most one application
#define PIP_UDP_CHANNELS 1 // At most one application

#define PIP_ICMP
#define PIP_UDP
#define PIP_TCP 1
#define PIP_ETHTX_WORDS 800

0 comments on commit f87acc5

Please sign in to comment.