⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ambatest.vhd

📁 free hardware ip core about sparcv8,a soc cpu in vhdl
💻 VHD
📖 第 1 页 / 共 2 页
字号:
--------------------------------------------------------------------------------  This file is a part of the GRLIB VHDL IP LIBRARY--  Copyright (C) 2003, Gaisler Research----  This program is free software; you can redistribute it and/or modify--  it under the terms of the GNU General Public License as published by--  the Free Software Foundation; either version 2 of the License, or--  (at your option) any later version.----  This program is distributed in the hope that it will be useful,--  but WITHOUT ANY WARRANTY; without even the implied warranty of--  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the--  GNU General Public License for more details.----  You should have received a copy of the GNU General Public License--  along with this program; if not, write to the Free Software--  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA ------------------------------------------------------------------------------- Entity: 	ambatest-- File:	ambatest.vhd-- Author:	Alf Vaerneus-- Description:	Test package for emulators-------------------------------------------------------------------------------- pragma translate_offlibrary ieee;use ieee.std_logic_1164.all;library grlib;use grlib.amba.all;library gaisler;use grlib.devices.all;use grlib.stdlib.all;library std;use std.textio.all;package ambatest isfunction printhex(value : std_logic_vector; len : integer) return string;function conv_std_logic_vector(value : string; len : integer) return std_logic_vector;function trimlen(str : string) return integer;procedure printf(str : string);procedure printf(str : string; vari : integer);procedure printf(str : string; vari : std_logic_vector);procedure printf(str : string; vari : string);procedure compfiles(file1 : string(18 downto 1); file2 : string(18 downto 1); format : integer);type command_type is (RD_SINGLE,                      RD_INCR,                      RD_WRAP4,                      RD_INCR4,                      RD_WRAP8,                      RD_INCR8,                      RD_WRAP16,                      RD_INCR16,                      WR_SINGLE,                      WR_INCR,                      WR_WRAP4,                      WR_INCR4,                      WR_WRAP8,                      WR_INCR8,                      WR_WRAP16,                      WR_INCR16,                      M_READ,                      M_READ_LINE,                      M_READ_MULT,                      M_WRITE,                      M_WRITE_INV,                      C_READ,                      C_WRITE,                      I_READ,                      I_WRITE                      );constant MAX_NO_TB : integer := 20;type tb_in_type is record  address   : std_logic_vector(31 downto 0);  data      : std_logic_vector(31 downto 0);  start     : std_logic;  command   : command_type;  no_words  : integer;  userfile  : boolean;  usewfile  : boolean;  rfile     : string(18 downto 1);  wfile     : string(18 downto 1);end record;type tbi_array_type is array(0 to MAX_NO_TB) of tb_in_type;type status_type is (OK, ERR, TIMEOUT, RETRY);type tb_out_type is record  data      : std_logic_vector(31 downto 0);  ready     : std_logic;  status    : status_type;end record;type tbo_array_type is array(0 to MAX_NO_TB) of tb_out_type;type ctrl_type is record  address   : std_logic_vector(31 downto 0);  data      : std_logic_vector(31 downto 0);  status    : status_type;  curword   : integer;  no_words  : integer;  userfile  : boolean;  usewfile  : boolean;  rfile     : string(18 downto 1);  wfile     : string(18 downto 1);end record;constant tb_in_init : tb_in_type := (  address => (others => '0'),  data => (others => '0'),  start => '0',  command => RD_SINGLE,  no_words => 0,  userfile => false,  usewfile => false,  rfile => "                  ",  wfile => "                  ");constant ctrl_init : ctrl_type := (  address => (others => '0'),  data => (others => '0'),  status => OK,  curword => 0,  no_words => 1,  userfile => false,  usewfile => false,  rfile => "                  ",  wfile => "                  ");constant AHB_IDLE : ahb_mst_out_type := (  hbusreq => '0',  hlock => '0',  htrans => HTRANS_IDLE,  haddr => (others => '0'),  hwrite => '0',  hsize => HSIZE_WORD,  hburst => HBURST_SINGLE,  hprot => (others => '0'),  hwdata => (others => '0'),  hirq => (others => '0'),  hconfig => (others => zero32),  hindex => 0  );constant READ_SINGLE : ahb_mst_out_type := (  hbusreq => '0',  hlock => '0',  htrans => HTRANS_NONSEQ,  haddr => (others => '0'),  hwrite => '0',  hsize => HSIZE_WORD,  hburst => HBURST_SINGLE,  hprot => (others => '0'),  hwdata => (others => '0'),  hirq => (others => '0'),  hconfig => (others => zero32),  hindex => 0  );constant READ_INCR : ahb_mst_out_type := (  hbusreq => '0',  hlock => '0',  htrans => HTRANS_NONSEQ,  haddr => (others => '0'),  hwrite => '0',  hsize => HSIZE_WORD,  hburst => HBURST_INCR,  hprot => (others => '0'),  hwdata => (others => '0'),  hirq => (others => '0'),  hconfig => (others => zero32),  hindex => 0  );constant WRITE_SINGLE : ahb_mst_out_type := (  hbusreq => '0',  hlock => '0',  htrans => HTRANS_NONSEQ,  haddr => (others => '0'),  hwrite => '1',  hsize => HSIZE_WORD,  hburst => HBURST_SINGLE,  hprot => (others => '0'),  hwdata => (others => '0'),  hirq => (others => '0'),  hconfig => (others => zero32),  hindex => 0  );constant WRITE_INCR : ahb_mst_out_type := (  hbusreq => '0',  hlock => '0',  htrans => HTRANS_NONSEQ,  haddr => (others => '0'),  hwrite => '1',  hsize => HSIZE_WORD,  hburst => HBURST_INCR,  hprot => (others => '0'),  hwdata => (others => '0'),  hirq => (others => '0'),  hconfig => (others => zero32),  hindex => 0  );-- AHB Master Emulatorcomponent ahbmst_em  generic(    hindex    : integer := 0;    timeoutc  : integer := 100;    dbglevel  : integer := 2  );  port(    rst       : in std_logic;    clk       : in std_logic;    -- AMBA signals    ahbmi     : in  ahb_mst_in_type;    ahbmo     : out ahb_mst_out_type;    -- TB signals    tbi       : in  tb_in_type;    tbo       : out  tb_out_type  );end component;-- AHB Slave Emulatorcomponent ahbslv_em  generic(    hindex    : integer := 0;    abits     : integer := 10;    waitcycles : integer := 2;    retries   : integer := 0;    memaddr   : integer := 16#E00#;    memmask   : integer := 16#FFF#;    ioaddr    : integer := 16#000#;    timeoutc   : integer := 100;    dbglevel  : integer := 2  );  port(    rst       : in std_logic;    clk       : in std_logic;    -- AMBA signals    ahbsi     : in  ahb_slv_in_type;    ahbso     : out ahb_slv_out_type;    -- TB signals    tbi       : in  tb_in_type;    tbo       : out  tb_out_type  );end component;end ambatest;package body ambatest isfunction printhex( value : std_logic_vector; len : integer) return string is variable str1, str2 : string (1 to 8); variable stmp  : string (8 downto 1); variable x : std_logic_vector(31 downto 0); begin  x:=value;  case len is  when 4 | 8 | 12 | 16 | 20 | 24 | 28 | 32 =>    for i in 0 to (len/4)-1 loop      case conv_integer(x(((len-1)-(i*4)) downto ((len-1)-(i*4)-3))) is        when 0 => stmp(i+1) := '0';        when 1 => stmp(i+1) := '1';        when 2 => stmp(i+1) := '2';        when 3 => stmp(i+1) := '3';        when 4 => stmp(i+1) := '4';        when 5 => stmp(i+1) := '5';        when 6 => stmp(i+1) := '6';        when 7 => stmp(i+1) := '7';        when 8 => stmp(i+1) := '8';        when 9 => stmp(i+1) := '9';        when 10 => stmp(i+1) := 'A';        when 11 => stmp(i+1) := 'B';        when 12 => stmp(i+1) := 'C';        when 13 => stmp(i+1) := 'D';        when 14 => stmp(i+1) := 'E';        when 15 => stmp(i+1) := 'F';        when others => stmp(i+1) := 'X';      end case;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -