| Author |
Message |
rakesh_aadhimoolam
Joined: 14 Mar 2006 Posts: 218 Helped: 16
|
14 Jul 2006 9:58 BIT STUFFING........ |
|
|
|
|
HELLO EVERYONE.............
i was doing a program on "bit stuffing"....
the q is "Design a bit stuffer. The circuit takes serial data in and gives serial data out. If in the input stream five consecutive 1’s or 0’s are detected than a ‘0’ or a ‘1’ is inserted in the stream respectively"
i tried to do the following program but though bit stuffing is processed but for
the next bits that are entered the re a bit loss..
how can i rectify it?
LIBRARY ieee;
USE ieee.std_logic_1164.ALL;
ENTITY BitStuffer IS
PORT
( serial_in :IN std_logic;
rst,clk :IN std_logic;
serial_out :IN std_logic;
);
END BitStuffer;
ARCHITECTURE arch OF Bitstuffer IS
begin
process(clk,rst,serial_in)
variable temp1 : std_logic(4 downto 0);
variable stuffbit:std_logic;
variable count:integer range 0 to 4;
begin
if(rst='1') then
temp:='0';
serial_out<='0';
count:=0;
elsif(clk'event and clk='1') then
case serial_in is
when 1=>
for i in 0 to 4 loop
temp(i):=temp(i+1);
temp(4):=serial_in;
count:=count+1;
if(count=5) then
stuffbit:='0';
else
count:='0';
end loop;
when 0=>
for i in 0 to 4 loop
temp(i):=temp(i+1);
temp(4):=serial_in;
count:=count+1;
if(count=5) then
stuffbit:='1';
else
count:='0';
end loop;
thank you.............
|
|
| Back to top |
|
 |
tkbits
Joined: 04 Dec 2004 Posts: 235 Helped: 36
|
16 Jul 2006 10:06 Re: BIT STUFFING........ |
|
|
|
|
You will lose bits if you don't control the shifting (external to BitStuffer) of serial_in. You need to stall the serial_in bit stream in order to provide the time to insert each one of the stuffing bits.
Last edited by tkbits on 17 Jul 2006 4:03; edited 4 times in total |
|
| Back to top |
|
 |
Google AdSense

|
16 Jul 2006 10:06 Ads |
|
|
|
|
|
|
| Back to top |
|
 |
bansalr
Joined: 22 Dec 2005 Posts: 158 Helped: 13
|
17 Jul 2006 3:08 Re: BIT STUFFING........ |
|
|
|
|
| Use the pipeling method to avoid loss of data. Register the input so that u will have one data in the storage and one data on the line.
|
|
| Back to top |
|
 |