Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
15 years ago

Homemade TestBench attmept

Hola All,

I recently made a vhd file from scratch that tested some simple logic circuits successfully. All I have had as resources in this task is the tutorial files from ModelSim (counter.vhd, and tcounter.vhd), and a single text on vhdl (Circuit Design with VHDL by Peroni). Things were looking good until I attempted to make and test a frequency divider.

http://sphotos.ak.fbcdn.net/hphotos-ak-snc4/hs148.snc4/36780_10150214314760055_754135054_13023800_1551964_n.jpg

This frequency divider has one input (clk) and two outputs (out1, and out2). The code for this divider is below as well as the testbench I made for it. The problem is I get an undefined signal coming out of both my outputs. Any explanation as to why would be much appreciated.

Thanks for the assist,

Triston

****************************Freq Divider code*******************************

Library ieee;

Use ieee.std_logic_1164.all;

------------------------------------>

Entity Freq_Div_1 is

Generic(n : integer := 4);

Port(

clk : IN std_logic;

out1,out2 : buffer std_logic

);

End Freq_Div_1;

------------------------------------>

Architecture Div of Freq_Div_1 is

Signal count1 : Integer Range 0 to 7;

Begin

Process (clk)

Variable count2 : integer range 0 to 7;

Begin

if (clk'EVENT and clk='1') then

count1 <= count1 + 1;

count2 := count2 + 1;

if ( count1 = n) then

out1 <= not out1;

count1 <= 0;

end if;

if(count2 = 2) then

out2 <= not out2;

count2 := 0;

end if;

end if;

End Process;

End Div;

*************************** My TestBench Debacle *************************

Library ieee;

Use ieee.std_logic_1164.all;

------------------------------------->

Entity tFreq_Div_1 is

Port(

out1,out2 : buffer std_logic

);

End tFreq_Div_1;

------------------------------------->

Architecture testBench of tFreq_Div_1 is

-- ******** Component ******** ----->

Component Freq_Div_1

Port(

clk : in std_logic;

out1,out2 : buffer std_logic

);

End Component Freq_Div_1;

--**** Test Signals ******* -------->

Signal clk : std_logic :='0';

------------------------------------->

Begin

dut:Freq_Div_1

Port MAP

(

clk => clk,

out1 => out1,

out2 => out2

);

clk_In : Process

Begin

wait for 10 ns; clk <= not clk;

End Process clk_In;

intialize : process

begin

wait for 1 ns; out1 <= '0';

wait for 1 ns; out2 <='0';

wait;

End process intialize;

End testBench;

12 Replies