902aa402b3830b9c9aa26758390b6eb93b42a0f5
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

1) -- MIPS I system
Stefan Schuermans replace email address in he...

Stefan Schuermans authored 12 years ago

2) -- Copyright 2011-2012 Stefan Schuermans <stefan@blinkenarea.org>
Stefan Schuermans added file headers

Stefan Schuermans authored 12 years ago

3) -- Copyleft GNU public license V2 or later
4) --          http://www.gnu.org/copyleft/gpl.html
5) 
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

6) LIBRARY ieee;
7) USE ieee.std_logic_1164.all;
8) USE ieee.numeric_std.all;
9) USE std.textio.all;
Stefan Schuermans records for ethernet pins

Stefan Schuermans authored 12 years ago

10) USE work.io_eth_pins.all;
Stefan Schuermans implemented LCD peripheral

Stefan Schuermans authored 12 years ago

11) USE work.io_lcd_pins.all;
Stefan Schuermans implemented switches

Stefan Schuermans authored 12 years ago

12) USE work.io_switches_pins.all;
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

13) 
14) ENTITY e_testbed IS
15) END ENTITY e_testbed;
16) 
17) ARCHITECTURE a_testbed OF e_testbed IS
18) 
19)     COMPONENT e_system IS
20)         PORT (
Stefan Schuermans records for ethernet pins

Stefan Schuermans authored 12 years ago

21)             clk:            IN  std_logic;
22)             pin_o_leds:     OUT std_logic_vector(7 DOWNTO 0);
23)             pin_o_lcd:      OUT t_io_lcd_pins;
24)             pin_i_switches: IN  t_io_switches_pins;
25)             pin_i_uart_rx:  IN  std_logic;
26)             pin_o_uart_tx:  OUT std_logic;
27)             pin_o_eth:      OUT t_io_eth_o_pins;
28)             pin_i_eth:      IN  t_io_eth_i_pins
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

29)         );
30)     END COMPONENT e_system;
31) 
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

32)     -- ICMP echo request
33)     TYPE t_eth_data IS ARRAY(0 TO 220 - 1) OF std_logic_vector(3 DOWNTO 0);
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

34)     CONSTANT eth_data: t_eth_data := (
35)         X"5", X"5", X"5", X"5", X"5", X"5", X"5", X"5",
36)         X"5", X"5", X"5", X"5", X"5", X"5", X"5", X"D",
Stefan Schuermans implemented IP + ICMP, fixe...

Stefan Schuermans authored 12 years ago

37)         X"2", X"0", X"D", X"4", X"9", X"4", X"0", X"5",
38)         X"3", X"5", X"1", X"0", X"0", X"0", X"D", X"1",
39)         X"0", X"6", X"C", X"D", X"5", X"7", X"D", X"2",
40)         X"8", X"0", X"0", X"0", X"5", X"4", X"0", X"0",
41)         X"0", X"0", X"4", X"5", X"0", X"0", X"0", X"0",
42)         X"0", X"4", X"0", X"0", X"0", X"4", X"1", X"0",
43)         X"8", X"B", X"5", X"F", X"0", X"C", X"8", X"A",
44)         X"0", X"0", X"A", X"0", X"0", X"C", X"8", X"A",
45)         X"0", X"0", X"9", X"5", X"8", X"0", X"0", X"0",
46)         X"E", X"8", X"7", X"5", X"F", X"0", X"2", X"6",
47)         X"0", X"0", X"1", X"0", X"6", X"E", X"4", X"B",
48)         X"D", X"6", X"F", X"4", X"0", X"0", X"0", X"0",
49)         X"0", X"0", X"0", X"0", X"4", X"4", X"E", X"6",
50)         X"3", X"0", X"0", X"0", X"0", X"0", X"0", X"0",
51)         X"0", X"0", X"0", X"0", X"0", X"1", X"1", X"1",
52)         X"2", X"1", X"3", X"1", X"4", X"1", X"5", X"1",
53)         X"6", X"1", X"7", X"1", X"8", X"1", X"9", X"1",
54)         X"A", X"1", X"B", X"1", X"C", X"1", X"D", X"1",
55)         X"E", X"1", X"F", X"1", X"0", X"2", X"1", X"2",
56)         X"2", X"2", X"3", X"2", X"4", X"2", X"5", X"2",
57)         X"6", X"2", X"7", X"2", X"8", X"2", X"9", X"2",
58)         X"A", X"2", X"B", X"2", X"C", X"2", X"D", X"2",
59)         X"E", X"2", X"F", X"2", X"0", X"3", X"1", X"3",
60)         X"2", X"3", X"3", X"3", X"4", X"3", X"5", X"3",
61)         X"6", X"3", X"7", X"3", X"2", X"9", X"1", X"C",
62)         X"0", X"1", X"2", X"C"
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

63)         );
64) 
Stefan Schuermans improve 200ms tick and task...

Stefan Schuermans authored 12 years ago

65)     SIGNAL s_clk:       std_logic;
66)     SIGNAL s_leds:      std_logic_vector(7 DOWNTO 0);
67)     SIGNAL s_lcd:       t_io_lcd_pins;
68)     SIGNAL s_uart:      std_logic;
Stefan Schuermans records for ethernet pins

Stefan Schuermans authored 12 years ago

69)     SIGNAL s_o_eth:     t_io_eth_o_pins;
70)     SIGNAL s_i_eth:     t_io_eth_i_pins;
Stefan Schuermans improve 200ms tick and task...

Stefan Schuermans authored 12 years ago

71)     SIGNAL s_eth_clk:   std_logic;
72)     SIGNAL s_eth_rxd_d: std_logic_vector(3 DOWNTO 0);
73)     SIGNAL s_eth_rx_dv: std_logic;
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

74) 
75) BEGIN
76) 
77)     system: e_system
78)         PORT MAP (
Stefan Schuermans records for ethernet pins

Stefan Schuermans authored 12 years ago

79)             clk            => s_clk,
80)             pin_o_leds     => s_leds,
81)             pin_o_lcd      => s_lcd,
82)             pin_i_switches => (sw => (OTHERS => '0'), OTHERS => '0'),
83)             pin_i_uart_rx  => '1',
84)             pin_o_uart_tx  => s_uart,
85)             pin_i_eth      => s_i_eth,
86)             pin_o_eth      => s_o_eth
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

87)         );
88) 
Stefan Schuermans records for ethernet pins

Stefan Schuermans authored 12 years ago

89)     s_i_eth.rx_clk <= s_eth_clk;
90)     s_i_eth.rxd    <= "0" & s_eth_rxd_d;
91)     s_i_eth.rx_dv  <= s_eth_rx_dv;
92)     s_i_eth.crs    <= s_eth_rx_dv;
93)     s_i_eth.col    <= '0';
94)     s_i_eth.tx_clk <= s_eth_clk;
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

95) 
96)     p_clk: PROCESS
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

97)     BEGIN
98)         WHILE TRUE LOOP
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

99)             s_clk <= '0';
Stefan Schuermans initial firmware and testbed

Stefan Schuermans authored 12 years ago

100)             WAIT FOR 10 ns;
101)             s_clk <= '1';
102)             WAIT FOR 10 ns;
103)         END LOOP;
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

104)     END PROCESS p_clk;
105) 
106)     p_eth_clk: PROCESS
107)     BEGIN
108)         WHILE TRUE LOOP
109)             s_eth_clk <= '0';
110)             WAIT FOR 20 ns;
111)             s_eth_clk <= '1';
112)             WAIT FOR 20 ns;
113)         END LOOP;
114)     END PROCESS p_eth_clk;
115) 
Stefan Schuermans extended testbed to log eth...

Stefan Schuermans authored 12 years ago

116)     p_eth_rx_data: PROCESS
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

117)     BEGIN
Stefan Schuermans extended testbed to log eth...

Stefan Schuermans authored 12 years ago

118)         s_eth_rxd_d <= "0000";
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

119)         s_eth_rx_dv <= '0';
Stefan Schuermans use ARP request packet as e...

Stefan Schuermans authored 12 years ago

120)         WAIT FOR 25 ms;
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

121)         WAIT UNTIL s_eth_clk = '1';
122)         WAIT UNTIL s_eth_clk = '0';
123)         FOR i IN 0 TO eth_data'length - 1 LOOP
Stefan Schuermans extended testbed to log eth...

Stefan Schuermans authored 12 years ago

124)             s_eth_rxd_d <= eth_data(i);
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

125)             s_eth_rx_dv <= '1';
126)             WAIT UNTIL s_eth_clk = '1';
127)             WAIT UNTIL s_eth_clk = '0';
128)         END LOOP;
Stefan Schuermans extended testbed to log eth...

Stefan Schuermans authored 12 years ago

129)         s_eth_rxd_d <= "0000";
Stefan Schuermans implemented ethernet RX pac...

Stefan Schuermans authored 12 years ago

130)         s_eth_rx_dv <= '0';
131)         WAIT;
Stefan Schuermans extended testbed to log eth...

Stefan Schuermans authored 12 years ago

132)     END PROCESS p_eth_rx_data;
133) 
134)     p_eth_tx_data: PROCESS
135)         VARIABLE l: line;
136)     BEGIN
137)         FOR i IN 0 TO eth_data'length - 1 LOOP
138)             WAIT UNTIL s_eth_clk = '0';
139)             WAIT UNTIL s_eth_clk = '1';
Stefan Schuermans records for ethernet pins

Stefan Schuermans authored 12 years ago

140)             IF s_o_eth.tx_en = '1' THEN
Stefan Schuermans extended testbed to log eth...

Stefan Schuermans authored 12 years ago

141)                 write(l, "ethernet TX: ");
Stefan Schuermans records for ethernet pins

Stefan Schuermans authored 12 years ago

142)                 write(l, to_integer(unsigned(s_o_eth.txd)));
Stefan Schuermans extended testbed to log eth...

Stefan Schuermans authored 12 years ago

143)                 writeline(output, l);
144)             END IF;
145)         END LOOP;
146)     END PROCESS p_eth_tx_data;