<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Silicon Monks</title>
    <description>The latest articles on DEV Community by Silicon Monks (@silicon_monks).</description>
    <link>https://dev.to/silicon_monks</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3752089%2Fe7dc0a5d-9933-4fc0-ac76-f42839faed0a.png</url>
      <title>DEV Community: Silicon Monks</title>
      <link>https://dev.to/silicon_monks</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/silicon_monks"/>
    <language>en</language>
    <item>
      <title>2. Lexical Tokens</title>
      <dc:creator>Silicon Monks</dc:creator>
      <pubDate>Mon, 09 Feb 2026 11:36:21 +0000</pubDate>
      <link>https://dev.to/silicon_monks/2-lexical-tokens-59na</link>
      <guid>https://dev.to/silicon_monks/2-lexical-tokens-59na</guid>
      <description>&lt;p&gt;Verilog source text files consists of the following lexical tokens:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;White Space&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;White spaces separate words and can contain spaces, tabs, new-lines and form feeds. Thus a statement can extend over multiple lines without special continuation characters.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Comments&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Comments can be specified in two ways ( exactly the same way as in &lt;code&gt;C/C++&lt;/code&gt; ):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Begin the comment with double slashes (&lt;code&gt;//&lt;/code&gt;). All text between these characters and the end of the line will be ignored by the Verilog compiler.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Enclose comments between the characters &lt;code&gt;/* and */&lt;/code&gt;. Using this method allows you to continue comments on more than one line. This is good for “commenting out” many lines code, or for very brief in-line comments.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a = c + d; // this is a simple single line comment
/* however, this comment continues on more
than one line this is multiline comment */
assign y = temp_reg;
assign x=ABC /* plus its compliment*/ + ABC_
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Numbers&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Number storage is defined as a number of bits, but values can be specified in binary, octal, decimal or hexadecimal.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;3’b001, a 3-bit number 
5’d30,    (=5’b11110)
16‘h5ED4, (=16’d24276)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reg [15:0] x = 16'h9678

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>verilog</category>
      <category>digital</category>
      <category>vlsi</category>
      <category>rtl</category>
    </item>
    <item>
      <title>1. Introduction to Verilog</title>
      <dc:creator>Silicon Monks</dc:creator>
      <pubDate>Wed, 04 Feb 2026 07:26:43 +0000</pubDate>
      <link>https://dev.to/silicon_monks/getting-started-with-verilog-e4c</link>
      <guid>https://dev.to/silicon_monks/getting-started-with-verilog-e4c</guid>
      <description>&lt;p&gt;Verilog HDL is one of the two most common Hardware Description Languages (HDL) used by integrated circuit(IC) designers. The other one is VHDL.&lt;br&gt;
HDL’s allows the design to be simulated earlier in the design cycle in order to correct errors or experiment with different architectures. Designs described in HDL are technology-independent, easy to design and debug, and are usually more readable than schematics, particularly for large circuits. &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Verilog can be used to describe designs at four levels of abstraction:&lt;/strong&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(i) Algorithmic level (much like c code with if, case and loop statements).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(ii) Register transfer level (RTL uses registers connected by Boolean equations).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(iii) Gate level (interconnected AND, NOR etc.).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;(iv) Switch level (the switches are MOS transistors inside gates).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The language also defines constructs that can be used to control the input and output of simulation.&lt;/p&gt;

&lt;p&gt;More recently Verilog is used as an input for synthesis programs which will generate a gate-level description (a&lt;br&gt;
netlist) for the circuit. Some Verilog constructs are not synthesizable. Also the way the code is written will greatly effect the size and speed of the synthesized circuit. &lt;br&gt;
Most readers will want to synthesize their circuits, so non-synthesizable constructs should be used only for test benches. &lt;/p&gt;

&lt;p&gt;These are program modules used to generate I/O needed to simulate the rest of the design. &lt;br&gt;
The words “not synthesizable” will be used for examples and constructs as needed that do not synthesize.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;There are two types of code in most HDLs:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structural, which is a verbal wiring diagram without storage.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;assign a=b &amp;amp; c | d; /* “|” is a OR */
assign d = e &amp;amp; (~c);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Here the order of the statements does not matter. Changing &lt;code&gt;e&lt;/code&gt; will change &lt;code&gt;a&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Procedural which is used for circuits with storage, or as a convenient way to write conditional logic.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;always @(posedge clk) // Execute the next statement on every rising clock edge.
count &amp;lt;= count+1;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Procedural code is written like c code and assumes every assignment is stored in memory until over written. For synthesis, with flip-flop storage, this type of thinking generates too much storage. However people prefer procedural code because it is usually much easier to write, for example, if and case statements are only allowed in procedural&lt;br&gt;
code. &lt;/p&gt;

&lt;p&gt;As a result, the synthesizers have been constructed which can recognize certain styles of procedural code as actually combinational. &lt;/p&gt;

&lt;p&gt;They generate a flip-flop only for left-hand variables which truly need to be stored. However if you stray from this style, beware. Your synthesis will start to fill with superfluous latches.&lt;/p&gt;

&lt;p&gt;This manual introduces the basic and most common Verilog behavioral and gate-level modelling constructs, as well as Verilog compiler directives and system functions. Full description of the language can be found in Cadence Verilog-XL Reference Manual and Synopsys HDL Compiler for Verilog Reference Manual. &lt;/p&gt;

&lt;p&gt;The latter emphasizes only those Verilog constructs that are supported for synthesis by the Synopsys Design Compiler synthesis tool.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verilog HDL: Syntax and Modeling Styles Explained Clearly&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Verilog is one of the most widely used Hardware Description Languages (HDLs) in digital design. It allows you to describe hardware behavior and structure at multiple abstraction levels, from simple logic gates to complete processors.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This post focuses on two things:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Core Verilog syntax you must understand&lt;/li&gt;
&lt;li&gt;The three main modeling styles used in real designs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you are coming from a software background, think of Verilog as a way to describe hardware behavior over time, not a program that runs line by line.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;What is Verilog?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Verilog is used to model digital systems such as:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Combinational logic&lt;/li&gt;
&lt;li&gt;Sequential logic&lt;/li&gt;
&lt;li&gt;Finite state machines&lt;/li&gt;
&lt;li&gt;Complete SoCs and ASIC designs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Verilog code can be:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simulated to verify functionality&lt;/li&gt;
&lt;li&gt;Synthesized to generate real hardware&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Basic Verilog Program Structure&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Every Verilog design is built using modules.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module example_module (
    input wire a,
    input wire b,
    output wire y
);
    assign y = a &amp;amp; b;
endmodule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Key points:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;module and endmodule define a hardware block&lt;/li&gt;
&lt;li&gt;Inputs and outputs describe the interface&lt;/li&gt;
&lt;li&gt;Internal logic describes how outputs depend on inputs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Common Data Types&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- Wire&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used for continuous connections.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wire sum;
assign sum = a ^ b;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;- Reg&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used to store values inside procedural blocks.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;reg q;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Despite the name, reg does not always mean a flip-flop. It simply means the signal is assigned inside an always block.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Operators You’ll Use Often&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;- Arithmetic         + - * /
- Logical            &amp;amp;&amp;amp;
- Bitwise            &amp;amp;
- Comparison         == != &amp;lt; &amp;gt;
- Assignment         = (blocking), &amp;lt;= (non-blocking)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Verilog Modeling Styles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Verilog supports three main modeling styles. Choosing the right one depends on what you are designing and how abstract you want the description to be.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Behavioral Modeling&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Behavioral modeling focuses on what the circuit does, not how it is built.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;- Example: 2:1 multiplexer&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module mux2_behavioral (
    input wire a,
    input wire b,
    input wire sel,
    output reg y
);
    always @(*) begin
        if (sel)
            y = b;
        else
            y = a;
    end
endmodule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Characteristics:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses always blocks&lt;/li&gt;
&lt;li&gt;Easy to read and write&lt;/li&gt;
&lt;li&gt;Ideal for control logic and FSMs&lt;/li&gt;
&lt;li&gt;Synthesizable when written carefully&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;2. Dataflow Modeling&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Dataflow modeling describes logic using continuous assignments and expressions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;- Example: Full adder&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module full_adder_dataflow (
    input wire a,
    input wire b,
    input wire cin,
    output wire sum,
    output wire cout
);
    assign sum  = a ^ b ^ cin;
    assign cout = (a &amp;amp; b) | (b &amp;amp; cin) | (a &amp;amp; cin);
endmodule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Characteristics:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses assign statements&lt;/li&gt;
&lt;li&gt;Very close to Boolean equations&lt;/li&gt;
&lt;li&gt;Best for combinational logic&lt;/li&gt;
&lt;li&gt;Simple and concise&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;3. Structural Modeling&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structural modeling connects lower-level modules together, similar to a schematic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;- Example: Full adder using two half adders&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module half_adder (
    input wire a,
    input wire b,
    output wire sum,
    output wire carry
);
    assign sum   = a ^ b;
    assign carry = a &amp;amp; b;
endmodule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module full_adder_structural (
    input wire a,
    input wire b,
    input wire cin,
    output wire sum,
    output wire cout
);
    wire s1, c1, c2;

    half_adder ha1 (a, b, s1, c1);
    half_adder ha2 (s1, cin, sum, c2);

    assign cout = c1 | c2;
endmodule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Characteristics:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hierarchical design&lt;/li&gt;
&lt;li&gt;Mirrors real hardware connections&lt;/li&gt;
&lt;li&gt;Common in large designs&lt;/li&gt;
&lt;li&gt;Improves reusability and clarity&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;4. Gate-level Modeling&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Gate-leve modeling uses Verilog primitives as shown in the below example.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;- Example: half adder&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module half_adder (
    input wire a,
    input wire b,
    output wire sum,
    output wire carry
);
    xor (sum, a, b);
    and (carry, a, b);    
endmodule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Characteristics:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;gate-level design&lt;/li&gt;
&lt;li&gt;very complex to code for big designs&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Blocking vs Non-Blocking Assignments
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;This is critical in Verilog.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- Blocking (=)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used for combinational logic.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;always @(*) begin
    x = a &amp;amp; b;
    y = x | c;
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;- Non-blocking (&amp;lt;=)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used for sequential logic.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;always @(posedge clk) begin
    q &amp;lt;= d;
end
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;- Rule of thumb:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use = in combinational logic&lt;/li&gt;
&lt;li&gt;Use &amp;lt;= in clocked logic&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Modeling Sequential Logic&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;- Example: D flip-flop with active-low reset&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;module dff (
    input wire clk,
    input wire rst,
    input wire d,
    output reg q
);
    always @(posedge clk or posedge rst) begin
        if (!rst)
            q &amp;lt;= 1'b0;
        else
            q &amp;lt;= d;
    end
endmodule
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;This style is synthesizable and maps directly to hardware flip-flops.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;When to Use Each Modeling Style&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Behavioral modeling&lt;/strong&gt; is best for control logic and finite state machines, where the focus is on describing how the circuit behaves rather than how it is physically built. It is easier to read and maintain, especially for complex decision-making logic.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Dataflow modeling&lt;/strong&gt; is ideal for combinational logic. It closely matches Boolean equations and is commonly used for arithmetic circuits, multiplexers, and simple logic blocks where outputs are directly derived from inputs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Structural modeling&lt;/strong&gt; is used for large, hierarchical designs. It connects smaller modules together to form bigger systems and closely reflects actual hardware structure, making it suitable for reusable and scalable designs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Gate-level modeling&lt;/strong&gt; is mainly used for demonstration and learning purposes. It is not used in large or modern designs. This style is written using Verilog gate primitives, which makes the code verbose and difficult to manage. As a result, it is not suitable for building reusable or scalable designs.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;In real projects, you will often mix of three styles(Behavioral, Dataflow, Structural) in the same design.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Final Thoughts&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Verilog is powerful because it lets you model hardware at different abstraction levels. Understanding syntax is important, but mastering modeling styles is what makes your designs clean, scalable, and synthesizable.&lt;/p&gt;

</description>
      <category>verilog</category>
      <category>vlsi</category>
      <category>rtldesign</category>
      <category>digital</category>
    </item>
  </channel>
</rss>
