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.

Can I do this in VHDL?

Status
Not open for further replies.

barry

Advanced Member level 7
Joined
Mar 31, 2005
Messages
6,330
Helped
1,194
Reputation
2,400
Reaction score
1,386
Trophy points
1,393
Location
California, USA
Activity points
34,456
Maybe I'm trying to do something I can't, but it seems like I should be able to.

Here's a snippet:

Code:
signal big:std_logic_vector(15 downto 0);
signal little:std_logic_vector(3 downto 0);
.
.
.
little<=(big-x"0010")(3 downto 0);

This is part of a testbench I'm using in Active-HDL, and it doesn't like the assignment. The error I get says it wants a ";" before the "(3 downto 0)". If I eliminate the "(3 downto 0)", it compiles ok, but then fails at runtime (as would be expected).

Any thoughts, guys?
 

Hmm, I always thought you could, but apparently not.

However, you can slice a function return, rather than an operator


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
library ieee;
use ieee.std_logic_1164.all;
--use ieee.std_logic_unsigned.all;
use ieee.numeric_std.all;
 
entity test is
end entity test;
 
architecture rtl of test is
  signal a : signed(15 downto 0);
  signal b : signed(3 downto 0);
  
  function minus(a : signed) return signed is
  begin
      return a - 1;
  end function;
  
begin
 
  b <= minus(a)(3 downto 0);
 
end rtl;

 
  • Like
Reactions: barry

    barry

    Points: 2
    Helpful Answer Positive Rating
Thanks Tricky

Just thought it would be nice if it worked MY way.

This might actually be a problem with the active-HDL compiler. Since it's a testbench, I haven't tried to synthesize it. I might just do a test to see if it synthesizes.
 

It failed in modelsim for me, so I assume its a language thing.
 

Haha
First try AHDL then get really mad...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top