-------------------------------------------
-- Support Package for AHB-Lite Protocol --
-------------------------------------------
library ieee;
context ieee.ieee_std_context;
package amba_ahbl_pkg
generic(
slaves_max_jg : positive := 3
);
is
constant slaves_total_jc : positive := slaves_max_jg; -- individual slaves
subtype slaves_total_jrt is natural range slaves_total_jc downto 1;
-------------------------------------------
-- Base types for AMBA AHB-Lite Protocol --
-------------------------------------------
-- AHBL Slave Select bus
subtype HSEL_vst is std_logic_vector(slaves_total_jrt);
-- AHBL Address bus
constant HADDR_width_jc : positive := 32;
subtype HADDR_jrt is natural range HADDR_width_jc- 1 downto 0;
subtype HADDR_vst is std_logic_vector(HADDR_jrt);
-- AHBL Size control
constant HSIZE_width_jc : positive := 3;
subtype HSIZE_jrt is natural range HSIZE_width_jc- 1 downto 0;
subtype HSIZE_vst is std_logic_vector(HSIZE_jrt);
-- AHBL Burst control
constant HBURST_width_jc : positive := 3;
subtype HBURST_jrt is natural range HBURST_width_jc- 1 downto 0;
subtype HBURST_vst is std_logic_vector(HBURST_jrt);
-- AHBL Protection control
constant HPROT_width_jc : positive := 4;
subtype HPROT_jrt is natural range HPROT_width_jc- 1 downto 0;
subtype HPROT_vst is std_logic_vector(HPROT_jrt);
-- AHBL Transfer Type control
constant HTRANS_width_jc : positive := 2;
subtype HTRANS_jrt is natural range HTRANS_width_jc- 1 downto 0;
subtype HTRANS_vst is std_logic_vector(HTRANS_jrt);
-- AHBL Data bus
constant HDATA_width_jc : positive := 32;
subtype HDATA_jrt is natural range HDATA_width_jc- 1 downto 0;
subtype HDATA_vst is std_logic_vector(HDATA_jrt);
-----------------------------------------------------
-- Record & Array Types for AMBA AHB-Lite Protocol --
-----------------------------------------------------
-- Global control record for AMBA AHB-Lite bus
type g_amba_ahb_rt is -- AMBA AHBL global record
record
HRESET_nl : std_logic; -- AHBL global reset
HCLK_l : std_logic; -- AHBL global clock
end record g_amba_ahb_rt;
-- Slave record for AMBA AHB-Lite bus
type s_amba_ahb_rt is -- AMBA AHBL slave return record
record
HREADYOUT_l : std_logic; -- AHBL transfer complete
HRESP_l : std_logic; -- AHBL transfer response
HRDATA_vl : HDATA_vst; -- AHBL read data bus (32bit)
end record s_amba_ahb_rt;
-- Slave array for AMBA AHB-Lite bus
type s_amba_ahb_at is
array(slaves_total_jrt)
of s_amba_ahb_rt; -- Array of slave return records
-- Master record for AMBA AHB-Lite bus
type m_amba_ahb_rt is -- AMBA AHBL master record
record
HREADY_l : std_logic; -- AHBL transfer complete
HADDR_vl : HADDR_vst; -- AHBL address bus (32bit)
HWRITE_l : std_logic; -- AHBL transfer write/read control
HSIZE_vl : HSIZE_vst; -- AHBL transfer size control (3bit)
HBURST_vl : HBURST_vst; -- AHBL transfer burst control (3bit)
HPROT_vl : HPROT_vst; -- AHBL access protection control (4bit)
HTRANS_vl : HTRANS_vst; -- AHBL transfer type control (2bit)
HMASTLOCK_l : std_logic; -- AHBL locked transfer control
HWDATA_vl : HDATA_vst; -- AHBL write data bus (32bit)
end record m_amba_ahb_rt;
--------------------------------------------------------
-- Record & Array Mode Views for AHBL Composite Types --
--------------------------------------------------------
-- Mode view only required for master connection - slave connection is
-- all of mode 'in'.
-- Decoder and multiplexor function inputs by default are of mode 'in'.
record view m_amba_ahb_rvw of m_amba_ahb_rt is
element(
HREADY_l : in std_logic;
HADDR_vl : out HADDR_vst;
HWRITE_l : out std_logic;
HSIZE_vl : out HSIZE_vst;
HBURST_vl : out HBURST_vst;
HPROT_vl : out HPROT_vst;
HTRANS_vl : out HTRANS_vst;
HMASTLOCK_l : out std_logic;
HRDATA_vl : out HDATA_vst;
);
end record view m_amba_ahb_rvw;
-----------------------------------------
-- Decoder and Multiplexor Subprograms --
-----------------------------------------
-- Slave select decoder function
function HSEL_decoder_f(;
g_amba_ahb_ri : g_amba_ahb_rt;
m_amba_ahb_ri : m_amba_ahb_rt
) return HSEL_vst;
-- Slave return multiplexor function
function slave_multiplexor_f(;
g_amba_ahb_ri : g_amba_ahb_rt;
m_amba_ahb_ri : m_amba_ahb_rt;
s_amba_ahb_ai : s_amba_ahb_at
) return s_amba_ahb_rt;
--------------------------------
-- Context Clause for Package --
--------------------------------
context amba_ahbl_context;
library ieee;
context ieee.ieee_std_context;
use work.amba_ahbl_pkg.all;
end context amba_ahbl_context;
end package amba_ahbl_pkg;
-- A package body is required to define the decoder and multiplexor
-- functions.
package body amba_ahbl_pkg;
-----------------------------------------
-- Decoder and Multiplexor Subprograms --
-----------------------------------------
-- Slave select decoder function
function HSEL_decoder_f(;
g_amba_ahb_ri : g_amba_ahb_rt;
m_amba_ahb_ri : m_amba_ahb_rt
) return HSEL_vst is
variable HSEL_vv : HSEL_vst;
begin
...
return HSEL_vv;
end function HSEL_decoder_f;
-- Slave return multiplexor function
function slave_multiplexor_f(;
g_amba_ahb_ri : g_amba_ahb_rt;
m_amba_ahb_ri : m_amba_ahb_rt;
s_amba_ahb_ai : s_amba_ahb_at
) return s_amba_ahb_rt is
variable s_amba_ahb_rv : s_amba_ahb_rt;
begin
...
return s_amba_ahb_rv;
end function HSEL_decode_f;
end package body amba_ahbl_pkg;
-----------------------------------------------------------------
-- Declare entities for AHBL Master, Slave and top-level Block --
-----------------------------------------------------------------
-- AHB-Lite Master Entity
context work.amba_ahbl_context;
entity ahbl_master_ent is(
port(
g_amba_ahb_ri : in g_amba_ahb_rt;
s_amba_ahb_ri : in s_amba_ahb_rt;
m_amba_ahb_rif : view m_amba_ahb_rt(m_amba_ahb_rvw)
);
end entity ahbl_master_ent;
architecture rtl_arch of ahbl_master_ent is
begin(
....
end architecture rtl_arch;
-- AHB-Lite Slave Entity
context work.amba_ahbl_context;
entity ahbl_slave_ent is(
port(
g_amba_ahb_ri : in g_amba_ahb_rt;
HSEL_i : in std_logic;
m_amba_ahb_ri : in m_amba_ahb_rt;
s_amba_ahb_ro : out s_amba_ahb_rt
);
end entity ahbl_slave_ent;
architecture rtl_arch of ahbl_slave_ent is
begin(
....
end architecture rtl_arch;
---------------
-- Top Level --
---------------
-- Top-level AHB-Lite Block Structure
context work.amba_ahbl_context;
entity ahbl_block_ent is(
end entity ahbl_block_ent;
architecture rtl_arch of ahbl_block_ent is
signal g_amba_ahb_rs : g_amba_ahb_rt;
signal m_amba_ahb_rs : m_amba_ahb_rt;
signal HSEL_vs : HSEL_vst;
signal s_amba_ahb_rs : s_amba_ahb_rt;
signal s_amba_ahb_as : s_amba_ahb_at;
begin(
-- Clock and Reset Control for AHB-Lite Block
clk_and_rst_inst : entity clk_and_rst_ent(rtl_arch)
port map(
rst_o => g_amba_ahb_rs.HRESET_nl,
clk_o => g_amba_ahb_rs.HCLK_l
);
-- Master Instantiation for AHB-Lite Block
ahbl_master_inst : entity ahbl_master_ent(rtl_arch)
port map(
g_amba_ahb_ri => g_amba_ahb_rs,
s_amba_ahb_ri => s_amba_ahb_rs,
m_amba_ahb_rif => m_amba_ahb_rs
);
-- Slave Decoder
HSEL_decoder_asgn :
HSEL_vs <= HSEL_decoder_f(g_amba_ahb_rs,m_amba_ahb_rs);
-- Slave Multiplexor
slave_multiplexor_asgn :
s_amba_ahb_rs <= slave_multiplexor_f(g_amba_ahb_rs,m_amba_ahb_rs, s_amba_ahb_as);
-- HREADY decode
HREADY_asgn :
m_amba_ahb_rs.HREADY_l <= s_amba_ahb_rs.HREADYOUT_l;
-- Slave Instantiations for AHB-Lite Block
ahbl_slave3_inst : entity ahbl_slave_ent(rtl_arch)
port map(
g_amba_ahb_ri => g_amba_ahb_rs,
HSEL_i => HSEL_vs(3),
m_amba_ahb_ri => m_amba_ahb_rs,
s_amba_ahb_ro => s_amba_ahb_as(3)
);
ahbl_slave2_inst : entity ahbl_slave_ent(rtl_arch)
port map(
g_amba_ahb_ri => g_amba_ahb_rs,
HSEL_i => HSEL_vs(2),
m_amba_ahb_ri => m_amba_ahb_rs,
s_amba_ahb_ro => s_amba_ahb_as(2)
);
ahbl_slave1_inst : entity ahbl_slave_ent(rtl_arch)
port map(
g_amba_ahb_ri => g_amba_ahb_rs,
HSEL_i => HSEL_vs(1),
m_amba_ahb_ri => m_amba_ahb_rs,
s_amba_ahb_ro => s_amba_ahb_as(1)
);
end architecture rtl_arch;
Control Instance: | |||
---|---|---|---|
clk_and_rst_inst | |||
Name | I/O Element | Mode | Composite Signal or Element |
HRESETn | rst_o | out | g_amba_ahb_rs.HRESET_nl |
HCLK | clk_o | out | g_amba_ahb_rs.HCLK_l |
Master Instance: | |||
ahbl_master_inst | |||
Name | I/O Element | Mode | Composite Signal or Element |
HRESETn | g_amba_ahb_ri.HRESET_nl | in | g_amba_ahb_rs.HRESET_nl |
HCLK | g_amba_ahb_ri.HCLK_l | in | g_amba_ahb_rs.HCLK_l |
HREADYOUT | s_amba_ahb_ri.HREADYOUT_l | in | s_amba_ahb_rs.HREADYOUT_l |
HRESP | s_amba_ahb_ri.HRESP_l | in | s_amba_ahb_rs.HRESP_l |
HRDATA[31:0] | s_amba_ahb_ri.HRDATA_vl(31 downto 0) | in | s_amba_ahb_rs.HRDATA_vl(31 downto 0) |
HREADY | m_amba_ahb_rif.HREADY_l | in | m_amba_ahb_rs.HREADY_l |
HADDR[31:0] | m_amba_ahb_rif.HADDR_vl(31 downto 0) | out | m_amba_ahb_rs.HADDR_vl(31 downto 0) |
HWRITE | m_amba_ahb_rif.HWRITE_l | out | m_amba_ahb_rs.HWRITE_l |
HSIZE[2:0] | m_amba_ahb_rif.HSIZE_vl(2 downto 0) | out | m_amba_ahb_rs.HSIZE_vl(2 downto 0) |
HBURST[2:0] | m_amba_ahb_rif.HBURST_vl(2 downto 0) | out | m_amba_ahb_rs.HBURST_vl(2 downto 0) |
HPROT[3:0] | m_amba_ahb_rif.HPROT_vl(3 downto 0) | out | m_amba_ahb_rs.HPROT_vl(3 downto 0) |
HTRANS[1:0] | m_amba_ahb_rif.HTRANS_vl(1 downto 0) | out | m_amba_ahb_rs.HTRANS_vl(1 downto 0) |
HMASTLOCK | m_amba_ahb_rif.HMASTLOCK_l | out | m_amba_ahb_rs.HMASTLOCK_l |
HWDATA[31:0] | m_amba_ahb_rif.HWDATA_vl(31 downto 0) | out | m_amba_ahb_rs.HWDATA_vl(31 downto 0) |
Slave Instances: | |||
ahbl_slavex_inst | |||
Name | I/O Element | Mode | Composite Signal or Element |
HRESETn | g_amba_ahb_ri.HRESET_nl | in | g_amba_ahb_rs.HRESET_nl |
HCLK | g_amba_ahb_ri.HCLK_l | in | g_amba_ahb_rs.HCLK_l |
HSEL | HSEL_i | in | HSEL_vs(x) |
HREADY | m_amba_ahb_ri.HREADY_l | in | m_amba_ahb_rs.HREADY_l |
HADDR[31:0] | m_amba_ahb_ri.HADDR_vl(31 downto 0) | in | m_amba_ahb_rs.HADDR_vl(31 downto 0) |
HWRITE | m_amba_ahb_ri.HWRITE_l | in | m_amba_ahb_rs.HWRITE_l |
HSIZE[2:0] | m_amba_ahb_ri.HSIZE_vl(2 downto 0) | in | m_amba_ahb_rs.HSIZE_vl(2 downto 0) |
HBURST[2:0] | m_amba_ahb_ri.HBURST_vl(2 downto 0) | in | m_amba_ahb_rs.HBURST_vl(2 downto 0) |
HPROT[3:0] | m_amba_ahb_ri.HPROT_vl(3 downto 0) | in | m_amba_ahb_rs.HPROT_vl(3 downto 0) |
HTRANS[1:0] | m_amba_ahb_ri.HTRANS_vl(1 downto 0) | in | m_amba_ahb_rs.HTRANS_vl(1 downto 0) |
HMASTLOCK | m_amba_ahb_ri.HMASTLOCK_l | in | m_amba_ahb_rs.HMASTLOCK_l |
HWDATA[31:0] | m_amba_ahb_ri.HWDATA_vl(31 downto 0) | in | m_amba_ahb_rs.HWDATA_vl(31 downto 0) |
HREADYOUT | s_amba_ahb_ro.HREADYOUT_l | out | s_amba_ahb_as(x).HREADYOUT_l |
HRESP | s_amba_ahb_ro.HRESP_l | out | s_amba_ahb_as(x).HRESP_l |
HRDATA[31:0] | s_amba_ahb_ro.HRDATA_vl(31 downto 0) | out | s_amba_ahb_as(x).HRDATA_vl(31 downto 0) |
Decoder Function: | |||
HSEL_decoder_asgn | |||
Name | Input Element | Mode | Composite Signal or Element |
HRESETn | g_amba_ahb_ri.HRESET_nl | in | g_amba_ahb_rs.HRESET_nl |
HCLK | g_amba_ahb_ri.HCLK_l | in | g_amba_ahb_rs.HCLK_l |
HREADY | m_amba_ahb_ri.HREADY_l | in | m_amba_ahb_rs.HREADY_l |
HADDR[31:0] | m_amba_ahb_ri.HADDR_vl(31 downto 0) | in | m_amba_ahb_rs.HADDR_vl(31 downto 0) |
HWRITE | m_amba_ahb_ri.HWRITE_l | in | m_amba_ahb_rs.HWRITE_l |
HSIZE[2:0] | m_amba_ahb_ri.HSIZE_vl(2 downto 0) | in | m_amba_ahb_rs.HSIZE_vl(2 downto 0) |
HBURST[2:0] | m_amba_ahb_ri.HBURST_vl(2 downto 0) | in | m_amba_ahb_rs.HBURST_vl(2 downto 0) |
HPROT[3:0] | m_amba_ahb_ri.HPROT_vl(3 downto 0) | in | m_amba_ahb_rs.HPROT_vl(3 downto 0) |
HTRANS[1:0] | m_amba_ahb_ri.HTRANS_vl(1 downto 0) | in | m_amba_ahb_rs.HTRANS_vl(1 downto 0) |
HMASTLOCK | m_amba_ahb_ri.HMASTLOCK_l | in | m_amba_ahb_rs.HMASTLOCK_l |
HWDATA[31:0] | m_amba_ahb_ri.HWDATA_vl(31 downto 0) | in | m_amba_ahb_rs.HWDATA_vl(31 downto 0) |
HSEL[3:1] | return | HSEL_vs(3 downto 1) | |
Multiplexor Function: | |||
slave_multiplexor_asgn | |||
Name | Input Element | Mode | Composite Signal or Element |
HRESETn | g_amba_ahb_ri.HRESET_nl | in | g_amba_ahb_rs.HRESET_nl |
HCLK | g_amba_ahb_ri.HCLK_l | in | g_amba_ahb_rs.HCLK_l |
HREADY | m_amba_ahb_ri.HREADY_l | in | m_amba_ahb_rs.HREADY_l |
HADDR[31:0] | m_amba_ahb_ri.HADDR_vl(31 downto 0) | in | m_amba_ahb_rs.HADDR_vl(31 downto 0) |
HWRITE | m_amba_ahb_ri.HWRITE_l | in | m_amba_ahb_rs.HWRITE_l |
HSIZE[2:0] | m_amba_ahb_ri.HSIZE_vl(2 downto 0) | in | m_amba_ahb_rs.HSIZE_vl(2 downto 0) |
HBURST[2:0] | m_amba_ahb_ri.HBURST_vl(2 downto 0) | in | m_amba_ahb_rs.HBURST_vl(2 downto 0) |
HPROT[3:0] | m_amba_ahb_ri.HPROT_vl(3 downto 0) | in | m_amba_ahb_rs.HPROT_vl(3 downto 0) |
HTRANS[1:0] | m_amba_ahb_ri.HTRANS_vl(1 downto 0) | in | m_amba_ahb_rs.HTRANS_vl(1 downto 0) |
HMASTLOCK | m_amba_ahb_ri.HMASTLOCK_l | in | m_amba_ahb_rs.HMASTLOCK_l |
HWDATA[31:0] | m_amba_ahb_ri.HWDATA_vl(31 downto 0) | in | m_amba_ahb_rs.HWDATA_vl(31 downto 0) |
HREADYOUT | s_amba_ahb_ai(3 downto 1).HREADYOUT_l | in | s_amba_ahb_as(3 downto 1).HREADYOUT_l |
HRESP | s_amba_ahb_ai(3 downto 1).HRESP_l | in | s_amba_ahb_as(3 downto 1).HRESP_l |
HRDATA[31:0] | s_amba_ahb_ai(3 downto 1).HRDATA_vl(31 downto 0) | in | s_amba_ahb_as(3 downto 1).HRDATA_vl(31 downto 0) |
HREADYOUT | return | s_amba_ahb_rs.HREADYOUT_l | |
HRESP | return | s_amba_ahb_rs.HRESP_l | |
HRDATA[31:0] | return | s_amba_ahb_rs.HRDATA_vl(31 downto 0) | |