Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic 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.

Register Log in

need help on VHDL 16 bit counter

Status
Not open for further replies.

frozenone

Newbie level 3
Joined
Dec 20, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,314
Need help on 16 bit counter, how do i write statement to check on my output count making sure it count from 0 to 15 and show error message.

library IEEE;
use IEEE.std.std_logic_1164.all;

entity counter_testbench is
end counter_testbench;

architecture counter_testbench of counter_testbench is
component counter
port ( count: out std_logic_vector(15 downto 0);
clk: in std_logic ;
reset: in std_logic;
end component;
signal count: std_logic_vector(15 downto 0);
signal clk: std_logic='0';
signal reset: std_logic='0';
begin
counter_circuit: counter
port map(count=>count,
clk=>clk,
reset=>reset);

clock:process
begin
wait for 10ns; clk<=not clk;
end process clock;

test _reset:process
begin
wait for 10ns; reset<='1';
wait for 10ns; reset<='0';
wait;
end process test_reset;

end counter_testbench;
 
Last edited:

TrickyDicky

Advanced Member level 5
Joined
Jun 7, 2010
Messages
7,045
Helped
2,069
Reputation
4,155
Reaction score
2,023
Trophy points
1,393
Activity points
38,827
first of all, there are syntax errors in the posted code.
Secondly, the clock will be stuck at 'U' with the posted code.

Please fix the code first, and come back with a clearer question.
 

frozenone

Newbie level 3
Joined
Dec 20, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,314
first of all, there are syntax errors in the posted code.
Secondly, the clock will be stuck at 'U' with the posted code.

Please fix the code first, and come back with a clearer question.
Done my code is working already i need a code that can monitor the output(count) making sure it increase by 1 and able to show an error message where the error is. Should be assert statement.
 
Last edited:

verylsi

Full Member level 2
Joined
Mar 12, 2012
Messages
123
Helped
16
Reputation
32
Reaction score
16
Trophy points
1,308
Activity points
2,130
Tricky is right..

u need to correct the initialization of signals clk and reset .. it is initialized through ":=" u must be knowing that , I guess its a human error..
 

frozenone

Newbie level 3
Joined
Dec 20, 2012
Messages
4
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,314
Tricky is right..

u need to correct the initialization of signals clk and reset .. it is initialized through ":=" u must be knowing that , I guess its a human error..
Is my testbench ok now? i need help on writing a code that can monitor the output(count) making sure it increase by 1 and able to show an error message where the error is. Should be assert statement but i don't know how to write it.


library IEEE;
use IEEE.std.std_logic_1164.all;

entity counter_testbench is
end counter_testbench;

architecture counter_testbench of counter_testbench is

component counter

port ( count: out std_logic_vector(15 downto 0);
clk: in std_logic;
reset: in std_logic;
end component;

signal count: std_logic_vector(15 downto 0);
signal clk: std_logic:='0';
signal reset: std_logic:='0';

begin

counter_circuit: counter

port map(count => count,
clk => clk,
reset => reset);

clock:process
begin
wait for 10ns; clk<=not clk;
end process clock;

test_reset:process
begin
wait for 10ns; reset<= '1';
wait for 10ns; reset<= '0';
wait;
end process test_reset;

end counter_testbench;
 
Last edited:

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top