Intel® Quartus® Prime Software
Intel® Quartus® Prime Design Software, Design Entry, Synthesis, Simulation, Verification, Timing Analysis, System Design (Platform Designer, formerly Qsys)
17249 Discussions

test bench from a program

Altera_Forum
Honored Contributor II
1,266 Views

how the test bench to run this program on ModelSim Altera? 

 

library ieee;  

use ieee.std_logic_1164.all;  

use ieee.std_logic_unsigned.all;  

use ieee.std_logic_arith.all;  

entity clkdiv is  

generic ( n : integer :=10);  

port (  

clkin : in std_logic;  

clkout : out std_logic);  

end clkdiv;  

architecture arc of clkdiv is  

signal clk_tmp : std_logic := '0';  

signal cnt : integer := 0 ;  

begin  

process (clkin,cnt) begin  

if (clkin'event and clkin='1') then  

cnt <= cnt + 1;  

if ( cnt = n-1 ) then  

clk_tmp <= not clk_tmp;  

cnt <= 0;  

end if;  

end if;  

end process;  

clkout <= clk_tmp ;  

end arc;
0 Kudos
1 Reply
Altera_Forum
Honored Contributor II
519 Views

You just need a process that generates the clock for the clkin port. Any good tutorial or book about VHDL simulation should tell you how to do it.

0 Kudos
Reply