1 |
4 |
sergio.tot |
-------------------------------------------------------------------------------
|
2 |
|
|
-- Title : Counter
|
3 |
|
|
-- Project : Bridge PIF to WISHBONE / WISHBONE to PIF
|
4 |
|
|
-------------------------------------------------------------------------------
|
5 |
|
|
-- File : COUNTER.vhd
|
6 |
|
|
-- Author : Edoardo Paone
|
7 |
|
|
-- Company : Politecnico of Torino
|
8 |
|
|
-- Last update: 2007/06/09
|
9 |
|
|
-- Platform :
|
10 |
|
|
-------------------------------------------------------------------------------
|
11 |
|
|
-- Description: It generates the correct addresses for burst transfers of PIF
|
12 |
|
|
-- masters to WISHBONE slaves
|
13 |
|
|
-------------------------------------------------------------------------------
|
14 |
|
|
-- Revisions :
|
15 |
|
|
-- Date Version Author Description
|
16 |
|
|
-- 2007/04/20 1.0 Edoardo Created
|
17 |
|
|
-------------------------------------------------------------------------------
|
18 |
|
|
|
19 |
|
|
library ieee;
|
20 |
|
|
use ieee.std_logic_1164.all;
|
21 |
|
|
use ieee.std_logic_unsigned.all;
|
22 |
|
|
use ieee.std_logic_arith.all;
|
23 |
|
|
|
24 |
|
|
entity Counter is
|
25 |
|
|
generic (
|
26 |
|
|
constant DATA_SIZE_WB : integer := 32;
|
27 |
|
|
constant ADRS_SIZE : integer := 32 ); -- Address bus length
|
28 |
|
|
port (
|
29 |
|
|
CLK : in std_logic; -- The clock input
|
30 |
|
|
RST : in std_logic; -- The reset input
|
31 |
|
|
LOAD_ADDR : in std_logic; -- Address Load Strobe signal
|
32 |
|
|
GO_UP : in std_logic; -- If '0' indicates there is a cycle pause
|
33 |
|
|
ADR_INIT : in std_logic_vector(ADRS_SIZE-1 downto 0);
|
34 |
|
|
-- The address where the read/write transfer starts
|
35 |
|
|
ADR_CNTR : out std_logic_vector(ADRS_SIZE-1 downto 0);
|
36 |
|
|
-- The new address correctly incremented
|
37 |
|
|
N_TRANSFER : out integer range 0 to 15 );
|
38 |
|
|
end Counter;
|
39 |
|
|
|
40 |
|
|
architecture Behavioral of Counter is
|
41 |
|
|
|
42 |
|
|
signal ADR_REG : std_logic_vector(ADRS_SIZE-1 downto 0);
|
43 |
|
|
-- The current address value
|
44 |
|
|
signal INC : std_logic_vector(ADRS_SIZE-1 downto 0);
|
45 |
|
|
-- The increment is dependent on the data array [DAT_O()], [DAT_I()] size
|
46 |
|
|
-- Byte address: Step = DATA_SIZE / 8
|
47 |
|
|
|
48 |
|
|
signal N : integer range 0 to 15;
|
49 |
|
|
|
50 |
|
|
begin -- Behavioral
|
51 |
|
|
|
52 |
|
|
-- purpose: Updates the address register to the new value
|
53 |
|
|
-- type : sequential
|
54 |
|
|
-- inputs : CLK, RST
|
55 |
|
|
-- outputs: ADR_REG, N_TRANSFER, INC
|
56 |
|
|
|
57 |
|
|
INC <= conv_std_logic_vector(DATA_SIZE_WB/8, ADRS_SIZE);
|
58 |
|
|
|
59 |
|
|
Output_Address : process (CLK, RST)
|
60 |
|
|
begin -- process Output_Address
|
61 |
|
|
if RST = '1' then -- asynchronous reset (active high)
|
62 |
|
|
ADR_REG <= (others => '0');
|
63 |
|
|
N <= 0;
|
64 |
|
|
elsif (CLK'event and CLK = '1') then -- rising clock edge
|
65 |
|
|
if(LOAD_ADDR = '1') then -- Load Base Address into register
|
66 |
|
|
ADR_REG <= ADR_INIT;
|
67 |
|
|
N <= 0;
|
68 |
|
|
elsif(GO_UP = '1') then
|
69 |
|
|
ADR_REG <= ADR_REG + INC;
|
70 |
|
|
N <= N + 1;
|
71 |
|
|
end if;
|
72 |
|
|
end if;
|
73 |
|
|
end process Output_Address;
|
74 |
|
|
|
75 |
|
|
ADR_CNTR <= ADR_REG;
|
76 |
|
|
N_TRANSFER <= N;
|
77 |
|
|
|
78 |
|
|
end Behavioral;
|