T
Takuon Soho
Guest
I have learned how to set up a process
properly with clk and reset signals so that it will
synthesize properly without getting the dreaded
"bad synchronous description" error.
But here I have 3 signals - a clk (of course),
a start signal, and a MessageRcvd signal.
I am supposed to accumulate a count
by adding 1 to a counter
only after getting a "Start" signal (hi).
Whenever the "MsgRcvd" signal goes
hi, I must output the count and clear the counter.
Whatever I try keeps running into the "bad synchrnous"
problem.
Question: Should I break this into two seperate processes
or is it doable in 1?? Can 2 processes have a common
variable (the counter?)
I was going to try to re-write it as a state machine
Here is one thing I tried (clearly wrong because
sw_linexx and send_xx are set low by
1 clock signal and set high by another).
Thanks for any suggestions.
Tak (VHDL newbie, obviously).
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.NUMERIC_STD.all;
entity count12 is port (
clk: in std_logic;
start: in std_logic
msgRcvd: in std_logic;
sw_linex: out std_logic;
send_xx: out std_logic := '0';
bus_0_11: out std_logic_vector(11 downto 0);
);
end count12;
architecture behavioral of count12 is
begin
process(clk,start,msgRcvd)
subtype counter_ty is integer range 0 to 4095;
variable my_counter : counter_ty := 0;
variable msgFlag :integer := 0; --make it a boolean flag later
begin
if (rising_edge(start)) then
msgFlag := 1;
end if;
if (rising_edge(clk) and msgFlag = 1) then
sw_linex <= '0';
send_xx <= '0';
my_counter := my_counter + 1;
elsif
(rising_edge(msgRcvd)) then
send_xx <= '1';
sw_linex <= '1';
msgFlag := 0;
bus_0_11 <= conv_std_logic_vector(my_counter, 12);
end if;
end process;
end behavioral;
properly with clk and reset signals so that it will
synthesize properly without getting the dreaded
"bad synchronous description" error.
But here I have 3 signals - a clk (of course),
a start signal, and a MessageRcvd signal.
I am supposed to accumulate a count
by adding 1 to a counter
only after getting a "Start" signal (hi).
Whenever the "MsgRcvd" signal goes
hi, I must output the count and clear the counter.
Whatever I try keeps running into the "bad synchrnous"
problem.
Question: Should I break this into two seperate processes
or is it doable in 1?? Can 2 processes have a common
variable (the counter?)
I was going to try to re-write it as a state machine
Here is one thing I tried (clearly wrong because
sw_linexx and send_xx are set low by
1 clock signal and set high by another).
Thanks for any suggestions.
Tak (VHDL newbie, obviously).
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.NUMERIC_STD.all;
entity count12 is port (
clk: in std_logic;
start: in std_logic
msgRcvd: in std_logic;
sw_linex: out std_logic;
send_xx: out std_logic := '0';
bus_0_11: out std_logic_vector(11 downto 0);
);
end count12;
architecture behavioral of count12 is
begin
process(clk,start,msgRcvd)
subtype counter_ty is integer range 0 to 4095;
variable my_counter : counter_ty := 0;
variable msgFlag :integer := 0; --make it a boolean flag later
begin
if (rising_edge(start)) then
msgFlag := 1;
end if;
if (rising_edge(clk) and msgFlag = 1) then
sw_linex <= '0';
send_xx <= '0';
my_counter := my_counter + 1;
elsif
(rising_edge(msgRcvd)) then
send_xx <= '1';
sw_linex <= '1';
msgFlag := 0;
bus_0_11 <= conv_std_logic_vector(my_counter, 12);
end if;
end process;
end behavioral;