Compare commits
7 Commits
75c50b63c1
...
dev-multip
Author | SHA1 | Date | |
---|---|---|---|
ee5da6812c | |||
763edd1900 | |||
9558851e8b | |||
69d26c3a46 | |||
0425710537 | |||
c909e0c703 | |||
9dd10afae1 |
@@ -7,29 +7,31 @@ end entity test;
|
|||||||
|
|
||||||
architecture bench of test is
|
architecture bench of test is
|
||||||
|
|
||||||
signal clk : std_logic;
|
signal clk : std_logic;
|
||||||
signal rst : std_logic := '1';
|
signal rst : std_logic := '1';
|
||||||
signal dv : std_logic;
|
signal dv : std_logic;
|
||||||
signal rx : std_logic_vector(1 downto 0);
|
signal rx : std_logic_vector(1 downto 0);
|
||||||
signal mdc : std_logic;
|
signal mdc : std_logic;
|
||||||
signal mdio : std_logic;
|
signal mdio : std_logic;
|
||||||
signal led : std_logic_vector(1 downto 0);
|
signal led : std_logic_vector(1 downto 0);
|
||||||
signal ws : std_logic;
|
signal ws : std_logic;
|
||||||
|
signal rst_hw : std_logic;
|
||||||
|
signal dat_cnt : std_logic_vector(3 downto 0);
|
||||||
begin -- architecture bench
|
begin -- architecture bench
|
||||||
|
|
||||||
|
|
||||||
top_1 : entity work.top
|
top_1 : entity work.top
|
||||||
port map (
|
port map (
|
||||||
clk => clk,
|
clk => clk,
|
||||||
rst => rst,
|
rst_hw => rst_hw,
|
||||||
mdio => mdio,
|
mdio => mdio,
|
||||||
mdc => mdc,
|
mdc => mdc,
|
||||||
rx => rx,
|
rx => rx,
|
||||||
dv => dv,
|
dv => dv,
|
||||||
led1 => led(0),
|
led1 => led(0),
|
||||||
led2 => led(1),
|
led2 => led(1),
|
||||||
ws_out => ws);
|
dat_cnt => dat_cnt,
|
||||||
|
ws_out => ws);
|
||||||
|
|
||||||
|
|
||||||
clkgen : process is
|
clkgen : process is
|
||||||
@@ -41,7 +43,7 @@ begin -- architecture bench
|
|||||||
end process clkgen;
|
end process clkgen;
|
||||||
|
|
||||||
|
|
||||||
|
rst_hw <= not rst;
|
||||||
|
|
||||||
|
|
||||||
sendphy : process is
|
sendphy : process is
|
||||||
@@ -60,12 +62,12 @@ begin -- architecture bench
|
|||||||
end procedure sendRMII;
|
end procedure sendRMII;
|
||||||
begin
|
begin
|
||||||
dv <= '0';
|
dv <= '0';
|
||||||
|
|
||||||
wait for 35 ns;
|
wait for 35 ns;
|
||||||
rst <= '0';
|
rst <= '0';
|
||||||
dv <= '0';
|
dv <= '0';
|
||||||
rx <= "00";
|
rx <= "00";
|
||||||
wait for 100 us;
|
wait for 350 us;
|
||||||
sendRMII(x"55");
|
sendRMII(x"55");
|
||||||
sendRMII(x"55");
|
sendRMII(x"55");
|
||||||
sendRMII(x"55");
|
sendRMII(x"55");
|
||||||
@@ -94,7 +96,6 @@ begin -- architecture bench
|
|||||||
sendRMII(x"02");
|
sendRMII(x"02");
|
||||||
|
|
||||||
sendRMII(x"AA");
|
sendRMII(x"AA");
|
||||||
|
|
||||||
sendRMII(x"01");
|
sendRMII(x"01");
|
||||||
sendRMII(x"02");
|
sendRMII(x"02");
|
||||||
|
|
||||||
@@ -103,10 +104,10 @@ begin -- architecture bench
|
|||||||
sendRMII(x"AA");
|
sendRMII(x"AA");
|
||||||
sendRMII(x"55");
|
sendRMII(x"55");
|
||||||
-- Send FCS
|
-- Send FCS
|
||||||
sendRMII(x"BD");
|
sendRMII(x"3A");
|
||||||
sendRMII(x"9B");
|
sendRMII(x"97");
|
||||||
sendRMII(x"AC");
|
sendRMII(x"D9");
|
||||||
sendRMII(x"54");
|
sendRMII(x"7A");
|
||||||
|
|
||||||
-- sendRMII(x"AB");
|
-- sendRMII(x"AB");
|
||||||
|
|
||||||
|
255
c/prog.c
255
c/prog.c
@@ -24,7 +24,8 @@
|
|||||||
#define MY_DEST_MAC5 0x00
|
#define MY_DEST_MAC5 0x00
|
||||||
|
|
||||||
#define DEFAULT_IF "enp5s0"
|
#define DEFAULT_IF "enp5s0"
|
||||||
#define BUF_SIZ 1024
|
#define BUF_SIZ 1500
|
||||||
|
#define LED_CNT 360
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
@@ -84,240 +85,28 @@ int main(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Packet data */
|
/* Packet data */
|
||||||
if (mode == 0) {
|
if (mode == 0) {
|
||||||
|
for (i = 0; i < LED_CNT; i++) {
|
||||||
|
switch (i%3) {
|
||||||
|
case 0:
|
||||||
|
sendbuf[tx_len++] = 0xff;
|
||||||
|
sendbuf[tx_len++] = 0x00;
|
||||||
|
sendbuf[tx_len++] = 0x00;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
sendbuf[tx_len++] = 0x00;
|
||||||
sendbuf[tx_len++] = 0xff;
|
sendbuf[tx_len++] = 0xff;
|
||||||
sendbuf[tx_len++] = 0x00;
|
sendbuf[tx_len++] = 0x00;
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
sendbuf[tx_len++] = 0x00;
|
||||||
sendbuf[tx_len++] = 0x00;
|
sendbuf[tx_len++] = 0x00;
|
||||||
|
sendbuf[tx_len++] = 0xff;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0x00;
|
|
||||||
sendbuf[tx_len++] = 0xff;
|
|
||||||
} else if (mode > 0 && mode < 4) {
|
} else if (mode > 0 && mode < 4) {
|
||||||
for (i = 0; i< 60; i++) {
|
for (i = 0; i< LED_CNT; i++) {
|
||||||
switch (mode) {
|
switch (mode) {
|
||||||
case 1:
|
case 1:
|
||||||
sendbuf[tx_len++] = 0xff;
|
sendbuf[tx_len++] = 0xff;
|
||||||
@@ -337,13 +126,13 @@ int main(int argc, char *argv[])
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (mode == 4) {
|
} else if (mode == 4) {
|
||||||
for (i = 0; i< 3*60; i++) {
|
for (i = 0; i< 3*LED_CNT; i++) {
|
||||||
sendbuf[tx_len++] = 0x00;
|
sendbuf[tx_len++] = 0x00;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (mode == 5) {
|
} else if (mode == 5) {
|
||||||
for (i = 0; i< 3*60; i++) {
|
for (i = 0; i< 3*LED_CNT; i++) {
|
||||||
sendbuf[tx_len++] = 0xff;
|
sendbuf[tx_len++] = 0xff;
|
||||||
}
|
}
|
||||||
} else if (mode == 6) {
|
} else if (mode == 6) {
|
||||||
@@ -351,7 +140,7 @@ sendbuf[tx_len++] = 0xff;
|
|||||||
r = (unsigned char) atoi(argv[2]);
|
r = (unsigned char) atoi(argv[2]);
|
||||||
g = (unsigned char) atoi(argv[3]);
|
g = (unsigned char) atoi(argv[3]);
|
||||||
b = (unsigned char) atoi(argv[4]);
|
b = (unsigned char) atoi(argv[4]);
|
||||||
for (i = 0; i< 60; i++) {
|
for (i = 0; i< LED_CNT; i++) {
|
||||||
sendbuf[tx_len++] = r;
|
sendbuf[tx_len++] = r;
|
||||||
sendbuf[tx_len++] = g;
|
sendbuf[tx_len++] = g;
|
||||||
sendbuf[tx_len++] = b;
|
sendbuf[tx_len++] = b;
|
||||||
|
115
top.vhd
115
top.vhd
@@ -6,7 +6,7 @@
|
|||||||
-- Author : Mario Hüttel <mario.huettel@gmx.net>
|
-- Author : Mario Hüttel <mario.huettel@gmx.net>
|
||||||
-- Company :
|
-- Company :
|
||||||
-- Created : 2018-04-05
|
-- Created : 2018-04-05
|
||||||
-- Last update: 2018-04-06
|
-- Last update: 2018-04-13
|
||||||
-- Platform :
|
-- Platform :
|
||||||
-- Standard : VHDL'93/02
|
-- Standard : VHDL'93/02
|
||||||
-------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------
|
||||||
@@ -36,21 +36,25 @@ entity top is
|
|||||||
end entity top;
|
end entity top;
|
||||||
|
|
||||||
architecture RTL of top is
|
architecture RTL of top is
|
||||||
constant DELAYCNTVAL : integer := 100000;
|
constant DELAYCNTVAL : integer := 100000; -- set to low value for
|
||||||
constant DEFMAC : std_logic_vector(47 downto 0) := x"00DEADBEEF00";
|
-- simulation
|
||||||
|
constant STARTUPDELAY : integer := 50000000;
|
||||||
|
constant DEFMAC : std_logic_vector(47 downto 0) := x"00DEADBEEF00";
|
||||||
|
constant PIPE_PKG : std_logic_vector(15 downto 0) := x"AA00";
|
||||||
|
constant FIN_PKG : std_logic_vector(15 downto 0) := x"55AA";
|
||||||
|
|
||||||
type smi_state_t is (IDLE, STROBE);
|
type smi_state_t is (IDLE, STROBE);
|
||||||
type smi_init_state_t is (RESET, INIT, DELAY, INIT_COMPLETE);
|
type smi_init_state_t is (SMI_POR, SMI_PORDELAY, RESET, INIT, DELAY, INIT_COMPLETE);
|
||||||
type ws_send_t is (WS_READY, WS_SYNC, WS_RED, WS_GREEN, WS_BLUE, WS_PIPE, WS_POST);
|
type ws_send_t is (WS_READY, WS_SYNC, WS_RED, WS_GREEN, WS_BLUE, WS_PIPE, WS_POST);
|
||||||
type receive_t is (PRE, DESTMAC, HEADER, RECV, WAITFORACK);
|
type receive_t is (PRE, DESTMAC, SRCMAC, TYPEFIELD, RECV, WAITFORACK);
|
||||||
|
|
||||||
signal rst : std_logic;
|
signal rst : std_logic;
|
||||||
signal dat_cnt_s : unsigned(3 downto 0);
|
signal dat_cnt_s : unsigned(3 downto 0);
|
||||||
|
|
||||||
signal sendstate : smi_state_t;
|
signal sendstate : smi_state_t;
|
||||||
signal initstate : smi_init_state_t := RESET;
|
signal initstate : smi_init_state_t := SMI_POR;
|
||||||
signal rst_rxtx : std_logic;
|
signal rst_rxtx : std_logic;
|
||||||
signal delaycounter : unsigned(19 downto 0);
|
signal delaycounter : unsigned(26 downto 0);
|
||||||
signal smi_reg : std_logic_vector(4 downto 0);
|
signal smi_reg : std_logic_vector(4 downto 0);
|
||||||
signal smi_dat : std_logic_vector(15 downto 0);
|
signal smi_dat : std_logic_vector(15 downto 0);
|
||||||
signal smi_strb : std_logic;
|
signal smi_strb : std_logic;
|
||||||
@@ -75,6 +79,7 @@ architecture RTL of top is
|
|||||||
signal recv_state : receive_t;
|
signal recv_state : receive_t;
|
||||||
signal mac : std_logic_vector(47 downto 0);
|
signal mac : std_logic_vector(47 downto 0);
|
||||||
signal recv_cnt : integer range 0 to 15;
|
signal recv_cnt : integer range 0 to 15;
|
||||||
|
signal pkg_type : std_logic_vector(15 downto 0);
|
||||||
--
|
--
|
||||||
signal ws_busy : std_logic;
|
signal ws_busy : std_logic;
|
||||||
signal ws_strb : std_logic;
|
signal ws_strb : std_logic;
|
||||||
@@ -86,7 +91,17 @@ architecture RTL of top is
|
|||||||
|
|
||||||
begin -- architecture RTL
|
begin -- architecture RTL
|
||||||
|
|
||||||
rst <= not rst_hw;
|
reset_sync : process(clk, rst_hw) is
|
||||||
|
begin
|
||||||
|
if rst_hw = '0' then
|
||||||
|
rst <= '1';
|
||||||
|
elsif rising_edge(clk) then
|
||||||
|
if rst_hw = '1' then
|
||||||
|
rst <= '0';
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
end process reset_sync;
|
||||||
|
|
||||||
|
|
||||||
smi_1 : entity work.smi
|
smi_1 : entity work.smi
|
||||||
generic map (
|
generic map (
|
||||||
@@ -134,7 +149,7 @@ begin -- architecture RTL
|
|||||||
STD_FIFO_1 : entity work.STD_FIFO
|
STD_FIFO_1 : entity work.STD_FIFO
|
||||||
generic map (
|
generic map (
|
||||||
DATA_WIDTH => 8,
|
DATA_WIDTH => 8,
|
||||||
FIFO_DEPTH => 256)
|
FIFO_DEPTH => 360*3)
|
||||||
port map (
|
port map (
|
||||||
CLK => clk,
|
CLK => clk,
|
||||||
RST => fifo_rst,
|
RST => fifo_rst,
|
||||||
@@ -186,15 +201,25 @@ begin -- architecture RTL
|
|||||||
smi_dat <= (others => '0');
|
smi_dat <= (others => '0');
|
||||||
smi_strb <= '0';
|
smi_strb <= '0';
|
||||||
rst_rxtx <= '1';
|
rst_rxtx <= '1';
|
||||||
initstate <= RESET;
|
initstate <= SMI_POR;
|
||||||
sendstate <= IDLE;
|
sendstate <= IDLE;
|
||||||
delaycounter <= (others => '0');
|
delaycounter <= (others => '0');
|
||||||
elsif rising_edge(clk) then
|
elsif rising_edge(clk) then
|
||||||
smi_strb <= '0';
|
smi_strb <= '0';
|
||||||
rst_rxtx <= '1';
|
rst_rxtx <= '1';
|
||||||
case initstate is
|
case initstate is
|
||||||
|
when SMI_POR =>
|
||||||
|
delaycounter <= (others => '0');
|
||||||
|
initstate <= SMI_PORDELAY;
|
||||||
|
when SMI_PORDELAY =>
|
||||||
|
delaycounter <= delaycounter + 1;
|
||||||
|
if delaycounter = STARTUPDELAY then
|
||||||
|
initstate <= RESET;
|
||||||
|
end if;
|
||||||
when RESET =>
|
when RESET =>
|
||||||
sendsmi((others => '0'), x"8000", DELAY);
|
delaycounter <= (others => '0');
|
||||||
|
sendsmi((others => '0'), x"8000", DELAY);
|
||||||
|
|
||||||
when DELAY =>
|
when DELAY =>
|
||||||
delaycounter <= delaycounter + 1;
|
delaycounter <= delaycounter + 1;
|
||||||
if delaycounter = DELAYCNTVAL then -- Set to 100000
|
if delaycounter = DELAYCNTVAL then -- Set to 100000
|
||||||
@@ -204,7 +229,9 @@ begin -- architecture RTL
|
|||||||
sendsmi((others => '0'), "00" & '1' & '1' & "000" & '1' & "00000000", INIT_COMPLETE);
|
sendsmi((others => '0'), "00" & '1' & '1' & "000" & '1' & "00000000", INIT_COMPLETE);
|
||||||
when INIT_COMPLETE =>
|
when INIT_COMPLETE =>
|
||||||
initstate <= INIT_COMPLETE;
|
initstate <= INIT_COMPLETE;
|
||||||
rst_rxtx <= '0';
|
if smi_busy = '0' then
|
||||||
|
rst_rxtx <= '0';
|
||||||
|
end if;
|
||||||
end case;
|
end case;
|
||||||
end if;
|
end if;
|
||||||
end process initphy;
|
end process initphy;
|
||||||
@@ -218,10 +245,11 @@ begin -- architecture RTL
|
|||||||
fifo_in <= (others => '0');
|
fifo_in <= (others => '0');
|
||||||
fifo_data_avail <= '0';
|
fifo_data_avail <= '0';
|
||||||
recv_state <= PRE;
|
recv_state <= PRE;
|
||||||
dat_cnt_s <= (others => '0');
|
dat_cnt_s <= (others => '0');
|
||||||
led1 <= '1';
|
led1 <= '1';
|
||||||
led2 <= '1';
|
led2 <= '1';
|
||||||
recv_cnt <= 0;
|
recv_cnt <= 0;
|
||||||
|
pkg_type <= (others => '0');
|
||||||
mac <= (others => '0');
|
mac <= (others => '0');
|
||||||
elsif rising_edge(clk) then -- rising clock edge
|
elsif rising_edge(clk) then -- rising clock edge
|
||||||
fifo_rst <= '0';
|
fifo_rst <= '0';
|
||||||
@@ -230,6 +258,7 @@ begin -- architecture RTL
|
|||||||
when PRE =>
|
when PRE =>
|
||||||
if sof = '1' then
|
if sof = '1' then
|
||||||
recv_cnt <= 0;
|
recv_cnt <= 0;
|
||||||
|
pkg_type <= (others => '0');
|
||||||
mac <= (others => '0');
|
mac <= (others => '0');
|
||||||
recv_state <= DESTMAC;
|
recv_state <= DESTMAC;
|
||||||
led1 <= '1';
|
led1 <= '1';
|
||||||
@@ -242,42 +271,56 @@ begin -- architecture RTL
|
|||||||
elsif eth_strb = '1' then
|
elsif eth_strb = '1' then
|
||||||
recv_cnt <= recv_cnt + 1;
|
recv_cnt <= recv_cnt + 1;
|
||||||
mac <= mac(39 downto 0) & eth_dat;
|
mac <= mac(39 downto 0) & eth_dat;
|
||||||
if recv_cnt = 5 then
|
if recv_cnt = 5 and (mac(39 downto 0) & eth_dat) = DEFMAC then
|
||||||
recv_cnt <= 0;
|
recv_cnt <= 0;
|
||||||
recv_state <= HEADER;
|
recv_state <= SRCMAC;
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
when HEADER =>
|
when SRCMAC =>
|
||||||
led1 <= '0';
|
|
||||||
if eof = '1' then
|
if eof = '1' then
|
||||||
recv_state <= PRE;
|
recv_state <= PRE;
|
||||||
elsif eth_strb = '1' then
|
elsif eth_strb = '1' then
|
||||||
recv_cnt <= recv_cnt + 1;
|
recv_cnt <= recv_cnt + 1;
|
||||||
if recv_cnt = 7 then
|
if recv_cnt 5 then -- SRC_MAC received
|
||||||
if mac = DEFMAC then
|
recv_state <= TYPEFIELD
|
||||||
recv_state <= RECV;
|
recv_cnt <= 0;
|
||||||
dat_cnt_s <= (others =>'0');
|
|
||||||
else
|
|
||||||
recv_state <= PRE;
|
|
||||||
|
|
||||||
end if;
|
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
|
|
||||||
|
when TYPEFIELD =>
|
||||||
|
if eof = '1' then
|
||||||
|
recv_state <= PRE;
|
||||||
|
elsif eth_strb = '1' then
|
||||||
|
recv_cnt <= recv_cnt + 1;
|
||||||
|
pkg_type <= pkg_type(7 downto 0) & eth_dat;
|
||||||
|
if recv_cnt = 1 then -- Type received
|
||||||
|
recv_cnt <= 0;
|
||||||
|
recv_state <= RECV;
|
||||||
|
end if;
|
||||||
|
end if;
|
||||||
|
|
||||||
when RECV =>
|
when RECV =>
|
||||||
led2 <= '0';
|
led2 <= '0';
|
||||||
if eth_strb = '1' and fifo_full /= '1' then
|
if eth_strb = '1' and fifo_full /= '1' then
|
||||||
fifo_in <= eth_dat;
|
fifo_in <= eth_dat;
|
||||||
fifo_wr <= '1';
|
fifo_wr <= '1';
|
||||||
dat_cnt_s <= dat_cnt_s +1;
|
dat_cnt_s <= dat_cnt_s +1;
|
||||||
end if;
|
end if;
|
||||||
if eof = '1' then
|
if eof = '1' then
|
||||||
if crc_valid = '1' then-- or crc_valid = '0' then
|
if crc_valid = '1' then
|
||||||
recv_state <= WAITFORACK;
|
if pkg_type = PIPE_PKG then
|
||||||
fifo_data_avail <= '1';
|
-- Wait for further frames
|
||||||
--led2 <= '0';
|
-- This is also called with any
|
||||||
else
|
-- undefined TYPEFIELD
|
||||||
--led2 <= '1';
|
recv_state <= PRE;
|
||||||
|
elsif pkg_type = FIN_PKG then
|
||||||
|
fifo_data_avail <= '1';
|
||||||
|
recv_state <= WAITFORACK;
|
||||||
|
else
|
||||||
|
recv_state <= PRE;
|
||||||
|
end if;
|
||||||
|
else -- Eth Frame invalid. Discard
|
||||||
fifo_rst <= '1';
|
fifo_rst <= '1';
|
||||||
recv_state <= PRE;
|
recv_state <= PRE;
|
||||||
end if;
|
end if;
|
||||||
|
Reference in New Issue
Block a user