Skip to Content
Verilog Coding for Logic Synthesis
book

Verilog Coding for Logic Synthesis

by Weng Fook Lee
April 2003
Intermediate to advanced
336 pages
6h 39m
English
Wiley-Interscience
Content preview from Verilog Coding for Logic Synthesis

Appendix

APPENDIX A.1 TWO-BIT BY TWO-BIT ADDER

Verilog code for a two-bit by two-bit adder:

module addition_2bit (inputA, inputB, outputA);

input [1:0] inputA, inputB;
output [2:0] outputA;

wire [2:0] outputA;

assign outputA = inputA + inputB;

endmodule

Verilog test bench to simulate the two-bit by two-bit adder:

module addition_2bit_tb ();

reg [1:0] reg_inputA, reg_inputB;
wire [2:0] wire_outputA;

integer i,j;

initial
begin
     for (i=0; i<4; i=i+1)
          begin
               reg_inputA = i;
for (j=0; j<4; j=j+1)
                begin
                         reg_inputB = j;
                         #10;
                    end
          end
end

addition_2bit addition_2bit_inst (.inputA(reg_inputA),
.inputB(reg_inputB), .outputA(wire_outputA));

initial
begin
     $monitor (“inputA %b%b inputB %b%b outputA
%b%b%b”, reg_inputA[1], reg_inputA[0], reg_inputB[1],
reg_inputB[0],
     wire_outputA[2], wire_outputA[1],
wire_outputA[0]);
end

endmodule

images

FIGURE A.1. Synthesized logic for the two-bit by two-bit adder.

Simulation results for simulating the two-bit by two-bit adder:

inputA 00 inputB 00 outputA 000 inputA 00 inputB 01 outputA 001 inputA 00 inputB 10 outputA 010 inputA 00 inputB 11 outputA 011 inputA 01 inputB 00 outputA 001 inputA 01 inputB 01 outputA 010 inputA 01 inputB 10 outputA 011 inputA 01 inputB 11 outputA 100 inputA 10 inputB 00 outputA 010 inputA 10 inputB 01 outputA 011 inputA 10 inputB 10 outputA 100 inputA 10 inputB 11 outputA 101 inputA 11 inputB 00 outputA 011 inputA 11 inputB 01 outputA ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

Design Recipes for FPGAs: Using Verilog and VHDL

Design Recipes for FPGAs: Using Verilog and VHDL

Peter Wilson
Rapid System Prototyping with FPGAs

Rapid System Prototyping with FPGAs

R. C. Cofer, Benjamin F. Harding

Publisher Resources

ISBN: 9780471429760Purchase book