OpenCores
URL https://opencores.org/ocsvn/fade_ether_protocol/fade_ether_protocol/trunk

Subversion Repositories fade_ether_protocol

[/] [fade_ether_protocol/] [trunk/] [stable_jumbo_frames_version/] [fpga/] [src/] [cmd_proc.vhd] - Blame information for rev 44

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 15 wzab
-------------------------------------------------------------------------------
2
-- Title      : User command processor
3
-- Project    : 
4
-------------------------------------------------------------------------------
5
-- File       : cmd_proc.vhd
6
-- Author     : Wojciech M. Zabolotny (wzab@ise.pw.edu.pl)
7
-- License    : BSD License
8
-- Company    : 
9
-- Created    : 2014-10-04
10 26 wzab
-- Last update: 2014-10-23
11 15 wzab
-- Platform   : 
12
-- Standard   : VHDL'93/02
13
-------------------------------------------------------------------------------
14
-- Description: This block performs the user defined commands
15 18 wzab
--              but also generates responses for some internal commands.
16
--              
17 15 wzab
-------------------------------------------------------------------------------
18
-- Copyright (c) 2014 
19
-------------------------------------------------------------------------------
20
-- Revisions  :
21
-- Date        Version  Author  Description
22 18 wzab
-- 2014-10-04  1.0      WZab    Created
23 15 wzab
-------------------------------------------------------------------------------
24
library ieee;
25
use ieee.std_logic_1164.all;
26
use ieee.numeric_std.all;
27
use std.textio.all;
28
library work;
29
use work.pkt_ack_pkg.all;
30
use work.desc_mgr_pkg.all;
31
use work.pkt_desc_pkg.all;
32
entity cmd_proc is
33
 
34
  port (
35 18 wzab
    cmd_code     : in  std_logic_vector(15 downto 0);
36
    cmd_seq      : in  std_logic_vector(15 downto 0);
37
    cmd_arg      : in  std_logic_vector(31 downto 0);
38
    cmd_run      : in  std_logic;
39
    cmd_ack      : out std_logic;
40
    cmd_response : out std_logic_vector(8*12-1 downto 0);
41
    clk          : in  std_logic;
42 26 wzab
    rst_p        : in  std_logic;
43
    -- Other inputs, needed to execute specific functions
44
    retr_count   : in std_logic_vector(31 downto 0)
45 15 wzab
    );
46
 
47
end entity cmd_proc;
48
 
49
architecture beh of cmd_proc is
50
 
51 18 wzab
  signal cmd_run_0, cmd_run_1, cmd_run_2 : std_logic               := '0';
52
  signal del_count                       : integer range 0 to 1000 := 0;
53 15 wzab
 
54
begin  -- architecture beh
55
 
56
  process (clk, rst_p) is
57
  begin  -- process
58
    if rst_p = '1' then                 -- asynchronous reset (active low)
59 18 wzab
      cmd_ack      <= '0';
60
      cmd_run_0    <= '0';
61
      cmd_run_1    <= '0';
62
      cmd_run_2    <= '0';
63
      del_count    <= 0;
64 15 wzab
      cmd_response <= (others => '0');
65
    elsif clk'event and clk = '1' then  -- rising clock edge
66
      -- Synchronize cmd_run signals
67
      cmd_run_2 <= cmd_run;
68
      cmd_run_1 <= cmd_run_2;
69
      cmd_run_0 <= cmd_run_1;
70
      -- Detect command strobe
71
      if cmd_run_1 /= cmd_run_0 then
72
        -- Line cmd_run has changed its state, it means that we need
73
        -- to execute a command
74 18 wzab
        if cmd_code(15 downto 8) = x"00" then
75
          -- For internal commands just send response immediately
76
          cmd_response <= cmd_code & cmd_seq &  -- This fields should be always
77
                                        -- sent on the begining of response!
78
                          x"00000000" & x"00000000";
79
          cmd_ack <= cmd_run;
80
        else
81
          -- Now we just simulate it, so let's start delay counter
82
          del_count <= 100;             -- execution of command takes 100 ckp
83
        end if;
84 15 wzab
      end if;
85 18 wzab
      -- We simulate execution of the user command, which was triggered by above
86
      -- "if" block
87 15 wzab
      if del_count > 0 then
88
        -- Decrease del_count until it is zero
89
        del_count <= del_count-1;
90
      end if;
91
      if del_count = 1 then
92
        -- Send response to the command:
93 18 wzab
        cmd_response <= cmd_code & cmd_seq &    -- This fields should be always
94
                                        -- sent on the begining of response!
95 26 wzab
                        cmd_arg & retr_count;
96 15 wzab
        cmd_ack <= cmd_run;
97
      end if;
98
    end if;
99
  end process;
100
 
101
end architecture beh;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.