EmbDev.net

Forum: FPGA, VHDL & Verilog variable vhdl


Author: siwar dammak (Company: ISIMSfax) (siwardammak)
Posted on:

Rate this post
0 useful
not useful
good morning
this is my vhdl code
library ieee  ; 
use ieee.std_logic_1164.all  ; 
use ieee.std_logic_arith.all  ;
use ieee.numeric_std.all;
use std.textio.all;
library work;
use work.genlfsr_pkgg.all;
-- use work.genlfsr_pkg.all;

ENTITY composantscrambler  IS 
  port ( e   : in  std_logic_vector (29 downto 0); 
         Sel : in  std_logic_vector  (3 downto 0);
         s   : out std_logic_vector (29 downto 0)
        );
END ;

process (doutGPRS, doutCDMA2000,doutUMTS,doutGSM,doutLTE,doutDVB,doutWCDMA,dout802154g,dout80220, Sel) is
   begin
      
if Sel = "0000" then 
  s <= doutCDMA2000 ;
elsif Sel = "0010" then 
  
  s <= doutGPRS;
elsif Sel = "0100" then 
    
    s <= doutUMTS;
elsif Sel = "0110" then 
   
    s <= doutGSM;
elsif Sel = "1000" then 
     
    s <= doutLTE;
elsif Sel = "1010" then 
  
    s <= doutDVB;
elsif Sel = "1100" then 
   
    s <= doutWCDMA;
elsif Sel = "0011" then 
    
    s <= dout80216b;
elsif Sel = "1001" then 
  
    s <= doutIS95;
elsif Sel = "0001" then 
     
    s <= doutHSDPA;
elsif Sel = "1111" then 
  
    s <= dout802154g;
else 
   
  s <= dout80220;
 end if ; 
 
 end process;

When I do simulation I got error (** Fatal: (vsim-3420) Array lengths do 
not match. Left is 30 (29 downto 0). Right is 14 (13 downto 0).
#    Time: 0 ns  Iteration: 0  Process: /composantscrambler/line__320 
File: C:/modeltech_10.0c/examples/composant-scrambler.vhd
# Fatal error in Process line__320 at 
C:/modeltech_10.0c/examples/composant-scrambler.vhd line 339) because I 
fixed s to std_logic_vector (29 downto 0) then it take differen value 
(doutIS95 , dout802154g, etc )
So what I can do ?
thanks

Author: Lothar Miller (lkmiller) (Moderator)
Posted on:

Rate this post
0 useful
not useful
> I fixed s to std_logic_vector (29 downto 0) then it take differen value
> (doutIS95 , dout802154g, etc )
> So what I can do ?
You can either (1) truncate the long vector or (2) lengthen the 
short one.

In the first case (1) you can assign a default value (others=>'0') to s 
and assign only the relevant bits:
process (doutGPRS, doutCDMA2000, doutUMTS, doutGSM, doutLTE, doutDVB, doutWCDMA, dout802154g, dout80220, Sel) is
   begin
      s <= (others=>'0'); -- default value
      if    Sel = "0000" then  s(29 downto 29-doutCDMA2000'high) <= doutCDMA2000 ;
      elsif Sel = "0010" then  s(29 downto 29-doutGPRS'high)     <= doutGPRS; 
      elsif Sel = "0100" then  s(29 downto 29-doutUMTS'high)     <= doutUMTS;
      elsif Sel = "0110" then  s(29 downto 29-doutGSM'high)      <= doutGSM;
      ....
      else                     s(29 downto 29-dout80220'high)    <= dout80220;
   end if ;  
 end process;
This was left aligned.
You can also do it right aligned:
process (doutGPRS, doutCDMA2000, doutUMTS, doutGSM, doutLTE, doutDVB, doutWCDMA, dout802154g, dout80220, Sel) is
   begin
      s <= (others=>'0'); -- default value
      if    Sel = "0000" then  s(doutCDMA2000'range) <= doutCDMA2000 ;
      elsif Sel = "0010" then  s(doutGPRS'range)     <= doutGPRS;
      elsif Sel = "0100" then  s(doutUMTS'range)     <= doutUMTS;
      elsif Sel = "0110" then  s(doutGSM'range)      <= doutGSM;
      ....
      else                     s(dout80220'range)    <= dout80220;
   end if ;  
 end process;
Got the idea? Its faily simple, isn't it?


And the second case (2) is already solved :
A few days ago the very same question popped up. Maybe it was asked by 
a classmate of you. He had the error in line 332. Have a look around 
here in the forum. If you try a search for "fatal error" you will find 
the solution: https://embdev.net/topic/302406.

> use ieee.std_logic_arith.all  ;
> use ieee.numeric_std.all;
Who teaches you to use them both together?

> use std.textio.all;
You know that that package is not synthesizeable?

Author: siwar dammak (Company: ISIMSfax) (siwardammak)
Posted on:

Rate this post
0 useful
not useful
thank you for your attention ,thank you very much

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.