Compare commits
3 Commits
c909e0c703
...
master
Author | SHA1 | Date | |
---|---|---|---|
9558851e8b | |||
69d26c3a46 | |||
0425710537 |
255
c/prog.c
255
c/prog.c
@@ -24,7 +24,8 @@
|
||||
#define MY_DEST_MAC5 0x00
|
||||
|
||||
#define DEFAULT_IF "enp5s0"
|
||||
#define BUF_SIZ 1024
|
||||
#define BUF_SIZ 1500
|
||||
#define LED_CNT 360
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
@@ -84,240 +85,28 @@ int main(int argc, char *argv[])
|
||||
|
||||
/* Packet data */
|
||||
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++] = 0x00;
|
||||
break;
|
||||
case 2:
|
||||
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) {
|
||||
for (i = 0; i< 60; i++) {
|
||||
for (i = 0; i< LED_CNT; i++) {
|
||||
switch (mode) {
|
||||
case 1:
|
||||
sendbuf[tx_len++] = 0xff;
|
||||
@@ -337,13 +126,13 @@ int main(int argc, char *argv[])
|
||||
}
|
||||
}
|
||||
} else if (mode == 4) {
|
||||
for (i = 0; i< 3*60; i++) {
|
||||
for (i = 0; i< 3*LED_CNT; i++) {
|
||||
sendbuf[tx_len++] = 0x00;
|
||||
|
||||
}
|
||||
|
||||
} else if (mode == 5) {
|
||||
for (i = 0; i< 3*60; i++) {
|
||||
for (i = 0; i< 3*LED_CNT; i++) {
|
||||
sendbuf[tx_len++] = 0xff;
|
||||
}
|
||||
} else if (mode == 6) {
|
||||
@@ -351,7 +140,7 @@ sendbuf[tx_len++] = 0xff;
|
||||
r = (unsigned char) atoi(argv[2]);
|
||||
g = (unsigned char) atoi(argv[3]);
|
||||
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++] = g;
|
||||
sendbuf[tx_len++] = b;
|
||||
|
52
top.vhd
52
top.vhd
@@ -6,7 +6,7 @@
|
||||
-- Author : Mario Hüttel <mario.huettel@gmx.net>
|
||||
-- Company :
|
||||
-- Created : 2018-04-05
|
||||
-- Last update: 2018-04-07
|
||||
-- Last update: 2018-04-13
|
||||
-- Platform :
|
||||
-- Standard : VHDL'93/02
|
||||
-------------------------------------------------------------------------------
|
||||
@@ -36,12 +36,13 @@ entity top is
|
||||
end entity top;
|
||||
|
||||
architecture RTL of top is
|
||||
constant DELAYCNTVAL : integer := 100000; -- set to low value for
|
||||
-- simulation
|
||||
constant DEFMAC : std_logic_vector(47 downto 0) := x"00DEADBEEF00";
|
||||
constant DELAYCNTVAL : integer := 100000; -- set to low value for
|
||||
-- simulation
|
||||
constant STARTUPDELAY : integer := 50000000;
|
||||
constant DEFMAC : std_logic_vector(47 downto 0) := x"00DEADBEEF00";
|
||||
|
||||
type smi_state_t is (IDLE, STROBE);
|
||||
type smi_init_state_t is (SMI_POR, 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 receive_t is (PRE, DESTMAC, HEADER, RECV, WAITFORACK);
|
||||
|
||||
@@ -50,9 +51,8 @@ architecture RTL of top is
|
||||
|
||||
signal sendstate : smi_state_t;
|
||||
signal initstate : smi_init_state_t := SMI_POR;
|
||||
signal after_delay_state : smi_init_state_t := RESET;
|
||||
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_dat : std_logic_vector(15 downto 0);
|
||||
signal smi_strb : std_logic;
|
||||
@@ -88,7 +88,17 @@ architecture RTL of top is
|
||||
|
||||
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
|
||||
generic map (
|
||||
@@ -136,7 +146,7 @@ begin -- architecture RTL
|
||||
STD_FIFO_1 : entity work.STD_FIFO
|
||||
generic map (
|
||||
DATA_WIDTH => 8,
|
||||
FIFO_DEPTH => 256)
|
||||
FIFO_DEPTH => 360*3)
|
||||
port map (
|
||||
CLK => clk,
|
||||
RST => fifo_rst,
|
||||
@@ -190,31 +200,35 @@ begin -- architecture RTL
|
||||
rst_rxtx <= '1';
|
||||
initstate <= SMI_POR;
|
||||
sendstate <= IDLE;
|
||||
after_delay_state <= RESET;
|
||||
delaycounter <= (others => '0');
|
||||
elsif rising_edge(clk) then
|
||||
smi_strb <= '0';
|
||||
rst_rxtx <= '1';
|
||||
case initstate is
|
||||
when SMI_POR =>
|
||||
after_delay_state <= RESET;
|
||||
delaycounter <= (others => '0');
|
||||
initstate <= DELAY;
|
||||
delaycounter <= (others => '0');
|
||||
initstate <= SMI_PORDELAY;
|
||||
when SMI_PORDELAY =>
|
||||
delaycounter <= delaycounter + 1;
|
||||
if delaycounter = STARTUPDELAY then
|
||||
initstate <= RESET;
|
||||
end if;
|
||||
when RESET =>
|
||||
after_delay_state <= INIT;
|
||||
delaycounter <= (others => '0');
|
||||
sendsmi((others => '0'), x"8000", DELAY);
|
||||
|
||||
delaycounter <= (others => '0');
|
||||
sendsmi((others => '0'), x"8000", DELAY);
|
||||
|
||||
when DELAY =>
|
||||
delaycounter <= delaycounter + 1;
|
||||
if delaycounter = DELAYCNTVAL then -- Set to 100000
|
||||
initstate <= after_delay_state;
|
||||
initstate <= INIT;
|
||||
end if;
|
||||
when INIT =>
|
||||
sendsmi((others => '0'), "00" & '1' & '1' & "000" & '1' & "00000000", INIT_COMPLETE);
|
||||
when INIT_COMPLETE =>
|
||||
initstate <= INIT_COMPLETE;
|
||||
rst_rxtx <= '0';
|
||||
if smi_busy = '0' then
|
||||
rst_rxtx <= '0';
|
||||
end if;
|
||||
end case;
|
||||
end if;
|
||||
end process initphy;
|
||||
|
Reference in New Issue
Block a user