N
Naimesh
Guest
Pls tell which is the better way of the two.
I have a SPARTAN II based design. there is serial output from the FPGA
which a uP will read. Clock for the serial (say RXC (output of FPGA))
output is divided by 16 clock of the master clock (say clk16x(input to
the FPGA)). FPGA will change the data on the positive edge of the RXC
and uP will read the data on the negative edge of the RXC.
There were two method I could think of to implement this.
Method 1
------------------------------------------------------
process(RXC,rst)
begin
if (rst = '1') then
OP <= '0';
elsif(RXC = '1' and RXC 'event) then
OP <= IPREG(7);
IPREG = IPREG(6 downto 0) & DATA_I;
end if;
end process;
-----------------------------------------------------
Method 2
-----------------------------------------------------
process(clk16x,rst)
begin
if(rst = '1') then
RXC0 = '0';
RXC1 = '0';
elsif (clk16x = '1' and clk16x 'event) then
RXC0 <= RXC;
RXC1 <= RXC0;
end if;
end process;
process(clk16x,rst)
begin
if (rst = '1') then
OP <= '0';
elsif(clk16x = '1' and clk16x 'event) then
if(RXC0 = '1' and RXC1 '0') then
OP <= IPREG(7);
IPREG = IPREG(6 downto 0) & DATA_I;
end if;
end if;
end process;
---------------------------------------------------------------
I dont have much experience in vhdl but have heard that you should not
use two clocks. that directly suggest use second method. Problem is in
second method ouput data will change two clk16x cycles after the
positve edge of the RXC. First positve edge after clk16x to update
RXC0 and RXC1 and seond edge of clk16x to give actual oupput.
which is the better method? any third one better than both?
RXC is 1.544 MHz
I have a SPARTAN II based design. there is serial output from the FPGA
which a uP will read. Clock for the serial (say RXC (output of FPGA))
output is divided by 16 clock of the master clock (say clk16x(input to
the FPGA)). FPGA will change the data on the positive edge of the RXC
and uP will read the data on the negative edge of the RXC.
There were two method I could think of to implement this.
Method 1
------------------------------------------------------
process(RXC,rst)
begin
if (rst = '1') then
OP <= '0';
elsif(RXC = '1' and RXC 'event) then
OP <= IPREG(7);
IPREG = IPREG(6 downto 0) & DATA_I;
end if;
end process;
-----------------------------------------------------
Method 2
-----------------------------------------------------
process(clk16x,rst)
begin
if(rst = '1') then
RXC0 = '0';
RXC1 = '0';
elsif (clk16x = '1' and clk16x 'event) then
RXC0 <= RXC;
RXC1 <= RXC0;
end if;
end process;
process(clk16x,rst)
begin
if (rst = '1') then
OP <= '0';
elsif(clk16x = '1' and clk16x 'event) then
if(RXC0 = '1' and RXC1 '0') then
OP <= IPREG(7);
IPREG = IPREG(6 downto 0) & DATA_I;
end if;
end if;
end process;
---------------------------------------------------------------
I dont have much experience in vhdl but have heard that you should not
use two clocks. that directly suggest use second method. Problem is in
second method ouput data will change two clk16x cycles after the
positve edge of the RXC. First positve edge after clk16x to update
RXC0 and RXC1 and seond edge of clk16x to give actual oupput.
which is the better method? any third one better than both?
RXC is 1.544 MHz