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.

VHDL coding style problem!!!!

Status
Not open for further replies.

dimon_k

Newbie level 2
Joined
Dec 8, 2012
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,296
Hi all,

I have written this lines


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
library ieee ;
  use ieee.std_logic_1164.all ;
  use ieee.std_logic_arith.all ; 
  use ieee.std_logic_unsigned.all ;
 
signal wr_addr  :std_logic_vector(3 downto 0); -- fifo write address 
signal rd_addr  :std_logic_vector(3 downto 0); -- fifo read address
 
a<= '1' when wr_addr > 6 + rd_addr else '0';



I want a to be 1 when difference between wr_addr and rd_addr is more then 6 e.g I have 6 written addresses in fifo,

but in the lab I see that it doesn't work properly.

writing :

f

Code VHDL - [expand]
1
2
ifo_lvl<= wr_addr - rd_addr ;
a<= '1' when fifo_lvl > 6  else '0';



solves the problem...

Can anybody explane what is the problem here???

thanks
 
Last edited by a moderator:

Consider that 6 + rd_addr can overflow the unsigned(3 downto 0) range. Then both constructs behave different.
 

So you say that if rd_addr = 14 then rd_addr + 6 will be 4 because it is unsigned
 

So you say that if rd_addr = 14 then rd_addr + 6 will be 4 because it is unsigned
Not exactly. The integer expression rd_addr +6 has the value 20. An unsigned[3 downto 0] fifo_lvl is assigned a value of 4.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top