Guest
I have written a code notes down the position of a particular element
of one array by comparing it with other array.
The program is running fine, with only problem that a value of 7 is
coming Initially in the waveform.
Can someone point what is that thing which is giving this initial 7 in
the output. (STAMP_var1 is the signal to be observer)
I have given the basic program below.
I am also posting code for 2 ROM's and Top level which connects all
of them which will ease you analyzing everything.
Just add the vhdls in a project and see the waveforms.
Thanks in advance.
--------------------------------------------------------------------------------------
---- Basic program
--This is the program I am writting for position stamp
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;
package CONV is
constant N : integer := 8 ; -- number of elements to sort
constant M : integer := 4 ; -- size of word to sort
type TYPE_IO is array(0 to N-1) of std_logic_vector(M-1 downto 0);
end CONV;
package body CONV is
end CONV;
--------------------------------------------------------
library WORK,IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;
use WORK.CONV.ALL;
entity numberINsorting is
port( in_ved: in std_logic_vector(M-1 downto 0);
in_jala: in std_logic_vector(M-1 downto 0);
clock,Reset: in std_logic;
STAMP_var : out integer:=0;
Z: out TYPE_IO);
end numberINsorting;
architecture BEHVnumberINsorting of numberINsorting is
signal ved: TYPE_IO ;
signal jala: TYPE_IO ;
begin
process(clock,Reset)
variable tmp : std_logic_vector(M-1 downto 0);
variable list : TYPE_IO ;
variable count : integer range 0 to (N-1) ;
------------------------------------------------
variable STS : Boolean;
variable var_temp : integer range 0 to N-1:=0;
constant A : integer :=24;
constant B_COUNT : integer :=32;
constant C : integer :=14;
-----------------------------------------------
begin
----------------------------------------------
--sig_temp <= 0;
if reset='1' then
count:=0;
STS := FALSE;
var_temp := 0;
else if rising_edge(clock) then
if count=(N-1) then ---changes when frame size is
increased count:=0;
else
count:=count +1;
end if;
ved(count)<= in_ved;
jala(count) <= in_jala;
-----------------------------
for i in 0 to N-1 loop
STS := ( ved(i) = jala(N-1) ) ; -- should assign the value TRUE to STS
if STS = TRUE then
var_temp := (i) ; --- assigned the position stamp to variable
end if ;
end loop ;
STAMP_var <= var_temp ;
end if; --end reset
------------------------------
end if; -- end clock
end process;
-----------------------------------------------
end BEHVnumberINsorting;
-------------------------------------------------------------------------
-------------------------------------------------------------------------
--ROM ved
library WORK,IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
--use IEEE.STD_LOGIC_SIGNED.ALL;
use WORK.CONV.ALL;
entity romVED is
port (
ADDRESS : in integer range 0 to N-1;
Q_rom : out std_logic_vector(M-1 downto 0)
);
end entity;
library IEEE;
use IEEE.std_logic_unsigned.all;
architecture romVEDarch of romVED is
begin
process(ADDRESS)
begin
case (ADDRESS) is
when 0 => Q_rom <= "1111"; -- F
when 1 => Q_rom <= "0000"; -- 0
when 2 => Q_rom <= "0011"; -- 3
when 3 => Q_rom <= "0001"; -- 1
when 4 => Q_rom <= "1100"; -- C
when 5 => Q_rom <= "1101"; -- D
when 6 => Q_rom <= "0101"; -- 5
when 7 => Q_rom <= "1000"; -- 8
--when others => Q_rom <= "0000";
end case;
end process;
end architecture;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
library WORK,IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
--use IEEE.STD_LOGIC_SIGNED.ALL;
use WORK.CONV.ALL;
entity romJALA is
port (
ADDRESS : in integer range 0 to N-1;
Q_rom : out std_logic_vector(M-1 downto 0)
);
end entity;
library IEEE;
use IEEE.std_logic_unsigned.all;
architecture romJALAarch of romJALA is
begin
process(ADDRESS)
begin
case (ADDRESS) is
when 0 => Q_rom <= "1100"; -- C
when 1 => Q_rom <= "1101"; -- D
when 2 => Q_rom <= "0011"; -- 3
when 3 => Q_rom <= "0101"; -- 5
when 4 => Q_rom <= "1000"; -- 8
when 5 => Q_rom <= "1111"; -- F
when 6 => Q_rom <= "0001"; -- 1
when 7 => Q_rom <= "0000"; -- 0
--when others => Q_rom <= "0000";
end case;
end process;
end architecture;
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
--TOP LEVEL
library WORK,IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;
use WORK.CONV.ALL;
entity numberstamp_TB is
port(
CLOCK : in STD_LOGIC;
STAMP_var1 : out integer;
Reset : in STD_LOGIC
);
end numberstamp_TB;
architecture archnumberstamp_TB of numberstamp_TB is
---- Component declarations -----
component counterForROM
port (
CLK : in STD_LOGIC;
CLR : in STD_LOGIC;
Q : out INTEGER range 0 to N-1
);
end component;
component numberINsorting
port (
Reset : in STD_LOGIC;
clock : in STD_LOGIC;
in_jala : in STD_LOGIC_VECTOR(M-1 downto 0);
in_ved : in STD_LOGIC_VECTOR(M-1 downto 0);
STAMP_var : out integer;
Z : out TYPE_IO
);
end component;
component romJALA
port (
ADDRESS : in INTEGER range 0 to N-1;
Q_rom : out STD_LOGIC_VECTOR(M-1 downto 0)
);
end component;
component romVED
port (
ADDRESS : in INTEGER range 0 to N-1;
Q_rom : out STD_LOGIC_VECTOR(M-1 downto 0)
);
end component;
---- Signal declarations used on the diagram ----
signal NET169 : INTEGER range 0 to N-1;
signal BUS56 : STD_LOGIC_VECTOR (M-1 downto 0);
signal BUS67 : STD_LOGIC_VECTOR (M-1 downto 0);
begin
---- Component instantiations ----
U1 : numberINsorting
port map(
Reset => Reset,
clock => CLOCK,
in_jala => BUS67( M-1 downto 0 ),
in_ved => BUS56( M-1 downto 0 ),
STAMP_var => STAMP_var1
);
U2 : romJALA
port map(
ADDRESS => NET169,
Q_rom => BUS67( M-1 downto 0 )
);
U3 : romVED
port map(
ADDRESS => NET169,
Q_rom => BUS56( M-1 downto 0 )
);
U4 : counterForROM
port map(
CLK => CLOCK,
CLR => Reset,
Q => NET169
);
end archnumberstamp_TB;
of one array by comparing it with other array.
The program is running fine, with only problem that a value of 7 is
coming Initially in the waveform.
Can someone point what is that thing which is giving this initial 7 in
the output. (STAMP_var1 is the signal to be observer)
I have given the basic program below.
I am also posting code for 2 ROM's and Top level which connects all
of them which will ease you analyzing everything.
Just add the vhdls in a project and see the waveforms.
Thanks in advance.
--------------------------------------------------------------------------------------
---- Basic program
--This is the program I am writting for position stamp
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;
package CONV is
constant N : integer := 8 ; -- number of elements to sort
constant M : integer := 4 ; -- size of word to sort
type TYPE_IO is array(0 to N-1) of std_logic_vector(M-1 downto 0);
end CONV;
package body CONV is
end CONV;
--------------------------------------------------------
library WORK,IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;
use WORK.CONV.ALL;
entity numberINsorting is
port( in_ved: in std_logic_vector(M-1 downto 0);
in_jala: in std_logic_vector(M-1 downto 0);
clock,Reset: in std_logic;
STAMP_var : out integer:=0;
Z: out TYPE_IO);
end numberINsorting;
architecture BEHVnumberINsorting of numberINsorting is
signal ved: TYPE_IO ;
signal jala: TYPE_IO ;
begin
process(clock,Reset)
variable tmp : std_logic_vector(M-1 downto 0);
variable list : TYPE_IO ;
variable count : integer range 0 to (N-1) ;
------------------------------------------------
variable STS : Boolean;
variable var_temp : integer range 0 to N-1:=0;
constant A : integer :=24;
constant B_COUNT : integer :=32;
constant C : integer :=14;
-----------------------------------------------
begin
----------------------------------------------
--sig_temp <= 0;
if reset='1' then
count:=0;
STS := FALSE;
var_temp := 0;
else if rising_edge(clock) then
if count=(N-1) then ---changes when frame size is
increased count:=0;
else
count:=count +1;
end if;
ved(count)<= in_ved;
jala(count) <= in_jala;
-----------------------------
for i in 0 to N-1 loop
STS := ( ved(i) = jala(N-1) ) ; -- should assign the value TRUE to STS
if STS = TRUE then
var_temp := (i) ; --- assigned the position stamp to variable
end if ;
end loop ;
STAMP_var <= var_temp ;
end if; --end reset
------------------------------
end if; -- end clock
end process;
-----------------------------------------------
end BEHVnumberINsorting;
-------------------------------------------------------------------------
-------------------------------------------------------------------------
--ROM ved
library WORK,IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
--use IEEE.STD_LOGIC_SIGNED.ALL;
use WORK.CONV.ALL;
entity romVED is
port (
ADDRESS : in integer range 0 to N-1;
Q_rom : out std_logic_vector(M-1 downto 0)
);
end entity;
library IEEE;
use IEEE.std_logic_unsigned.all;
architecture romVEDarch of romVED is
begin
process(ADDRESS)
begin
case (ADDRESS) is
when 0 => Q_rom <= "1111"; -- F
when 1 => Q_rom <= "0000"; -- 0
when 2 => Q_rom <= "0011"; -- 3
when 3 => Q_rom <= "0001"; -- 1
when 4 => Q_rom <= "1100"; -- C
when 5 => Q_rom <= "1101"; -- D
when 6 => Q_rom <= "0101"; -- 5
when 7 => Q_rom <= "1000"; -- 8
--when others => Q_rom <= "0000";
end case;
end process;
end architecture;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
library WORK,IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
--use IEEE.STD_LOGIC_SIGNED.ALL;
use WORK.CONV.ALL;
entity romJALA is
port (
ADDRESS : in integer range 0 to N-1;
Q_rom : out std_logic_vector(M-1 downto 0)
);
end entity;
library IEEE;
use IEEE.std_logic_unsigned.all;
architecture romJALAarch of romJALA is
begin
process(ADDRESS)
begin
case (ADDRESS) is
when 0 => Q_rom <= "1100"; -- C
when 1 => Q_rom <= "1101"; -- D
when 2 => Q_rom <= "0011"; -- 3
when 3 => Q_rom <= "0101"; -- 5
when 4 => Q_rom <= "1000"; -- 8
when 5 => Q_rom <= "1111"; -- F
when 6 => Q_rom <= "0001"; -- 1
when 7 => Q_rom <= "0000"; -- 0
--when others => Q_rom <= "0000";
end case;
end process;
end architecture;
--------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------
--TOP LEVEL
library WORK,IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_SIGNED.ALL;
use WORK.CONV.ALL;
entity numberstamp_TB is
port(
CLOCK : in STD_LOGIC;
STAMP_var1 : out integer;
Reset : in STD_LOGIC
);
end numberstamp_TB;
architecture archnumberstamp_TB of numberstamp_TB is
---- Component declarations -----
component counterForROM
port (
CLK : in STD_LOGIC;
CLR : in STD_LOGIC;
Q : out INTEGER range 0 to N-1
);
end component;
component numberINsorting
port (
Reset : in STD_LOGIC;
clock : in STD_LOGIC;
in_jala : in STD_LOGIC_VECTOR(M-1 downto 0);
in_ved : in STD_LOGIC_VECTOR(M-1 downto 0);
STAMP_var : out integer;
Z : out TYPE_IO
);
end component;
component romJALA
port (
ADDRESS : in INTEGER range 0 to N-1;
Q_rom : out STD_LOGIC_VECTOR(M-1 downto 0)
);
end component;
component romVED
port (
ADDRESS : in INTEGER range 0 to N-1;
Q_rom : out STD_LOGIC_VECTOR(M-1 downto 0)
);
end component;
---- Signal declarations used on the diagram ----
signal NET169 : INTEGER range 0 to N-1;
signal BUS56 : STD_LOGIC_VECTOR (M-1 downto 0);
signal BUS67 : STD_LOGIC_VECTOR (M-1 downto 0);
begin
---- Component instantiations ----
U1 : numberINsorting
port map(
Reset => Reset,
clock => CLOCK,
in_jala => BUS67( M-1 downto 0 ),
in_ved => BUS56( M-1 downto 0 ),
STAMP_var => STAMP_var1
);
U2 : romJALA
port map(
ADDRESS => NET169,
Q_rom => BUS67( M-1 downto 0 )
);
U3 : romVED
port map(
ADDRESS => NET169,
Q_rom => BUS56( M-1 downto 0 )
);
U4 : counterForROM
port map(
CLK => CLOCK,
CLR => Reset,
Q => NET169
);
end archnumberstamp_TB;