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.

Need help with this VHDL code. Integer output showing as binary in Isim.

Status
Not open for further replies.

navienavnav

Member level 1
Joined
Dec 12, 2011
Messages
36
Helped
1
Reputation
2
Reaction score
1
Trophy points
1,288
Location
India.
Activity points
1,627
I wrote the following code the purpose of which is to count the number of 1's in an 8-bit binary number....

Code:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;


entity count_ones_nav is

port ( inp : in std_logic_vector(7 downto 0);
       outp : out integer range 0 to 8);
end count_ones_nav;

architecture Behavioral of count_ones_nav is

begin

process(inp)
variable c : integer range 0 to 8;
begin

c := 0;
for x in 0 to 7 loop
 if inp(x)='1' then
    c:=c+1;
 end if;
end loop;

outp<=c;
end process;

end Behavioral;

It is showing the correct count in ISim, but it is showing it as binary. For example, if the number of 1's are 6, then it is showing 110 after simulation in the ISim. Is this the correct way because ISim only shows values in binary (because of the waveform and being a digital output) or am I doing something wrong?
 

the eventual design will have outp as a binary number, as everything in an fpga is binary. I assume you're doing a post place and route simulation, rather than an RTL simulation (because that should show an integer).
 

RTL simulation shows integer value and GLS simulation shows binary value.
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top