P. 1
Wiley .Verilog.coding.for.Logic.synthesis.(2003)

Wiley .Verilog.coding.for.Logic.synthesis.(2003)

|Views: 15,967|Likes:
Published by Berba Chuot
verilog for fun
verilog for fun

More info:

Published by: Berba Chuot on May 18, 2011
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

06/02/2013

pdf

text

original

module addition (inputA, inputB, outputA);

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

wire [1:0] outputA;

assign outputA = inputA + inputB;

endmodule

Figure 4.20 shows a diagram of the synthesized logic module “addition”in
Example 4.25.

Example 4.26 is a Verilog test bench that can be used to simulate the Verilog
code of module “addition.”The simulation results are shown in Example 4.27.

Example 4.26Verilog Test Bench to Simulate Verilog Code for
Module “addition

module addition_tb ();

reg reg_inputA, reg_inputB;

VERILOG OPERATORS

79

inputA

inputB

outputA(0)

outputA(1:0)

outputA(1)

Figure 4.20.Diagram showing synthesized logic for module “addition.”

wire [1:0] wire_outputA;

integer i,j;

initial
begin

for (i=0; i<2; i=i+1)
begin

reg_inputA = i;
for (j=0; j<2; j=j+1)
begin

reg_inputB = j;
#10;

end

end

end

addition addition_inst (.inputA(reg_inputA),
.inputB(reg_inputB), .outputA(wire_outputA));

initial
begin

$monitor ("inputA %b inputB %b outputA %b%b",
reg_inputA, reg_inputB, wire_outputA[1],
wire_outputA[0]);
end

endmodule

Example 4.27Simulation Results for Verilog Test Bench Module
addition_tb

inputA 0 inputB 0 outputA 00
inputA 0 inputB 1 outputA 01
inputA 1 inputB 0 outputA 01
inputA 1 inputB 1 outputA 10

Appendix A.1 shows the Verilog code for a two-bit by two-bit adder design
that uses an addition operator.It also includes a Verilog test bench,simula-
tion results,and the synthesized logic circuit.

4.8.4.2 Subtraction operatorAs the name implies,the subtraction
operator allows a subtract operation.It is coded in Verilog by using the
symbol “-”.

80

CODING STYLE: BEST-KNOWN METHOD FOR SYNTHESIS

You're Reading a Free Preview

Download
scribd
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->