Go Back   Velocity Reviews > Newsgroups > VHDL
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

Reply

VHDL - manchester encoder

 
Thread Tools Search this Thread
Old 08-07-2003, 04:01 PM   #1
Default manchester encoder


Hello everybody

From a student a got the code below. It is a manchster encoder realized as
moore - finite state machine + testbench. The encoder doesn't detect the
rising edge of the input and detects a logical one as zero. Can anybody
help me? Please!

LIBRARY ieee ;
use ieee.std_logic_1164.all ;
use ieee.std_logic_arith.all ;

ENTITY manchesterE IS
PORT ( clk : in std_logic;
reset : in std_logic;
NRZ : in std_logic;
flag: out std_logic;
z : out std_logic
);
END manchesterE ;

ARCHITECTURE fsm_man OF manchesterE IS
-- Architecture Declarations
TYPE STATE_TYPE IS ( s0,s1,s2,s3 );

-- Declare current and next state signals
SIGNAL current_state : STATE_TYPE ;
SIGNAL next_state : STATE_TYPE ;

BEGIN
--------------------------------------------------------------------------
--
clocked : PROCESS(
clk,
reset
)
-------------------------------------------------------------------------
---
BEGIN
IF (reset = '0') THEN
current_state <= s0;
-- Reset Values
ELSIF (clk'EVENT AND clk = '1') THEN
current_state <= next_state;
-- Default Assignment To Internals

END IF;

END PROCESS clocked;

-------------------------------------------------------------------------
---
nextstate : PROCESS (
current_state,
NRZ
)
-------------------------------------------------------------------------
---
BEGIN
CASE current_state IS
WHEN s0 =>
next_state <= s0;
IF (NRZ = '0') THEN
next_state <= s1;
END IF;
IF (NRZ = '1') THEN
next_state <= s3;
END IF;
WHEN s1 =>
IF (NRZ = '0') THEN
next_state <= s2;
ELSE
next_state <= s1;
END IF;
WHEN s2 =>
next_state <= s2;
IF (NRZ = '0') THEN
next_state <= s1;
END IF;
IF (NRZ = '1') THEN
next_state <= s3;
END IF;
WHEN s3 =>
IF (NRZ = '1') THEN
next_state <= s0;
ELSE
next_state <= s3;
END IF;
WHEN OTHERS =>
next_state <= s0;
END CASE;

END PROCESS nextstate;

-------------------------------------------------------------------------
---
output : PROCESS (
current_state
)
-------------------------------------------------------------------------
---
BEGIN
-- Default Assignment
z <= '0';
-- Default Assignment To Internals

-- Combined Actions
CASE current_state IS
WHEN s0 =>
z <= '1' ;
flag <= '0';
WHEN s1 =>
z <= '0' ;
flag <= '1';
WHEN s2 =>
z <= '1';
flag <= '0';
WHEN s3 =>
z <= '1' ;
flag <= '1';
WHEN OTHERS =>
NULL;
END CASE;

END PROCESS output;

-- Concurrent Statements

END fsm_man;
---------------------------------------------------Testbench
library IEEE;
use ieee.numeric_std.all;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_ARITH.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;

ENTITY tb_manchester IS
END tb_manchester;

ARCHITECTURE verhalten OF tb_manchester IS

COMPONENT manchesterE
PORT( clk : in std_logic;
reset : in std_logic;
NRZ : in std_logic;
flag: out std_logic;
z : out std_logic
);
END COMPONENT;

COMPONENT manchesterD
PORT( clk : IN std_logic;
reset : IN std_logic;
flag : IN std_logic;
z : IN std_logic;
NRZ : OUT std_logic
);
END COMPONENT;


SIGNAL streambit: std_logic;
SIGNAL tb_in: std_logic_vector(11 DOWNTO 0);

SIGNAL tb_clk, tb_reset : std_logic;
SIGNAL tb_out : std_logic;
SIGNAL tb_Z : std_logic;
SIGNAL count : std_logic_vector (7 downto 0);
SIGNAL tb_flag : std_logic;

BEGIN

uut_E : manchesterE
PORT MAP(
clk => tb_clk,
reset => tb_reset,
NRZ => tb_out,
flag => tb_flag,
z => tb_Z
);

uut_D : manchesterD
PORT MAP(
clk => tb_clk,
reset => tb_reset,
--NRZ => tb_out,
flag => tb_flag,
z => tb_Z
);

Shift_Out : process (tb_clk)

begin

if tb_reset = '0' then

tb_in <= "001110101101";
streambit <= '0';
tb_out <= '0';
count <= (others => '0');

else

if tb_clk'event and tb_clk = '1' then

streambit <= tb_in(11) xor tb_in(7);
tb_in( 11 downto 0) <= tb_in( 10 downto 0) & streambit;

if count(0) = '0' then
tb_out <= tb_in(11);
END IF; count <= count + '1';
end if;

end if;
end process Shift_Out;
-- ------------------------------------------
-- Clk Generation
Clk_Gen : process
begin

-- 25 MHZ >> LOW: 20 ns, HIGH: 20 ns
tb_clk <= '0';
wait for 10 ns;

tb_clk <= '1';
wait for 10 ns;

end process Clk_Gen;
-- ------------------------------------------
-- Reset Generation

Reset_Gen : process
begin

tb_reset <= '1';
wait for 5 ns;

tb_reset <= '0';
wait for 13 ns;

tb_reset <= '1';
wait;
end process reset_Gen;
end verhalten;





Ronny Hengst
  Reply With Quote
Old 08-08-2003, 09:04 AM   #2
Ronny Hengst
 
Posts: n/a
Default Re: manchester encoder
The state machine seems to be from

http://www.fpga.com.cn/application/safe_sm_12157.pdf

and I think it is correct. The state machine doesn't detect with the
rising edge of NRZ. But the falling edge is detected.
I hope for help.

Thanks


Ronny Hengst
  Reply With Quote
Old 08-08-2003, 10:23 AM   #3
Jonathan Bromley
 
Posts: n/a
Default Re: manchester encoder
"Ronny Hengst" <> wrote in message
news: om...
> The state machine seems to be from
>
> http://www.fpga.com.cn/application/safe_sm_12157.pdf
>
> and I think it is correct.


It is a correct description of the wrong state machine.
--

Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.





Jonathan Bromley
  Reply With Quote
Old 08-08-2003, 12:41 PM   #4
Ronny Hengst
 
Posts: n/a
Default Re: manchester encoder
> It is a correct description of the wrong state machine.
> --
>
> Jonathan Bromley, Consultant


And the write one is......?




Ronny Hengst
  Reply With Quote
Old 08-08-2003, 02:23 PM   #5
Jonathan Bromley
 
Posts: n/a
Default Re: manchester encoder
"Ronny Hengst" <> wrote in message
news:bh021v$svjpn$...

> > It is a correct description of the wrong state machine.


> And the write one is......?


Any one of the infinite set of state machines that
(a) does not suffer the same error that appears to
exist in the Mentor appnote you quoted;
(b) meets your specification, which so far you have
not vouchsafed to us.
--
Jonathan Bromley, Consultant

DOULOS - Developing Design Know-how
VHDL * Verilog * SystemC * Perl * Tcl/Tk * Verification * Project Services

Doulos Ltd. Church Hatch, 22 Market Place, Ringwood, Hampshire, BH24 1AW, UK
Tel: +44 (0)1425 471223 mail:
Fax: +44 (0)1425 471573 Web: http://www.doulos.com

The contents of this message may contain personal views which
are not the views of Doulos Ltd., unless specifically stated.





Jonathan Bromley
  Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Can Webcam encode to Divx with an Encoder card Dirrectly realtime ? Paul GoodBar DVD Video 0 05-13-2005 06:40 PM
Manchester United Virus Kenny A+ Certification 3 09-07-2004 07:41 PM
Premiere 6.5: PAL to NTSC conversion with Adobe Mpeg encoder 1.2 Jane DVD Video 4 01-10-2004 10:40 AM
mpeg encoder card Johan Wagener DVD Video 1 11-16-2003 07:00 PM
capture card/mpeg2 hardvare encoder Giuliano DVD Video 0 09-24-2003 12:05 PM




SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46