D
dhudson01
Let's say I'm building a simple 8-bit shift register (serial in,
parallel out) for a Xilinx XC2C256 CoolRunner-II CPLD. I am using the
Xilinx Webpack 8.1.03 running under Win XP Pro.
I have the 1.842 MHz system oscillator on my development board
disconnected from the CPLD. That is, no clock signal is running to the
IO_GCK2 clock input of the CPLD.
Is it okay to bring an external 125 kHz clock signal in on a general
purpose I/O line of the CPLD? This is the input that I am using to
clock my shift register.
The reason I'm asking is because I am having some reset problems when
shifting data on the falling edge of my 125 kHz clock. No reset
problems at all if I change a single line of code to shift from falling
edge to rising edge (see code below).
Someone told me (a Verilog guy, not a VHDL expert) that the problem
could be because I'm not using the "real" system clock as the clock for
my shift register. I could find no other reference that supported that
view. Any thoughts?
For anyone still reading, the details of my "reset problem" are as
follows:
Following a power cycle, I assert the Reset signal. I then clock in 8
bits of serial data at 125 kHz. The DataReady output signal is
asserted 1 cycle too soon (i.e. it is as if the Count variable is
initialized to '1' instead of '0' at Reset) and my DataOut is off by 1
bit position.
If the Reset signal is asserted again and data is clocked in, the
output is correct. Subsequent data clockings work as expected. The
problem only occurs after power cycling. It is as if I have to clock
in some data before the Reset works correctly after power cycling.
Interestingly, if I change the code to shift on the rising edge,
everything works correctly!
What am I doing wrong? Thanks in advance for any help!
Regards,
Doug
============
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity SerialToParallel is
generic(DATA_WIDTH: natural := 8);
Port ( Clock : in STD_LOGIC; -- 125 kHz shift
clock
SerialDataIn : in STD_LOGIC;
Reset : in STD_LOGIC;
DataReady : out STD_LOGIC;
DataOut : out STD_LOGIC_VECTOR (7 downto 0);
TestOut : out STD_LOGIC);
end SerialToParallel;
architecture Behavioral of SerialToParallel is
begin
process(Clock, Reset)
variable DataReg : STD_LOGIC_VECTOR (7 downto 0);
variable Count : integer range 0 to DATA_WIDTH;
begin
if (Reset = '1') then
DataReg := (others => '0');
Count := 0;
DataOut <= (others => '0');
DataReady <= '1';
TestOut <= '1';
-- elsif (rising_edge(Clock)) then
elsif (falling_edge(Clock)) then
DataReg := DataReg((DATA_WIDTH - 2) downto 0) & SerialDataIn;
Count := Count + 1;
if (Count = DATA_WIDTH) then
DataOut <= DataReg;
Count := 0;
DataReady <= '1';
TestOut <= '1';
else
DataReady <= '0';
TestOut <= '0';
end if;
end if;
end process;
end Behavioral;
parallel out) for a Xilinx XC2C256 CoolRunner-II CPLD. I am using the
Xilinx Webpack 8.1.03 running under Win XP Pro.
I have the 1.842 MHz system oscillator on my development board
disconnected from the CPLD. That is, no clock signal is running to the
IO_GCK2 clock input of the CPLD.
Is it okay to bring an external 125 kHz clock signal in on a general
purpose I/O line of the CPLD? This is the input that I am using to
clock my shift register.
The reason I'm asking is because I am having some reset problems when
shifting data on the falling edge of my 125 kHz clock. No reset
problems at all if I change a single line of code to shift from falling
edge to rising edge (see code below).
Someone told me (a Verilog guy, not a VHDL expert) that the problem
could be because I'm not using the "real" system clock as the clock for
my shift register. I could find no other reference that supported that
view. Any thoughts?
For anyone still reading, the details of my "reset problem" are as
follows:
Following a power cycle, I assert the Reset signal. I then clock in 8
bits of serial data at 125 kHz. The DataReady output signal is
asserted 1 cycle too soon (i.e. it is as if the Count variable is
initialized to '1' instead of '0' at Reset) and my DataOut is off by 1
bit position.
If the Reset signal is asserted again and data is clocked in, the
output is correct. Subsequent data clockings work as expected. The
problem only occurs after power cycling. It is as if I have to clock
in some data before the Reset works correctly after power cycling.
Interestingly, if I change the code to shift on the rising edge,
everything works correctly!
What am I doing wrong? Thanks in advance for any help!
Regards,
Doug
============
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity SerialToParallel is
generic(DATA_WIDTH: natural := 8);
Port ( Clock : in STD_LOGIC; -- 125 kHz shift
clock
SerialDataIn : in STD_LOGIC;
Reset : in STD_LOGIC;
DataReady : out STD_LOGIC;
DataOut : out STD_LOGIC_VECTOR (7 downto 0);
TestOut : out STD_LOGIC);
end SerialToParallel;
architecture Behavioral of SerialToParallel is
begin
process(Clock, Reset)
variable DataReg : STD_LOGIC_VECTOR (7 downto 0);
variable Count : integer range 0 to DATA_WIDTH;
begin
if (Reset = '1') then
DataReg := (others => '0');
Count := 0;
DataOut <= (others => '0');
DataReady <= '1';
TestOut <= '1';
-- elsif (rising_edge(Clock)) then
elsif (falling_edge(Clock)) then
DataReg := DataReg((DATA_WIDTH - 2) downto 0) & SerialDataIn;
Count := Count + 1;
if (Count = DATA_WIDTH) then
DataOut <= DataReg;
Count := 0;
DataReady <= '1';
TestOut <= '1';
else
DataReady <= '0';
TestOut <= '0';
end if;
end if;
end process;
end Behavioral;