Alrighty. State machines don't seem to churn out my output well, ie. not churning out...

But I managed to come out with this easier code (though I'm going bald from trying to figure out the basics):

Code:

library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity counter is
Port ( clk : in STD_LOGIC;
sig : in STD_LOGIC;
t : out std_logic_vector(0 to 7)); --hoping to have t(0),..., t(7)
end counter;
architecture Behavioral of counter is
signal count : std_logic_vector(7 downto 0); --8 bit counter
begin
process(clk,sig) is
begin
if sig='1' then
count<=(others=>'0');
elsif rising_edge(clk) then
count<=count+1;
end if;
t<=count;
end process;
end Behavioral;

Now, I'm trying to output the counts (as integers) at each sig='1', like

clk_||_||_||_||_||_||_||_||_||_||_||_

sig____||_____||__||__||____||_____

........start.......t0...t1..t2.....t3

......counter

Thus I will get t0 = 2, t1 = 1, t2 = 1, t3 = 2

I tried to automate the process with a FOR LOOP by having

Code:

port ( ... t : out std_logic_vector(0 to 7));
process
variable i : integer;
begin
for i in 1 to 8 loop
...counting...
t(i) <= conv_integer(unsigned(count));
end loop;
end process;

Failed miserably. conv_integer also requires that "count" be std_ulogic. After digging around for a while, it turns out that conv_integer doesn't seem to work well with std_logic.

Anyway I thought of a way to output the counts is subtraction from previous count. So like, T0 = t0 - 0, T1 = t1 - t0, T2 = t2 - t1,

where tn is counts relative to 0 and Tn relative to Tn-1. Haven't quite figured out the code for that yet.

Nutshell:

1) how to output integer counts for each t0, t1, ...t7

2) what's up with conv_integer and std_ulogic? Jeez.

edit:

another uneducated idea I have is this:

make an array of sixteen t's such that each holds a 16-bit value of "count"

example: t(0) = 00001100, t(1) = 00000101, etc. After which, I would like to do something like, for example, b(0) = t(0) + t(1)

or essentially, b(i) <= t(i) + t(i+1) (b(15) <= t(15) + t(16) will not exist). Is all this possible or am I just hoping for something non-existent? I tried loops, and I don't wish to continue with state machines. Any others ideas on where I can start?