Altera_Forum
Honored Contributor
12 years agohow many nanosecond used for after for ethernet to send 32 bits one by one
i harded code with counter to send a ethernet frame, any alternatives to do smartly? if using after x ns, how many nano seconds i use for this and how?
process(clk)
VARIABLE last_clk : std_logic := U;
VARIABLE counter : integer := 0;
VARIABLE last_counter : integer := 0;
begin
while (whilelooptrue = enableit) loop
if SW(0) = '1' then
beginwrite <= '1';
ff_tx_wren_enable <= enableit;
startpacket <= enableit;
tx_data <= preamble;
startpacket <= disableit;
if (clk = '0') AND (last_clk = '1') then
if (counter = 0) then
tx_data <= preamble;
end if;
if (counter = 1) then
tx_data <= preamble;
end if;
if (counter = 2) then
tx_data <= preamble;
end if;
if (counter = 3) then
tx_data <= preamble;
end if;
if (counter = 4) then
tx_data <= preamble;
end if;
if (counter = 5) then
tx_data <= preamble;
end if;
if (counter = 6) then
tx_data <= preamble;
end if;
if (counter = 7) then
tx_data <= SFD;
end if;
if (counter = 8) then
tx_data <= dest_mac_addr1;
end if;
if (counter = 9) then
tx_data <= dest_mac_addr2;
end if;
if (counter = 10) then
tx_data <= dest_mac_addr3;
end if;
if (counter = 11) then
tx_data <= dest_mac_addr4;
end if;
if (counter = 12) then
tx_data <= dest_mac_addr5;
end if;
if (counter = 13) then
tx_data <= dest_mac_addr6;
end if;
if (counter = 14) then
tx_data <= src_mac_addr1;
end if;
if (counter = 15) then
tx_data <= src_mac_addr2;
end if;
if (counter = 16) then
tx_data <= src_mac_addr3;
end if;
if (counter = 17) then
tx_data <= src_mac_addr4;
end if;
if (counter = 18) then
tx_data <= src_mac_addr5;
end if;
if (counter = 19) then
tx_data <= src_mac_addr6;
end if;
if (counter = 20) then
tx_data <= wholepacketlength1;
end if;
if (counter = 21) then
tx_data <= wholepacketlength2;
end if;
if (counter = 22) then
tx_data <= payload;
end if;
if (counter = 23) then
tx_data <= CheckSumResult4;
end if;
if (counter = 24) then
tx_data <= CheckSumResult3;
end if;
if (counter = 25) then
tx_data <= CheckSumResult2;
end if;
if (counter = 26) then
endpacket <= enableit;
tx_data <= CheckSumResult1;
end if;
last_counter := counter;
counter := counter + 1;
end if;
if (clk = '1') AND (last_clk = '0') then
if (counter >= 26) then
endpacket <= disableit;
ff_tx_wren_enable <= disableit;
end if;
end if;
else
beginwrite <= '0';
end if;
end loop;
last_clk := clk;
end process;