EmbDev.net

Forum: FPGA, VHDL & Verilog Vhdl project: mini-router


von Luciana (luciana)


Attached files:

Rate this post
useful
not useful
I have a project about design and implementation of a mini router. I' ll 
share the source code I wrote and the design in Vivado. Can someone 
expalin why the design is organized in this way? Is it correct?
1
-- -------------------------
2
-- Libreria
3
-- -------------------------
4
library IEEE;
5
use IEEE.std_logic_1164.all;
6
use IEEE.numeric_std.all;
7
8
9
-- -------------------------
10
-- Entity 
11
-- -------------------------
12
entity mini_router is
13
   port (
14
         clk       : in  std_logic; 
15
         reset     : in  std_logic; -- Reset asincrono attivo basso
16
     data1     : in  std_logic_vector(9 downto 0); 
17
     req1      : in  std_logic; 
18
     grant1    : out std_logic;
19
         data2     : in  std_logic_vector(9 downto 0); 
20
     req2      : in  std_logic; 
21
     grant2    : out std_logic;
22
     data_out  : out std_logic_vector(7 downto 0); 
23
     valid     : out std_logic
24
        );
25
end entity;
26
  
27
  
28
-- -------------------------
29
-- Architecture 
30
-- -------------------------  
31
architecture arch of mini_router is  
32
33
-- Segnale per controllo req
34
   signal request    : std_logic_vector (1 downto 0);  
35
  
36
-- Segnali per controllo bit di parità
37
   signal a          : std_logic; -- '1' se A < B altrimenti '0'
38
   signal b          : std_logic; -- '1' se A = B altrimenti '0'  
39
   signal c          : std_logic; -- '1' se A > B altrimenti '0'
40
  
41
-- Segnale per applicazione dell'algoritmo Round Robin
42
   signal r          : std_logic; 
43
   
44
45
-- Comparatore per controllo sui bit di parità  
46
  component comparator is
47
     port (
48
            A           : in std_logic_vector(1 downto 0); 
49
            B           : in std_logic_vector(1 downto 0); 
50
            A_less_B    : out std_logic; 
51
            A_equal_B   : out std_logic;
52
            A_greater_B : out std_logic      
53
          );
54
   end component;
55
  
56
 
57
 begin
58
59
  request     <= req1&req2;
60
  
61
   COMPARATORE: comparator
62
    port map ( 
63
      A           => data1 (1 downto 0),
64
      B           => data2 (1 downto 0),
65
      A_less_B    => a,
66
      A_equal_B   => b,
67
      A_greater_B => c
68
           );
69
 
70
 mini_router: process(clk,reset)
71
  
72
 begin
73
74
   if reset = '0' then
75
       data_out    <= (others => '0');
76
     grant1      <= '0';
77
     grant2      <= '0';   
78
     valid       <= '0';
79
     r           <= '0';
80
       
81
     
82
   elsif rising_edge(clk) then
83
   
84
 -- Un solo req è alto
85
      if request = "10" then 
86
    
87
       data_out <= data1(9 downto 2);
88
         grant1   <= '1';
89
       grant2   <= '0';
90
       valid    <= '1';
91
  
92
   elsif request = "01" then 
93
  
94
         data_out <= data2(9 downto 2);
95
         grant1   <= '0';
96
       grant2   <= '1';
97
       valid    <= '1';
98
99
-- Entrambi i req sono bassi    
100
     elsif request = "00" then  
101
   
102
      data_out <= (others => '0');
103
      grant1   <= '0';
104
        grant2   <= '0';
105
        valid    <= '0'; 
106
  
107
-- Entrambi i req sono alti  
108
   elsif request = "11" then
109
110
-- Il link 1 ha maggiore priorità
111
        if c='1' then
112
    
113
           data_out  <= data1(9 downto 2);
114
           grant1    <= '1';
115
         grant2    <= '0';
116
         valid     <= '1';
117
118
-- Il link 2 ha maggiore priorità      
119
        elsif a='1' then
120
    
121
           data_out  <= data2(9 downto 2);
122
         grant1    <= '0';
123
         grant2    <= '1';
124
         valid     <= '1';
125
 
126
 -- Data conflict
127
        elsif b='1' then  
128
    
129
-- Applicazione dell'algoritmo Round Robin
130
           if r = '0' then 
131
       
132
              data_out  <= data1(9 downto 2);
133
              grant1    <= '1';
134
            grant2    <= '0';
135
            valid     <= '1';
136
              r         <= '1';
137
  
138
           else 
139
       
140
              data_out  <= data2(9 downto 2);
141
          grant1    <= '0';
142
            grant2    <= '1';
143
            valid     <= '1';
144
              r         <= '0';
145
        
146
           end if;
147
148
        end if;
149
150
      end if; 
151
  
152
    end if; 
153
   
154
  end process;
155
156
end architecture;

Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
No account? Register here.