two-ticks / verilog

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

microprocessor, the heart of computer

verilog-workflow

We can use any text-editor and any extension for setting up our verilog workflow. I am using Visual Studio Code with a verilog extension. We can use Model Simulator also.

example in vscode

file structure

├── half-adder
   ├── half-adder.v
   └── half-adder-tb.v

code

half-adder.v is main code

module halfadder(a,b,sum,carry);

    input a,b;
    output sum, carry;

    wire sum, carry;
    assign sum = a ^ b;      // sum bit  (a xor b)
    assign carry = (a & b) ; //carry bit

endmodule 

half-adder-tb.v is testbench

`timescale 1ns/1ns
`include "half-adder.v"

module half_adder_tb;
    reg a, b;
    wire sum, carry;

    halfadder uut(a,b,sum,carry);
  
    initial // initial block executes only once
    begin
        $dumpfile("half-adder-tb.vcd"); 
        $dumpvars(0, half_adder_tb); //dumps ALL the variables of tOP module and all the variables in ALL lower level modules instantiated by this top module
       
        a = 0; b = 0; #5;
        a = 0; b = 1; #5;
        a = 1; b = 0; #5;
        a = 1; b = 1; #5;
        
        $display("test is complete");
    end

endmodule

terminal

timing-diagram

reference

About


Languages

Language:Tcl 26.6%Language:Verilog 21.6%Language:JavaScript 17.0%Language:C 15.2%Language:HTML 8.5%Language:Shell 5.5%Language:Batchfile 3.2%Language:Python 1.9%Language:Pascal 0.3%Language:Assembly 0.1%Language:PureBasic 0.0%