AHB-Lite Modified Interface

Example Code


   -------------------------------------------
   -- 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;

      -- Top record for AMBA AHB-Lite bus
      type amba_ahb_rt is  -- AMBA AHBL top record record
         record
            g_amba_ahb_rl : g_amba_ahb_rt; -- AMBA AHBL global record
            HSEL_vl       : HSEL_vst;      -- AHBL slave select vector
            s_amba_ahb_al : s_amba_ahb_at; -- AHBL slave return array
            m_amba_ahb_rl : m_amba_ahb_rt; -- AHBL master record
         end record amba_ahb_rt;

      --------------------------------------------------------
      -- Record & Array Mode Views for AHBL Composite Types --
      --------------------------------------------------------
      -- Slave array mode view
      array view s_amba_ahb_avw of s_amba_ahb_at is
         generic(
            HSEL_id_jg : slaves_total_jrt
         );
         element(
            HSEL_id_jg : out  s_amba_ahb_rt;
            others     : null s_amba_ahb_rt
         );
      end array view s_slave_avw;

      -- AMBA AHB-Lite slave record mode view
      record view amba_ahb_slave_rvw of amba_ahb_rt is
         generic(
            slave_id_jg : slaves_total_jrt
         );
         element(
            g_amba_ahb_rl : in       g_amba_ahb_rt;
            HSEL_vl       : in       HSEL_vst;
            s_amba_ahb_al : view     s_amba_ahb_at(s_amba_ahb_avw(HSEL_id_jg => slave_id_jg));
            m_amba_ahb_rl : in       m_amba_ahb_rt;
         );
      end record view amba_ahb_slave_rvw;

      -- AMBA AHB-Lite master record mode view
      record view amba_ahb_master_rvw of amba_ahb_rt is
         element(
            g_amba_ahb_rl : in       g_amba_ahb_rt;
            HSEL_vl       : out      HSEL_vst;
            s_amba_ahb_al : in       s_amba_ahb_at;
            m_amba_ahb_rl : out      m_amba_ahb_rt;
         );
      end record view amba_ahb_master_rvw;

      -----------------------------------------
      -- Decoder and Multiplexor Subprograms --
      -----------------------------------------
      -- Slave select decoder function
      function HSEL_decoder_f(;
            amba_ahb_ri : amba_ahb_rt
         ) return HSEL_vst;

      -- Slave return multiplexor function
      function slave_multiplexor_f(;
            amba_ahb_ri : amba_ahb_rt
         ) 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(;
            amba_ahb_ri : 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(;
            amba_ahb_ri : amba_ahb_rt
         ) 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(
         amba_ahb_rif : view amba_ahb_rt(amba_ahb_master_rvw)
      );
   end entity ahbl_master_ent;
   architecture rtl_arch of ahbl_master_ent is
      signal s_amba_ahb_rs : s_amba_ahb_rt;
   begin(
      -- Slave Decoder now internal to master instance
      HSEL_decoder_asgn :
         amba_ahb_rif.HSEL_vl <= HSEL_decoder_f(amba_ahb_rif);

      -- Slave Multiplexor now internal to master instance
      slave_multiplexor_asgn :
         s_amba_ahb_rs <= slave_multiplexor_f(amba_ahb_rif);

      -- HREADY decode
      HREADY_asgn :
         amba_ahb_rif.m_amba_ahb_rl.HREADY_l <= s_amba_ahb_rs.HREADYOUT_l;
     ....
   end architecture rtl_arch;

   -- AHB-Lite Slave Entity
   context work.amba_ahbl_context;
   entity ahbl_slave_ent is(
      generic(
         inst_id_jg : positive
      );
      port(
         amba_ahb_rif : view amba_ahb_rt(amba_ahb_slave_rvw(slave_id_jg => inst_id_jg))
      );
   end entity ahbl_slave_ent;
   architecture rtl_arch of ahbl_slave_ent is
      -- Slave Decoder
      alias HSEL_s : std_logic is amba_ahb_rif.HSEL_vl(inst_id_jg);
      -- Slave multiplexor return
      alias s_amba_ahb_rs : s_amba_ahb_rt is amba_ahb_rif.s_amba_ahb_al(inst_id_jg);
   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 amba_ahb_rs : amba_ahb_rt;
   begin(

      -- Clock and Reset Control for AHB-Lite Block
      clk_and_rst_inst : entity clk_and_rst_ent(rtl_arch)
         port map(
            rst_o => amba_ahb_rs.g_amba_ahb_rl.HRESET_nl,
            clk_o => amba_ahb_rs.g_amba_ahb_rl.HCLK_l
         );

      -- Master Instantiation for AHB-Lite Block
      ahbl_master_inst : entity ahbl_master_ent(rtl_arch)
         port map(
            amba_ahb_rif => amba_ahb_rs
         );

      -- Slave Instantiations for AHB-Lite Block
      ahbl_slave_gen : for i_jlv in slaves_total_jrt
         generate
         ahbl_slave_inst : entity ahbl_slave_ent(rtl_arch)
            generic map(
               inst_id_jg => i_jlv,
            )
            port map(
               amba_ahb_rif => amba_ahb_rif
            );
      end generate;
   end architecture rtl_arch;

Interface Connections

Control Instance:
clk_and_rst_inst
Name I/O Element Mode Composite Signal or Element
HRESETn rst_o out amba_ahb_rs.g_amba_ahb_rl.HRESET_nl
HCLK clk_o out amba_ahb_rs.g_amba_ahb_rl.HCLK_l
 
Master Instance:
ahbl_master_inst
Name I/O Element Mode Composite Signal or Element
HRESETn amba_ahb_rif.g_amba_ahb_rl.HRESET_nl in amba_ahb_rs.g_amba_ahb_rl.HRESET_nl
HCLK amba_ahb_rif.g_amba_ahb_rl.HCLK_l in amba_ahb_rs.g_amba_ahb_rl.HCLK_l
 
array of
HSEL

amba_ahb_rif.HSEL_vl(3 downto 1)

out

amba_ahb_rs.HSEL_vl(3 downto 1)
 
array of
HREADYOUT

amba_ahb_rif.s_amba_ahb_al(3 downto 1).HREADYOUT_l

in

amba_ahb_rs.s_amba_ahb_al(3 downto 1).HREADYOUT_l
array of
HRESP

amba_ahb_rif.s_amba_ahb_al(3 downto 1).HRESP_l

in

amba_ahb_rs.s_amba_ahb_al(3 downto 1).HRESP_l
array of
HRDATA[31:0]

amba_ahb_rif.s_amba_ahb_al(3 downto 1).HRDATA_vl(31 downto 0)

in

amba_ahb_rs.s_amba_ahb_al(3 downto 1).HRDATA_vl(31 downto 0)
 
HREADY amba_ahb_rif.m_amba_ahb_rl.HREADY_l out amba_ahb_rs.m_amba_ahb_rl.HADDR_vl(31 downto 0)
HWRITE amba_ahb_rif.m_amba_ahb_rl.HWRITE_l out amba_ahb_rs.m_amba_ahb_rl.HWRITE_l
HSIZE[2:0] amba_ahb_rif.m_amba_ahb_rl.HSIZE_vl(2 downto 0) out amba_ahb_rs.m_amba_ahb_rl.HSIZE_vl(2 downto 0)
HBURST[2:0] amba_ahb_rif.m_amba_ahb_rl.HBURST_vl(2 downto 0) out amba_ahb_rs.m_amba_ahb_rl.HBURST_vl(2 downto 0)
HPROT[3:0] amba_ahb_rif.m_amba_ahb_rl.HPROT_vl(3 downto 0) out amba_ahb_rs.m_amba_ahb_rl.HPROT_vl(3 downto 0)
HTRANS[1:0] amba_ahb_rif.m_amba_ahb_rl.HTRANS_vl(1 downto 0) out amba_ahb_rs.m_amba_ahb_rl.HTRANS_vl(1 downto 0)
HMASTLOCK amba_ahb_rif.m_amba_ahb_rl.HMASTLOCK_l out amba_ahb_rs.m_amba_ahb_rl.HMASTLOCK_l
HWDATA[31:0] amba_ahb_rif.m_amba_ahb_rl.HWDATA_vl(31 downto 0) out amba_ahb_rs.m_amba_ahb_rl.HWDATA_vl(31 downto 0)
 
Slave Instances:
ahbl_slavex_gen(x).ahbl_slave_inst
Name I/O Element Mode Composite Signal or Element
HRESETn amba_ahb_rif.g_amba_ahb_rl.HRESET_nl in amba_ahb_rs.g_amba_ahb_rl.HRESET_nl
HCLK amba_ahb_rif.g_amba_ahb_rl.HCLK_l in amba_ahb_rs.g_amba_ahb_rl.HCLK_l
 
array of
HSEL
amba_ahb_rif.HSEL_vl(x)
amba_ahb_rif.HSEL_vl(others)
in
in
amba_ahb_rs.HSEL_vl(x)
amba_ahb_rs.HSEL_vl(others)
 
array of
HREADYOUT
amba_ahb_rif.s_amba_ahb_al(x).HREADYOUT_l
amba_ahb_rif.s_amba_ahb_al(others).HREADYOUT_l
out
in
amba_ahb_rs.s_amba_ahb_al(x).HREADYOUT_l
amba_ahb_rs.s_amba_ahb_al(others).HREADYOUT_l
array of
HRESP
amba_ahb_rif.s_amba_ahb_al(x).HRESP_l
amba_ahb_rif.s_amba_ahb_al(others).HRESP_l
out
in
amba_ahb_rs.s_amba_ahb_al(x).HRESP_l
amba_ahb_rs.s_amba_ahb_al(others).HRESP_l
array of
HRDATA[31:0]
amba_ahb_rif.s_amba_ahb_al(x).HRDATA_vl(31 downto 0)
amba_ahb_rif.s_amba_ahb_al(others).HRDATA_vl(31 downto 0)
out
in
amba_ahb_rs.s_amba_ahb_al(x).HRDATA_vl(31 downto 0)
amba_ahb_rs.s_amba_ahb_al(others).HRDATA_vl(31 downto 0)
 
HREADY amba_ahb_rif.m_amba_ahb_rl.HREADY_l in amba_ahb_rs.m_amba_ahb_rl.HREADY_l
HADDR[31:0] amba_ahb_rif.m_amba_ahb_rl.HADDR_vl(31 downto 0) in amba_ahb_rs.m_amba_ahb_rl.HADDR_vl(31 downto 0)
HWRITE amba_ahb_rif.m_amba_ahb_rl.HWRITE_l in amba_ahb_rs.m_amba_ahb_rl.HWRITE_l
HSIZE[2:0] amba_ahb_rif.m_amba_ahb_rl.HSIZE_vl(2 downto 0) in amba_ahb_rs.m_amba_ahb_rl.HSIZE_vl(2 downto 0)
HBURST[2:0] amba_ahb_rif.m_amba_ahb_rl.HBURST_vl(2 downto 0) in amba_ahb_rs.m_amba_ahb_rl.HBURST_vl(2 downto 0)
HPROT[3:0] amba_ahb_rif.m_amba_ahb_rl.HPROT_vl(3 downto 0) in amba_ahb_rs.m_amba_ahb_rl.HPROT_vl(3 downto 0)
HTRANS[1:0] amba_ahb_rif.m_amba_ahb_rl.HTRANS_vl(1 downto 0) in amba_ahb_rs.m_amba_ahb_rl.HTRANS_vl(1 downto 0)
HMASTLOCK amba_ahb_rif.m_amba_ahb_rl.HMASTLOCK_l in amba_ahb_rs.m_amba_ahb_rl.HMASTLOCK_l
HWDATA[31:0] amba_ahb_rif.m_amba_ahb_rl.HWDATA_vl(31 downto 0) in amba_ahb_rs.m_amba_ahb_rl.HWDATA_vl(31 downto 0)
 
Decoder Function:
ahbl_master_inst.HSEL_decoder_asgn
Name Input Element Mode Composite Signal or Element
HRESETn amba_ahb_rif.g_amba_ahb_rl.HRESET_nl in amba_ahb_rs.g_amba_ahb_rl.HRESET_nl
HCLK amba_ahb_rif.g_amba_ahb_rl.HCLK_l in amba_ahb_rs.g_amba_ahb_rl.HCLK_l
 
array of
HSEL

amba_ahb_ri.HSEL_vl(3 downto 1)

in

amba_ahb_rif.HSEL_vl(3 downto 1)
 
array of
HREADYOUT

amba_ahb_ri.s_amba_ahb_al(3 downto 1).HREADYOUT_l

in

amba_ahb_rif.s_amba_ahb_al(3 downto 1).HREADYOUT_l
array of
HRESP

amba_ahb_ri.s_amba_ahb_al(3 downto 1).HRESP_l

in

amba_ahb_rif.s_amba_ahb_al(3 downto 1).HRESP_l
array of
HRDATA[31:0]

amba_ahb_ri.s_amba_ahb_al(3 downto 1).HRDATA_vl(31 downto 0)

in

amba_ahb_rif.s_amba_ahb_al(3 downto 1).HRDATA_vl(31 downto 0)
 
HREADY amba_ahb_ri.m_amba_ahb_rl.HREADY_l in amba_ahb_rif.m_amba_ahb_rl.HREADY_l
HADDR[31:0] amba_ahb_ri.m_amba_ahb_rl.HADDR_vl(31 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HADDR_vl(31 downto 0)
HWRITE amba_ahb_ri.m_amba_ahb_rl.HWRITE_l in amba_ahb_rif.m_amba_ahb_rl.HWRITE_l
HSIZE[2:0] amba_ahb_ri.m_amba_ahb_rl.HSIZE_vl(2 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HSIZE_vl(2 downto 0)
HBURST[2:0] amba_ahb_ri.m_amba_ahb_rl.HBURST_vl(2 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HBURST_vl(2 downto 0)
HPROT[3:0] amba_ahb_ri.m_amba_ahb_rl.HPROT_vl(3 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HPROT_vl(3 downto 0)
HTRANS[1:0] amba_ahb_ri.m_amba_ahb_rl.HTRANS_vl(1 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HTRANS_vl(1 downto 0)
HMASTLOCK amba_ahb_ri.m_amba_ahb_rl.HMASTLOCK_l in amba_ahb_rif.m_amba_ahb_rl.HMASTLOCK_l
HWDATA[31:0] amba_ahb_ri.m_amba_ahb_rl.HWDATA_vl(31 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HWDATA_vl(31 downto 0)
 
HSEL[3:1]   return amba_ahb_rif.HSEL_vl(3 downto 1)
 
Multiplexor Function:
ahbl_master_inst.slave_multiplexor_asgn
Name Input Element Mode Composite Signal or Element
HRESETn amba_ahb_rif.g_amba_ahb_rl.HRESET_nl in amba_ahb_rs.g_amba_ahb_rl.HRESET_nl
HCLK amba_ahb_rif.g_amba_ahb_rl.HCLK_l in amba_ahb_rs.g_amba_ahb_rl.HCLK_l
 
array of
HSEL
amba_ahb_ri.HSEL_vl(3 downto 1) in amba_ahb_rif.HSEL_vl(3 downto 1)
 
array of
HREADYOUT

amba_ahb_ri.s_amba_ahb_al(3 downto 1).HREADYOUT_l

in

amba_ahb_rif.s_amba_ahb_al(3 downto 1).HREADYOUT_l
array of
HRESP

amba_ahb_ri.s_amba_ahb_al(3 downto 1).HRESP_l

in

amba_ahb_rif.s_amba_ahb_al(3 downto 1).HRESP_l
array of
HRDATA[31:0]

amba_ahb_ri.s_amba_ahb_al(3 downto 1).HRDATA_vl(31 downto 0)

in

amba_ahb_rif.s_amba_ahb_al(3 downto 1).HRDATA_vl(31 downto 0)
 
HREADY amba_ahb_ri.m_amba_ahb_rl.HREADY_l in amba_ahb_rif.m_amba_ahb_rl.HREADY_l
HADDR[31:0] amba_ahb_ri.m_amba_ahb_rl.HADDR_vl(31 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HADDR_vl(31 downto 0)
HWRITE amba_ahb_ri.m_amba_ahb_rl.HWRITE_l in amba_ahb_rif.m_amba_ahb_rl.HWRITE_l
HSIZE[2:0] amba_ahb_ri.m_amba_ahb_rl.HSIZE_vl(2 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HSIZE_vl(2 downto 0)
HBURST[2:0] amba_ahb_ri.m_amba_ahb_rl.HBURST_vl(2 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HBURST_vl(2 downto 0)
HPROT[3:0] amba_ahb_ri.m_amba_ahb_rl.HPROT_vl(3 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HPROT_vl(3 downto 0)
HTRANS[1:0] amba_ahb_ri.m_amba_ahb_rl.HTRANS_vl(1 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HTRANS_vl(1 downto 0)
HMASTLOCK amba_ahb_ri.m_amba_ahb_rl.HMASTLOCK_l in amba_ahb_rif.m_amba_ahb_rl.HMASTLOCK_l
HWDATA[31:0] amba_ahb_ri.m_amba_ahb_rl.HWDATA_vl(31 downto 0) in amba_ahb_rif.m_amba_ahb_rl.HWDATA_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)
 

-- Brent Hayhoe - 2016-09-09

Comments

Topic revision: r6 - 2016-10-10 - 15:22:28 - BrentHahoe
 
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback