<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title></title>
	<atom:link href="http://blog.ektel.com.np/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.ektel.com.np</link>
	<description>ektel communication system</description>
	<lastBuildDate>Sat, 21 Apr 2012 09:52:50 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Telecommunication Entropy</title>
		<link>http://blog.ektel.com.np/2012/04/telecommunication-entropy/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=telecommunication-entropy</link>
		<comments>http://blog.ektel.com.np/2012/04/telecommunication-entropy/#comments</comments>
		<pubDate>Sat, 21 Apr 2012 05:54:18 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Categoryless Articles Collection]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=375</guid>
		<description><![CDATA[Telecommunication Entropy can be regarded as the fundamental unit of information that is being transferred, received and/or stored with the passage of time. The information being transferred or received as electromagnetic waves having both wave and particle and stored in electronic circuits as charges by virtual of transistor capacitor or gate capacitance such as RAM and ROM devices. There is also flow of the stored charges on the huge number of transistors and gates and it is being conceived by us as data flow between the electronic circuits. Such signal manipulation is done and studied under DSP(Digital Signal Processing) which involves their analysis and research. Entropy itself is probabilistic in nature. Self information is measure of occurrence of the quantized amplitude during quantization process. Say an amplitude of 4Volt occurred 3 times(frequency) then the self information would be log(1/3) in base 1o. Mutual Entropy is the total aggregated self information of the  possible sample space of any number of samples taken randomly from the information source. The information source is transducers such as antenna that captures frequency of electromagnetic waves when incident on it and converts that energy of the wave to equivalent proportional voltage signal. This voltage signal is quantized, source encoded, channel encoded and modulated before sending them out again out to the air or space.]]></description>
			<content:encoded><![CDATA[<p>Telecommunication Entropy can be regarded as the fundamental unit of information that is being transferred, received and/or stored with the passage of time. The information being transferred or received as electromagnetic waves having both wave and particle and stored in electronic circuits as charges by virtual of transistor capacitor or gate capacitance such as RAM and ROM devices. There is also flow of the stored charges on the huge number of transistors and gates and it is being conceived by us as data flow between the electronic circuits. Such signal manipulation is done and studied under DSP(Digital Signal Processing) which involves their analysis and research.</p>
<p>Entropy itself is probabilistic in nature. Self information is measure of occurrence of the quantized amplitude during quantization process. Say an amplitude of 4Volt occurred 3 times(frequency) then the self information would be log(1/3) in base 1o. Mutual Entropy is the total aggregated self information of the  possible sample space of any number of samples taken randomly from the information source. The information source is transducers such as antenna that captures frequency of electromagnetic waves when incident on it and converts that energy of the wave to equivalent proportional voltage signal. This voltage signal is quantized, source encoded, channel encoded and modulated before sending them out again out to the air or space.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/04/telecommunication-entropy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Huffman encoder decoder VLSI design Systematic Block Diagram</title>
		<link>http://blog.ektel.com.np/2012/04/huffman-encoder-decoder-vlsi-design-systematic-block-diagram/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=huffman-encoder-decoder-vlsi-design-systematic-block-diagram</link>
		<comments>http://blog.ektel.com.np/2012/04/huffman-encoder-decoder-vlsi-design-systematic-block-diagram/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 02:51:59 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Categoryless Articles Collection]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=347</guid>
		<description><![CDATA[Note: Click the picture below to understand clearly The picture below shows the huffman encoder decoder vlsi design systematic block diagram using the verilog HDL or VHDL codes and implemented on Xilinx ISE software. About the picture: This is a block diagram showing Huffman Encoder/ Decoder VLSI implemented block diagram. Huffman encoders decoders are source encoder decoder that are widely used in image and video compression. The circuit above has gates within it (shown below) that actually performs Huffman algorithm calculation and is based on concept of compactization of bits to lower the entropy without any actual loss of bits. Compactization of bits means compression. Say 10 bits/symbol is the initial entropy of image or a frame of video signal. The signal content of these(image,video frame) is spread out in space in such a way that most of real content of image that we require(for distinguishing objects) occupies less space than the space of the captured image or video frame. This is because units of signals in time does not does not seem to occur or born out in a random manner but in some deterministic manner since some units occur frequently and some unit occur less frequently, that is , probabilistic nature. In other words, if you had only the signal information(frequency spectrum) of the real content then you could store, transmit and upon unfolding the real content you would see the exact image or video signal. There is no loss of information just compactization of units based on probabilistic nature of occurrence of information units. Hence, it is known as Lossless compression and related to the Shanon Paper on Entropy and Source coding.  Hence source encoding means the reduce the redundancy(Captured space - Compacted Captured Space) contained with the captured space of image or video frame. Hence, source encoding is also known as removing redundancy in direct correspondence to channel encoding which is also known as adding redundancy. Meaning first, reduce(compress) redundant signal content at the source encoder and second add redundant signal content to the output from source encoder. &#160; Gate Level: The picture below shows the gate level of the same chip level block diagram above. Shown in the pictures are logic units and functional components(adder, subtractor, multiplexers, shifters, counters etc), input and output ports and interconnection between all the elements that makes up the VLSI huffman encoder, decoder. This is from Xilinx software. You can read more below: Free Download of Xilinx ISE software VLSI Implementation of Huffman algorithm based source encoder using Xilinx software Verilog and VHDL codes for Huffman based source encoder &#160;]]></description>
			<content:encoded><![CDATA[<p>Note: Click the picture below to understand clearly</p>
<p>The picture below shows the huffman encoder decoder vlsi design systematic block diagram using the verilog HDL or VHDL codes and implemented on Xilinx ISE software.</p>
<p>About the picture:</p>
<p>This is a block diagram showing Huffman Encoder/ Decoder VLSI implemented block diagram. Huffman encoders decoders are source encoder decoder that are widely used in image and video compression. The circuit above has gates within it (shown below) that actually performs Huffman algorithm calculation and is based on concept of compactization of bits to lower the entropy without any actual loss of bits. Compactization of bits means compression. Say 10 bits/symbol is the initial entropy of image or a frame of video signal. The signal content of these(image,video frame) is spread out in space in such a way that most of real content of image that we require(for distinguishing objects) occupies less space than the space of the captured image or video frame. This is because units of signals in time does not does not seem to occur or born out in a random manner but in some deterministic manner since some units occur frequently and some unit occur less frequently, that is , probabilistic nature. In other words, if you had only the signal information(frequency spectrum) of the real content then you could store, transmit and upon unfolding the real content you would see the exact image or video signal. There is no loss of information just compactization of units based on probabilistic nature of occurrence of information units. Hence, it is known as Lossless compression and related to the Shanon Paper on Entropy and Source coding.  Hence source encoding means the reduce the redundancy(Captured space - Compacted Captured Space) contained with the captured space of image or video frame. Hence, source encoding is also known as removing redundancy in direct correspondence to channel encoding which is also known as adding redundancy. Meaning first, reduce(compress) redundant signal content at the source encoder and second add redundant signal content to the output from source encoder.</p>
<div id="attachment_348" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/04/huffman-systematic-VHDL-block-diagram.png"><img class="size-medium wp-image-348" title="Huffman systematic VHDL block diagram" src="http://blog.ektel.com.np/wp-content/uploads/2012/04/huffman-systematic-VHDL-block-diagram-300x168.png" alt="Huffman systematic VHDL block diagram" width="300" height="168" /></a><p class="wp-caption-text">Fig: Huffman systematic VHDL block diagram</p></div>
<p>&nbsp;</p>
<p>Gate Level:</p>
<p>The picture below shows the gate level of the same chip level block diagram above. Shown in the pictures are logic units and functional components(adder, subtractor, multiplexers, shifters, counters etc), input and output ports and interconnection between all the elements that makes up the VLSI huffman encoder, decoder. This is from Xilinx software.</p>
<div id="attachment_351" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/04/huffman-encoder-gate-level-diagram.png"><img class="size-medium wp-image-351" title="Huffman encoder gate level diagram" src="http://blog.ektel.com.np/wp-content/uploads/2012/04/huffman-encoder-gate-level-diagram-300x168.png" alt="Huffman encoder gate level diagram" width="300" height="168" /></a><p class="wp-caption-text">Fig: Huffman encoder gate level diagram</p></div>
<div id="attachment_352" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/04/source-encoder-gate-level-diagram.png"><img class="size-medium wp-image-352" title="Source encoder gate level diagram" src="http://blog.ektel.com.np/wp-content/uploads/2012/04/source-encoder-gate-level-diagram-300x168.png" alt="Source encoder gate level diagram" width="300" height="168" /></a><p class="wp-caption-text">Fig: Source encoder gate level diagram</p></div>
<div id="attachment_354" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/04/huffman-compression-gate-level-diagram.png"><img class="size-medium wp-image-354" title="Huffman compression gate level diagram" src="http://blog.ektel.com.np/wp-content/uploads/2012/04/huffman-compression-gate-level-diagram-300x168.png" alt="Huffman compression gate level diagram" width="300" height="168" /></a><p class="wp-caption-text">Fig: Huffman compression gate level diagram</p></div>
<div id="attachment_355" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/04/vlsi-design-gate-level-diagram.png"><img class="size-medium wp-image-355" title="VLSI design gate level diagram" src="http://blog.ektel.com.np/wp-content/uploads/2012/04/vlsi-design-gate-level-diagram-300x168.png" alt="VLSI design gate level diagram" width="300" height="168" /></a><p class="wp-caption-text">Fig: VLSI design gate level diagram</p></div>
<p>You can read more below:</p>
<ul style="list-style-type: square;">
<li><a title="Dowload Xilinx EDA software for free" href="http://blog.ektel.com.np/2012/04/dowload-xilinx-eda-software-for-free/" target="_blank">Free Download of Xilinx ISE software</a></li>
<li><a title="VLSI Architecture and Design for MPEG Encoder Decoder" href="http://blog.ektel.com.np/2012/03/vlsi-architecture-and-design-for-mpeg-encoder-decoder/" target="_blank">VLSI Implementation of Huffman algorithm based source encoder using Xilinx software</a></li>
<li><a title="Huffman Encoder Verilog HDL code" href="http://blog.ektel.com.np/2012/04/huffman-encoder-verilog-hdl-code/" target="_blank">Verilog</a> and <a title="Huffman Encoder VHDL code" href="http://blog.ektel.com.np/2012/04/huffman-encoder-vhdl-code/" target="_blank">VHDL codes for Huffman based source encoder</a></li>
</ul>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/04/huffman-encoder-decoder-vlsi-design-systematic-block-diagram/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Huffman Encoder VHDL code</title>
		<link>http://blog.ektel.com.np/2012/04/huffman-encoder-vhdl-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=huffman-encoder-vhdl-code</link>
		<comments>http://blog.ektel.com.np/2012/04/huffman-encoder-vhdl-code/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 01:48:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Categoryless Articles Collection]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=344</guid>
		<description><![CDATA[Huffman Encoder VHDL code, vlsi implementation of source encoder and decoder, zigzag scanning, xilinx, fpga, huffman algorithm, compression, mpeg encoder, variable length encoding, ]]></description>
			<content:encoded><![CDATA[<p>library IEEE;<br />
use IEEE.std_logic_1164.all;<br />
use IEEE.std_logic_arith.all;<br />
use IEEE.std_logic_unsigned.all;<br />
use IEEE.numeric_std.all;</p>
<p>ENTITY huffman_en IS<br />
PORT (<br />
CLK                     : IN std_logic;<br />
RST                     : IN std_logic;<br />
rdy_in                  : IN std_logic;<br />
rl_in                   : IN std_logic_vector(17 DOWNTO 0);<br />
dc_in                   : IN std_logic_vector(11 DOWNTO 0);<br />
scan_type               : IN std_logic;<br />
luma                    : IN std_logic;<br />
huffman_out             : OUT std_logic_vector(15 DOWNTO 0);<br />
eob                     : IN std_logic;<br />
rdy_out                 : OUT std_logic);<br />
END huffman_en;</p>
<p>ARCHITECTURE translated OF huffman_en IS</p>
<p>-- signals<br />
SIGNAL cntr64                   :  std_logic_vector(6 DOWNTO 0);<br />
SIGNAL cl_sum_rdy               :  std_logic;<br />
SIGNAL size                     :  std_logic_vector(3 DOWNTO 0);<br />
SIGNAL cl_sum                   :  std_logic_vector(5 DOWNTO 0);<br />
SIGNAL cl_sum_prev              :  std_logic_vector(5 DOWNTO 0);<br />
SIGNAL codelength_dc            :  std_logic_vector(3 DOWNTO 0);<br />
SIGNAL codelength_ac            :  std_logic_vector(4 DOWNTO 0);<br />
SIGNAL codelength1              :  std_logic_vector(4 DOWNTO 0);<br />
SIGNAL codelength2              :  std_logic_vector(4 DOWNTO 0);<br />
SIGNAL codelength_ac1           :  std_logic_vector(4 DOWNTO 0);<br />
SIGNAL vlcode_dc                :  std_logic_vector(9 DOWNTO 0);<br />
SIGNAL vlcode1                  :  std_logic_vector(17 DOWNTO 0);<br />
SIGNAL vlcode2                  :  std_logic_vector(17 DOWNTO 0);<br />
SIGNAL vlcode3                  :  std_logic_vector(17 DOWNTO 0);<br />
SIGNAL vlcode4                  :  std_logic_vector(17 DOWNTO 0);<br />
SIGNAL vlcode_ac1               :  std_logic_vector(17 DOWNTO 0);<br />
SIGNAL vlcode_ac                :  std_logic_vector(17 DOWNTO 0);<br />
SIGNAL cl_sum_shift             :  std_logic_vector(38 DOWNTO 0);<br />
SIGNAL full_flag1               :  std_logic;<br />
SIGNAL half_flag1               :  std_logic;<br />
SIGNAL half_flag2               :  std_logic;<br />
SIGNAL full_flag2               :  std_logic;<br />
SIGNAL half_flag3               :  std_logic;<br />
SIGNAL full_flag3               :  std_logic;<br />
SIGNAL full_flag4               :  std_logic;<br />
SIGNAL half_flag4               :  std_logic;<br />
SIGNAL full_flag5               :  std_logic;<br />
SIGNAL full_flag6               :  std_logic;<br />
SIGNAL half_flag5               :  std_logic;<br />
SIGNAL mult_out                 :  std_logic_vector(38 DOWNTO 0);<br />
SIGNAL mult_out_int                 :  std_logic_vector(56 DOWNTO 0);<br />
SIGNAL upper_reg1               :  std_logic_vector(16 DOWNTO 1);<br />
SIGNAL middle_reg1              :  std_logic_vector(16 DOWNTO 1);<br />
SIGNAL lower_reg1               :  std_logic_vector(16 DOWNTO 1);<br />
SIGNAL upper_reg2               :  std_logic_vector(16 DOWNTO 1);<br />
SIGNAL middle_reg2              :  std_logic_vector(16 DOWNTO 1);<br />
SIGNAL middle_reg3              :  std_logic_vector(16 DOWNTO 1);</p>
<p>SIGNAL temp4,temp5              :  std_logic_vector(11 DOWNTO 0);<br />
SIGNAL temp6,temp7              :  std_logic_vector(11 DOWNTO 0);<br />
SIGNAL temp8,temp9              :  std_logic_vector(11 DOWNTO 0);<br />
SIGNAL temp10                   :  std_logic_vector(17 DOWNTO 0);<br />
SIGNAL temp11                   :  std_logic_vector(1 DOWNTO 0);</p>
<p>BEGIN</p>
<p>--***************************************************************************<br />
-- Find the size for the "Differential_DC" value. The differential_dc_size gives the number of<br />
--  Find the size for the "Differential_DC" value. The differential_dc_size gives the number of<br />
-- bits to be used to denote the DC_difference value. ram_dc_diff . Table 1 in document</p>
<p>--   PROCESS (CLK)<br />
--   BEGIN<br />
--      IF (CLK'EVENT AND CLK = '1') THEN<br />
--         CASE dc_in IS<br />
--         WHEN "111111111111" =&gt; size &lt;= "0001";<br />
--         WHEN "11111111110-" =&gt; size &lt;= "0010";<br />
--         WHEN "1111111110--" =&gt; size &lt;= "0011";<br />
--         WHEN "111111110---" =&gt; size &lt;= "0100";<br />
--         WHEN "11111110----" =&gt; size &lt;= "0101";<br />
--         WHEN "1111110-----" =&gt; size &lt;= "0110";<br />
--         WHEN "111110------" =&gt; size &lt;= "0111";<br />
--         WHEN "11110-------" =&gt; size &lt;= "1000";<br />
--         WHEN "1110--------" =&gt; size &lt;= "1001";<br />
--         WHEN "110---------" =&gt; size &lt;= "1010";<br />
--         WHEN "10----------" =&gt; size &lt;= "1011";<br />
--         WHEN "000000000000" =&gt; size &lt;= "0000";<br />
--         WHEN "000000000001" =&gt; size &lt;= "0001";<br />
--         WHEN "00000000001-" =&gt; size &lt;= "0010";<br />
--         WHEN "0000000001--" =&gt; size &lt;= "0011";<br />
--         WHEN "000000001---" =&gt; size &lt;= "0100";<br />
--         WHEN "00000001----" =&gt; size &lt;= "0101";<br />
--         WHEN "0000001-----" =&gt; size &lt;= "0110";<br />
--         WHEN "000001------" =&gt; size &lt;= "0111";<br />
--         WHEN "00001-------" =&gt; size &lt;= "1000";<br />
--         WHEN "0001--------" =&gt; size &lt;= "1001";<br />
--         WHEN "001---------" =&gt; size &lt;= "1010";<br />
--         WHEN "01----------" =&gt; size &lt;= "1011";<br />
--         WHEN OTHERS =&gt; size &lt;= "0000";<br />
--         END CASE;<br />
--      END IF;<br />
--   END PROCESS;</p>
<p>PROCESS (CLK)<br />
VARIABLE size_temp  : std_logic_vector(3 DOWNTO 0);<br />
BEGIN<br />
IF (CLK'EVENT AND CLK = '1') THEN<br />
IF (std_match(dc_in, "111111111111")) THEN<br />
size_temp := "0001";<br />
ELSIF (std_match(dc_in, "11111111110-")) THEN<br />
size_temp := "0010";<br />
ELSIF (std_match(dc_in, "1111111110--")) THEN<br />
size_temp := "0011";<br />
ELSIF (std_match(dc_in, "111111110---")) THEN<br />
size_temp := "0100";<br />
ELSIF (std_match(dc_in, "11111110----")) THEN<br />
size_temp := "0101";<br />
ELSIF (std_match(dc_in, "1111110-----")) THEN<br />
size_temp := "0110";<br />
ELSIF (std_match(dc_in, "111110------")) THEN<br />
size_temp := "0111";<br />
ELSIF (std_match(dc_in, "11110-------")) THEN<br />
size_temp := "1000";<br />
ELSIF (std_match(dc_in, "1110--------")) THEN<br />
size_temp := "1001";<br />
ELSIF (std_match(dc_in, "110---------")) THEN<br />
size_temp := "1010";<br />
ELSIF (std_match(dc_in, "10----------")) THEN<br />
size_temp := "1011";<br />
ELSIF (std_match(dc_in, "000000000000")) THEN<br />
size_temp := "0000";<br />
ELSIF (std_match(dc_in, "000000000001")) THEN<br />
size_temp := "0001";<br />
ELSIF (std_match(dc_in, "00000000001-")) THEN<br />
size_temp := "0010";<br />
ELSIF (std_match(dc_in, "0000000001--")) THEN<br />
size_temp := "0011";<br />
ELSIF (std_match(dc_in, "000000001---")) THEN<br />
size_temp := "0100";<br />
ELSIF (std_match(dc_in, "00000001----")) THEN<br />
size_temp := "0101";<br />
ELSIF (std_match(dc_in, "0000001-----")) THEN<br />
size_temp := "0110";<br />
ELSIF (std_match(dc_in, "000001------")) THEN<br />
size_temp := "0111";<br />
ELSIF (std_match(dc_in, "00001-------")) THEN<br />
size_temp := "1000";<br />
ELSIF (std_match(dc_in, "0001--------")) THEN<br />
size_temp := "1001";<br />
ELSIF (std_match(dc_in, "001---------")) THEN<br />
size_temp := "1010";<br />
ELSIF (std_match(dc_in, "01----------")) THEN<br />
size_temp := "1011";<br />
ELSE<br />
size_temp := "0000";</p>
<p>END IF;<br />
END IF;<br />
size &lt;= size_temp;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- variable length code and the corresponding code length for DC_Differential<br />
-- After finding the size of the DC_Differential, the variable length code used to denote it is found.<br />
--  After finding the size of the DC_Differential, the variable length code used to denote it is found.<br />
-- For example, if the size is 10, 10 bits are used to denote the dc_differential value and a variable<br />
-- length code prefix of "111111110" is used along with the 10 bit value.</p>
<p>-- luma = 1'b1 denotes a luminance block and lume = 1'b0 denotes a chrominance block<br />
PROCESS (CLK)<br />
BEGIN<br />
IF (CLK'EVENT AND CLK = '1') THEN<br />
IF (RST = '1') THEN<br />
vlcode_dc &lt;= "0000000000";<br />
codelength_dc &lt;= "0000";<br />
ELSE<br />
IF (cntr64 = "0000001") THEN<br />
CASE luma IS<br />
WHEN '1' =&gt;<br />
CASE size IS --ram_dc_size1<br />
WHEN "0000" =&gt; vlcode_dc &lt;= "0000000100"; codelength_dc &lt;= "0011";<br />
WHEN "0001" =&gt; vlcode_dc &lt;= "0000000000"; codelength_dc &lt;= "0010";<br />
WHEN "0010" =&gt; vlcode_dc &lt;= "0000000001"; codelength_dc &lt;= "0010";<br />
WHEN "0011" =&gt; vlcode_dc &lt;= "0000000101"; codelength_dc &lt;= "0011";<br />
WHEN "0100" =&gt; vlcode_dc &lt;= "0000000110"; codelength_dc &lt;= "0011";<br />
WHEN "0101" =&gt; vlcode_dc &lt;= "0000001110"; codelength_dc &lt;= "0100";<br />
WHEN "0110" =&gt; vlcode_dc &lt;= "0000011110"; codelength_dc &lt;= "0101";<br />
WHEN "0111" =&gt; vlcode_dc &lt;= "0000111110"; codelength_dc &lt;= "0110";<br />
WHEN "1000" =&gt; vlcode_dc &lt;= "0001111110"; codelength_dc &lt;= "0111";<br />
WHEN "1001" =&gt; vlcode_dc &lt;= "0011111110"; codelength_dc &lt;= "1000";<br />
WHEN "1010" =&gt; vlcode_dc &lt;= "0111111110"; codelength_dc &lt;= "1001";<br />
WHEN "1011" =&gt; vlcode_dc &lt;= "0111111111"; codelength_dc &lt;= "1001";<br />
WHEN OTHERS =&gt; vlcode_dc &lt;= "0000000000"; codelength_dc &lt;= "0000";<br />
END CASE;<br />
WHEN '0' =&gt;<br />
CASE size IS --ram_dc_size2<br />
WHEN "0000" =&gt; vlcode_dc &lt;= "0000000000"; codelength_dc &lt;= "0010";<br />
WHEN "0001" =&gt; vlcode_dc &lt;= "0000000001"; codelength_dc &lt;= "0010";<br />
WHEN "0010" =&gt; vlcode_dc &lt;= "0000000010"; codelength_dc &lt;= "0010";<br />
WHEN "0011" =&gt; vlcode_dc &lt;= "0000000110"; codelength_dc &lt;= "0011";<br />
WHEN "0100" =&gt; vlcode_dc &lt;= "0000001110"; codelength_dc &lt;= "0100";<br />
WHEN "0101" =&gt; vlcode_dc &lt;= "0000011110"; codelength_dc &lt;= "0101";<br />
WHEN "0110" =&gt; vlcode_dc &lt;= "0000111110"; codelength_dc &lt;= "0110";<br />
WHEN "0111" =&gt; vlcode_dc &lt;= "0001111110"; codelength_dc &lt;= "0111";<br />
WHEN "1000" =&gt; vlcode_dc &lt;= "0011111110"; codelength_dc &lt;= "1000";<br />
WHEN "1001" =&gt; vlcode_dc &lt;= "0111111110"; codelength_dc &lt;= "1001";<br />
WHEN "1010" =&gt; vlcode_dc &lt;= "1111111110"; codelength_dc &lt;= "1010";<br />
WHEN "1011" =&gt; vlcode_dc &lt;= "1111111111"; codelength_dc &lt;= "1010";<br />
WHEN OTHERS =&gt; vlcode_dc &lt;= "0000000000"; codelength_dc &lt;= "0000";<br />
END CASE;<br />
WHEN OTHERS =&gt; NULL;<br />
END CASE;<br />
END IF;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- variable length code and corresponding code length for AC coefficients.<br />
--  variable length code and corresponding code length for AC coefficients.<br />
--    Table zero is used for intra blocks anf table one is used for non-intra<br />
--    blocks.  For a run/level pair not defined in table zero or one, an escape<br />
--    code followed by a 6 bit run symbol and 12 bit level is used.</p>
<p>--assign run_level_pair &lt;= {run_in,level_in};</p>
<p>--always @ (posedge CLK)<br />
-- always @ (posedge CLK)<br />
-- begin<br />
--   if (RST)<br />
--      begin vlcode_ac1 &lt;= {18'b0}; codelength_ac1 &lt;= 5'd0; end<br />
--   else<br />
-- begin if (rdy_in == 1'b1)<br />
-- begin<br />
-- case(rl_in)<br />
--         18'b000000000000000001:<br />
--            begin  vlcode_ac1 &lt;= {17'b00000000000001010,rl_in[11]}; codelength_ac1 &lt;= 5'd5; end<br />
--         18'b000000000000000101:<br />
--            begin  vlcode_ac1 &lt;= {17'b00000000000000111,rl_in[11]}; codelength_ac1 &lt;= 5'd4; end<br />
--         18'b000000000000001010:<br />
--            begin  vlcode_ac1 &lt;= {17'b00000000000001110,rl_in[11]}; codelength_ac1 &lt;= 5'd5; end<br />
--         18'b000001000000000101:<br />
--            begin  vlcode_ac1 &lt;= {18'b111100001111001101}; codelength_ac1 &lt;= 5'd18; end<br />
--         18'b000011000000000111:<br />
--            begin  vlcode_ac1 &lt;= {17'b00000000000010111,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
--       18'b000111000000001001:<br />
--            begin  vlcode_ac1 &lt;= {17'b00000000000000000,rl_in[11]}; codelength_ac1 &lt;= 5'd5; end<br />
--       18'b010000000000010000:<br />
--            begin  vlcode_ac1 &lt;= {17'b10000000000010110,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
--       18'b010101000000001001:<br />
--            begin  vlcode_ac1 &lt;= {17'b00000000000010110,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
--     default:<br />
--            begin  vlcode_ac1 &lt;= {18'b111111111111111111}; codelength_ac1 &lt;= 5'd18; end<br />
-- endcase<br />
-- end<br />
-- end<br />
-- end</p>
<p>--***************************************************************************</p>
<p>temp4 &lt;= '0' &amp; rl_in(10 DOWNTO 0);<br />
temp5 &lt;= '0' &amp; rl_in(10 DOWNTO 0);<br />
temp6 &lt;= '0' &amp; rl_in(10 DOWNTO 0);<br />
temp7 &lt;= '0' &amp; rl_in(10 DOWNTO 0);<br />
temp8 &lt;= '0' &amp; rl_in(10 DOWNTO 0);<br />
temp9 &lt;= '0' &amp; rl_in(10 DOWNTO 0);<br />
temp10 &lt;= scan_type &amp; rl_in(17 DOWNTO 12) &amp;  rl_in(10 DOWNTO 0);<br />
temp11 &lt;= full_flag4 &amp; half_flag4;</p>
<p>PROCESS (CLK)<br />
BEGIN<br />
IF (CLK'EVENT AND CLK = '1') THEN<br />
IF (RST = '1') THEN<br />
vlcode_ac1 &lt;= "000000000000000000"; codelength_ac1 &lt;= "00000";<br />
ELSE<br />
IF (eob = '1' AND scan_type = '1') THEN<br />
vlcode_ac1 &lt;= "000000000000000010"; -- NOTE 2<br />
codelength_ac1 &lt;= "00010";   -- NOTE 2<br />
ELSE<br />
IF (eob = '1' AND scan_type = '0') THEN<br />
vlcode_ac1 &lt;= "000000000000000110";<br />
codelength_ac1 &lt;= "00100";   -- NOTE 2<br />
ELSE<br />
IF (cntr64 = "0000001" AND (rl_in(17 DOWNTO 12) &amp;<br />
rl_in(10 DOWNTO 0)) = "00000000000000001") THEN<br />
vlcode_ac1 &lt;= "00000000000000001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00010"; -- note3, DC coeff<br />
ELSE<br />
--******************* scan type = x, run = x, level = 1 *******<br />
CASE temp10 IS<br />
WHEN 'X' &amp; "XXXXXX" &amp;"00000000001"  =&gt;   -- level = 1<br />
CASE rl_in(17 DOWNTO 12) IS --run<br />
WHEN "010001" =&gt; --17<br />
vlcode_ac1 &lt;= "00000000000011111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "010010" =&gt; --18<br />
vlcode_ac1 &lt;= "00000000000011010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "010011" =&gt; --19<br />
vlcode_ac1 &lt;= "00000000000011001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "010100" =&gt; --20<br />
vlcode_ac1 &lt;= "00000000000010111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "010101" =&gt; --21<br />
vlcode_ac1 &lt;= "00000000000010110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "010110" =&gt; --22<br />
vlcode_ac1 &lt;= "00000000000011111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "010111" =&gt; --23<br />
vlcode_ac1 &lt;= "00000000000011110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "011000" =&gt; --24<br />
vlcode_ac1 &lt;="00000000000011101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "011001" =&gt; --25<br />
vlcode_ac1 &lt;= "00000000000011100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "011010" =&gt; --26<br />
vlcode_ac1 &lt;= "00000000000011011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "011011" =&gt; --27<br />
vlcode_ac1 &lt;= "00000000000011111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "011100" =&gt; --28<br />
vlcode_ac1 &lt;= "00000000000011110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "011101" =&gt; --29<br />
vlcode_ac1 &lt;= "00000000000011101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "011110" =&gt; --30<br />
vlcode_ac1 &lt;= "00000000000011100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "011111" =&gt; --31<br />
vlcode_ac1 &lt;= "00000000000011011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN OTHERS =&gt;NULL;<br />
END CASE;<br />
WHEN 'X' &amp; "XXXXXX" &amp; "00000000010" =&gt; --level = 2<br />
CASE rl_in(17 DOWNTO 12) IS --(run)<br />
WHEN "000110" =&gt; --6<br />
vlcode_ac1 &lt;= "00000000000011110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "000111" =&gt; --7<br />
vlcode_ac1 &lt;= "00000000000010101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "001000" =&gt; --8<br />
vlcode_ac1 &lt;= "00000000000010001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "001001" =&gt; --9<br />
vlcode_ac1 &lt;= "00000000000010001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "001010" =&gt; --10<br />
vlcode_ac1 &lt;= "00000000000010000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "001011" =&gt; --11<br />
vlcode_ac1 &lt;= "00000000000011010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "001100" =&gt; --12<br />
vlcode_ac1 &lt;= "00000000000011001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "001101" =&gt; --13<br />
vlcode_ac1 &lt;= "00000000000011000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "001110" =&gt; --14<br />
vlcode_ac1 &lt;= "00000000000010111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "001111" =&gt; --15<br />
vlcode_ac1 &lt;= "00000000000010110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "010000" =&gt; --16<br />
vlcode_ac1 &lt;= "00000000000010101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN OTHERS =&gt; NULL;<br />
END CASE;<br />
WHEN 'X' &amp; "XXXXXX" &amp; "00000000011" =&gt; --level = 3<br />
CASE rl_in(17 DOWNTO 12) IS --(run)<br />
WHEN "000011" =&gt; --3<br />
vlcode_ac1 &lt;= "00000000000011100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "000100" =&gt; --4<br />
vlcode_ac1 &lt;= "00000000000010010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "000101" =&gt; --5<br />
vlcode_ac1 &lt;= "00000000000010010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "000110" =&gt; --6<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN OTHERS =&gt; NULL;<br />
END CASE;<br />
WHEN 'X' &amp; "000000" &amp; "XXXXXXXXXXX" =&gt;  --run = 0<br />
CASE temp4 IS --(level)<br />
WHEN "000000010000" =&gt; --16<br />
vlcode_ac1 &lt;= "00000000000011111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000010001" =&gt; --17<br />
vlcode_ac1 &lt;= "00000000000011110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000010010" =&gt; --18<br />
vlcode_ac1 &lt;= "00000000000011101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000010011" =&gt; --19<br />
vlcode_ac1 &lt;= "00000000000011100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000010100" =&gt; --20<br />
vlcode_ac1 &lt;= "00000000000011011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000010101" =&gt; --21<br />
vlcode_ac1 &lt;= "00000000000011010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000010110" =&gt; --22<br />
vlcode_ac1 &lt;= "00000000000011001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000010111" =&gt; --23<br />
vlcode_ac1 &lt;= "00000000000011000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000011000" =&gt; --24<br />
vlcode_ac1 &lt;= "00000000000010111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000011001" =&gt; --25<br />
vlcode_ac1 &lt;= "00000000000010110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000011010" =&gt; --26<br />
vlcode_ac1 &lt;= "00000000000010101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000011011" =&gt; --27<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000011100" =&gt; --28<br />
vlcode_ac1 &lt;= "00000000000010011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000011101" =&gt; --29<br />
vlcode_ac1 &lt;= "00000000000010010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000011110" =&gt; --30<br />
vlcode_ac1 &lt;= "00000000000010001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000011111" =&gt; --31<br />
vlcode_ac1 &lt;= "00000000000010000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01111";<br />
WHEN "000000100000" =&gt; --32<br />
vlcode_ac1 &lt;= "00000000000011000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000100001" =&gt; --33<br />
vlcode_ac1 &lt;= "00000000000010111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000100010" =&gt; --34<br />
vlcode_ac1 &lt;= "00000000000010110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000100011" =&gt; --35<br />
vlcode_ac1 &lt;= "00000000000010101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000100100" =&gt; --36<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000100101" =&gt; --37<br />
vlcode_ac1 &lt;= "00000000000010011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000100110" =&gt; --38<br />
vlcode_ac1 &lt;= "00000000000010010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000100111" =&gt; --39<br />
vlcode_ac1 &lt;= "00000000000010001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000101000" =&gt; --40<br />
vlcode_ac1 &lt;= "00000000000010000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN OTHERS =&gt; NULL;<br />
END CASE;<br />
WHEN 'X' &amp; "000001" &amp;  "XXXXXXXXXXX" =&gt; -- run = 1<br />
CASE temp5 IS --(level)<br />
WHEN "000000000110" =&gt; --6<br />
vlcode_ac1 &lt;= "00000000000010110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "000000000111" =&gt; --7<br />
vlcode_ac1 &lt;= "00000000000010101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "000000001000" =&gt; --8<br />
vlcode_ac1 &lt;= "00000000000011111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000001001" =&gt; --9<br />
vlcode_ac1 &lt;= "00000000000011110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000001010" =&gt; --10<br />
vlcode_ac1 &lt;= "00000000000011101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000001011" =&gt; --11<br />
vlcode_ac1 &lt;= "00000000000011100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000001100" =&gt; --12<br />
vlcode_ac1 &lt;= "00000000000011011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000001101" =&gt; --13<br />
vlcode_ac1 &lt;= "00000000000011010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000001110" =&gt; --14<br />
vlcode_ac1 &lt;= "00000000000011001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10000";<br />
WHEN "000000001111" =&gt; --15<br />
vlcode_ac1 &lt;= "00000000000010011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "000000010000" =&gt; --16<br />
vlcode_ac1 &lt;= "00000000000010010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "000000010001" =&gt; --17<br />
vlcode_ac1 &lt;= "00000000000010001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN "000000010010" =&gt; --18<br />
vlcode_ac1 &lt;= "00000000000010000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "10001";<br />
WHEN OTHERS =&gt; NULL;<br />
END CASE;<br />
WHEN 'X' &amp; "000010" &amp; "00000000101" =&gt;  -- scan type = x, run = 2, level = 5<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN 'X' &amp; "000011" &amp; "00000000011" =&gt; -- scan type = x, run = 3, level = 4<br />
vlcode_ac1 &lt;= "00000000000010011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN '0' &amp; "XXXXXX" &amp; "00000000001" =&gt;  -- scan type = 0, run = x, level = 1<br />
CASE rl_in(17 DOWNTO 12) IS --(run)<br />
WHEN "000001" =&gt; --1<br />
vlcode_ac1 &lt;= "00000000000000011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00100";<br />
WHEN "000010" =&gt; --2<br />
vlcode_ac1 &lt;= "00000000000000101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00101";<br />
WHEN "000011" =&gt; --3<br />
vlcode_ac1 &lt;= "00000000000000111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00110";<br />
WHEN "000100" =&gt;  --4<br />
vlcode_ac1 &lt;= "00000000000000110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00110";<br />
WHEN "000101" =&gt;  --5<br />
vlcode_ac1 &lt;= "00000000000000111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00111";<br />
WHEN "000110" =&gt; --6<br />
vlcode_ac1 &lt;= "00000000000000101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00111";<br />
WHEN "000111" =&gt;  --7<br />
vlcode_ac1 &lt;= "00000000000000100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00111";<br />
WHEN "001000" =&gt;  --8<br />
vlcode_ac1 &lt;= "00000000000000111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "001001" =&gt; --9<br />
vlcode_ac1 &lt;= "00000000000000101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "001010" =&gt; --10<br />
vlcode_ac1 &lt;= "00000000000100111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "001011" =&gt; --11<br />
vlcode_ac1 &lt;= "00000000000100011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "001100" =&gt; --12<br />
vlcode_ac1 &lt;= "00000000000100010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "001101" =&gt;  --13<br />
vlcode_ac1 &lt;= "00000000000100000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "001110" =&gt; --14<br />
vlcode_ac1 &lt;= "00000000000001110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01011";<br />
WHEN "001111" =&gt; --15<br />
vlcode_ac1 &lt;= "00000000000001101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01011";<br />
WHEN "010000" =&gt; --16<br />
vlcode_ac1 &lt;= "00000000000001000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01011";<br />
WHEN OTHERS =&gt;  NULL;<br />
END CASE;<br />
WHEN '1' &amp; "XXXXXX" &amp; "00000000001" =&gt; -- scan type = 1, run = x, level = 1<br />
CASE rl_in(17 DOWNTO 12) IS --(run)<br />
WHEN "000001" =&gt; --1<br />
vlcode_ac1 &lt;= "00000000000000010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00100";<br />
WHEN "000010" =&gt; --2<br />
vlcode_ac1 &lt;= "00000000000000101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00110";<br />
WHEN "000011" =&gt;  --3<br />
vlcode_ac1 &lt;= "00000000000000111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00110";<br />
WHEN "000100" =&gt;  --4<br />
vlcode_ac1 &lt;= "00000000000000110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00111";<br />
WHEN "000101" =&gt;  --5<br />
vlcode_ac1 &lt;= "00000000000000111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00111";<br />
WHEN "000110" =&gt; --6<br />
vlcode_ac1 &lt;= "00000000000000110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "000111" =&gt; --7<br />
vlcode_ac1 &lt;= "00000000000000100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "001000" =&gt; --8<br />
vlcode_ac1 &lt;= "00000000000000101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "001001" =&gt; --9<br />
vlcode_ac1 &lt;= "00000000001111000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "001010" =&gt; --10<br />
vlcode_ac1 &lt;= "00000000001111010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "001011" =&gt; --11<br />
vlcode_ac1 &lt;= "00000000000100001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "001100" =&gt; --12<br />
vlcode_ac1 &lt;= "00000000000100101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "001101" =&gt; --13<br />
vlcode_ac1 &lt;= "00000000000100100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "001110" =&gt; --14<br />
vlcode_ac1 &lt;= "00000000000000101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01010";<br />
WHEN "001111" =&gt; --15<br />
vlcode_ac1 &lt;= "00000000000000111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01010";<br />
WHEN "010000" =&gt; --16<br />
vlcode_ac1 &lt;= "00000000000001101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01011";<br />
WHEN OTHERS =&gt; NULL;<br />
END CASE;<br />
WHEN '0' &amp; "000000" &amp; "XXXXXXXXXXX" =&gt; -- scan type = 0, run = 0, level = x<br />
CASE temp6 IS --(level)<br />
WHEN "000000000010" =&gt; --2<br />
vlcode_ac1 &lt;= "00000000000000100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00101";<br />
WHEN "000000000011" =&gt; --3<br />
vlcode_ac1 &lt;= "00000000000000101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00110";<br />
WHEN "000000000100" =&gt; --4<br />
vlcode_ac1 &lt;= "00000000000000110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "000000000101" =&gt; --5<br />
vlcode_ac1 &lt;= "00000000000100110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000000110" =&gt; --6<br />
vlcode_ac1 &lt;= "00000000000100001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000000111" =&gt; --7<br />
vlcode_ac1 &lt;= "00000000000001010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01011";<br />
WHEN "000000001000" =&gt; --8<br />
vlcode_ac1 &lt;= "00000000000011101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "000000001001" =&gt; --9<br />
vlcode_ac1 &lt;= "00000000000011000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "000000001010" =&gt; --10<br />
vlcode_ac1 &lt;= "00000000000010011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "000000001011" =&gt; --11<br />
vlcode_ac1 &lt;= "00000000000010000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01101";<br />
WHEN "000000001100" =&gt; --12<br />
vlcode_ac1 &lt;= "00000000000011010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "000000001101" =&gt;  --13<br />
vlcode_ac1 &lt;= "00000000000011001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "000000001110" =&gt; --14<br />
vlcode_ac1 &lt;= "00000000000011000" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN "000000001111" =&gt; --15<br />
vlcode_ac1 &lt;= "00000000000010111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN OTHERS =&gt; NULL;<br />
END CASE;<br />
WHEN '1' &amp; "000000" &amp; "XXXXXXXXXXX" =&gt; -- scan type = 1, run = 0, level = x<br />
CASE temp7 IS --(level)<br />
WHEN "000000000001" =&gt; --1<br />
vlcode_ac1 &lt;= "00000000000000010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00011";<br />
WHEN "000000000010" =&gt; --2<br />
vlcode_ac1 &lt;= "00000000000000110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00100";<br />
WHEN "000000000011" =&gt; --3<br />
vlcode_ac1 &lt;= "00000000000000111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00101";<br />
WHEN "000000000100" =&gt; --4<br />
vlcode_ac1 &lt;= "00000000000011100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00110";<br />
WHEN "000000000101" =&gt; --5<br />
vlcode_ac1 &lt;= "00000000000011101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00110";<br />
WHEN "000000000110" =&gt; --6<br />
vlcode_ac1 &lt;= "00000000000000101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00111";<br />
WHEN "000000000111" =&gt; --7<br />
vlcode_ac1 &lt;= "00000000000000100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00111";<br />
WHEN "000000001000" =&gt; --8<br />
vlcode_ac1 &lt;= "00000000001111011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "000000001001" =&gt; --9<br />
vlcode_ac1 &lt;= "00000000001111100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "000000001010" =&gt; --10<br />
vlcode_ac1 &lt;= "00000000000100011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000001011" =&gt; --11<br />
vlcode_ac1 &lt;= "00000000000100010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000001100" =&gt; --12<br />
vlcode_ac1 &lt;= "00000000011111010" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000001101" =&gt; --13<br />
vlcode_ac1 &lt;= "00000000011111011" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000001110" =&gt; --14<br />
vlcode_ac1 &lt;= "00000000011111110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000001111" =&gt; --15<br />
vlcode_ac1 &lt;= "00000000011111111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN OTHERS =&gt;  NULL;<br />
END CASE;<br />
WHEN '0' &amp; "XXXXXX" &amp; "00000000010" =&gt; -- scan type = 0, run = x, level = 2<br />
CASE temp8 IS --(level)<br />
WHEN "000000000001" =&gt; --1<br />
vlcode_ac1 &lt;=  "00000000000000110" &amp; rl_in(11) ;<br />
codelength_ac1 &lt;= "00111";<br />
WHEN "000000000010" =&gt; --2<br />
vlcode_ac1 &lt;= "00000000000000100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "000000000011" =&gt; --3<br />
vlcode_ac1 &lt;= "00000000000100100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000000100" =&gt; --4<br />
vlcode_ac1 &lt;= "00000000000001111" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01011";<br />
WHEN "000000000101" =&gt;  --5<br />
vlcode_ac1 &lt;= "00000000000001001" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01011";<br />
WHEN OTHERS =&gt; NULL;<br />
END CASE;<br />
WHEN '1' &amp; "XXXXXX" &amp; "00000000010" =&gt;  -- scan type = 1, run = x, level = 2<br />
CASE temp9 IS --(level)<br />
WHEN "000000000001" =&gt; --1<br />
vlcode_ac1 &lt;= "00000000000000110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "00110";<br />
WHEN "000000000010" =&gt; --2<br />
vlcode_ac1 &lt;= "00000000000001110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01000";<br />
WHEN "000000000011" =&gt; --3<br />
vlcode_ac1 &lt;= "00000000000100110" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000000100" =&gt; --4<br />
vlcode_ac1 &lt;= "00000000011111101" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01001";<br />
WHEN "000000000101" =&gt; --5<br />
vlcode_ac1 &lt;= "00000000000000100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01010";<br />
WHEN OTHERS =&gt; NULL;<br />
END CASE;<br />
WHEN 'X' &amp; "000010" &amp; "00000000101" =&gt; -- scan_type = 0, EOB<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN 'X' &amp; "000010" &amp; "00000000101" =&gt; -- scan type = x, run = 2, level = 5<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN 'X' &amp; "000010" &amp; "00000000101" =&gt; -- scan type = x, run = 2, level = 5<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN 'X' &amp; "000010" &amp; "00000000101" =&gt; -- scan type = x, run = 2, level = 5<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN 'X' &amp; "000010" &amp; "00000000101" =&gt; -- scan type = x, run = 2, level = 5<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN 'X' &amp; "000010" &amp; "00000000101" =&gt; -- scan type = x, run = 2, level = 5<br />
vlcode_ac1 &lt;= "00000000000010100" &amp; rl_in(11);<br />
codelength_ac1 &lt;= "01110";<br />
WHEN OTHERS =&gt;<br />
vlcode_ac1 &lt;= rl_in;<br />
codelength_ac1 &lt;= "10010";<br />
END CASE;<br />
END IF;<br />
END IF;<br />
END IF;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- pipeline vlcode_ac1 and codelength_ac1 to match the 2 pipe stages of the<br />
--  pipeline vlcode_ac1 and codelength_ac1 to match the 2 pipe stages of the<br />
-- corresponding DC values</p>
<p>PROCESS (CLK)<br />
BEGIN<br />
IF (CLK'EVENT AND CLK = '1') THEN<br />
IF (RST = '1') THEN<br />
vlcode_ac &lt;= "000000000000000000";<br />
codelength_ac &lt;= "00000";<br />
ELSE<br />
vlcode_ac &lt;= vlcode_ac1;<br />
codelength_ac &lt;= codelength_ac1;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- select code and codelength. Counter value set at 2 because of the 2 pipestages<br />
--  select code and codelength. Counter value set at 2 because of the 2 pipestages<br />
-- od the AC and DC codelengths and vl codes</p>
<p>PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
codelength1 &lt;= "00000";<br />
vlcode1 &lt;= "000000000000000000";<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (rdy_in = '1' AND cntr64 = "0000010") THEN<br />
codelength1 &lt;= '0' &amp; codelength_dc;<br />
vlcode1 &lt;= "00000000" &amp; vlcode_dc;<br />
ELSE<br />
codelength1 &lt;= codelength_ac;<br />
vlcode1 &lt;= vlcode_ac;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- pipeline code and codelength. This is done to match the pipestages with<br />
--  pipeline code and codelength. This is done to match the pipestages with<br />
-- cl_sum_prev which is multiplied with vlcode.</p>
<p>PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
codelength2 &lt;= "00000";<br />
vlcode2 &lt;= "000000000000000000";<br />
vlcode3 &lt;= "000000000000000000";<br />
vlcode4 &lt;= "000000000000000000";<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (rdy_in = '1') THEN<br />
codelength2 &lt;= codelength1;<br />
vlcode2 &lt;= vlcode1;<br />
vlcode3 &lt;= vlcode2;<br />
vlcode4 &lt;= vlcode3;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- The maximum length of the vlc code can be 18 bits + 6 bits = 24 bits. This happens<br />
--  The maximum length of the vlc code can be 18 bits + 6 bits = 24 bits. This happens<br />
-- when a run level pair not defined in the table is encountered. In this case , a 6 bit<br />
-- escape code followed by 6 bit run code and 12 bit level code is used.  The minimum<br />
-- length of the vlc code is 2 bits. This happens when encoding an "EOB" symbol. After<br />
-- finding the vlc code for a particular run/level pair, the code is shifted into a<br />
-- barrel shifter.<br />
-- Every time there are 16 bits in the barrel shifter, the contends of the shifter is<br />
-- enabled out as the huffman_out signal. Each run length value is read in and the corresponding<br />
-- vlc code is found out (vlcode_dc or vlcode_ac1). For each code, the codelength is also<br />
-- stored in a ROM. The codelengths are added up (cl_sum) and when it reaches 16 or 32,<br />
-- the code is sent out.<br />
-- The maximum  value for cl_sum happens when a 15 bit code is followed by a 24 bit<br />
-- code. So the max. value for cl_sum is 15 + 24 = 39. The barrel shifter has 39 valid<br />
-- registers. For ease of coding, 48 (3 * 16) registers are used. These registers are<br />
-- divided into upper_reg, middle_reg and lower_reg. Each time upper_reg if full (ie.,<br />
-- 16 or more bits in barrel shifter), the contends are sent out. The remaining bits<br />
-- , if any, in the middle_reg are moved up to the upper_reg. If the barrel shifter<br />
-- has 32 or more valid data, the upper and middle registers are full and the upper<br />
-- reg data is sent out followed by the middle reg data. The remaining bits, if any<br />
-- in the lower register is moved up to the upper register.</p>
<p>--***************************************************************************<br />
-- calculate sum of codelength. set half flag and full flag . Half flags indicates<br />
--  calculate sum of codelength. set half flag and full flag . Half flags indicates<br />
-- that the upper_reg is full and full flag indicates that the lower register is full.<br />
-- cl_sum_prev gives the sum of the codelengths which is used to set the flags. cl_sum<br />
-- is used to find out the number of shifts to be done in the barrel shifts.</p>
<p>PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
cl_sum &lt;= "100111";<br />
cl_sum_prev &lt;= "000000";<br />
half_flag1 &lt;= '0';<br />
full_flag1 &lt;= '0';<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (cl_sum_rdy = '1') THEN<br />
IF (cl_sum_prev &lt; "010000") THEN<br />
cl_sum_prev &lt;= "0" &amp; codelength1 + cl_sum_prev;<br />
cl_sum &lt;= "100111" - cl_sum_prev;<br />
half_flag1 &lt;= '0';<br />
full_flag1 &lt;= '0';<br />
ELSE<br />
IF (cl_sum_prev&lt;="100000" AND cl_sum_prev &gt;= "010000")<br />
THEN<br />
cl_sum_prev &lt;= "0" &amp; codelength1 + (cl_sum_prev -<br />
"010000");<br />
cl_sum &lt;= "100111" - cl_sum_prev;<br />
half_flag1 &lt;= '1';<br />
full_flag1 &lt;= '0';<br />
ELSE<br />
IF (cl_sum_prev &gt;= "100000") THEN<br />
cl_sum_prev &lt;= "0" &amp; codelength1 + (cl_sum_prev -<br />
"100000");<br />
cl_sum &lt;= "100111" - cl_sum_prev;<br />
half_flag1 &lt;= '1';<br />
full_flag1 &lt;= '1';<br />
END IF;<br />
END IF;<br />
END IF;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- barrel shifting done using multiplier. Barrel shifting coefficients are<br />
--  barrel shifting done using multiplier. Barrel shifting coefficients are<br />
-- stored in a ROM and selected depending on the value of cl_sum</p>
<p>PROCESS (CLK)<br />
BEGIN<br />
IF (CLK'EVENT AND CLK = '1') THEN<br />
IF (RST = '1') THEN<br />
cl_sum_shift &lt;= "000000000000000000000000000000000000000";<br />
ELSE<br />
CASE cl_sum IS<br />
WHEN "000000" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000000000000";<br />
WHEN "000001" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000000000010";<br />
WHEN "000010" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000000000100";<br />
WHEN "000011" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000000001000";<br />
WHEN "000100" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000000010000";<br />
WHEN "000101" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000000100000";<br />
WHEN "000110" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000001000000";<br />
WHEN "000111" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000010000000";<br />
WHEN "001000" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000100000000";<br />
WHEN "001001" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000001000000000";<br />
WHEN "001010" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000010000000000";<br />
WHEN "001011" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000100000000000";<br />
WHEN "001100" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000001000000000000";<br />
WHEN "001101" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000010000000000000";<br />
WHEN "001110" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000100000000000000";<br />
WHEN "001111" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000001000000000000000";<br />
WHEN "010000" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000010000000000000000";<br />
WHEN "010001" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000100000000000000000";<br />
WHEN "010010" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000001000000000000000000";<br />
WHEN "010011" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000010000000000000000000";<br />
WHEN "010100" =&gt;<br />
cl_sum_shift &lt;= "000000000000000000100000000000000000000";<br />
WHEN "010101" =&gt;<br />
cl_sum_shift &lt;= "000000000000000001000000000000000000000";<br />
WHEN "010110" =&gt;<br />
cl_sum_shift &lt;= "000000000000000010000000000000000000000";<br />
WHEN "010111" =&gt;<br />
cl_sum_shift &lt;= "000000000000000100000000000000000000000";<br />
WHEN "011000" =&gt;<br />
cl_sum_shift &lt;= "000000000000001000000000000000000000000";<br />
WHEN "011001" =&gt;<br />
cl_sum_shift &lt;= "000000000000010000000000000000000000000";<br />
WHEN "011010" =&gt;<br />
cl_sum_shift &lt;= "000000000000100000000000000000000000000";<br />
WHEN "011011" =&gt;<br />
cl_sum_shift &lt;= "000000000001000000000000000000000000000";<br />
WHEN "011100" =&gt;<br />
cl_sum_shift &lt;= "000000000010000000000000000000000000000";<br />
WHEN "011101" =&gt;<br />
cl_sum_shift &lt;= "000000000100000000000000000000000000000";<br />
WHEN "011110" =&gt;<br />
cl_sum_shift &lt;= "000000001000000000000000000000000000000";<br />
WHEN "011111" =&gt;<br />
cl_sum_shift &lt;= "000000010000000000000000000000000000000";<br />
WHEN "100000" =&gt;<br />
cl_sum_shift &lt;= "000000100000000000000000000000000000000";<br />
WHEN "100001" =&gt;<br />
cl_sum_shift &lt;= "000001000000000000000000000000000000000";<br />
WHEN "100010" =&gt;<br />
cl_sum_shift &lt;= "000010000000000000000000000000000000000";<br />
WHEN "100011" =&gt;<br />
cl_sum_shift &lt;= "000100000000000000000000000000000000000";<br />
WHEN "100100" =&gt;<br />
cl_sum_shift &lt;= "001000000000000000000000000000000000000";<br />
WHEN "100101" =&gt;<br />
cl_sum_shift &lt;= "010000000000000000000000000000000000000";<br />
WHEN "100110" =&gt;<br />
cl_sum_shift &lt;= "100000000000000000000000000000000000000";<br />
WHEN OTHERS  =&gt;<br />
cl_sum_shift &lt;= "000000000000000000000000000000000000000";<br />
END CASE;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- multiplier used to do barrel shifting of codeword. flags pipeleined to match<br />
--  multiplier used to do barrel shifting of codeword. flags pipeleined to match<br />
-- the pipe line stages of upper, middle and lower registers.</p>
<p>PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
mult_out_int &lt;= (OTHERS =&gt; '0');<br />
full_flag2 &lt;= '0';<br />
half_flag2 &lt;= '0';<br />
full_flag3 &lt;= '0';<br />
half_flag3 &lt;= '0';<br />
full_flag4 &lt;= '0';<br />
half_flag4 &lt;= '0';<br />
full_flag5 &lt;= '0';<br />
half_flag5 &lt;= '0';<br />
full_flag6 &lt;= '0';<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (rdy_in = '1') THEN<br />
mult_out_int &lt;=  vlcode4 * cl_sum_shift;<br />
full_flag2 &lt;= full_flag1;<br />
half_flag2 &lt;= half_flag1;<br />
full_flag3 &lt;= full_flag2;<br />
half_flag3 &lt;= half_flag2;<br />
full_flag4 &lt;= full_flag3;<br />
half_flag4 &lt;= half_flag3;<br />
full_flag5 &lt;= full_flag4;<br />
half_flag5 &lt;= half_flag4;<br />
full_flag6 &lt;= full_flag5;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>mult_out &lt;= mult_out_int (38 downto 0);<br />
--***************************************************************************<br />
PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
upper_reg1 &lt;= "0000000000000000";<br />
middle_reg1 &lt;= "0000000000000000";<br />
lower_reg1 &lt;= "0000000000000000";<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (rdy_in = '1') THEN<br />
CASE temp11 IS<br />
WHEN "00" =&gt;<br />
upper_reg1(16 DOWNTO 1) &lt;= mult_out(38 DOWNTO 23)<br />
OR upper_reg1(16 DOWNTO 1);<br />
middle_reg1 &lt;= mult_out(22 DOWNTO 7);<br />
lower_reg1 &lt;= mult_out(6 DOWNTO 0) &amp;<br />
"000000000";<br />
WHEN "01" =&gt;<br />
upper_reg1(16 DOWNTO 1) &lt;= mult_out(38 DOWNTO 23)<br />
OR middle_reg1(16 DOWNTO 1);<br />
middle_reg1 &lt;= mult_out(22 DOWNTO 7);<br />
lower_reg1 &lt;= mult_out(6 DOWNTO 0) &amp;<br />
"000000000";<br />
WHEN "11" =&gt;<br />
upper_reg1 &lt;= mult_out(38 DOWNTO 23) OR<br />
lower_reg1;<br />
middle_reg1 &lt;= mult_out(22 DOWNTO 7);<br />
lower_reg1 &lt;= "0000000000000000";<br />
WHEN OTHERS  =&gt;<br />
upper_reg1 &lt;= upper_reg1;<br />
middle_reg1 &lt;= middle_reg1;<br />
lower_reg1 &lt;= lower_reg1;</p>
<p>END CASE;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
upper_reg2 &lt;= "0000000000000000";<br />
middle_reg2 &lt;= "0000000000000000";<br />
middle_reg3 &lt;= "0000000000000000";<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (rdy_in = '1') THEN<br />
upper_reg2 &lt;= upper_reg1;<br />
middle_reg2 &lt;= middle_reg1;<br />
middle_reg3 &lt;= middle_reg2;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
huffman_out &lt;= "0000000000000000";<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (rdy_in = '1') THEN<br />
IF (half_flag5 = '1') THEN<br />
huffman_out &lt;= upper_reg2;<br />
ELSE<br />
IF (full_flag6 = '1') THEN<br />
huffman_out &lt;= middle_reg3;<br />
END IF;<br />
END IF;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- counter that counts upto 64.<br />
PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
cntr64 &lt;= "1000000";<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (rdy_in = '1') THEN<br />
IF (cntr64 &lt; "1000000") THEN<br />
cntr64 &lt;= cntr64 + "0000001";<br />
ELSE<br />
cntr64 &lt;= "0000001";<br />
END IF;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>-- cl_sum starts after 2 clks from reset.<br />
PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
cl_sum_rdy &lt;= '0';<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (cntr64 = "0000010") THEN<br />
cl_sum_rdy &lt;= '1';<br />
ELSE<br />
cl_sum_rdy &lt;= cl_sum_rdy;<br />
END IF;<br />
END IF;<br />
END PROCESS;</p>
<p>--***************************************************************************<br />
-- counter that counts upto 64.<br />
PROCESS (CLK, RST)<br />
BEGIN<br />
IF (RST = '1') THEN<br />
rdy_out &lt;= '0';<br />
ELSIF (CLK'EVENT AND CLK = '1') THEN<br />
IF (rdy_in = '1') THEN<br />
rdy_out &lt;= '1';<br />
END IF;<br />
END IF;<br />
END PROCESS;<br />
--***************************************************************************</p>
<p>END translated;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/04/huffman-encoder-vhdl-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Huffman Encoder Verilog HDL code</title>
		<link>http://blog.ektel.com.np/2012/04/huffman-encoder-verilog-hdl-code/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=huffman-encoder-verilog-hdl-code</link>
		<comments>http://blog.ektel.com.np/2012/04/huffman-encoder-verilog-hdl-code/#comments</comments>
		<pubDate>Fri, 20 Apr 2012 01:42:34 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Categoryless Articles Collection]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=341</guid>
		<description><![CDATA[Huffman Encoder Verilog HDL code, vlsi implementation of source encoder and decoder, Huffman algorithm, variable length encoding, zigzag scanner, image compression, video compression,mpeg encoder]]></description>
			<content:encoded><![CDATA[<p>/**********************************************************************/<br />
//scale factor --- how many bits ?<br />
`timescale 1ns/1ps</p>
<p>module huffman_en   (CLK, RST, rdy_in, rl_in, dc_in, scan_type, luma,<br />
huffman_out, eob, rdy_out);</p>
<p>output [15:0] huffman_out;<br />
output rdy_out;<br />
input CLK, RST, eob;<br />
input [11:0] dc_in;<br />
input rdy_in,  luma;<br />
input scan_type;           /* used to choose b/n intra(0) &amp; non-intra(1)<br />
blocks */<br />
input[17:0] rl_in;   /* run[5:0] + value[11:0] */<br />
/* signals */</p>
<p>reg[6:0] cntr64;<br />
reg  rdy_out,cl_sum_rdy;<br />
reg[3:0] size/* synthesis syn_romstyle = "select_rom" */;<br />
reg[5:0] cl_sum, cl_sum_prev;<br />
reg[15:0] huffman_out;<br />
reg[3:0] codelength_dc  /* synthesis syn_romstyle = "block_rom" */;<br />
reg[4:0] codelength_ac,codelength1,codelength2;<br />
reg[4:0] codelength_ac1;<br />
reg[9:0] vlcode_dc  /* synthesis syn_romstyle = "block_rom" */;<br />
reg[17:0] vlcode1, vlcode2,vlcode3,vlcode4;<br />
reg[17:0] vlcode_ac1,vlcode_ac;<br />
reg[38:0] cl_sum_shift;<br />
reg full_flag1,half_flag1,half_flag2,full_flag2,half_flag3,full_flag3;<br />
reg full_flag4,half_flag4,full_flag5,full_flag6,half_flag5;<br />
reg[38:0] mult_out;<br />
reg[16:1] upper_reg1,middle_reg1,lower_reg1;<br />
reg[16:1] upper_reg2, middle_reg2, middle_reg3;<br />
/*****************************************************************************/</p>
<p>/* Find the size for the "Differential_DC" value. The differential_dc_size gives the number of<br />
bits to be used to denote the DC_difference value. ram_dc_diff . Table 1 in document*/</p>
<p>always @ (posedge CLK)<br />
begin<br />
casex (dc_in)<br />
12'b111111111111 :  size = 4'd1;<br />
12'b11111111110x :   size = 4'd2;<br />
12'b1111111110xx :   size = 4'd3;<br />
12'b111111110xxx :   size = 4'd4;<br />
12'b11111110xxxx :   size = 4'd5;<br />
12'b1111110xxxxx :   size = 4'd6;<br />
12'b111110xxxxxx :   size = 4'd7;<br />
12'b11110xxxxxxx :   size = 4'd8;<br />
12'b1110xxxxxxxx :   size = 4'd9;<br />
12'b110xxxxxxxxx :   size = 4'd10;<br />
12'b10xxxxxxxxxx :   size = 4'd11;<br />
12'b000000000000 :   size = 4'd0;<br />
12'b000000000001 :   size = 4'd1;<br />
12'b00000000001x :   size = 4'd2;<br />
12'b0000000001xx :   size = 4'd3;<br />
12'b000000001xxx :   size = 4'd4;<br />
12'b00000001xxxx :   size = 4'd5;<br />
12'b0000001xxxxx :   size = 4'd6;<br />
12'b000001xxxxxx :   size = 4'd7;<br />
12'b00001xxxxxxx :   size = 4'd8;<br />
12'b0001xxxxxxxx :   size = 4'd9;<br />
12'b001xxxxxxxxx :   size = 4'd10;<br />
12'b01xxxxxxxxxx :  size = 4'd11;<br />
default: size = 4'd0;<br />
endcase<br />
end</p>
<p>/*****************************************************************************/<br />
/* variable length code and the corresponding code length for DC_Differential */<br />
/* After finding the size of the DC_Differential, the variable length code used to denote it is found.<br />
For example, if the size is 10, 10 bits are used to denote the dc_differential value and a variable<br />
length code prefix of "111111110" is used along with the 10 bit value. */</p>
<p>/* luma = 1'b1 denotes a luminance block and lume = 1'b0 denotes a chrominance block */</p>
<p>always @ (posedge CLK)<br />
begin<br />
if (RST)<br />
begin<br />
vlcode_dc &lt;= 10'b0; codelength_dc &lt;= 4'd0;<br />
end<br />
else if (cntr64 == 1'b1)<br />
begin<br />
case (luma)<br />
1'b1: begin<br />
case (size) //ram_dc_size1<br />
4'd0 : begin vlcode_dc &lt;= 10'b0000000100; codelength_dc &lt;= 4'd3; end<br />
4'd1 : begin vlcode_dc &lt;= 10'b0000000000; codelength_dc &lt;= 4'd2; end<br />
4'd2 : begin vlcode_dc &lt;= 10'b0000000001; codelength_dc &lt;= 4'd2; end<br />
4'd3 : begin vlcode_dc &lt;= 10'b0000000101; codelength_dc &lt;= 4'd3; end<br />
4'd4 : begin vlcode_dc &lt;= 10'b0000000110; codelength_dc &lt;= 4'd3; end<br />
4'd5 : begin vlcode_dc &lt;= 10'b0000001110; codelength_dc &lt;= 4'd4; end<br />
4'd6 : begin vlcode_dc &lt;= 10'b0000011110; codelength_dc &lt;= 4'd5; end<br />
4'd7 : begin vlcode_dc &lt;= 10'b0000111110; codelength_dc &lt;= 4'd6; end<br />
4'd8 : begin vlcode_dc &lt;= 10'b0001111110; codelength_dc &lt;= 4'd7; end<br />
4'd9 : begin vlcode_dc &lt;= 10'b0011111110; codelength_dc &lt;= 4'd8; end<br />
4'd10 : begin vlcode_dc &lt;= 10'b0111111110; codelength_dc &lt;= 4'd9; end<br />
4'd11 : begin vlcode_dc &lt;= 10'b0111111111; codelength_dc &lt;= 4'd9; end<br />
default: begin vlcode_dc &lt;= 10'b0; codelength_dc &lt;= 4'd0; end<br />
endcase<br />
end<br />
//always @(size)<br />
1'b0: begin<br />
case (size) //ram_dc_size2<br />
4'd0 : begin vlcode_dc &lt;= 10'b0000000000; codelength_dc &lt;= 4'd2; end<br />
4'd1 : begin vlcode_dc &lt;= 10'b0000000001; codelength_dc &lt;= 4'd2; end<br />
4'd2 : begin vlcode_dc &lt;= 10'b0000000010; codelength_dc &lt;= 4'd2; end<br />
4'd3 : begin vlcode_dc &lt;= 10'b0000000110; codelength_dc &lt;= 4'd3; end<br />
4'd4 : begin vlcode_dc &lt;= 10'b0000001110; codelength_dc &lt;= 4'd4; end<br />
4'd5 : begin vlcode_dc &lt;= 10'b0000011110; codelength_dc &lt;= 4'd5; end<br />
4'd6 : begin vlcode_dc &lt;= 10'b0000111110; codelength_dc &lt;= 4'd6; end<br />
4'd7 : begin vlcode_dc &lt;= 10'b0001111110; codelength_dc &lt;= 4'd7; end<br />
4'd8 : begin vlcode_dc &lt;= 10'b0011111110; codelength_dc &lt;= 4'd8; end<br />
4'd9 : begin vlcode_dc &lt;= 10'b0111111110; codelength_dc &lt;= 4'd9; end<br />
4'd10 : begin vlcode_dc &lt;= 10'b1111111110; codelength_dc &lt;= 4'd10; end<br />
4'd11 : begin vlcode_dc &lt;= 10'b1111111111; codelength_dc &lt;= 4'd10; end<br />
default: begin vlcode_dc &lt;= 10'b0; codelength_dc &lt;= 4'd0; end</p>
<p>endcase<br />
end<br />
endcase<br />
end<br />
end</p>
<p>/*****************************************************************************/<br />
/* variable length code and corresponding code length for AC coefficients.<br />
Table zero is used for intra blocks anf table one is used for non-intra<br />
blocks.  For a run/level pair not defined in table zero or one, an escape<br />
code followed by a 6 bit run symbol and 12 bit level is used.*/<br />
//assign run_level_pair &lt;= {run_in,level_in};</p>
<p>/*always @ (posedge CLK)<br />
begin<br />
if (RST)<br />
begin vlcode_ac1 &lt;= {18'b0}; codelength_ac1 &lt;= 5'd0; end<br />
else<br />
begin if (rdy_in == 1'b1)<br />
begin<br />
case(rl_in)<br />
18'b000000000000000001:<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001010,rl_in[11]}; codelength_ac1 &lt;= 5'd5; end<br />
18'b000000000000000101:<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000111,rl_in[11]}; codelength_ac1 &lt;= 5'd4; end<br />
18'b000000000000001010:<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001110,rl_in[11]}; codelength_ac1 &lt;= 5'd5; end<br />
18'b000001000000000101:<br />
begin  vlcode_ac1 &lt;= {18'b111100001111001101}; codelength_ac1 &lt;= 5'd18; end<br />
18'b000011000000000111:<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010111,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
18'b000111000000001001:<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000000,rl_in[11]}; codelength_ac1 &lt;= 5'd5; end<br />
18'b010000000000010000:<br />
begin  vlcode_ac1 &lt;= {17'b10000000000010110,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
18'b010101000000001001:<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010110,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
default:<br />
begin  vlcode_ac1 &lt;= {18'b111111111111111111}; codelength_ac1 &lt;= 5'd18; end<br />
endcase<br />
end<br />
end<br />
end*/</p>
<p>/*****************************************************************************/</p>
<p>always @ (posedge CLK)<br />
if (RST)<br />
begin vlcode_ac1 &lt;= {18'b0}; codelength_ac1 &lt;= 5'd0; end<br />
else<br />
begin<br />
if (eob == 1'b1 &amp;&amp; scan_type == 1'b1)<br />
begin  vlcode_ac1 &lt;= 000000000000000010; codelength_ac1 &lt;= 5'd2; end // NOTE 2<br />
else if (eob == 1'b1 &amp;&amp; scan_type == 1'b0)<br />
begin  vlcode_ac1 &lt;= 000000000000000110; codelength_ac1 &lt;= 5'd4; end // NOTE 2<br />
else if (cntr64 == 7'b0000001 &amp;&amp; ({rl_in[17:12],rl_in[10:0]}) == 17'b00000000000000001)<br />
begin vlcode_ac1 &lt;= {17'b00000000000000001,rl_in[11]};<br />
codelength_ac1 &lt;= 5'd2; end // note3, DC coeff<br />
else<br />
begin</p>
<p>/******************** scan type = x, run = x, level = 1 ********/</p>
<p>casex ({scan_type,rl_in[17:12],rl_in[10:0]})//(check)</p>
<p>{1'bx,6'bx,11'b00000000001}: // level = 1<br />
begin<br />
case({rl_in[17:12]}) //run<br />
6'b010001: //17<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011111,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b010010: //18<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011010,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b010011: //19<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011001,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b010100: //20<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010111,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b010101: //21<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010110,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b010110: //22<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011111,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
6'b010111: //23<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011110,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
6'b011000: //24<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011101,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
6'b011001: //25<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011100,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
6'b011010: //26<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011011,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
6'b011011: //27<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011111,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
6'b011100: //28<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011110,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
6'b011101: //29<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011101,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
6'b011110: //30<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011100,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
6'b011111: //31<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011011,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
endcase<br />
end<br />
/******************** scan type = x, run = x, level = 2 ********/<br />
{1'bx,6'bx,11'b00000000010}: //level = 2<br />
begin<br />
case({rl_in[17:12]}) //(run)<br />
6'b000110: //6<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011110,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b000111: //7<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010101,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b001000: //8<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010001,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b001001: //9<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010001,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
6'b001010: //10<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010000,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
6'b001011: //11<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011010,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
6'b001100: //12<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011001,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
6'b001101: //13<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011000,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
6'b001110: //14<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010111,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
6'b001111: //15<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010110,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
6'b010000: //16<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010101,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
endcase<br />
end<br />
/******************** scan type = x, run = x, level = 3 ********/<br />
{1'bx,6'bx,11'b00000000011}: //level = 3<br />
begin<br />
case ({rl_in[17:12]}) //(run)<br />
6'b000011: //3<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011100,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b000100: //4<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010010,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
6'b000101: //5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010010,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
6'b000110: //6<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
endcase<br />
end<br />
/******************** scan type = x, run = 0, level = x ********/<br />
{1'bx,6'b000000,11'bx}: //run = 0<br />
begin<br />
case ({1'b0,rl_in[10:0]}) //(level)<br />
12'b000000010000: //16<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011111,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000010001: //17<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011110,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000010010: //18<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011101,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000010011: //19<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011100,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000010100: //20<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011011,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000010101: //21<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011010,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000010110: //22<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011001,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000010111: //23<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011000,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000011000: //24<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010111,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000011001: //25<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010110,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000011010: //26<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010101,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000011011: //27<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000011100: //28<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010011,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000011101: //29<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010010,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000011110: //30<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010001,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000011111: //31<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010000,rl_in[11]}; codelength_ac1 &lt;= 5'd15; end<br />
12'b000000100000: //32<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011000,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000100001: //33<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010111,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000100010: //34<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010110,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000100011: //35<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010101,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000100100: //36<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000100101: //37<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010011,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000100110: //38<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010010,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000100111: //39<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010001,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000101000: //40<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010000,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
endcase<br />
end<br />
/******************** scan type = x, run = 1, level = x ********/<br />
{1'bx,6'b000001,11'bx}: // run = 1<br />
begin<br />
case ({1'b0,rl_in[10:0]}) //(level)<br />
12'b000000000110: //6<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010110,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
12'b000000000111: //7<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010101,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
12'b000000001000: //8<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011111,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000001001: //9<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011110,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000001010: //10<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011101,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000001011: //11<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011100,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000001100: //12<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011011,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000001101: //13<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011010,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000001110: //14<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011001,rl_in[11]}; codelength_ac1 &lt;= 5'd16; end<br />
12'b000000001111: //15<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010011,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
12'b000000010000: //16<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010010,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
12'b000000010001: //17<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010001,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
12'b000000010010: //18<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010000,rl_in[11]}; codelength_ac1 &lt;= 5'd17; end<br />
endcase<br />
end</p>
<p>/***************************************************************************************/</p>
<p>{1'bx,6'b000010,11'b00000000101}: // scan type = x, run = 2, level = 5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
{1'bx,6'b000011,11'b00000000011}: // scan type = x, run = 3, level = 4<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010011,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end</p>
<p>/***************************************************************************************/</p>
<p>{1'b0,6'bx,11'b00000000001}: // scan type = 0, run = x, level = 1<br />
begin<br />
case ({rl_in[17:12]}) //(run)<br />
6'b000001 : //1<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000011,rl_in[11]}; codelength_ac1 &lt;= 5'd4; end<br />
6'b000010 : //2<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000101,rl_in[11]}; codelength_ac1 &lt;= 5'd5; end<br />
6'b000011 : //3<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000111,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
6'b000100 : //4<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000110,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
6'b000101 : //5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000111,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
6'b000110 : //6<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000101,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
6'b000111 : //7<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000100,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
6'b001000 : //8<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000111,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
6'b001001 : //9<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000101,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
6'b001010 : //10<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100111,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
6'b001011 : //11<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100011,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
6'b001100 : //12<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100010,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
6'b001101 : //13<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100000,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
6'b001110 : //14<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001110,rl_in[11]}; codelength_ac1 &lt;= 5'd11; end<br />
6'b001111 : //15<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001101,rl_in[11]}; codelength_ac1 &lt;= 5'd11; end<br />
6'b010000 : //16<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001000,rl_in[11]}; codelength_ac1 &lt;= 5'd11; end<br />
endcase<br />
end</p>
<p>/***************************************************************************************/</p>
<p>{1'b1,6'bx,11'b00000000001}: // scan type = 1, run = x, level = 1<br />
begin<br />
case ({rl_in[17:12]}) //(run)<br />
6'b000001 : //1<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000010,rl_in[11]}; codelength_ac1 &lt;= 5'd4; end<br />
6'b000010 : //2<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000101,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
6'b000011 : //3<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000111,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
6'b000100 : //4<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000110,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
6'b000101 : //5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000111,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
6'b000110 : //6<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000110,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
6'b000111 : //7<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000100,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
6'b001000 : //8<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000101,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
6'b001001 : //9<br />
begin  vlcode_ac1 &lt;= {17'b00000000001111000,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
6'b001010 : //10<br />
begin  vlcode_ac1 &lt;= {17'b00000000001111010,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
6'b001011 : //11<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100001,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
6'b001100 : //12<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100101,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
6'b001101 : //13<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100100,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
6'b001110 : //14<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000101,rl_in[11]}; codelength_ac1 &lt;= 5'd10; end<br />
6'b001111 : //15<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000111,rl_in[11]}; codelength_ac1 &lt;= 5'd10; end<br />
6'b010000 : //16<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001101,rl_in[11]}; codelength_ac1 &lt;= 5'd11; end<br />
endcase<br />
end</p>
<p>/***************************************************************************************/</p>
<p>{1'b0,6'b000000,11'bx}: // scan type = 0, run = 0, level = x<br />
begin<br />
case ({1'b0,rl_in[10:0]}) //(level)<br />
12'b000000000010 : //2<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000100,rl_in[11]}; codelength_ac1 &lt;= 5'd5; end<br />
12'b000000000011 : //3<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000101,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
12'b000000000100 : //4<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000110,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
12'b000000000101 : //5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100110,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000000110 : //6<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100001,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000000111 : //7<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001010,rl_in[11]}; codelength_ac1 &lt;= 5'd11; end<br />
12'b000000001000 : //8<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011101,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
12'b000000001001 : //9<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011000,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
12'b000000001010 : //10<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010011,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
12'b000000001011 : //11<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010000,rl_in[11]}; codelength_ac1 &lt;= 5'd13; end<br />
12'b000000001100 : //12<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011010,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
12'b000000001101 : //13<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011001,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
12'b000000001110 : //14<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011000,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
12'b000000001111 : //15<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010111,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
endcase<br />
end</p>
<p>/***************************************************************************************/</p>
<p>{1'b1,6'b000000,11'bx}: // scan type = 1, run = 0, level = x<br />
begin<br />
case ({1'b0,rl_in[10:0]}) //(level)<br />
12'b000000000001 : //1<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000010,rl_in[11]}; codelength_ac1 &lt;= 5'd3; end<br />
12'b000000000010 : //2<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000110,rl_in[11]}; codelength_ac1 &lt;= 5'd4; end<br />
12'b000000000011 : //3<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000111,rl_in[11]}; codelength_ac1 &lt;= 5'd5; end<br />
12'b000000000100 : //4<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011100,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
12'b000000000101 : //5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000011101,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
12'b000000000110 : //6<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000101,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
12'b000000000111 : //7<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000100,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
12'b000000001000 : //8<br />
begin  vlcode_ac1 &lt;= {17'b00000000001111011,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
12'b000000001001 : //9<br />
begin  vlcode_ac1 &lt;= {17'b00000000001111100,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
12'b000000001010 : //10<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100011,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000001011 : //11<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100010,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000001100 : //12<br />
begin  vlcode_ac1 &lt;= {17'b00000000011111010,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000001101 : //13<br />
begin  vlcode_ac1 &lt;= {17'b00000000011111011,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000001110 : //14<br />
begin  vlcode_ac1 &lt;= {17'b00000000011111110,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000001111 : //15<br />
begin  vlcode_ac1 &lt;= {17'b00000000011111111,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
endcase<br />
end</p>
<p>/***************************************************************************************/</p>
<p>{1'b0,6'bx,11'b00000000010}: // scan type = 0, run = x, level = 2<br />
begin<br />
case ({1'b0,rl_in[10:0]}) //(level)<br />
12'b000000000001 : //1<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000110,rl_in[11]}; codelength_ac1 &lt;= 5'd7; end<br />
12'b000000000010 : //2<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000100,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
12'b000000000011 : //3<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100100,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000000100 : //4<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001111,rl_in[11]}; codelength_ac1 &lt;= 5'd11; end<br />
12'b000000000101 : //5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001001,rl_in[11]}; codelength_ac1 &lt;= 5'd11; end<br />
endcase<br />
end</p>
<p>/***************************************************************************************/</p>
<p>{1'b1,6'bx,11'b00000000010}: // scan type = 1, run = x, level = 2<br />
begin<br />
case ({1'b0,rl_in[10:0]}) //(level)<br />
12'b000000000001 : //1<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000110,rl_in[11]}; codelength_ac1 &lt;= 5'd6; end<br />
12'b000000000010 : //2<br />
begin  vlcode_ac1 &lt;= {17'b00000000000001110,rl_in[11]}; codelength_ac1 &lt;= 5'd8; end<br />
12'b000000000011 : //3<br />
begin  vlcode_ac1 &lt;= {17'b00000000000100110,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000000100 : //4<br />
begin  vlcode_ac1 &lt;= {17'b00000000011111101,rl_in[11]}; codelength_ac1 &lt;= 5'd9; end<br />
12'b000000000101 : //5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000000100,rl_in[11]}; codelength_ac1 &lt;= 5'd10; end<br />
endcase<br />
end</p>
<p>/***************************************************************************************/</p>
<p>{1'bx,6'b000010,11'b00000000101}: // scan_type = 0, EOB<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
{1'bx,6'b000010,11'b00000000101}: // scan type = x, run = 2, level = 5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
{1'bx,6'b000010,11'b00000000101}: // scan type = x, run = 2, level = 5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
{1'bx,6'b000010,11'b00000000101}: // scan type = x, run = 2, level = 5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
{1'bx,6'b000010,11'b00000000101}: // scan type = x, run = 2, level = 5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end<br />
{1'bx,6'b000010,11'b00000000101}: // scan type = x, run = 2, level = 5<br />
begin  vlcode_ac1 &lt;= {17'b00000000000010100,rl_in[11]}; codelength_ac1 &lt;= 5'd14; end</p>
<p>default:<br />
begin  vlcode_ac1 &lt;= rl_in; codelength_ac1 &lt;= 5'd18; end</p>
<p>endcase<br />
end<br />
end</p>
<p>/*****************************************************************************/</p>
<p>/* pipeline vlcode_ac1 and codelength_ac1 to match the 2 pipe stages of the<br />
corresponding DC values */</p>
<p>always @ (posedge CLK)<br />
if (RST)<br />
begin<br />
vlcode_ac &lt;= {18'b0}; codelength_ac &lt;= 5'd0;<br />
end<br />
else<br />
begin<br />
vlcode_ac &lt;= vlcode_ac1; codelength_ac &lt;= codelength_ac1;<br />
end</p>
<p>/*****************************************************************************/</p>
<p>/* select code and codelength. Counter value set at 2 because of the 2 pipestages<br />
od the AC and DC codelengths and vl codes */</p>
<p>always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
codelength1 &lt;= 5'b0;  vlcode1 &lt;= 18'b0;<br />
end<br />
else if (rdy_in == 1'b1 &amp; cntr64 == 7'b0000010)<br />
begin<br />
codelength1 &lt;= {1'b0,codelength_dc};<br />
vlcode1 &lt;= {8'b0,vlcode_dc};<br />
end<br />
else<br />
begin<br />
codelength1 &lt;= codelength_ac;<br />
vlcode1 &lt;= {vlcode_ac};<br />
end<br />
end</p>
<p>/*****************************************************************************/</p>
<p>/* pipeline code and codelength. This is done to match the pipestages with<br />
cl_sum_prev which is multiplied with vlcode. */</p>
<p>always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
codelength2 &lt;= 5'b0;<br />
vlcode2 &lt;= 18'b0; vlcode3 &lt;= 18'b0;vlcode4 &lt;= 18'b0;<br />
end<br />
else if (rdy_in == 1'b1)<br />
begin<br />
codelength2 &lt;= codelength1;<br />
vlcode2 &lt;= vlcode1; vlcode3 &lt;= vlcode2;vlcode4 &lt;= vlcode3;<br />
end<br />
end</p>
<p>/*****************************************************************************/<br />
/* The maximum length of the vlc code can be 18 bits + 6 bits = 24 bits. This happens<br />
when a run level pair not defined in the table is encountered. In this case , a 6 bit<br />
escape code followed by 6 bit run code and 12 bit level code is used.  The minimum<br />
length of the vlc code is 2 bits. This happens when encoding an "EOB" symbol. After<br />
finding the vlc code for a particular run/level pair, the code is shifted into a<br />
barrel shifter.</p>
<p>Every time there are 16 bits in the barrel shifter, the contends of the shifter is<br />
enabled out as the huffman_out signal. Each run length value is read in and the corresponding<br />
vlc code is found out (vlcode_dc or vlcode_ac1). For each code, the codelength is also<br />
stored in a ROM. The codelengths are added up (cl_sum) and when it reaches 16 or 32,<br />
the code is sent out.</p>
<p>The maximum  value for cl_sum happens when a 15 bit code is followed by a 24 bit<br />
code. So the max. value for cl_sum is 15 + 24 = 39. The barrel shifter has 39 valid<br />
registers. For ease of coding, 48 (3 * 16) registers are used. These registers are<br />
divided into upper_reg, middle_reg and lower_reg. Each time upper_reg if full (ie.,<br />
16 or more bits in barrel shifter), the contends are sent out. The remaining bits<br />
, if any, in the middle_reg are moved up to the upper_reg. If the barrel shifter<br />
has 32 or more valid data, the upper and middle registers are full and the upper<br />
reg data is sent out followed by the middle reg data. The remaining bits, if any<br />
in the lower register is moved up to the upper register.*/</p>
<p>/*****************************************************************************/<br />
/* calculate sum of codelength. set half flag and full flag . Half flags indicates<br />
that the upper_reg is full and full flag indicates that the lower register is full.<br />
cl_sum_prev gives the sum of the codelengths which is used to set the flags. cl_sum<br />
is used to find out the number of shifts to be done in the barrel shifts.*/</p>
<p>always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
cl_sum &lt;= 6'b100111; cl_sum_prev &lt;= 6'b0;<br />
half_flag1 &lt;= 1'b0; full_flag1 &lt;= 1'b0;<br />
end<br />
else if ( cl_sum_rdy == 1'b1)<br />
begin<br />
if (cl_sum_prev &lt; 6'd16)<br />
begin<br />
cl_sum_prev &lt;= codelength1 + cl_sum_prev;<br />
cl_sum &lt;= (6'b100111 - cl_sum_prev);<br />
half_flag1 &lt;= 1'b0;<br />
full_flag1 &lt;= 1'b0;<br />
end<br />
else if (cl_sum_prev &lt;= 6'd32 &amp;&amp; cl_sum_prev &gt;= 6'd16)<br />
begin<br />
cl_sum_prev &lt;= codelength1 + (cl_sum_prev - 5'b10000);<br />
cl_sum &lt;= (6'b100111 - cl_sum_prev);<br />
half_flag1 &lt;= 1'b1;<br />
full_flag1 &lt;= 1'b0;<br />
end<br />
else if (cl_sum_prev &gt;= 6'd32)<br />
begin<br />
cl_sum_prev &lt;= codelength1 + (cl_sum_prev - 6'b100000);<br />
cl_sum &lt;= (6'b100111 - cl_sum_prev);<br />
half_flag1 &lt;= 1'b1;<br />
full_flag1 &lt;= 1'b1;<br />
end<br />
end<br />
end</p>
<p>/*****************************************************************************/</p>
<p>/* barrel shifting done using multiplier. Barrel shifting coefficients are<br />
stored in a ROM and selected depending on the value of cl_sum */</p>
<p>always @ (posedge CLK)<br />
begin<br />
if (RST)<br />
begin<br />
cl_sum_shift &lt;= 39'b0;<br />
end<br />
else<br />
begin<br />
case (cl_sum)<br />
6'd0 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000000000000000; end<br />
6'd1 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000000000000010; end<br />
6'd2 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000000000000100; end<br />
6'd3 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000000000001000; end<br />
6'd4 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000000000010000; end<br />
6'd5 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000000000100000; end<br />
6'd6 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000000001000000; end<br />
6'd7 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000000010000000; end<br />
6'd8 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000000100000000; end<br />
6'd9 : begin cl_sum_shift &lt;=  39'b000000000000000000000000000001000000000; end<br />
6'd10 : begin cl_sum_shift &lt;= 39'b000000000000000000000000000010000000000; end<br />
6'd11 : begin cl_sum_shift &lt;= 39'b000000000000000000000000000100000000000; end<br />
6'd12 : begin cl_sum_shift &lt;= 39'b000000000000000000000000001000000000000; end<br />
6'd13 : begin cl_sum_shift &lt;= 39'b000000000000000000000000010000000000000; end<br />
6'd14 : begin cl_sum_shift &lt;= 39'b000000000000000000000000100000000000000; end<br />
6'd15 : begin cl_sum_shift &lt;= 39'b000000000000000000000001000000000000000; end<br />
6'd16 : begin cl_sum_shift &lt;= 39'b000000000000000000000010000000000000000; end<br />
6'd17 : begin cl_sum_shift &lt;= 39'b000000000000000000000100000000000000000; end<br />
6'd18 : begin cl_sum_shift &lt;= 39'b000000000000000000001000000000000000000; end<br />
6'd19 : begin cl_sum_shift &lt;= 39'b000000000000000000010000000000000000000; end<br />
6'd20 : begin cl_sum_shift &lt;= 39'b000000000000000000100000000000000000000; end<br />
6'd21 : begin cl_sum_shift &lt;= 39'b000000000000000001000000000000000000000; end<br />
6'd22 : begin cl_sum_shift &lt;= 39'b000000000000000010000000000000000000000; end<br />
6'd23 : begin cl_sum_shift &lt;= 39'b000000000000000100000000000000000000000; end<br />
6'd24 : begin cl_sum_shift &lt;= 39'b000000000000001000000000000000000000000; end<br />
6'd25 : begin cl_sum_shift &lt;= 39'b000000000000010000000000000000000000000; end<br />
6'd26 : begin cl_sum_shift &lt;= 39'b000000000000100000000000000000000000000; end<br />
6'd27 : begin cl_sum_shift &lt;= 39'b000000000001000000000000000000000000000; end<br />
6'd28 : begin cl_sum_shift &lt;= 39'b000000000010000000000000000000000000000; end<br />
6'd29 : begin cl_sum_shift &lt;= 39'b000000000100000000000000000000000000000; end<br />
6'd30 : begin cl_sum_shift &lt;= 39'b000000001000000000000000000000000000000; end<br />
6'd31 : begin cl_sum_shift &lt;= 39'b000000010000000000000000000000000000000; end<br />
6'd32 : begin cl_sum_shift &lt;= 39'b000000100000000000000000000000000000000; end<br />
6'd33 : begin cl_sum_shift &lt;= 39'b000001000000000000000000000000000000000; end<br />
6'd34 : begin cl_sum_shift &lt;= 39'b000010000000000000000000000000000000000; end<br />
6'd35 : begin cl_sum_shift &lt;= 39'b000100000000000000000000000000000000000; end<br />
6'd36 : begin cl_sum_shift &lt;= 39'b001000000000000000000000000000000000000; end<br />
6'd37 : begin cl_sum_shift &lt;= 39'b010000000000000000000000000000000000000; end<br />
6'd38 : begin cl_sum_shift &lt;= 39'b100000000000000000000000000000000000000; end<br />
default : begin cl_sum_shift &lt;= 39'b000000000000000000000000000000000000000; end<br />
endcase<br />
end<br />
end</p>
<p>/*****************************************************************************/<br />
/* multiplier used to do barrel shifting of codeword. flags pipeleined to match<br />
the pipe line stages of upper, middle and lower registers. */</p>
<p>always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
mult_out &lt;= 39'b0;<br />
full_flag2 &lt;= 1'b0; half_flag2 &lt;= 1'b0;<br />
full_flag3 &lt;= 1'b0; half_flag3 &lt;= 1'b0;<br />
full_flag4 &lt;= 1'b0; half_flag4 &lt;= 1'b0;<br />
full_flag5 &lt;= 1'b0; half_flag5 &lt;= 1'b0;<br />
full_flag6 &lt;= 1'b0;<br />
end<br />
else if (rdy_in == 1'b1)<br />
begin<br />
mult_out &lt;= vlcode4 * cl_sum_shift;<br />
full_flag2 &lt;= full_flag1; half_flag2 &lt;= half_flag1;<br />
full_flag3 &lt;= full_flag2; half_flag3 &lt;= half_flag2;<br />
full_flag4 &lt;= full_flag3; half_flag4 &lt;= half_flag3;<br />
full_flag5 &lt;= full_flag4; half_flag5 &lt;= half_flag4;<br />
full_flag6 &lt;= full_flag5;<br />
end<br />
end</p>
<p>/*****************************************************************************/<br />
always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
upper_reg1 &lt;= 16'b0; middle_reg1 &lt;= 16'b0; lower_reg1 &lt;= 16'b0;<br />
end<br />
else if (rdy_in == 1'b1)<br />
begin<br />
case({full_flag4, half_flag4})<br />
2'b00: begin upper_reg1[16:1] &lt;= mult_out[38:23] | upper_reg1[16:1];<br />
middle_reg1 &lt;= mult_out[22:7] ;<br />
lower_reg1 &lt;= {mult_out[6:0],9'b0 }; end<br />
2'b01: begin upper_reg1[16:1] &lt;= mult_out[38:23] | middle_reg1[16:1];<br />
middle_reg1 &lt;= mult_out[22:7];<br />
lower_reg1 &lt;= {mult_out[6:0],9'b0}; end<br />
2'b11: begin upper_reg1 &lt;= mult_out[38:23] | lower_reg1;<br />
middle_reg1 &lt;= mult_out[22:7];<br />
lower_reg1 &lt;= {16'b0}; end<br />
default:begin upper_reg1 &lt;= upper_reg1;<br />
middle_reg1 &lt;= middle_reg1;<br />
lower_reg1 &lt;= lower_reg1; end<br />
endcase<br />
end<br />
end</p>
<p>/*****************************************************************************/</p>
<p>always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
upper_reg2 &lt;= 16'b0; middle_reg2 &lt;= 16'b0;<br />
middle_reg3 &lt;= 16'b0;<br />
end<br />
else if (rdy_in == 1'b1)<br />
begin<br />
upper_reg2 &lt;= upper_reg1;<br />
middle_reg2 &lt;= middle_reg1;<br />
middle_reg3 &lt;= middle_reg2;</p>
<p>end<br />
end</p>
<p>/*****************************************************************************/</p>
<p>always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
huffman_out &lt;= 16'b0;<br />
end<br />
else if (rdy_in == 1'b1)<br />
begin<br />
if (half_flag5 == 1'b1)<br />
huffman_out &lt;= upper_reg2;<br />
else if (full_flag6 == 1'b1)<br />
huffman_out &lt;= middle_reg3;<br />
end<br />
end</p>
<p>/*****************************************************************************/</p>
<p>/* counter that counts upto 64. */</p>
<p>always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
cntr64 &lt;= 7'b1000000;<br />
end<br />
else if (rdy_in == 1'b1)<br />
begin<br />
if (cntr64 &lt; 7'b1000000)<br />
cntr64 &lt;= cntr64 + 1;<br />
else<br />
cntr64 &lt;= 7'b0000001;<br />
end<br />
end</p>
<p>/* cl_sum starts after 2 clks from reset. */</p>
<p>always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
cl_sum_rdy &lt;= 1'b0;<br />
end<br />
else<br />
begin<br />
if (cntr64 == 7'b0000010)<br />
cl_sum_rdy &lt;= 1'b1;<br />
else<br />
cl_sum_rdy &lt;= cl_sum_rdy;<br />
end<br />
end<br />
/*****************************************************************************/</p>
<p>/* counter that counts upto 64. */</p>
<p>always @ (posedge CLK or posedge RST)<br />
begin<br />
if (RST)<br />
begin<br />
rdy_out &lt;= 1'b0;<br />
end<br />
else if (rdy_in == 1'b1)<br />
begin<br />
rdy_out &lt;= 1'b1;<br />
end<br />
end</p>
<p>/*****************************************************************************/<br />
endmodule</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/04/huffman-encoder-verilog-hdl-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dowload Xilinx EDA software for free</title>
		<link>http://blog.ektel.com.np/2012/04/dowload-xilinx-eda-software-for-free/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=dowload-xilinx-eda-software-for-free</link>
		<comments>http://blog.ektel.com.np/2012/04/dowload-xilinx-eda-software-for-free/#comments</comments>
		<pubDate>Sun, 15 Apr 2012 15:36:48 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Categoryless Articles Collection]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=334</guid>
		<description><![CDATA[Here I want to share download link for Xilinx ISE 13.4 for free. Xilinx is one of the most popular EDA software that is used by professional engineers and companies to produce VLSI FPGA architecture design, optimization and prototyping. The Xilinx software is one of the most expensive EDA software and it's competitor FPGA vendor is Altera. With Xilinx you can do all kinds of electronics design using logic gates and optimize the logic gates for power, speed and area. As an example you can create simple counter, multiplexer, encoder, adder, subtractor and use those building blocks to model real application electronic system such as mobile handset or router or switches or modulator/demodulator.Video encoder/decoder such as Mpeg-2 encoder/decoder, MPeg4 encoder/decoder, LTE advanced system can also be build with Xilinx. See below for the free download link for Xilinx. There are lots of other things you can do. Xilinx is compactible with MATLAB so that you can do simulation in MATLAB and optimize it on Xilinx or vice versa. You can create systematic map which shows you all the interconnected gates. After that you can do VLSI architecture design and optimization. Here is the free download link for Xilinx, http://www.netload.in/datei6nf5D9iOE3/tbex134l.part06.rar.htm http://www.netload.in/dateiBFRo4tK8Lz/tbex134l.part05.rar.htm http://www.netload.in/datei3kJxBY7UFV/tbex134l.part04.rar.htm http://www.netload.in/dateiOZ1HJl7FoE/tbex134l.part03.rar.htm http://www.netload.in/dateizePIcgC66Q/tbex134l.part02.rar.htm http://www.netload.in/dateiYD8XnP3W3U/tbex134l.part01.rar.htm http://www.netload.in/dateiVb7pdiyWiQ/tbex134l.part12.rar.htm http://www.netload.in/dateirCTQQbex3n/tbex134l.part11.rar.htm http://www.netload.in/dateilcuH20i6PE/tbex134l.part10.rar.htm http://www.netload.in/dateiX0IlSyPxXp/tbex134l.part09.rar.htm http://www.netload.in/dateiMYqGmGex5p/tbex134l.part08.rar.htm http://www.netload.in/datei8hA8KQw9At/tbex134l.part07.rar.htm If the free download link for Xilinx does not work please contact me You can read more below: Huffman encoder decoder VLSI design Systematic Block Diagram VLSI Implementation of Huffman algorithm based source encoder using Xilinx software Verilog and VHDL codes for Huffman based source encoder]]></description>
			<content:encoded><![CDATA[<p>Here I want to share download link for Xilinx ISE 13.4 for free. Xilinx is one of the most popular EDA software that is used by professional engineers and companies to produce VLSI FPGA architecture design, optimization and prototyping. The Xilinx software is one of the most expensive EDA software and it's competitor FPGA vendor is Altera. With Xilinx you can do all kinds of electronics design using logic gates and optimize the logic gates for power, speed and area. As an example you can create simple counter, multiplexer, encoder, adder, subtractor and use those building blocks to model real application electronic system such as mobile handset or router or switches or modulator/demodulator.Video encoder/decoder such as Mpeg-2 encoder/decoder, MPeg4 encoder/decoder, LTE advanced system can also be build with Xilinx. See below for the free download link for Xilinx. There are lots of other things you can do. Xilinx is compactible with MATLAB so that you can do simulation in MATLAB and optimize it on Xilinx or vice versa. You can create systematic map which shows you all the interconnected gates. After that you can do VLSI architecture design and optimization.</p>
<p>Here is the free download link for Xilinx,</p>
<p>http://www.netload.in/datei6nf5D9iOE3/tbex134l.part06.rar.htm</p>
<p>http://www.netload.in/dateiBFRo4tK8Lz/tbex134l.part05.rar.htm</p>
<p>http://www.netload.in/datei3kJxBY7UFV/tbex134l.part04.rar.htm</p>
<p>http://www.netload.in/dateiOZ1HJl7FoE/tbex134l.part03.rar.htm</p>
<p>http://www.netload.in/dateizePIcgC66Q/tbex134l.part02.rar.htm</p>
<p>http://www.netload.in/dateiYD8XnP3W3U/tbex134l.part01.rar.htm</p>
<p>http://www.netload.in/dateiVb7pdiyWiQ/tbex134l.part12.rar.htm</p>
<p>http://www.netload.in/dateirCTQQbex3n/tbex134l.part11.rar.htm</p>
<p>http://www.netload.in/dateilcuH20i6PE/tbex134l.part10.rar.htm</p>
<p>http://www.netload.in/dateiX0IlSyPxXp/tbex134l.part09.rar.htm</p>
<p>http://www.netload.in/dateiMYqGmGex5p/tbex134l.part08.rar.htm</p>
<p>http://www.netload.in/datei8hA8KQw9At/tbex134l.part07.rar.htm</p>
<p>If the free download link for Xilinx does not work please contact me</p>
<p>You can read more below:</p>
<ul>
<li><a title="Huffman encoder decoder VLSI design Systematic Block Diagram" href="../2012/04/huffman-encoder-decoder-vlsi-design-systematic-block-diagram/">Huffman encoder decoder VLSI design Systematic Block Diagram</a></li>
<li><a title="VLSI Architecture and Design for MPEG Encoder Decoder" href="http://blog.ektel.com.np/2012/03/vlsi-architecture-and-design-for-mpeg-encoder-decoder/" target="_blank">VLSI Implementation of Huffman algorithm based source encoder using Xilinx software</a></li>
<li><a title="Huffman Encoder Verilog HDL code" href="http://blog.ektel.com.np/2012/04/huffman-encoder-verilog-hdl-code/" target="_blank">Verilog</a> and <a title="Huffman Encoder VHDL code" href="http://blog.ektel.com.np/2012/04/huffman-encoder-vhdl-code/" target="_blank">VHDL codes for Huffman based source encoder</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/04/dowload-xilinx-eda-software-for-free/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VLSI Architecture and Design for MPEG Encoder Decoder</title>
		<link>http://blog.ektel.com.np/2012/03/vlsi-architecture-and-design-for-mpeg-encoder-decoder/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=vlsi-architecture-and-design-for-mpeg-encoder-decoder</link>
		<comments>http://blog.ektel.com.np/2012/03/vlsi-architecture-and-design-for-mpeg-encoder-decoder/#comments</comments>
		<pubDate>Wed, 21 Mar 2012 08:41:10 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Categoryless Articles Collection]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[decoder]]></category>
		<category><![CDATA[fpga]]></category>
		<category><![CDATA[functional units]]></category>
		<category><![CDATA[gate level schematic block diagram]]></category>
		<category><![CDATA[huffman algorithm]]></category>
		<category><![CDATA[huffman encoder]]></category>
		<category><![CDATA[logic gates]]></category>
		<category><![CDATA[source encoder]]></category>
		<category><![CDATA[vlsi architecture]]></category>
		<category><![CDATA[vlsi design]]></category>
		<category><![CDATA[xilinx]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=311</guid>
		<description><![CDATA[This article is about the design of source encoder and decoder using Huffman algorithm that are widely used today, eg MPEG Encoder. First systematic block diagram of essential components such as Discrete Fourier Transform(DCT), Run Length encoder, Huffman Encoder are  explained. Note that decoder are same and only encoder are different manufactured by different companies. Next the verilog and vhdl codes are obtained for the block diagram components and then xilinx eda software is used to simulate and synthesis the HDL codes to obtain encoder schematic layout, gate level design schematic showing functional units. Final output is FPGA VLSI electronic processor for source encoder based on Huffman algorithm to compress the input signal. This design is itself a small part of communication system which includes LPF, source encoding, channel encoding, modulation of the signal. VLSI Architecture and Design for MPEG Encoder Decoder The encoder uses 3 functional blocks as: Zigzag encoder Run Length Encoder(RLE) Variable Length Encoder (Huffman Encoder) This is illustrated below: 1. Zigzag encoder The input to the Zigzag encoder is the quantized DCT coefficients (DC and AC coefficient). The DCT coefficient are produced by applying Discrete Fourier Transform to the 8 by 8 block input pixel. These quantized DCT coefficients will have non-zero low frequency components in the top left corner of the 8×8 block and higher frequency components in the remaining places. The higher frequency components approximate to zero after quantization. The low frequency DCT coefficients are more important than higher frequency DCT coefficients. Even if we ignore some of the higher frequency coefficients, we can successfully reconstruct the image from the low frequency coefficients only. The zigzag scanner scans the DCT coefficients input in zigzag manner as shown in the figure below: The reason for applying Zigzag scan on the DC coefficient is to put the high frequency components together. The output of the zigzag scanner is thus strings of quantized DC coefficients with DC first and then high frequency AC components. The Zigzag scan block diagram is shown below: 2. Run Length Encoder(RLE): The Run Length Encoder works by recording runs of same input symbol as  the the symbol and its count. For eg., if input is "a a a a b b c c c c c c....." then Run Length Encoder would result "4a2b6c"etc. Here a, b, c would be level and 4,2,6 would be runs. Thus the output of the RLE is run/level combination. The general block diagram and internal architecture block diagram of Run Length Encoder is shown below: Fig: Internal Architecture of Run Length Encoder &#160; &#160; &#160; 3. Huffman Encoder/ Decoder: The output of the run length encoder is fed into Huffman Encoder. Each of the Run/Level input is assigned variable length codes such that the high probability run/level is assigned small codes and low probability run/level larger codes. This conversion table or lookup table is maintained in both the Encoder and Decoder and implemented as ROM. The block diagram of the Huffman Encoder are shown below: General Block Diagram of Huffman Encoder &#160; The VLSI architecture of Huffman Encoder/Decoder is shown below: &#160; The verilog HDL and VHDL codes for the mpeg encoder based on huffman encoding is below for downloads: Go to Next Section Huffman encoder Verilog code Huffman encoder VHDL code Huffman encoder VLSI systematic block  diagram Decoder essential performs the reverse algorithm of the source encoder algorithm. In this case the decoding algorithm is performed using decoding tables which is the same as the encoder table wherein different signal amplitude level is assigned variable length codes. This conversion table is maintained in the decoder [...]]]></description>
			<content:encoded><![CDATA[<p>This article is about the design of source encoder and decoder using Huffman algorithm that are widely used today, eg MPEG Encoder. First systematic block diagram of essential components such as Discrete Fourier Transform(DCT), Run Length encoder, Huffman Encoder are  explained. Note that decoder are same and only encoder are different manufactured by different companies. Next the <a title="Huffman Encoder Verilog HDL code" href="http://blog.ektel.com.np/2012/04/huffman-encoder-verilog-hdl-code/">verilog</a> and <a title="Huffman Encoder VHDL code" href="http://blog.ektel.com.np/2012/04/huffman-encoder-vhdl-code/">vhdl codes</a> are obtained for the block diagram components and then <a href="http://blog.ektel.com.np/2012/04/dowload-xilinx-eda-software-for-free/">xilinx eda software</a> is used to simulate and synthesis the HDL codes to obtain <a title="Huffman encoder decoder VLSI design Systematic Block Diagram" href="http://blog.ektel.com.np/2012/04/huffman-encoder-decoder-vlsi-design-systematic-block-diagram/">encoder schematic layout</a>, gate level design schematic showing functional units. Final output is FPGA VLSI electronic processor for source encoder based on Huffman algorithm to compress the input signal. This design is itself a small part of communication system which includes LPF, source encoding, channel encoding, modulation of the signal.</p>
<p><strong><span style="font-size: 16px;">VLSI Architecture and Design for MPEG Encoder Decoder</span></strong></p>
<p>The encoder uses 3 functional blocks as:</p>
<ol>
<li>Zigzag encoder</li>
<li>Run Length Encoder(RLE)</li>
<li>Variable Length Encoder (Huffman Encoder)</li>
</ol>
<p>This is illustrated below:</p>
<div id="attachment_314" class="wp-caption aligncenter" style="width: 473px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/03/vlc1.png"><img class=" wp-image-314" title="variable length encoder" src="http://blog.ektel.com.np/wp-content/uploads/2012/03/vlc1-300x68.png" alt="variable length encoder" width="463" height="136" /></a><p class="wp-caption-text">Fig: Variable Length Encoder</p></div>
<p>1. Zigzag encoder</p>
<p>The input to the Zigzag encoder is the quantized DCT coefficients (DC and AC coefficient). The DCT coefficient are produced by applying Discrete Fourier Transform to the 8 by 8 block input pixel. These quantized DCT coefficients will have non-zero low frequency components in the top left corner of the 8×8 block and higher frequency components in the remaining places. The higher frequency components approximate to zero after quantization. The low frequency DCT coefficients are more important than higher frequency DCT coefficients. Even if we ignore some of the higher frequency coefficients, we can successfully reconstruct the image from the low frequency coefficients only. The zigzag scanner scans the DCT coefficients input in zigzag manner as shown in the figure below:</p>
<div id="attachment_315" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/03/zigzag-scan.png"><img class="size-medium wp-image-315" title="zigzag scanner for MPEG" src="http://blog.ektel.com.np/wp-content/uploads/2012/03/zigzag-scan-300x167.png" alt="zigzag scanner for MPEG" width="300" height="167" /></a><p class="wp-caption-text">Fig: ZigZag Scanner</p></div>
<p>The reason for applying Zigzag scan on the DC coefficient is to put the high frequency components together. The output of the zigzag scanner is thus strings of quantized DC coefficients with DC first and then high frequency AC components. The Zigzag scan block diagram is shown below:</p>
<div id="attachment_316" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/03/zigzag.png"><img class="size-medium wp-image-316" title="zigzag scanner block diagram" src="http://blog.ektel.com.np/wp-content/uploads/2012/03/zigzag-300x107.png" alt="zigzag scanner block diagram" width="300" height="107" /></a><p class="wp-caption-text">Fig: zigzag scanner block diagram</p></div>
<p>2. Run Length Encoder(RLE):</p>
<p>The Run Length Encoder works by recording runs of same input symbol as  the the symbol and its count. For eg., if input is "a a a a b b c c c c c c....." then Run Length Encoder would result "4a2b6c"etc. Here a, b, c would be level and 4,2,6 would be runs. Thus the output of the RLE is run/level combination.</p>
<p>The general block diagram and internal architecture block diagram of Run Length Encoder is shown below:</p>
<div id="attachment_317" class="wp-caption alignleft" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/03/rle.png"><img class=" wp-image-317" title="Block Diagram of Run Length Encoder" src="http://blog.ektel.com.np/wp-content/uploads/2012/03/rle-300x128.png" alt="Block Diagram of Run Length Encoder" width="300" height="128" /></a><p class="wp-caption-text">Fig: Block Diagram of Run Length Encoder</p></div>
<p><a href="http://blog.ektel.com.np/wp-content/uploads/2012/03/rle-architecture.png"><img class=" wp-image-318" title="Internal Architecture of Run Length Encoder" src="http://blog.ektel.com.np/wp-content/uploads/2012/03/rle-architecture-300x99.png" alt="Internal Architecture of Run Length Encoder" width="300" height="96" /></a></p>
<div class="mceTemp">
<dl id="attachment_318" class="wp-caption   alignleft" style="width: 310px;">
<dd class="wp-caption-dd">Fig: Internal Architecture of Run Length Encoder</dd>
</dl>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>3. Huffman Encoder/ Decoder:</p>
<p>The output of the run length encoder is fed into Huffman Encoder. Each of the Run/Level input is assigned variable length codes such that the high probability run/level is assigned small codes and low probability run/level larger codes. This conversion table or lookup table is maintained in both the Encoder and Decoder and implemented as ROM.</p>
<p>The block diagram of the Huffman Encoder are shown below:</p>
<p>General Block Diagram of Huffman Encoder</p>
<div id="attachment_319" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/03/huffman-encoder.png"><img class="size-medium wp-image-319" title="Huffman Encoder" src="http://blog.ektel.com.np/wp-content/uploads/2012/03/huffman-encoder-300x94.png" alt="Huffman Encoder" width="300" height="94" /></a><p class="wp-caption-text">Fig: Huffman Encoder</p></div>
<p>&nbsp;</p>
<div id="attachment_320" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/03/huffman-encoder-architecture.png"><img class="size-medium wp-image-320" title="Inside huffman encoder" src="http://blog.ektel.com.np/wp-content/uploads/2012/03/huffman-encoder-architecture-300x136.png" alt="Inside Huffman Encoder" width="300" height="136" /></a><p class="wp-caption-text">Fig: Inside Huffman Encoder</p></div>
<p>The VLSI architecture of Huffman Encoder/Decoder is shown below:</p>
<div id="attachment_321" class="wp-caption aligncenter" style="width: 401px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/03/huffman-encoder-decoder-architecture.png"><img class=" wp-image-321" title="vlsi architecture of huffman encoder-decoder" src="http://blog.ektel.com.np/wp-content/uploads/2012/03/huffman-encoder-decoder-architecture-300x214.png" alt="vlsi architecture of huffman encoder-decoder" width="391" height="278" /></a><p class="wp-caption-text">Fig: VLSI architecture of huffman encoder-decoder</p></div>
<p>&nbsp;</p>
<p>The verilog HDL and VHDL codes for the mpeg encoder based on huffman encoding is below for downloads:</p>
<p>Go to Next Section</p>
<ol>
<li><a title="Huffman Encoder Verilog HDL code" href="http://blog.ektel.com.np/2012/04/huffman-encoder-verilog-hdl-code/" target="_blank">Huffman encoder Verilog code</a></li>
<li><a title="Huffman Encoder VHDL code" href="http://blog.ektel.com.np/2012/04/huffman-encoder-vhdl-code/" target="_blank">Huffman encoder VHDL code</a></li>
<li><a href="http://blog.ektel.com.np/2012/04/huffman-encoder-decoder-vlsi-design-systematic-block-diagram/">Huffman encoder VLSI systematic block  diagram</a></li>
</ol>
<p>Decoder essential performs the reverse algorithm of the source encoder algorithm. In this case the decoding algorithm is performed using decoding tables which is the same as the encoder table wherein different signal amplitude level is assigned variable length codes. This conversion table is maintained in the decoder circuits as said before, to get back the signal amplitude and hence the video or audio or both signal as used in mpeg encoder</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/03/vlsi-architecture-and-design-for-mpeg-encoder-decoder/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>ITU-T recommendation for telephone numbering plan for PSTN</title>
		<link>http://blog.ektel.com.np/2012/03/itu-t-recommendation-for-telephone-numbering-plan-for-pstn/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=itu-t-recommendation-for-telephone-numbering-plan-for-pstn</link>
		<comments>http://blog.ektel.com.np/2012/03/itu-t-recommendation-for-telephone-numbering-plan-for-pstn/#comments</comments>
		<pubDate>Sat, 17 Mar 2012 11:53:33 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Categoryless Articles Collection]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=306</guid>
		<description><![CDATA[As of now, ITU-T recommends E.164 standard for the telephone numbering plan for the PSTN. Rec E.164 defines use of prefix "+" for international call followed by 15 digits. The 15 digits includes country code(cc), the national destination code(NDC) and the subscriber number. The national destination code(NDC) refers to the combination of the area code and the exchange code. Exchange code is the code number of the PSTN switch. The following different codes makes up telephone number. Country cod  National Destination Code (NDC) Subscriber Number 1. Country Code: Country code are assigned for each country for identification purpose. This can be of 1 digit to 3 digit long. The country codes are assigned based on 9 zones as follows: Zone 1: North America(eg, for US or Canada, +1) Zone 2: Africa (eg, +216 for Tunisia) Zone 3/4: Europe(eg, +30 for Greece) Zone 5: South America(eg, +54 Argentine) Zone 6: South East Asia and Oceania(eg, +61 for Australia) Zone 7: Eurasia(eg, +7 for Russia) Zone 8: East Asia(eg, +86 for China) Zone 9: Central,South,Western Asia(eg, +977 for NEpal) 2. National Destination Code(NDC): Area code and exchange code together forms the national destination code a. Area Code: A country is usually divided into districts and/or zones. Each of which is given an area code(for example Kathmandu is 1, whereas Dharan is 25). b. Exchange Code: An area may contain several exchanges and to identify them exchange code is assigned to them. 3. Subscriber Number: The number given to a subscriber telephone line is called subscriber number.]]></description>
			<content:encoded><![CDATA[<p>As of now, ITU-T recommends E.164 standard for the telephone numbering plan for the PSTN. Rec E.164 defines use of prefix "+" for international call followed by 15 digits. The 15 digits includes country code(cc), the national destination code(NDC) and the subscriber number. The national destination code(NDC) refers to the combination of the area code and the exchange code. Exchange code is the code number of the PSTN switch.</p>
<p>The following different codes makes up telephone number.</p>
<ol>
<li>Country cod</li>
<li> National Destination Code (NDC)</li>
<li>Subscriber Number</li>
</ol>
<p>1. Country Code:</p>
<p>Country code are assigned for each country for identification purpose. This can be of 1 digit to 3 digit long. The country codes are assigned based on 9 zones as follows:<br />
Zone 1: North America(eg, for US or Canada, +1)<br />
Zone 2: Africa (eg, +216 for Tunisia)<br />
Zone 3/4: Europe(eg, +30 for Greece)<br />
Zone 5: South America(eg, +54 Argentine)<br />
Zone 6: South East Asia and Oceania(eg, +61 for Australia)<br />
Zone 7: Eurasia(eg, +7 for Russia)<br />
Zone 8: East Asia(eg, +86 for China)<br />
Zone 9: Central,South,Western Asia(eg, +977 for NEpal)</p>
<p>2. National Destination Code(NDC):<br />
Area code and exchange code together forms the national destination code<br />
a. Area Code:<br />
A country is usually divided into districts and/or zones. Each of which is given an area code(for example Kathmandu is 1, whereas Dharan is 25).<br />
b. Exchange Code:<br />
An area may contain several exchanges and to identify them exchange code is assigned to them.<br />
3. Subscriber Number:<br />
The number given to a subscriber telephone line is called subscriber number.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/03/itu-t-recommendation-for-telephone-numbering-plan-for-pstn/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CBRT System implementation within IN(Intelligent Network)</title>
		<link>http://blog.ektel.com.np/2012/02/cbrt-system-implementation-within-inintelligent-network/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cbrt-system-implementation-within-inintelligent-network</link>
		<comments>http://blog.ektel.com.np/2012/02/cbrt-system-implementation-within-inintelligent-network/#comments</comments>
		<pubDate>Sat, 18 Feb 2012 07:35:01 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Categoryless Articles Collection]]></category>
		<category><![CDATA[Featured]]></category>
		<category><![CDATA[crbt]]></category>
		<category><![CDATA[crbt system in IN network]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=285</guid>
		<description><![CDATA[CRBT(Color Ring Back Tone) is a Telecommunication VAS in which the caller can hear songs tune if the called party has CRBT enabled. This article explains how CRBT operates within the Intelligent Network architecture. The MSC (or SSP) must support the CAMEL Application Part(CAP) Phase 4 (or INAP CS2). The MSCs, SCPs and IPs are all interconnected as shown in the figure. The IPs(Intelligent Peripherals) are responsible for playing the CRBT tunes as directed by the SCP. The IN has separate SCPs dedicated for CRBT. The number of SCP depends on the number of mobile subscriber the Network Operator has, that is it is subject to capacity. The SCPs(Service Control Points) function is to co-ordinate the call, check the whether the dialed number has CRBT feature enabled by inquiring the HLR, directing IP to play the CRBT and other functions. Consider a mobile subscriber A who is calling a subscriber B. Let the subscriber B has CRBT service so that when subscriber A calls subscriber B, subscriber A hears subscriber CRBT song. Let us also consider that subscriber A is handled by MSC A and subscriber B is handled by MSC B. The CRBT signal flow animation is shown below: Click to see the Animation The steps are as follows; 1. The subscriber A makes a call, which is received by the MSC A. MSC A sends an IAM(Initial Address Message) to SCP which triggers the SCPs for making service status checks for the number. 2. The SCP processes the data received from MSC A. It makes inquiry to HLR(database) to check whether the dialed number has CRBT service provisioned or not. 3. At the same time, the SCP sends ICA(Initiate Call Attempt) message to MSC A, instructing MSC A to make an outgoing call to the called party. That is it instructs MSC A to connect to MSC B to make temporal ordinary phone call. 4. To make the outgoing call, MSC A connects to MSC B(because subscriber B is handled by MSC B). This call flow is called the Leg 2. This signal is monitored by the SCP so that it knows the status of the call(ringing, answered, busy). 5.  The MSC B sends reply to MSC A with the ACM(Address Complete Message). Path from subscriber A to subscriber B is now connected. The call can be ringing tone or busy tone. 6. The subscriber B phone starts to ring, and the MSC A notifies SCP about this ringing status by sending ERB (Event Reprot BCSM) message. BCSM stands for Basic Call State Machine. 7. After receiving the ringing status from MSC A, SCP replies to MSC A by sending ETC(Establish Temporary Connection) message that instructs MSC A to connect to the IP(Intelligent Peripheral) temporarily. 8.  MSC A connects to the IP by communicating messages between as follows: MSC A sends ISUP IAM to IP, the IP responds by sending ACM followed by  ANM message. Now IP is connected to MSC A. 9. Once the IP and MSC A are connected, IP sends ARI(Assist Request Instruction) message to the SCP that ask SCP what CRBT tune to play. The SCP responds by sending PA(Play Announcement) message to IP, instructing IP which CRBT tune to play. Now the subscriber A is connected to the IP via MSC A and can hear CRBT tone. This path is known as Leg1. The other path connection from MSC A to MSC B which is still active and in normal ringing tone is called Leg 2 and due to this the called party hears a normal call tone. This leg 2 is being [...]]]></description>
			<content:encoded><![CDATA[<p>CRBT(Color Ring Back Tone) is a Telecommunication VAS in which the caller can hear songs tune if the called party has CRBT enabled.</p>
<p>This article explains how CRBT operates within the Intelligent Network architecture. The MSC (or SSP) must support the CAMEL Application Part(CAP) Phase 4 (or INAP CS2). The MSCs, SCPs and IPs are all interconnected as shown in the figure. The IPs(Intelligent Peripherals) are responsible for playing the CRBT tunes as directed by the SCP. The IN has separate SCPs dedicated for CRBT. The number of SCP depends on the number of mobile subscriber the Network Operator has, that is it is subject to capacity. The SCPs(Service Control Points) function is to co-ordinate the call, check the whether the dialed number has CRBT feature enabled by inquiring the HLR, directing IP to play the CRBT and other functions.</p>
<p>Consider a mobile subscriber A who is calling a subscriber B. Let the subscriber B has CRBT service so that when subscriber A calls subscriber B, subscriber A hears subscriber CRBT song. Let us also consider that subscriber A is handled by MSC A and subscriber B is handled by MSC B.</p>
<p>The CRBT signal flow animation is shown below: <strong>Click to see the Animation</strong></p>
<div id="attachment_296" class="wp-caption aligncenter" style="width: 407px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/02/crbt-flow-diagram1.gif"><img class=" wp-image-296 " title="CBRT System implementation within IN(Intelligent Network) " src="http://blog.ektel.com.np/wp-content/uploads/2012/02/crbt-flow-diagram1-300x212.gif" alt="CBRT System implementation within IN(Intelligent Network) " width="397" height="236" /></a><p class="wp-caption-text">Fig: CBRT System implementation within IN(Intelligent Network) Animation</p></div>
<p>The steps are as follows;</p>
<p>1. The subscriber A makes a call, which is received by the MSC A. MSC A sends an IAM(Initial Address Message) to SCP which triggers the SCPs for making service status checks for the number.</p>
<p>2. The SCP processes the data received from MSC A. It makes inquiry to HLR(database) to check whether the dialed number has CRBT service provisioned or not.</p>
<p>3. At the same time, the SCP sends ICA(Initiate Call Attempt) message to MSC A, instructing MSC A to make an outgoing call to the called party. That is it instructs MSC A to connect to MSC B to make temporal ordinary phone call.</p>
<p>4. To make the outgoing call, MSC A connects to MSC B(because subscriber B is handled by MSC B). This call flow is called the Leg 2. This signal is monitored by the SCP so that it knows the status of the call(ringing, answered, busy).</p>
<p>5.  The MSC B sends reply to MSC A with the ACM(Address Complete Message). Path from subscriber A to subscriber B is now connected. The call can be ringing tone or busy tone.</p>
<p>6. The subscriber B phone starts to ring, and the MSC A notifies SCP about this ringing status by sending ERB (Event Reprot BCSM) message. BCSM stands for Basic Call State Machine.</p>
<p>7. After receiving the ringing status from MSC A, SCP replies to MSC A by sending ETC(Establish Temporary Connection) message that instructs MSC A to connect to the IP(Intelligent Peripheral) temporarily.</p>
<p>8.  MSC A connects to the IP by communicating messages between as follows: MSC A sends ISUP IAM to IP, the IP responds by sending ACM followed by  ANM message. Now IP is connected to MSC A.</p>
<p>9. Once the IP and MSC A are connected, IP sends ARI(Assist Request Instruction) message to the SCP that ask SCP what CRBT tune to play. The SCP responds by sending PA(Play Announcement) message to IP, instructing IP which CRBT tune to play.</p>
<p>Now the subscriber A is connected to the IP via MSC A and can hear CRBT tone. This path is known as Leg1. The other path connection from MSC A to MSC B which is still active and in normal ringing tone is called Leg 2 and due to this the called party hears a normal call tone. This leg 2 is being monitored by the SCP to know the status of the call.</p>
<p>10. Once the subscriber B answers the call, MSC B sends the MSC A an ANM message notifying MSC A that called party has answered the phone.</p>
<p>11. Now the MSC A notifies SCP that the called party(subscriber B) has answered the call by sending ERB message. This is leg 2 answer.</p>
<p>12. Now the SCP has to disconnect the CRBT connection(leg1) between subscriber A (via MSC A) and IP. This is done as follows; SCP sends MSC A a DFCWA(Disconnect Forward Connection With Argument) message instructing MSC A to disconnect its connection to IP. The MSC A upon receiving this message sends a REL(Release) message to the IP to disconnect the trunk lines between them. IP notifies the MSC A to acknowledge this by sending RLC message.</p>
<p>Now the connection between MSC A and IP is disconnected.</p>
<p>13. Finally SCP sends MOVEleg message to the MSC A. This is initiated to join the two legs.  The MSC A replies to SCP with MOVEleg return result message. This causes the two signalling legs to be joined and the subscriber A and B are now connected directly with normal speech path.</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/02/cbrt-system-implementation-within-inintelligent-network/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SMSC SMPP Server</title>
		<link>http://blog.ektel.com.np/2012/01/smsc-smpp-server/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=smsc-smpp-server</link>
		<comments>http://blog.ektel.com.np/2012/01/smsc-smpp-server/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 21:50:35 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Featured]]></category>
		<category><![CDATA[Mobile Network]]></category>
		<category><![CDATA[cluster configuration]]></category>
		<category><![CDATA[smpp server]]></category>
		<category><![CDATA[smpp server in cluster]]></category>
		<category><![CDATA[SMSC Architecture]]></category>
		<category><![CDATA[smsc smpp]]></category>
		<category><![CDATA[windows 2003 servers]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=248</guid>
		<description><![CDATA[SMPP(Short Message Peer to Peer) is a standardized protocol that handles the communication between SMSC and other SMS entities. It is an interface between the SMSC and NON-PLMN SMEs ( Short Message Entity). Typically it specifies the interface used between the SMSC and ESME ( External Short Message Entity) systems. This SMPP protocol may be implemented over a variety of underlying communications protocols  X.25 or TCP/IP over internet or leased line by pluging in the IP cables into the SMPP server and opening the correct SMPP port.]]></description>
			<content:encoded><![CDATA[<p>SMPP(Short Message Peer to Peer) is a standardized protocol that handles the communication between SMSC and other SMS entities. It is an interface between the SMSC and NON-PLMN SMEs ( Short Message Entity). Typically it specifies the interface used between the SMSC and ESME ( External Short Message Entity) systems. This SMPP protocol may be implemented over a variety of underlying communications protocols  X.25 or TCP/IP over internet or leased line by pluging in the IP cables into the SMPP server and opening the correct SMPP port.</p>
<p>The diagram below shows how ESME is connected to the SMSC via the SMPP server (SMPP gateway).</p>
<div id="attachment_249" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/01/esme-smsc-interconnection.png"><img class="size-medium wp-image-249 " title="ESME to SMSC Interconnection" src="http://blog.ektel.com.np/wp-content/uploads/2012/01/esmesmsc1-300x204.png" alt="ESME to SMSC Interconnection" width="300" height="204" /></a><p class="wp-caption-text">Fig: ESME to SMSC Interconnection (click to enlarge)</p></div>
<p>The SMPP Agent (process) is responsible for maintaining the communication link with the ESME, accomplishing the conversion of the SMPP standard message and the internal message of the SMSC ( Short Message Service Centre ) system, and providing the external short message entity (ESME) with the open interface to access the SMSC system. The current version of SMPP protocol is 3.4  (SMPP3.4).</p>
<p>As explained in the communication between ESME and SMSC servers post, there are two transmission modes between ESME and SMSC servers, namely-</p>
<ol>
<li>Transmitter Mode</li>
<li>Receiver Mode</li>
</ol>
<p>The following diagram explains the role of SMPP server during the connection establishment and release between the ESME server and SMS server</p>
<p>Transmission Mode:</p>
<div id="attachment_250" class="wp-caption aligncenter" style="width: 283px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/01/smpp-transmitter-mode.png"><img class="size-medium wp-image-250" title="Role of SMPP server during transmission mode" src="http://blog.ektel.com.np/wp-content/uploads/2012/01/smpp-transmitter-mode-273x300.png" alt="Role of SMPP server during transmission mode" width="273" height="300" /></a><p class="wp-caption-text">Fig: Role of SMPP server during transmission mode(click to enlarge)</p></div>
<p>In the figure,</p>
<div>•Steps (1)  to (4): ESME is bound with SMSC in transmitter mode, so that short messages can be sent to SMSC;</div>
<div>•Steps (5) to (8): ESME submits short messages to SMSC;</div>
<div>•Steps (9) to (10): ESME sends link detection messages to SMPP AGENT.</div>
<div>•Steps (11) to (14): Disconnect the link between ESME and SMSC.</div>
<div></div>
<div>Receiver Mode:</div>
<div>
<div id="attachment_251" class="wp-caption aligncenter" style="width: 285px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/01/smpp-receiver-mode.png"><img class="size-medium wp-image-251" title="Role of SMPP server in Receiver Mode" src="http://blog.ektel.com.np/wp-content/uploads/2012/01/smpp-receiver-mode-275x300.png" alt="Role of SMPP server in Receiver Mode" width="275" height="300" /></a><p class="wp-caption-text">Fig: Role of SMPP server in Receiver Mode(Click to Enlarge)</p></div>
<p>In the figure:</p>
<div>•Steps (1) to (4): ESME is bound with SMSC in Receiver mode and is ready to receive short messages from SMSC;</div>
<div>•Steps (5) to (8): SMSC distributes a short message to ESME.</div>
<div>•Steps (9) to  (12): Disconnect the link between ESME and SMSC.</div>
</div>
<div></div>
<div>The SMPP server and/or SMPP gateway is usually used in cluster mode, meaning that it has two same processor(active and standby) such that when one is down the other will be automatically turned on. Thus it has two IP address for each server processor and one floating IP for identification as single SMPP server and/or SMPP gateway. The server may run on Windows servers or linux servers. SMPP client is required on the ESME server side if there is need of SMS server. To connect to the ESME server to SMPP server the SMPP port number, username, password and SMS shortcode are required.</div>
<div></div>
<div></div>
<div>More on</div>
<div><a href="http://blog.ektel.com.np/2011/12/short-message-service-center-smsc/">SMSC Architecture in Mobile Network</a></div>
<div><a href="http://blog.ektel.com.np/2012/01/sms-messages-between-esme-server-and-smsc-server/">ESME and SMSC interconnection</a></div>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/01/smsc-smpp-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SMS Messages between ESME Server and SMSC Server</title>
		<link>http://blog.ektel.com.np/2012/01/sms-messages-between-esme-server-and-smsc-server/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=sms-messages-between-esme-server-and-smsc-server</link>
		<comments>http://blog.ektel.com.np/2012/01/sms-messages-between-esme-server-and-smsc-server/#comments</comments>
		<pubDate>Fri, 06 Jan 2012 15:19:37 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Categoryless Articles Collection]]></category>
		<category><![CDATA[Mobile Network]]></category>
		<category><![CDATA[email to sms gateway]]></category>
		<category><![CDATA[send sms]]></category>
		<category><![CDATA[sms gateway provider]]></category>
		<category><![CDATA[sms gateways]]></category>
		<category><![CDATA[sms messages]]></category>
		<category><![CDATA[sms messaging]]></category>
		<category><![CDATA[sms provider]]></category>
		<category><![CDATA[sms server]]></category>
		<category><![CDATA[sms services]]></category>
		<category><![CDATA[sms short code]]></category>

		<guid isPermaLink="false">http://blog.ektel.com.np/?p=231</guid>
		<description><![CDATA[This article explains the processes involved during sms messaging from a ESME server to the SMSC server. This helps in understanding the underlying sms messaging concept which can be applied to design of ESME. First the meaning of elementary components are explained. ESME(External Short Message Entity) is the name given to SMS Server(s) or SMS provider external to the SMS service provider network. Usually ESME server are owned by private business companies or government organizations that use SMS messaging service to provide various sms application such as Mobile Commerce(advertising), Mobile Banking by Banks, Email gateway (where email is send to sms gateway), notification applications, directory services, telemetry, vehicle tracking, cell broadcast etc. On the other hand, the SMSC server/ SMS server are usually owned by telecommunication or mobile operators (owning to the fact of  SMSC cost and operation cost). Both Entities are known as SMS provider but the telecommunication company or mobile operators are usually the sms gateway provider. SMS Short Codes or just short codes are given to ESME owners by the SMSC owners for identification purpose and connection between the ESME and SMSC servers. Multiple ESME servers can be connected to SMSC via SMS gateway. SMS gateway of SMSC is also the gateway for sending international SMS. The interconnection of SMSC with MSC and HLR is shown in this SMSC post. The status of the connections between the multiple ESME servers and SMSC can be viewed at the SMSC location. The connection between the ESME servers and SMSC server is such that, ESME server is connected TCP/IP or X.25 network (internet or leased line). The TCP/IP or X.25 network is connected to the SMPP server and then SMPP server is connected to the SMSC server. This is illustrated in figure below. Method of the ESME to access the SMSC In order to design ESME, the ESME interface must support TCP/IP and/or X.25 networking capabilities.  The software part of ESME must be capable of executing the following modes of transmission. Interworking between the SMSC and ESMEs are categorised as: Messages from ESMEs to the SMSC Messages from SMSC to ESMEs Transmission mode between ESME and SMSC There are two transmission mode between ESMS and SMSC Transmitter Mode Receiver Mode 1. Transmitter Mode In transmitter binding mode, the ESME binds with the SMSC as a transmitter. When the binding is successful, the ESME can initiate messages to the SMSC. For example, the ESME can transmit to the SMSC submit_sm, query_sm, cancel_sm, replace_sm, enquire_link and other messages. 2. Receiver Mode In this mode, the ESME binds with the SMSC as a receiver. When the binding is successful, the ESME can receive messages initiated by the SMSC. SMSC can send a deliver_sm message to ESME. Message Types Major Operation between ESME and SMSC The major operation between ESME and SMSC are: Bind operation Unbind operation Submit_SM operation Deliver_SM operation Bind operation is carried out to connect ESME server and SMSC server. Unbind Operation is carried out to release connection between ESEM server and SMSC server. Submit_SM and Deliver_SM are operation carried out to send and deliver short message between ESME and SMSC server. There are two types of bind operation: Bind_Transmitter Bind_Receiver All these operation process is explained below with figure. The figure below illustrates the process of bind_transmitter operation between ESME and SMSC servers. The figure below illustrates the process of bind_receiver operation between ESME and SMSC servers. The figure below illustrates the communication process between ESME server and SMSC server for transmitting and receiving Short Messages &#160; Thus mobile user sends sms to ESME and is then send to by that [...]]]></description>
			<content:encoded><![CDATA[<p>This article explains the processes involved during sms messaging from a ESME server to the SMSC server. This helps in understanding the underlying sms messaging concept which can be applied to design of ESME. First the meaning of elementary components are explained.</p>
<p>ESME(External Short Message Entity) is the name given to SMS Server(s) or SMS provider external to the SMS service provider network. Usually ESME server are owned by private business companies or government organizations that use SMS messaging service to provide various <a>sms application</a> such as Mobile Commerce(advertising), Mobile Banking by Banks, Email gateway (where email is send to sms gateway), notification applications, directory services, telemetry, vehicle tracking, cell broadcast etc. On the other hand, the SMSC server/ SMS server are usually owned by telecommunication or mobile operators (owning to the fact of  SMSC cost and operation cost). Both Entities are known as SMS provider but the telecommunication company or mobile operators are usually the sms gateway provider. SMS Short Codes or just short codes are given to ESME owners by the SMSC owners for identification purpose and connection between the ESME and SMSC servers. Multiple ESME servers can be connected to SMSC via SMS gateway. SMS gateway of SMSC is also the gateway for sending international SMS. The interconnection of SMSC with MSC and HLR is shown in this <a href="http://blog.ektel.com.np/2011/12/short-message-service-center-smsc/">SMSC post</a>. The status of the connections between the multiple ESME servers and SMSC can be viewed at the SMSC location. The connection between the ESME servers and SMSC server is such that, ESME server is connected TCP/IP or X.25 network (internet or leased line). The TCP/IP or X.25 network is connected to the SMPP server and then SMPP server is connected to the SMSC server. This is illustrated in figure below.</p>
<ul>
<li><strong>Method of the ESME to access the SMSC</strong></li>
</ul>
<div id="attachment_232" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/01/esmesmsc.png"><img class="size-medium wp-image-232" title="ESME and SMSC Communication" src="http://blog.ektel.com.np/wp-content/uploads/2012/01/esmesmsc-300x204.png" alt="ESME and SMSC Communication" width="300" height="204" /></a><p class="wp-caption-text">Fig: ESME and SMSC Communication</p></div>
<p>In order to design ESME, the ESME interface must support TCP/IP and/or X.25 networking capabilities.  The software part of ESME must be capable of executing the following modes of transmission.</p>
<p>Interworking between the SMSC and ESMEs are categorised as:</p>
<ol>
<li>Messages from ESMEs to the SMSC</li>
<li>Messages from SMSC to ESMEs</li>
</ol>
<ul>
<li><strong>Transmission mode between ESME and SMSC</strong></li>
</ul>
<p>There are two transmission mode between ESMS and SMSC</p>
<ol>
<li>Transmitter Mode</li>
<li>Receiver Mode</li>
</ol>
<p>1. Transmitter Mode</p>
<div>In transmitter binding mode, the ESME binds with the SMSC as a transmitter. When the binding is successful, the ESME can initiate messages to the SMSC. For example, the ESME can transmit to the SMSC submit_sm, query_sm, cancel_sm, replace_sm, enquire_link and other messages.</div>
<div></div>
<div>2. Receiver Mode</div>
<div></div>
<div>
<div>In this mode, the ESME binds with the SMSC as a receiver. When the binding is successful, the ESME can receive messages initiated by the SMSC. SMSC can send a deliver_sm message to ESME.</div>
</div>
<div></div>
<div>
<ul>
<li>Message Types</li>
</ul>
</div>
<div id="attachment_237" class="wp-caption aligncenter" style="width: 310px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/01/esme-smsc-messages.png"><img class="size-medium wp-image-237 " title="Messages between ESME and SMSC" src="http://blog.ektel.com.np/wp-content/uploads/2012/01/messageypes1-300x192.png" alt="Messages between ESME and SMSC" width="300" height="192" /></a><p class="wp-caption-text">Fig: Messages between ESME and SMSC</p></div>
<ul>
<li><strong>Major Operation between ESME and SMSC</strong></li>
</ul>
<p>The major operation between ESME and SMSC are:</p>
<ol>
<li>Bind operation</li>
<li>Unbind operation</li>
<li>Submit_SM operation</li>
<li>Deliver_SM operation</li>
</ol>
<p>Bind operation is carried out to connect ESME server and SMSC server. Unbind Operation is carried out to release connection between ESEM server and SMSC server. Submit_SM and Deliver_SM are operation carried out to send and deliver short message between ESME and SMSC server. There are two types of bind operation:</p>
<ol>
<li>Bind_Transmitter</li>
<li>Bind_Receiver</li>
</ol>
<p>All these operation process is explained below with figure.</p>
<p>The figure below illustrates the process of bind_transmitter operation between ESME and SMSC servers.</p>
<div id="attachment_238" class="wp-caption aligncenter" style="width: 268px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/01/bind-operation.png"><img class="size-medium wp-image-238" title="Bind Process between ESME and SMSC servers" src="http://blog.ektel.com.np/wp-content/uploads/2012/01/bind-operation-258x300.png" alt="Bind Process between ESME and SMSC servers" width="258" height="300" /></a><p class="wp-caption-text">Fig: Bind_Transmitter (Bind Process between ESME and SMSC servers)</p></div>
<p>The figure below illustrates the process of bind_receiver operation between ESME and SMSC servers.</p>
<div id="attachment_239" class="wp-caption aligncenter" style="width: 271px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/01/bind_receiver.png"><img class="size-medium wp-image-239" title="Bind_Receiver Process" src="http://blog.ektel.com.np/wp-content/uploads/2012/01/bind_receiver-261x300.png" alt="Bind_Receiver Process" width="261" height="300" /></a><p class="wp-caption-text">Fig: Bind_Receiver Process between ESME and SMSC</p></div>
<p>The figure below illustrates the communication process between ESME server and SMSC server for transmitting and receiving Short Messages</p>
<p>&nbsp;</p>
<div id="attachment_240" class="wp-caption aligncenter" style="width: 279px"><a href="http://blog.ektel.com.np/wp-content/uploads/2012/01/submit-receive-message.png"><img class="size-medium wp-image-240" title="Short Message transfer between ESME and SMSC" src="http://blog.ektel.com.np/wp-content/uploads/2012/01/submit-receive-message-269x300.png" alt="Short Message transfer between ESME and SMSC" width="269" height="300" /></a><p class="wp-caption-text">Fig: Short Message transfer between ESME and SMSC</p></div>
<p>Thus mobile user sends sms to ESME and is then send to by that ESME to the SMSC server and the bill is generated by counting the number of SMS send or received. The SMS count for each ESME account is identfied by the SMS short code given at the time of interconnection of the ESME and SMSC. The amount per SMS is subject to business policy between the two SMS service provider.</p>
<p>Thus the design of ESME involves the software support of the above feature.</p>
<p>&nbsp;</p>
<table style="width: 1px;" border="0" cellspacing="0" cellpadding="0">
<tbody>
<tr>
<td style="height: 15pt; width: 158pt;" width="210" height="20"></td>
</tr>
</tbody>
</table>
]]></content:encoded>
			<wfw:commentRss>http://blog.ektel.com.np/2012/01/sms-messages-between-esme-server-and-smsc-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

