Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

[SOLVED] Using range is slv case statement

Status
Not open for further replies.

wtr

Full Member level 5
Joined
May 1, 2014
Messages
299
Helped
29
Reputation
58
Reaction score
25
Trophy points
1,308
Activity points
4,108
Hello all,

I'm looking at some legacy code. The guy has done the following


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
PADDR                                   : in  std_logic_vector(31 downto 0);
------------------------------------------------------------
signal PADDR_N                                  : natural range 0 to 1048575; -- 2^20 = [19:0]
------------------------------------------------------------
-- APB Bus    
    PADDR_N <= conv_integer(PADDR(19 downto 0));   
------------------------------------------------------------
if PSEL = '1' and PWRITE = '0' then                                          
                case PADDR_N is
 
                    -- MRI-0 (Base: 0x0000_0000)
                    when 16#00000# => PRDATA <= FPAD_SLV(32, ARM_WR_MRI0_DARK_START_S);
                    --- more options
                    when 16#B8000# to 16#B9FFC# => PRDATA <= ARM_RD_FDDR_RDATA;     -- 8KB Address Space



The use of a natural is used to allow the case statement to have a range.
I know slv ranges' wasn't allowed in the 93 vhdl.

nowadays could I do

Code VHDL - [expand]
1
when x"B8000" to x"B9FFC" => PRDATA <= ARM_RD_FDDR_RDATA;     -- 8KB Address Space


Or do I need some fancy subtype range?

At this moment of time I haven't got access to a tool licenses check if this synthesis

Regards,
Wes
 

Hello all,

I'm looking at some legacy code. The guy has done the following


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
PADDR                                   : in  std_logic_vector(31 downto 0);
------------------------------------------------------------
signal PADDR_N                                  : natural range 0 to 1048575; -- 2^20 = [19:0]
------------------------------------------------------------
-- APB Bus    
    PADDR_N <= conv_integer(PADDR(19 downto 0));   
------------------------------------------------------------
if PSEL = '1' and PWRITE = '0' then                                          
                case PADDR_N is
 
                    -- MRI-0 (Base: 0x0000_0000)
                    when 16#00000# => PRDATA <= FPAD_SLV(32, ARM_WR_MRI0_DARK_START_S);
                    --- more options
                    when 16#B8000# to 16#B9FFC# => PRDATA <= ARM_RD_FDDR_RDATA;     -- 8KB Address Space



The use of a natural is used to allow the case statement to have a range.
I know slv ranges' wasn't allowed in the 93 vhdl.

nowadays could I do

Code VHDL - [expand]
1
when x"B8000" to x"B9FFC" => PRDATA <= ARM_RD_FDDR_RDATA;     -- 8KB Address Space


Or do I need some fancy subtype range?

At this moment of time I haven't got access to a tool licenses check if this synthesis

Regards,
Wes

Nothing fancy possible - this just isnt possible with SLV for several reasons.
1. SLV are arrays, not discrete types like std_logic or integer.
2. Ranges only work for discrete types
3. A SLV is not a number anyway, just a bag'o'bits.

For this to work this way, you will have to convert it to a discrete type anyway.

BUT

What is included in VHDL 2008 is the matching case statement (case?), which allows the use of '-' in std_logic based arrays for case matching. One Caveat is you'll have to write it in binary. like this:


Code VHDL - [expand]
1
2
3
4
case? addr_top_bits is
  when "1010_100-" => --"B8000" to "B9FFC"
  when "1010_101-" => --"BA000" to "BBFFC"
  .. etc



To be honest, Id stick with the '93 version.
 
  • Like
Reactions: wtr

    wtr

    Points: 2
    Helpful Answer Positive Rating
Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top