Sunday, December 13, 2009

Address range decode using CASE statement in VHDL

-- Type decleration
SUBTYPE sram_dev_addr IS INTEGER RANGE 16#100000# TO 16#13FFFF#;
SUBTYPE ctrl_reg_addr IS INTEGER RANGE 16#1FC000# TO 16#1FFFFF#;

-- Address decoding process
proc_access_decode : PROCESS (clk_80m)
VARIABLE own_addr_var : INTEGER RANGE 0 TO 16#1FFFFF#;
VARIABLE dev_sel : STD_LOGIC_VECTOR (1 DOWNTO 0) := "00";

BEGIN
-- type convert the input proc_addr
own_addr_var := conv_integer (UNSIGNED (proc_addr)) ;
CASE own_addr_var IS
WHEN sram_dev_addr => dev_sel := "01";
WHEN ctrl_reg_addr => dev_sel := "10";
WHEN OTHERS => dev_sel := "11";
END CASE;
END PROCESS proc_access_decode;

Wednesday, December 9, 2009

Delete unwanted whitespaces

VIM Command to delete unwanted whitespaces at the end of line in a file.

:%s/\s*$//

Tuesday, December 8, 2009

RANGE DECLERATION IN VHDL

Range cannot be declared for STD_LOGIC_VECTOR types.


CONSTANT ARINC1_ADDR_RNG_L : STD_LOGIC_VECTOR (22 DOWNTO 2) := '1' & X"F0000" ;
CONSTANT ARINC1_ADDR_RNG_H : STD_LOGIC_VECTOR (22 DOWNTO 2) := '1' & X"F1FFF" ;

TYPE ARINC1_ADDR_RNG IS RANGE ARINC1_ADDR_RNG_L TO ARINC1_ADDR_RNG_H ;

Hint: Range must be a scalar type.