hassan590
Newbie level 3
- Joined
- Sep 17, 2013
- Messages
- 3
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1
- Activity points
- 37
I am a beginner in vhdl. i just learned how do we program in vhdl. i was trying to make a program which has two entities as counters i declared an array and different values are placed at each location in that array. the counter has to pick a value from each location and decrements it down to zero i want both counters to pick values from the same array in such away that 1st counter picks value from 1st location and 2nd counter from second counter picks from second location the one who decrements to zero first, picks the value from next location. My supervisor gave me this task to understand how to entities interact with each other. I need some help to complete that task. i have written code for one counter which is decrementing the values after picking them from array and i have no idea how 2nd counter would be working with counter 1 to perform the actual task which is mentioned above.what should i be doing? i hope u people would help me.
Code VHDL - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 library IEEE; use IEEE.std_logic_1164.all; use IEEE.std_logic_unsigned.all use ieee.numeric_std.all; entity counter is port(clk,reset :in std_logic; type my_array is array(1 to 8) of integer; total:out unsigned(3 downto 0); constant set:my_array:= (2,4,6,8,10,12,14,16)); architecture imp of counter is signal count:unsigned(3 downto 0); variable i : integer RANGE 0 TO 8 := 0; variable t : integer:=0 begin process(clk); count=set(i+1) if rising_edge(Clk) then if (count>0) then count<=count-1; t<=t+1 else i:=i+1; end if; end if; end process; total=t; end imp;
Last edited by a moderator: