<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by RAO MUHAMMAD UMER on Medium]]></title>
        <description><![CDATA[Stories by RAO MUHAMMAD UMER on Medium]]></description>
        <link>https://medium.com/@raoumer160903?source=rss-8959fd97c24b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*aKQTRBTr0efmX5c8</url>
            <title>Stories by RAO MUHAMMAD UMER on Medium</title>
            <link>https://medium.com/@raoumer160903?source=rss-8959fd97c24b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 18:08:36 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@raoumer160903/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Decade Counter Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/decade-counter-implementation-in-verilog-a607fe114c76?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/a607fe114c76</guid>
            <category><![CDATA[counter]]></category>
            <category><![CDATA[verification]]></category>
            <category><![CDATA[verilog-hdl]]></category>
            <category><![CDATA[dld]]></category>
            <category><![CDATA[decadecounter]]></category>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Mon, 04 Mar 2024 17:35:29 GMT</pubDate>
            <atom:updated>2024-03-04T17:35:29.218Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>The given Verilog code defines a module named “</em>decade_counter<em>” which implements the functionality of a </em>decade counter<em>. Here’s a breakdown of the module:</em></blockquote><pre>module decade_counter #(parameter N = 4)(<br>    output reg [N-1:0]q,<br>    input clk,rst<br>    );<br>    always @(posedge clk) begin<br>    if(rst) begin<br>    q &lt;= 4&#39;b0000;<br>    end<br>    else if(q == 4&#39;b1001) begin<br>            q &lt;= 4&#39;b0000;<br>    end<br>     else begin<br>          q &lt;= q + 1;<br>      end<br>    end<br>endmodule</pre><p>The Verilog module “decade_counter_tb” is a testbench designed to verify the functionality of the “decade_counter” module, which implements a decade counter. Below is an explanation of the“decade_counter_tb” module:</p><pre>module decade_counter_tb;<br>    wire [3:0]q;<br>    reg clk,rst;<br>    decade_counter #(.N(4)) dut(q,clk,rst);<br>    <br>    initial begin<br>        rst = 1;<br>        clk = 0;<br>        #20 rst = 0;<br>        #500 $finish();<br>    end<br>    always #10 clk = ~clk;<br>    <br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KU_puQmhl7F06A9nj5FgKQ.png" /><figcaption><strong>RTL Diagram</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7InLl8HLBAmoFGef7lrgSQ.png" /><figcaption><strong>Waveform</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a607fe114c76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mod Up-Down Counter Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/mod-up-down-counter-implementation-in-verilog-674c800c4076?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/674c800c4076</guid>
            <category><![CDATA[verilog-hdl]]></category>
            <category><![CDATA[waveform]]></category>
            <category><![CDATA[counter]]></category>
            <category><![CDATA[verilog]]></category>
            <category><![CDATA[up-down-counter]]></category>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Sun, 03 Mar 2024 11:31:58 GMT</pubDate>
            <atom:updated>2024-03-03T11:31:58.990Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>The given Verilog code defines a module named “mod8_up_down” which implements the functionality of a up_down counter. Here’s a breakdown of the module:</blockquote><pre>module mod8_up_down #(parameter N = 3)(<br> output reg [N-1:0]q,<br> input  mod,clk, rst);<br><br> always @(posedge clk) begin<br>  if (rst) begin<br>   q &lt;= 0;<br>  end<br>  else begin<br>   if(mod)<br>              begin<br>              q &lt;= q + 1;<br>              end<br>    else<br>              begin<br>              q &lt;= q - 1;<br>              end<br>  end<br> end<br>endmodule</pre><h4>Explanation:</h4><ul><li>The module is named mod8_up_down.</li><li>It has a parameter N with a default value of 3.</li><li>It has three ports:</li><li>output reg [N-1:0] q: This is an output port which is a register of width N minus one. It holds the value of the counter.</li><li>input mod: This is an input port which is used to determine the direction of counting. If mod is asserted (non-zero), the counter increments; otherwise, it decrements.</li><li>input clk, rst: These are input ports for clock and reset signals respectively. The counter increments or decrements on the positive edge of the clock signal. When rst is asserted, the counter is reset to 0.</li><li>Inside the always block triggered by the positive edge of the clock:</li><li>If rst is asserted, the counter q is reset to 0.</li><li>If rst is not asserted, the counter q is either incremented by 1 or decremented by 1 based on the value of mod. If mod is true (non-zero), q increments by 1; otherwise, it decrements by 1.</li></ul><p>The Verilog module “mod8_up_down_tb” is a testbench designed to verify the functionality of the “mod8_up_down” module, which implements an up-down counter. Below is an explanation of the“mod8_up_down_tb” module:</p><pre><br>module mod8_up_down_tb;<br> wire [2:0] q;<br> reg mod;<br> reg clk;<br> reg rst;<br> <br> mod8_up_down dut (q,mod, clk, rst);  <br> initial begin<br>  clk = 0;<br>  rst = 1;<br>  mod = 0;<br>  #20 rst = 0;<br>  #500 $finish();<br> end<br> always #180 mod = ~mod;<br> always #10 clk = ~clk;<br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DtV1iH20eXp3w0KxThRWvQ.png" /><figcaption><strong>RTL Diagram</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Knm8J2_TRuhhPc-hhKp1SA.png" /><figcaption><strong>Waveform</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=674c800c4076" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Counter Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/counter-implementation-in-verilog-73f6a4ae0f79?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/73f6a4ae0f79</guid>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Sat, 02 Mar 2024 17:19:25 GMT</pubDate>
            <atom:updated>2024-03-03T11:37:22.331Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>The given Verilog code defines a module named “counter” which implements the functionality of a counter. Here’s a breakdown of the module:</blockquote><pre>module counter #(parameter N = 8)<br>                (input              clk,<br>                 input              reset,<br>                 output reg [N-1:0] q);<br><br>  always @(posedge clk or posedge reset)<br>    if (reset) q &lt;= 0;<br>    else q &lt;= q + 1;<br>endmodule</pre><h4>Explanation:</h4><ul><li>module counter #(parameter N = 8) (input clk, input reset, output reg [N-1:0] q);</li><li>module counter: Defines the name of the module.</li><li>#(parameter N = 8): Defines a parameter named N with a default value of 8. This parameter determines the width of the counter.</li><li>(input clk, input reset, output reg [N-1:0] q): Declares the module ports:</li><li>clk: Input port representing the clock signal.</li><li>reset: Input port representing the reset signal.</li><li>q: Output port representing the counter output, declared as a register of width N.</li><li>always @(posedge clk or posedge reset): This is a procedural block that triggers whenever there is a positive edge on either the clk or reset signal.</li><li>if (reset) q &lt;= 0; else q &lt;= q + 1;: This is a conditional statement inside the always block. It updates the value of q based on the condition of the reset signal:</li><li>if (reset): Checks if the reset the signal is asserted (high).</li><li>q &lt;= 0;: If reset is asserted, the value of q is set to 0.</li><li>else: If the reset the signal is not asserted.</li><li>q &lt;= q + 1;: The value of q is incremented by 1.</li></ul><p>The Verilog module “counter_tb” is a testbench designed to verify the functionality of the “counter” module, which implements a counter. Below is an explanation of the“counter_tb” module:</p><pre>module counter_tb;<br><br>  // Signals<br>  reg clk =0;<br>  reg reset;<br>  wire [7:0] q; // Assuming 8-bit counter<br>  // Instantiate the counter module<br>  counter dut (<br>    .clk(clk),<br>    .reset(reset),<br>    .q(q)<br>  );<br>  // Clock generation<br>  always #5 clk = ~clk; // Assuming a 10ns clock period<br><br>  // Reset generation<br>  initial begin<br>    reset = 1;<br>    #20; // Reset for 20 ns<br>    reset = 0;<br>  end<br>  // Stimulus<br>  initial begin<br>    // Allow some time for reset to take effect<br>    #30;<br>    // Apply additional stimuli here if needed<br>    // For example, toggling the reset signal<br>    #100;<br>    reset = 1;<br>    #10;<br>    reset = 0;<br>   // Run simulation for time<br>    #200;<br>    // End simulation<br>    $finish;<br>  end<br><br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Spd7EVlEdVBtQM9v-oiVQ.png" /><figcaption><strong>RTL Diagram</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iLd1K_1I5qgtkS2q9BV3fA.png" /><figcaption><strong>Waveform</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=73f6a4ae0f79" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Register Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/register-implementation-in-verilog-d677e558c913?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/d677e558c913</guid>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Fri, 01 Mar 2024 16:53:52 GMT</pubDate>
            <atom:updated>2024-03-01T16:53:52.826Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>The given Verilog code defines a module named “register_64bit” which implements the functionality of a 64bit register.Here’s a breakdown of the module:</blockquote><pre>//Design a 64 bit register with asynchronous,active low reset. Also write its testbench.<br>module register_64bit(input wire [64-1:0] data_in,<br>input wire clk,<br>input wire reset,<br>output reg [64-1:0] data_out);<br><br><br>always@(posedge clk or negedge reset)begin <br><br>if(reset==0)begin   // active low reset  (!reset)<br>  data_out &lt;= 64&#39;b0;<br>end<br>else begin<br>  data_out &lt;= data_in;<br>end<br><br>end<br><br>endmodule</pre><h4>Explanation:</h4><p>Inputs:</p><ul><li>data_in: 64-bit input data</li><li>clk: Clock signal</li><li>reset: Asynchronous active low reset signal</li></ul><p>Outputs:</p><ul><li>data_out: 64-bit output data</li></ul><p>Behavior:</p><ul><li>On every positive clock edge, or when the reset signal transitions from high to low (active low reset), the module behaves as follows:</li><li>If the reset signal is active (low), the output data data_out is set to all zeros.</li><li>Otherwise, the output data data_out is updated with the input data data_in.</li></ul><p>The Verilog module “register_64bit_tb” is a testbench designed to verify the functionality of the “register_64bit” module, which implements a 64bit register. Below is an explanation of the“register_64bit_tb” module:</p><pre><br>module register_64bit_tb();<br>reg [64-1:0] data_in;<br>reg reset;<br>bit clk;  // default=0<br>wire [64-1:0] data_out;<br><br>// Instantiate <br><br>register_64bit dut(.data_out(data_out),.data_in(data_in),.clk(clk),.reset(reset)); <br><br>// Clock generation<br>initial begin<br>  forever #5 clk = ~clk;    // Toggle clock every 5 time units<br>end<br><br>// Initial values<br>initial begin<br>  reset = 0;<br>  data_in = 64&#39;d9; <br>  #10; <br>  reset = 1; <br>  #10; <br>  data_in = 64&#39;d1; <br>  #10;<br>  data_in = 64&#39;d2; <br>  #10; <br>  reset = 0; <br>  #10; <br>  data_in = 64&#39;d3; <br>  #10; <br>  data_in = 64&#39;d4; <br>  #10;<br>  data_in = 64&#39;d5; <br>  #10; <br><br>  $finish; // End simulation<br>end<br><br> initial begin <br>  <br>  $dumpfile(&quot;dumped.vcd&quot;);<br>  $dumpvars(0);<br>  #100;<br>  $finish();<br>  <br> end    <br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dD5Qe7JxDmUf1gMp3jHLjg.png" /><figcaption><strong>RTL Diagram</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*05iIlj-iM6rKXkuZV-VFfQ.png" /><figcaption><strong>Waveform</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d677e558c913" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[4-Bit Multiplier Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/4-bit-multiplierimplementation-in-verilog-8a6c1a33ff4b?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a6c1a33ff4b</guid>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Thu, 29 Feb 2024 16:52:12 GMT</pubDate>
            <atom:updated>2024-02-29T16:52:39.074Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>The given Verilog code defines a module named “Multiplier_4bit” which implements the functionality of a 4-bit Multiplier. Here’s a breakdown of the module:</em></blockquote><pre>module Multiplier_4bit(<br>    input [3:0] A,       // 4-bit input A<br>    input [3:0] B,       // 4-bit input B<br>    output reg [7:0] P   // 8-bit output P (result of multiplication)<br>);<br><br>always @ (A or B) begin<br>    P = A * B;           // Multiplication operation, result stored in P<br>end<br><br>endmodule</pre><h4>Explanation:</h4><ul><li>module Multiplier_4bit: This line declares the start of a module named Multiplier_4bit.</li><li>(input [3:0] A, input [3:0] B, output reg [7:0] P): This line declares the module ports. A and B are 4-bit inputs, while P is an 8-bit output. reg indicates that P is a registered output.</li><li>always @ (A or B) begin: This is a combinational logic block triggered whenever there is a change in inputs A or B.</li><li>P = A * B;: This line performs the multiplication of inputs A and B, and stores the result in P. Since P is 8 bits wide, it can store the result of multiplying two 4-bit numbers.</li></ul><p>The Verilog module “Multiplier_4bit_tb” is a testbench designed to verify the functionality of the “Multiplier_4bit” module, which implements a 4-bit Multiplier. Below is an explanation of the“t_ff_tb” module:</p><pre>module Multiplier_4bit_tb;<br><br>    // Signals<br>    reg [3:0] A, B;<br>    wire [7:0] P;<br><br>    // Instantiate the Multiplier_4bit module<br>    Multiplier_4bit UUT(<br>        .A(A),<br>        .B(B),<br>        .P(P)<br>    );<br><br>    // Test stimuli<br>    initial begin<br>        // Initialize inputs<br>        A = 4&#39;b0000;<br>        B = 4&#39;b0000;<br><br>        // Apply test vectors<br>        #10 A = 4&#39;b0001; B = 4&#39;b0010; // 1 * 2 = 2<br>        #10 A = 4&#39;b0011; B = 4&#39;b0011; // 3 * 3 = 9<br>        #10 A = 4&#39;b1010; B = 4&#39;b0100; // 10 * 4 = 40<br><br>        // Add more test vectors as needed<br><br>        // Finish simulation<br>        #10 $finish;<br>    end<br><br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*50aRL6dmtlc_unoSGYI-Eg.png" /><figcaption><strong>RTL Diagram of Multiplier_4bit</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B3e74Swi0cecvFH5Yru6ZA.png" /><figcaption><strong>Waveform of Multiplier_4bit</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a6c1a33ff4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[T Flip Flop (Behavioral) Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/t-flip-flop-behavioral-implementation-in-verilog-3ce9a632abaf?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/3ce9a632abaf</guid>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 10:23:18 GMT</pubDate>
            <atom:updated>2024-02-27T10:56:42.005Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>The given Verilog code defines a module named “t<em>_ff</em>” which implements the functionality of a D Flipflop. Here’s a breakdown of the module:</blockquote><pre>module t_ff(<br>    output reg q,   // Output register q<br>    input t,        // Input signal t<br>    input rst_n,    // Reset signal (active low)<br>    input clk       // Clock signal<br>    );<br><br>    always @(posedge clk or  negedge rst_n) // Always block triggered on positive clock edge or negative reset edge<br>    begin<br>        if (!rst_n) // If reset is active<br>        begin<br>            q &lt;= 0; // Set output q to 0<br>        end<br>        else       // If reset is inactive<br>        begin<br>            q &lt;= ~t; // Toggle output q (invert input t)<br>        end<br>    end<br>endmodule</pre><h4>Explanation:</h4><ul><li>It has four ports: q, t, rst_n, and clk.</li></ul><p>Port Descriptions:</p><ul><li>q: Output register representing the output of the flip-flop.</li><li>t: Input signal to toggle the output q.</li><li>rst_n: Reset signal, active low.</li><li>clk: Clock signal.</li></ul><p>Behavioral Logic:</p><ul><li>Inside the always block, the output q is assigned based on the clock signal clk and the reset signal rst_n.</li><li>If rst_n is low (active), q is asynchronously set to 0.</li><li>If rst_n is high (inactive), q is toggled by negating the input signal t using ~t.</li></ul><p>Synchronous Behavior:</p><ul><li>The flip-flop operates synchronously with the positive edge of the clock signal clk.</li><li>Reset Functionality:</li><li>When the reset signal rst_n is active low, the output q is asynchronously set to 0 regardless of the clock signal.</li></ul><p>Toggle Functionality:</p><ul><li>When the reset signal rst_n is inactive, the output q toggles its state based on the input signal t. If t is high, q becomes low, and vice versa.</li></ul><p>The Verilog module “t_ff_tb” is a testbench designed to verify the functionality of the “t_ff” module, which implements a D flipflop. Below is an explanation of the“t_ff_tb” module:</p><pre>module t_ff_tb;<br><br>    // Signals<br>    reg t;<br>    reg rst_n;<br>    reg clk;<br><br>    wire q;<br><br>    // Instantiate the DUT<br>    t_ff dut (<br>        .q(q),<br>        .t(t),<br>        .rst_n(rst_n),<br>        .clk(clk)<br>    );<br><br>    // Clock generation<br>    always #5 clk = ~clk;<br><br>    // Initial values<br>    initial begin<br>        clk = 0;<br>        rst_n = 0;<br>        t = 0;<br>        #15;<br>        rst_n = 1;<br>        #15;<br>        t = 1;<br>        #15;<br>        t = 0;<br>        #15;<br><br>        // Test case 3: Toggle t input <br>        repeat(5) begin<br>            t = 1;<br>            #5;<br>            t = 0;<br>            #5;<br>        end<br><br>        $finish;<br>    end<br><br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OMCLJ0TYgdMALikj9PBCPA.png" /><figcaption><strong>RTL Diagram of T-Flip Flop</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6qelK7HHM22pO2Y0TPR7Kw.png" /><figcaption><strong>Waveform of T-Flip Flop</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3ce9a632abaf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Barrel Shifter Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/barrel-shifter-implementation-in-verilog-c2a80d6a1d78?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c2a80d6a1d78</guid>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Tue, 27 Feb 2024 09:56:10 GMT</pubDate>
            <atom:updated>2024-02-29T11:06:58.356Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>A barrel shifter is a digital circuit used in computer processors to efficiently perform bitwise shifting operations on binary data, either left or right by a specified number of positions.The given Verilog code defines a module named “barrel_bh” which implements the functionality of an barrel shifter. Here’s a breakdown of the module:</blockquote><pre>/**************************************************<br>P1.1 8-bit BARREL SHIFTER BEHAVIORAL<br>************************************************/<br><br>module barrel_bh(Out,In,Lr,n);<br><br> input [7:0]In;// input number<br> input [2:0]n;  // how many bits you want to shift<br> input Lr; // select the direction left ==1 otherwise right <br> output reg [7:0]Out; // output result<br><br> always@(*) begin<br>  if(Lr)<br>   Out = In &lt;&lt; n;<br>  else<br>   Out = In &gt;&gt; n;<br> end <br>endmodule</pre><h4>Explanation:</h4><ul><li>The module is named barrel_bh.</li><li>It has four ports: In, Lr, n, and Out.</li></ul><p>Port Descriptions:</p><ul><li>In: An 8-bit input representing the binary number to be shifted.</li><li>Lr: A single bit input representing the direction of the shift. If Lr is 1, the shift is left; otherwise, it&#39;s right.</li><li>n: A 3-bit input representing the number of bit positions to shift.</li><li>Out: An 8-bit output representing the result of the shift operation.</li></ul><p>Behavioral Logic:</p><ul><li>Inside the always block, the Out value is determined based on the inputs In, Lr, and n.</li><li>If Lr is 1 (indicating a left shift), In is shifted left by n positions.</li><li>If Lr is 0 (indicating a right shift), In is shifted right by n positions.</li><li>The result of the shift operation is stored in the Out register.</li><li>Parallel Execution:</li><li>The always block executes in parallel, meaning it continuously updates Out based on any changes in the input values In, Lr, or n.</li></ul><p>Behavioral Modeling:</p><ul><li>This Verilog code represents a behavioral model of an 8-bit barrel shifter, describing its functionality without specifying the underlying hardware implementation.</li></ul><p>Functionality:</p><ul><li>The module implements a basic barrel shifter behavior, allowing shifting of an 8-bit binary number either left or right by a specified number of bit positions (n), based on the value of Lr.</li></ul><p>The Verilog module “barrel_bh_tb” is a testbench designed to verify the functionality of the “barrel_bh” module, which implements a barrel shifter. Below is an explanation of the“barrel_bh_tb” module:</p><pre>module barrel_bh_tb;<br><br>  // Inputs<br>  reg [7:0] In;<br>  reg [2:0] n;<br>  reg Lr;<br><br>  // Outputs<br>  wire [7:0] Out;<br><br>  // Instantiate the Barrel Shifter Behavioral module<br>  barrel_bh dut(<br>    .Out(Out),<br>    .In(In),<br>    .n(n),<br>    .Lr(Lr)<br>  );<br><br>  // Stimulus<br>  initial begin<br>    // Initialize inputs<br>    In = 8&#39;b10101010;<br>    n = 3&#39;b001;<br>    Lr = 0;<br><br>    // Test case 1: Left shift<br>    #20;<br>    Lr = 1;<br>    #20;<br>    <br>    // Test case 2: Right shift<br>    n = 3&#39;b010;<br>    #20;<br>    Lr = 0;<br>    #20;<br>    <br>    // Test case 3: Another left shift<br>    n = 3&#39;b101;<br>    #20;<br>    Lr = 1;<br>    #20;<br>    <br>    // End simulation<br>    $finish;<br>  end<br><br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRmiUw94Z4lBSDFUgpOwSg.png" /><figcaption><strong>RTL Diagram of Barrel Shifter</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J2lbDHsBE5RGIO_Ebm5pPg.png" /><figcaption><strong>Waveform of Barrel Shifter</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c2a80d6a1d78" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[D Flip Flop (Behavioral) Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/d-flip-flop-behavioral-implementation-in-verilog-98743f876528?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/98743f876528</guid>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 19:11:33 GMT</pubDate>
            <atom:updated>2024-02-24T19:11:33.605Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>The given Verilog code defines a module named “d</em>_ff<em>” which implements the functionality of a D Flipflop. Here’s a breakdown of the module:</em></blockquote><pre>// D flip-flop<br>module d_ff(<br>    output reg q,<br>    input d,<br>    input rst_n,<br>    input clk<br>    );<br><br>    always @(posedge clk or negedge rst_n)<br> begin<br>        if (!rst_n)<br>        begin<br>            q &lt;= 0;<br>        end<br>        else<br>        begin<br>            q &lt;= d;<br>        end<br>    end<br>  <br>endmodule</pre><h4>Explanation:</h4><ul><li>The module is named d_ff.</li><li>It has four ports:</li><li>q (output): Represents the output of the D flip-flop.</li><li>d (input): Represents the input data.</li><li>rst_n (input): Represents the active low reset signal.</li><li>clk (input): Represents the clock signal.</li><li>Inside the module, there’s an always block that triggers on the positive edge of the clock (posedge clk) or the negative edge of the reset signal (negedge rst_n).</li><li>The always block uses an if-else construct to control the behavior of the flip-flop:</li><li>If the reset signal (rst_n) is low (active), the flip-flop resets (!rst_n evaluates to true):</li><li>In the reset condition (if (!rst_n)), the output q is forced to 0.</li><li>If the reset signal is not active (high), meaning rst_n is high:</li><li>The else block executes, and the output q is assigned the value of the input d.</li></ul><p>The Verilog module “d_ff_tb” is a testbench designed to verify the functionality of the “d_ff” module, which implements a D flipflop. Below is an explanation of the“d_ff_tb” module:</p><pre>module d_ff_tb;<br><br>    // Inputs<br>    reg d;<br>    reg rst_n;<br>    reg clk;<br><br>    // Outputs<br>    wire q;<br><br>    // Instantiate the D flip-flop module<br>    d_ff uut (<br>        .q(q),<br>        .d(d),<br>        .rst_n(rst_n),<br>        .clk(clk)<br>    );<br><br>    // Clock generation<br>    always #5 clk = ~clk;<br><br>    // Testbench initialization<br>    initial begin<br>        // Initialize inputs<br>        d = 0;<br>        rst_n = 0;<br>        clk = 0;<br><br>        // Reset de-assertion after some time<br>        #50 rst_n = 1;<br><br>        // Apply input d changes<br>        #10 d = 1;<br>        #20 d = 0;<br>        #30 d = 1;<br><br>        // End simulation<br>        #100 $finish;<br>    end<br><br>   <br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*olUSmAJxykxiA-_yrMWoEQ.png" /><figcaption><strong>RTL Diagram of D-Flip Flop</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6wcNukPM3h9co3z-KXtAjw.png" /><figcaption><strong>Waveform of D-Flip Flop</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=98743f876528" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[D-Latch(Behavioral) Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/d-latch-behavioral-implementation-in-verilog-0dc7a3414c85?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/0dc7a3414c85</guid>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Sat, 24 Feb 2024 16:32:46 GMT</pubDate>
            <atom:updated>2024-02-24T17:02:09.741Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>The given Verilog code defines a module named “dlatch_bh” which implements the functionality of an d-latch. Here’s a breakdown of the module:</blockquote><pre>/**************************************************<br> D-LATCH BEHAVIORAL<br>************************************************/<br>module dlatch_bh(q,d,clk);<br><br>output reg q;<br><br>input d,clk;<br><br>always @(clk,d)<br>begin<br> if (clk)<br>   q = d;<br>end<br><br>endmodule</pre><h4>Explanation:</h4><ul><li>module dlatch_bh(q, d, clk);: Declares a module named dlatch_bh with three ports: q (output), d (input), and clk (input).</li><li>output reg q;: Declares an output port.</li><li>input d, clk;: Declares two input ports d and clk, where d represents the data input to the D-Latch, and clk represents the clock input.</li><li>always @(clk, d): This line indicates that the block of code within the always construct will execute whenever there&#39;s a change in clk or d.</li><li>begin: Marks the beginning of the block of procedural statements within the always construct.</li><li>if (clk): This condition checks whether the clk signal is asserted (i.e., it is true, non-zero, or high).</li><li>q = d;: When the condition if (clk) is true, the value of q is updated with the value of d.</li><li>end: Marks the end of the always block.</li><li>endmodule: Marks the end of the module definition.</li></ul><p>The Verilog module “dlatch_bh_tb” is a testbench designed to verify the functionality of the “dlatch_bh” module, which implements a d-latch. Below is an explanation of the“dlatch_bh_tb” module:</p><pre>module dlatch_bh_tb;<br>    wire q;<br>    reg d;<br>    reg clk;<br>    dlatch_bh dut(.clk(clk),.d(d),.q(q));<br>    initial<br>    begin<br>        clk = 0;<br>        d = 0; #5;<br>        d = 1; #5;<br>        d = 0; #5;<br>        d = 1; #4;<br>        d = 0; #4;<br>        d = 1; #5;<br>        d = 0; #5;<br>        d = 0; #5;<br>        d = 1; #5;<br>        #60 $finish;<br>    end<br>    always #5 clk = ~clk;<br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8ReqEJ2lSQPRfIiovDBEiA.png" /><figcaption><strong>RTL Diagram of D-Latch</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5wxEH89pVSVODL6eFCLBmA.png" /><figcaption><strong>Waveform of D-Latch</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0dc7a3414c85" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JK Flip Flop (Behavioral) Implementation in Verilog]]></title>
            <link>https://medium.com/@raoumer160903/jk-flip-flop-behavioral-implementation-in-verilog-8610beb62dfe?source=rss-8959fd97c24b------2</link>
            <guid isPermaLink="false">https://medium.com/p/8610beb62dfe</guid>
            <dc:creator><![CDATA[RAO MUHAMMAD UMER]]></dc:creator>
            <pubDate>Fri, 23 Feb 2024 16:06:00 GMT</pubDate>
            <atom:updated>2024-02-23T16:06:00.712Z</atom:updated>
            <content:encoded><![CDATA[<p><em>The given Verilog code defines a module named “</em>jk_ff<em>” which implements the functionality of a JK Flipflop. Here’s a breakdown of the module:</em></p><pre>module jk_ff(<br>      output reg q,<br>      output reg qb,<br>      input j,<br>      input k,<br>      input clk<br>    );<br>    <br>      always @(posedge clk) begin<br>         // TRUTH TABLE OF JK FF<br>          if (j == 0 &amp;&amp; k == 0) <br>            begin<br>              q &lt;= q;<br>              qb &lt;= ~qb;<br>            end<br>            else if (j == 0 &amp;&amp; k == 1) <br>            begin<br>              q &lt;= 0;<br>              qb &lt;= 1;<br>            end<br>            else if (j == 1 &amp;&amp; k == 0) <br>            begin<br>              q &lt;= 1;<br>              qb &lt;= 0;<br>            end<br>            else if (j == 1 &amp;&amp; k == 1) <br>            begin<br>              q &lt;= ~q;<br>              qb &lt;= qb;<br>            end<br>      end<br><br>endmodule</pre><h4>Explanation:</h4><ul><li>output reg q, output reg qb, input j, input k, input clk;: Here, q and qb are the outputs representing the Q and Q-bar outputs of the flip-flop. j and k are the inputs representing the J and K inputs of the flip-flop clk is the clock input.</li><li>always @(posedge clk) begin: This line begins the always block, which means that the statements inside it will execute whenever there is a positive edge of the clock signal.</li><li>Inside the always @(posedge clk) block:</li><li>The code checks the values of j and k to determine the behavior of the flip-flop based on the JK flip-flop truth table.</li><li>If both j and k are 0, the flip-flop maintains its state (q &lt;= q) and the complemented output (qb &lt;= ~qb).</li><li>If j is 0 and k is 1, the flip-flop resets (q &lt;= 0) and its complement (qb &lt;= 1).</li><li>If j is 1 and k is 0, the flip-flop sets (q &lt;= 1) and its complement (qb &lt;= 0).</li><li>If both j and k are 1, the flip-flop toggles its state (q &lt;= ~q) and maintains its complemented output (qb &lt;= qb).</li></ul><p>The Verilog module “jk_ff_tb” is a testbench designed to verify the functionality of the “jk_ff” module, which implements a JK flipflop. Below is an explanation of the“jk_ff_tb” module:</p><pre>module jk_ff_tb;<br>    wire q;          // Output Q<br>    wire qb;         // Output Q-bar<br>    reg j;           // Input J<br>    reg k;           // Input K<br>    reg clk;         // Clock input<br><br>    jk_ff uut (q, qb, j, k, clk); // Instantiation of the JK flip-flop module<br><br>    initial begin<br>        j = 0;<br>        k = 0;<br>        clk = 0;<br>        #1000 $finish;  // Finishes simulation after 1000 time units<br>    end<br><br>    // Clock toggling process<br>    always #30 clk = ~clk;  // Toggles the clock every 30 time units<br><br>    // K input toggling process<br>    always #50 k = ~k;  // Toggles the K input every 50 time units<br><br>    // J input toggling process<br>    always #100 j = ~j;  // Toggles the J input every 100 time units<br><br>endmodule</pre><h4>RTL Viewer:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*frh9r3Nd0cpakK_GhSJYsA.png" /><figcaption><strong>RTL Diagram of JK Flip Flop</strong></figcaption></figure><h4>Simulation Waveform:</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nykqxgkB5aCJudtQPQ_LKg.png" /><figcaption><strong>Waveform of JK Flip Flop</strong></figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8610beb62dfe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>