T
Takuon Soho
Guest
I have a 12 bit counter whoose value
needs to be output to 12 output pins
of a cpld
when flag signal goes high (see Process code below).
But I can't figure out how to output my_counter
to a std_logic_vector
because it is a subtype of integer.
I tried things like
bus_0_11 <= std_logic_vector(counter_ty my_counter);
without compilation success.
Anyone know how to do this?
Thanks
Tak
code follows:
entity count12 is port (
clk : in std_logic;
....
bus_0_11: out std_logic_vector(11 downto 0)
);
end count12;
Process(clk,flag)
-- my counter variable declaration
subtype counter_ty is integer range 0 to 4095; -- 12 bit counter,
integer
variable my_counter : counter_ty := 0;
begin
.....
if (flag = '1') then -- flag hi, output count to bus
bus_0_11 <= std_logic_vector(counter_ty my_counter);
flag = '0';
elsif (clk'event and clk = '1') then
my_counter = my_counter + 1;
end if;
end process;
needs to be output to 12 output pins
of a cpld
when flag signal goes high (see Process code below).
But I can't figure out how to output my_counter
to a std_logic_vector
because it is a subtype of integer.
I tried things like
bus_0_11 <= std_logic_vector(counter_ty my_counter);
without compilation success.
Anyone know how to do this?
Thanks
Tak
code follows:
entity count12 is port (
clk : in std_logic;
....
bus_0_11: out std_logic_vector(11 downto 0)
);
end count12;
Process(clk,flag)
-- my counter variable declaration
subtype counter_ty is integer range 0 to 4095; -- 12 bit counter,
integer
variable my_counter : counter_ty := 0;
begin
.....
if (flag = '1') then -- flag hi, output count to bus
bus_0_11 <= std_logic_vector(counter_ty my_counter);
flag = '0';
elsif (clk'event and clk = '1') then
my_counter = my_counter + 1;
end if;
end process;