- added command fifo for xfer unit
- completed first version of receiver Committed on the Free edition of March Hare Software CVSNT Server. Upgrade to CVS Suite for more features and support: http://march-hare.com/cvsnt/ git-svn-id: http://moon:8086/svn/vhdl/trunk@811 cc03376c-175c-47c8-b038-4cd826a8556b
This commit is contained in:
@@ -68,7 +68,7 @@ ARCHITECTURE behavior OF tb_emac_top_jb IS
|
||||
|
||||
signal loop_back_en : std_logic := '0';
|
||||
|
||||
type emac_action_t is (emac_idle, emac_alloc, emac_write, emac_read);
|
||||
type emac_action_t is (emac_idle, emac_alloc, emac_write, emac_read, emac_free);
|
||||
signal emac_action : emac_action_t;
|
||||
|
||||
BEGIN
|
||||
@@ -163,7 +163,7 @@ STIMULUS: process
|
||||
-- set alloc request
|
||||
CYC_I <= '1';
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
DAT_I <= X"0001_0000";
|
||||
DAT_I <= X"0002_0000";
|
||||
STB_I <= '1';
|
||||
WE_I <= '1';
|
||||
ADDR_I <= X"0000_0000";
|
||||
@@ -183,7 +183,7 @@ STIMULUS: process
|
||||
STB_I <= '0';
|
||||
wait until rising_edge(CLK) and ACK_O = '1';
|
||||
wait until rising_edge(CLK);
|
||||
if DAT_O_reg(16) = '0' then
|
||||
if DAT_O_reg(17) = '0' then
|
||||
exit check_bsy;
|
||||
end if;
|
||||
end loop;
|
||||
@@ -228,6 +228,90 @@ STIMULUS: process
|
||||
|
||||
end procedure emac_write;
|
||||
|
||||
procedure emac_read (size_in : natural) is
|
||||
variable data : unsigned (7 downto 0);
|
||||
variable size, num_words : natural;
|
||||
begin
|
||||
|
||||
emac_action <= emac_read;
|
||||
|
||||
-- check if data available
|
||||
check_data_avail:
|
||||
while (true) loop
|
||||
CYC_I <= '1';
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
WE_I <= '0';
|
||||
STB_I <= '1';
|
||||
ADDR_I <= X"0000_0000";
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
STB_I <= '0';
|
||||
wait until rising_edge(CLK) and ACK_O = '1';
|
||||
wait until rising_edge(CLK);
|
||||
if DAT_O_reg(16) = '1' then
|
||||
exit check_data_avail;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
read_size:
|
||||
CYC_I <= '1';
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
WE_I <= '0';
|
||||
STB_I <= '1';
|
||||
ADDR_I <= X"0000_0004";
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
STB_I <= '0';
|
||||
wait until rising_edge(CLK) and ACK_O = '1';
|
||||
wait until rising_edge(CLK);
|
||||
|
||||
|
||||
-- Read RX data
|
||||
size := size_in;
|
||||
if (size_in = 0) then
|
||||
size := to_integer(DAT_O_reg(15 downto 0));
|
||||
end if;
|
||||
|
||||
if (size mod 4) = 0 then
|
||||
num_words := size/4;
|
||||
else
|
||||
num_words := size/4 + 1;
|
||||
end if;
|
||||
|
||||
CYC_I <= '1';
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
data := X"00";
|
||||
ADDR_I <= X"0000_0008";
|
||||
WE_I <= '0';
|
||||
STB_I <= '1';
|
||||
for i in 1 to num_words loop
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
end loop;
|
||||
STB_I <= '0';
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
emac_action <= emac_idle;
|
||||
|
||||
end procedure emac_read;
|
||||
|
||||
procedure emac_free is
|
||||
begin
|
||||
|
||||
-- RX- DEALLOCATION
|
||||
emac_action <= emac_free;
|
||||
|
||||
-- set free request
|
||||
CYC_I <= '1';
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
DAT_I <= X"0001_0000";
|
||||
STB_I <= '1';
|
||||
WE_I <= '1';
|
||||
ADDR_I <= X"0000_0000";
|
||||
wait until rising_edge(CLK) and SRDY_O = '1';
|
||||
STB_I <= '0';
|
||||
WE_I <= '0';
|
||||
|
||||
emac_action <= emac_idle;
|
||||
|
||||
end procedure emac_free;
|
||||
|
||||
begin
|
||||
|
||||
wait for 6*MII_CLK_PERIOD;
|
||||
@@ -238,49 +322,79 @@ STIMULUS: process
|
||||
|
||||
emac_alloc (1536);
|
||||
emac_write (1536);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (1536);
|
||||
emac_write (1536);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (1536);
|
||||
emac_write (1536);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (1536);
|
||||
emac_write (1536);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (1536);
|
||||
emac_write (1536);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (1536);
|
||||
emac_write (1536);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (1536);
|
||||
emac_write (1536);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (64);
|
||||
emac_write (64);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (512);
|
||||
emac_write (512);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (1536);
|
||||
emac_write (1536);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (65);
|
||||
emac_write (65);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (66);
|
||||
emac_write (66);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (67);
|
||||
emac_write (67);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (512);
|
||||
emac_write (64);
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
emac_alloc (128);
|
||||
emac_write (128);
|
||||
|
||||
emac_read (0);
|
||||
emac_free;
|
||||
|
||||
wait;
|
||||
|
||||
end process;
|
||||
|
||||
Reference in New Issue
Block a user