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

📄 busmonitor.vhd

📁 文件ARM_core_VHDL.rar 嵌入式arm核的vhdl语言描述.
💻 VHD
字号:
-- *********************************************************************************************				  
-- Bus monitor for ARM core simulation
-- Modified 04.02.2003
-- Designed by Ruslan Lepetenok
-- *********************************************************************************************				  

library IEEE;
use IEEE.std_logic_1164.all;
use IEEE.std_logic_unsigned.all;
use IEEE.std_logic_arith.all;

use STD.textio.all;

use WORK.ARMPackage.all;

entity BusMonitor is generic(LogFileName : string := "Log.txt"); 
	                 port(
								   -- Global control signals
	                               nRESET  : in  std_logic;
						           CLK     : in  std_logic;
								   CLKEN   : in  std_logic;	
								   -- Address class signals
								   ADDR    : in  std_logic_vector(31 downto 0);
								   WRITE_I : in  std_logic;
								   SIZE    : in  std_logic_vector(1 downto 0);
								   PROT	   : in  std_logic_vector(1 downto 0);
								   LOCK	   : in  std_logic;
								   -- Memory request signals
								   TRANS   : in  std_logic_vector(1 downto 0);
								   -- Data timed signals
								   WDATA   : in  std_logic_vector(31 downto 0);
								   RDATA   : in  std_logic_vector(31 downto 0);
								   ABORT   : in  std_logic
								   );


end BusMonitor;

architecture Beh of BusMonitor is

type TransferType is (IDLE,COPR,NONSEQ,SEQ); 
type TransferSizeType is (Word,HalfWord,Byte,Reserved);
type OperationType is (ReadOp,WriteOp); 
type ProtectionType is (UsrOpc,UsrData,PrivOpc,PrivData);

constant CPT_UsrOpc   : std_logic_vector(1 downto 0) := "00";
constant CPT_UsrData  : std_logic_vector(1 downto 0) := "01";
constant CPT_PrivOpc  : std_logic_vector(1 downto 0) := "10";
constant CPT_PrivData : std_logic_vector(1 downto 0) := "11";

file OutLogFile : text open write_mode is LogFileName;

type AddressClassSignalsType is record 
  Address      : integer; 
  Operation	   : OperationType;
  Transfer     : TransferType;
  TransferSize : TransferSizeType;
  Protection   : ProtectionType;
  Lock         : boolean;
end record;

type DataTimedSignalsType is record 
  WData         : integer; 
  RData         : integer; 
  Abort         : boolean;  
end record;

function WordToString(InWord : integer) return string is
variable WordString : string (8 downto 1) := (others => ' ');
variable TempVar    : std_logic_vector(31 downto 0) := (others => '0');
variable TempNibble : std_logic_vector(3 downto 0)  := (others => '0');

begin

 TempVar := CONV_STD_LOGIC_VECTOR(InWord,32);	
	
for i in 0 to 7 loop
 TempNibble := TempVar(i*4+3 downto i*4); 

 if  TempNibble <= 9 then -- 0..9
  WordString(i+1) := character'val(character'pos('0') + CONV_INTEGER(TempNibble));
   else			        -- A..F
  WordString(i+1) := character'val(character'pos('A') + CONV_INTEGER(TempNibble) - 10);
    end if;	
	
end loop;	

return WordString;	
end function; 	

begin
	
AddressAndControlLatch:process

variable L : line;

variable FirstCycle : boolean := TRUE;

variable CurrentAdrCtrlSgs : AddressClassSignalsType;
variable PrevAdrCtrlSgs    : AddressClassSignalsType;
variable DataTimedSignals  : DataTimedSignalsType;

variable CycleCounter : integer := 0;

constant Separator : character := ':';

begin

 wait until nRESET='1' and CLK='1' and CLK'event and CLKEN='1'; 

 -- Decode address class signals 
  CurrentAdrCtrlSgs.Address := CONV_INTEGER(ADDR);
  
  if WRITE_I='1' then
    CurrentAdrCtrlSgs.Operation := WriteOp;
     else 	
          CurrentAdrCtrlSgs.Operation := ReadOp;
   end if;

   case TRANS is 
	when CTT_I  => CurrentAdrCtrlSgs.Transfer := IDLE;
   	when CTT_C  => CurrentAdrCtrlSgs.Transfer := COPR;
 	when CTT_N  => CurrentAdrCtrlSgs.Transfer := NONSEQ;
	when CTT_S  => CurrentAdrCtrlSgs.Transfer := SEQ;
	when others => null;
   end case;
        
   case SIZE is 
	when CTS_B  => CurrentAdrCtrlSgs.TransferSize := Byte;
   	when CTS_HW => CurrentAdrCtrlSgs.TransferSize := HalfWord;
	when CTS_W  => CurrentAdrCtrlSgs.TransferSize := Word;
	when "11"   => CurrentAdrCtrlSgs.TransferSize := Reserved;
				   report "Unsupported transfer size" severity ERROR;
	when others => null;
   end case;
   
   case PROT is
    when CPT_UsrOpc => CurrentAdrCtrlSgs.Protection := UsrOpc;
	when CPT_UsrData => CurrentAdrCtrlSgs.Protection := UsrData;
	when CPT_PrivOpc => CurrentAdrCtrlSgs.Protection := PrivOpc;
	when CPT_PrivData => CurrentAdrCtrlSgs.Protection := PrivData;
	when others => null;
   end case;		
   
   CurrentAdrCtrlSgs.Lock := LOCK='1';

 if not FirstCycle then 

 CycleCounter := CycleCounter+1;  
 
  assert CycleCounter>0 
   report"Wrong cycle counter value"
     severity FAILURE;
	 
-- Data signals   
  DataTimedSignals.WData := CONV_INTEGER(WDATA);
  DataTimedSignals.RData :=	CONV_INTEGER(RDATA); 
  DataTimedSignals.Abort :=	ABORT='1'; 

-- Write log file
 write(L,"Cycle cnt. = "); 
 write(L,integer'image(CycleCounter)); 
 write(L,Separator); 

-- Address
 write(L,"0x");
 write(L,WordToString(PrevAdrCtrlSgs.Address));
 write(L,Separator); 

-- Control 
  write(L,OperationType'image(PrevAdrCtrlSgs.Operation));
  write(L,Separator);         
  write(L,TransferType'image(PrevAdrCtrlSgs.Transfer));
  write(L,Separator); 
  write(L,TransferSizeType'image(PrevAdrCtrlSgs.TransferSize));
  write(L,Separator); 
  write(L,ProtectionType'image(PrevAdrCtrlSgs.Protection));
  write(L,Separator); 
  
  if PrevAdrCtrlSgs.Lock then
   write(L,"Locked transaction"); 	  
   write(L,Separator); 
  end if;	  
 
  write(L,"0x");
  if PrevAdrCtrlSgs.Operation=ReadOp then
   	write(L,WordToString(DataTimedSignals.RData));
	write(L," -- Was read"); 	   
   else
	write(L,WordToString(DataTimedSignals.WData));
	write(L," -- Was write"); 	     
   end if;
   
   write(L,Separator); 
   
   if DataTimedSignals.Abort then
     write(L,"Memory abort"); 	     
     write(L,Separator); 
   end if;
   
  writeline(OutLogFile,L); -- Write to file
  
 else
  FirstCycle := FALSE;
 end if; 

  PrevAdrCtrlSgs := CurrentAdrCtrlSgs;
   
end process;	


end Beh;


⌨️ 快捷键说明

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