introduction to digital design using verilogintroduction to digital design using verilog ee370...
TRANSCRIPT
![Page 1: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/1.jpg)
Introduction to Digital Design using Verilog
EE370Ashish Bhatia
![Page 2: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/2.jpg)
![Page 3: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/3.jpg)
What is Verilog?
models digital hardwareto what extent?
models digital hardwarecombinatoricsequential
use for synthesizing digital hardwarefpgaasic
![Page 4: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/4.jpg)
modeling digital hardware
to what extent?
![Page 5: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/5.jpg)
A CMOS inverter has nMOS transistor with L = 10 units, W = 20 units, Kn = 400 and pMOS transistor with L = 10 units, W=40 units, Kp = 400
Can Verilog model this?
![Page 6: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/6.jpg)
A CS amplifier has gain = -10 and cut-off freq = 20 MHz
Can Verilog model this?
![Page 7: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/7.jpg)
A spice generated netlist of resistors and capacitors
Can Verilog model this?
![Page 8: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/8.jpg)
An inverter with Tr = 1 ns, Tf = 500 ps and Tp = 800 ps
Can Verilog model this?
![Page 9: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/9.jpg)
Can Verilog model this?
A B F
0 0 0
0 1 1
1 0 1
1 1 0
![Page 10: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/10.jpg)
Can Verilog model this?
Q(n) X Q(n+1)
0 0 0
0 1 1
1 0 1
1 1 0
![Page 11: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/11.jpg)
modeling digital hardware
combinatoricsequential
![Page 12: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/12.jpg)
consider combinatoric first
![Page 13: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/13.jpg)
NOT Gate
module Not ( input wire x, output wire y);
assign y = ~x;
endmodule
![Page 14: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/14.jpg)
NOT Gate
module Not ( input wire x, output wire y);
assign y = ~x;
endmodule
![Page 15: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/15.jpg)
NOT Gate
module Not ( input wire x, output wire y);
assign y = ~x;
endmodule
![Page 16: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/16.jpg)
NOT Gate
module Not ( input wire x, output wire y);
assign y = ~x;
endmodule
![Page 17: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/17.jpg)
NOT Gate (of parallel bus)
module Not ( input wire [7:0] x, output wire [7:0] y);
assign y = ~x;
endmodule
![Page 18: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/18.jpg)
AND Gate
module And ( input wire x, input wire y output wire z);
assign z = x&y;
endmodule
![Page 19: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/19.jpg)
do Nand, Nor, Xor, Or gate yourself
![Page 20: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/20.jpg)
Hardware Abstraction
behavioralhighest level of abstractionfarthest from hardwareclosest to ideas (thinking)
dataflowhardware described in boolean (logic)
combinatoricsequential
structuralhardware described in terms of fundamental gates
![Page 21: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/21.jpg)
Let us analyze 1-bit adder for all three cases
![Page 22: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/22.jpg)
Behavioral design (adder)
module adder_b(in1, in2, sum, carry);
input wire in1, in2;output wire sum, carry;
assign {carry, sum} = in1 + in2; endmodule
![Page 23: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/23.jpg)
Behavioral design (adder)
module adder_b(in1, in2, sum, carry);
input wire in1, in2;output wire sum, carry;
assign {carry, sum} = in1 + in2; endmodule
Addition is a high level construct Verilog compiler will generate the code for addition
![Page 24: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/24.jpg)
DataFlow Design (adder)
module adder_d(in1, in2, sum, carry);
input wire in1, in2;output wire sum, carry;
assign sum = in1 ^ in2;assign carry = in1 & in2; endmodule
![Page 25: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/25.jpg)
DataFlow Design (adder)
module adder_d(in1, in2, sum, carry);
input wire in1, in2;output wire sum, carry;
assign sum = in1 ^ in2;assign carry = in1 & in2; endmodule
Boolean logic - more fundamental construct than addition
![Page 26: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/26.jpg)
Structural Design (adder)
module adder_s(in1, in2, sum, carry);
input wire in1, in2;output wire sum, carry;
and g0(carry,in1,in2);
xor g1(sum,in1,in2);
endmodule
![Page 27: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/27.jpg)
Structural Design (adder)
module adder_s(in1, in2, sum, carry);
input wire in1, in2;output wire sum, carry;
and g0(carry,in1,in2);
xor g1(sum,in1,in2);
endmoduleAssuming and and xor gates are available
![Page 28: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/28.jpg)
Structural Design (adder)
module adder_s(in1, in2, sum, carry);//Assume only NAND gates are available
input wire in1, in2;output wire sum, carry;wire signal1, signal2, signal3;//intermediate wires
nand n0 (signal1, in1, in2);nand n1 (carry, signal1, signal1);
nand n2 (signal2, in1, signal1);nand n3 (signal3, in2, signal1);nand n4 (sum, signal2, signal3);endmodule
Assuming only nand gates are available
![Page 29: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/29.jpg)
what about sequential elements?
![Page 30: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/30.jpg)
let us consider D F/F
![Page 31: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/31.jpg)
D F/F
module D_FF ( input wire clk, input wire d, output reg q ); always @(posedge clk) begin q <= #2 d; endendmodule
![Page 32: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/32.jpg)
D F/F
module D_FF ( input wire clk, //every sequential circuit element has a trigger input wire d, output reg q ); always @(posedge clk) begin q <= #2 d; endendmodule
![Page 33: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/33.jpg)
D F/F
module D_FF ( input wire clk, //every sequential circuit element has a trigger input wire d, output reg q //output need to be a register to hold the value ); always @(posedge clk) begin q <= #2 d;
endendmodule
![Page 34: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/34.jpg)
D F/F
module D_FF ( input wire clk, //every sequential circuit element has a trigger input wire d, output reg q //output need to be a register to hold the value ); always @(posedge clk) begin //posedge triggered q <= #2 d;
endendmodule
![Page 35: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/35.jpg)
D F/F
module D_FF ( input wire clk, //every sequential circuit element has a trigger input wire d, output reg q //output need to be a register to hold the value ); always @(posedge clk) begin //posedge triggered q <= #2 d; //2 units (propagation delay)
endendmodule
![Page 36: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/36.jpg)
D F/F
module D_FF ( input wire clk, //every sequential circuit element has a trigger input wire d, output reg q //output need to be a register to hold the value ); always @(posedge clk) begin //posedge triggered q <= #2 d; //2 units (propagation delay) //non-blocking assignment
endendmodule
![Page 37: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/37.jpg)
D F/F
module D_FF ( input wire clk, //every sequential circuit element has a trigger input wire d, output reg q //output need to be a register to hold the value ); always @(posedge clk) begin //posedge triggered q <= #2 d; //2 units (propagation delay) //non-blocking assignment //assuming setup and hold are not //violated endendmodule
![Page 38: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/38.jpg)
D F/F (with reset)module D_FF ( input wire clk, //every sequential circuit element has a trigger input wire d, input wire rst, output reg q ); always @(posedge clk or posedge rst) begin //posedge triggered if(rst == 1) q <= #2 1'b0; else q <= #2 d; //2 units (propagation delay) //non-blocking assignment //assuming setup and hold are not //violated endendmodule
![Page 39: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/39.jpg)
Will "reg" always correspond to reg in hardware?
![Page 40: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/40.jpg)
Consider 2x1 MUX
![Page 41: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/41.jpg)
2x1 MUX
module MUX_2_1 ( input wire a, input wire b, input wire sel output reg op);
always @(sel or a or b) begin if(sel) op = b; else op = a;end endmodule
![Page 42: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/42.jpg)
2x1 MUX
module MUX_2_1 ( input wire a, input wire b, input wire sel output reg op);
always @(sel or a or b) begin if(sel) op = b; else op = a;end endmodule
op will be implemented as wire only if 1) a and b both are in sensitivity list of always block 2) all possible cases are covered in if-else or switch
![Page 43: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/43.jpg)
2x1 MUX
module MUX_2_1 ( input wire a, input wire b, input wire sel output reg op);
always @(sel or a or b) begin if(sel) op = b; else op = a;end endmodule
op will be implemented as wire only if 1) a and b both are in sensitivity list of always block 2) all possible cases are covered in if-else or switch
This is behavioral model of 2-1 MUXwhat will be dataflow model?
![Page 44: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/44.jpg)
2x1 MUX (data flow model)
module MUX_2_1 ( input wire a, input wire b, input wire sel output wire op);
assign op = sel?b:a; endmodule
![Page 45: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/45.jpg)
4x1 MUX (data flow model)
module MUX_2_1 ( input wire a, input wire b, input wire c, input wire d, input wire sel[1:0], output wire op);
assign op = (sel[1]==1)?(sel[0]==1?d:c):(sel[0]==1?b:a); endmodule
A 32 operation ALU is like 32-1 MUX, try writing ternary operations for that :)
![Page 46: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/46.jpg)
4x1 MUX - behavioral model
module MUX_2_1 ( input wire a, input wire b, input wire c, input wire d, input wire sel[1:0], output reg op);
always @(sel or a or b or c or d) begin case(sel) 2'b00: op = a; 2'b01: op = b; 2'b10: op = c; 2'b11: op = d; endendmodule
![Page 47: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/47.jpg)
is wire (in verilog) always synthesized as wire?
![Page 48: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/48.jpg)
yes
![Page 49: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/49.jpg)
is reg (in verilog) always synthesized as reg?
![Page 50: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/50.jpg)
most of the times yes, but in some case if design permits,
optimization occurs
![Page 51: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/51.jpg)
Designing Test Benches
why?
![Page 52: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/52.jpg)
Consider XOR Gate
module XOR(input wire A, input wire B, output wire X); assign X = A^B; endmodule
![Page 53: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/53.jpg)
XOR Test Bench
module TB_XOR(); reg A, B; reg clk; wire X; XOR xor1(.A(A), .B(B), .X(X)); initial begin clk = 0; end initial begin forever clk = #5 ~clk; //clk with period = 10 end
always @(posedge clk) begin A<=0; B<=0; #5; A<=0; B<=1; #5; A<=1; B<=0; #5; A<=1; B<=1; end
endmodule
![Page 54: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/54.jpg)
Unsynthesizable Constructs
reg clk;
intial begin clk <= 0; forever clk = #10 ~clk; end
![Page 55: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/55.jpg)
Unsynthesizable Constructs
reg a = 1'bx;reg b = 1'bz;
x or X (uninitialized state)z or Z (high impedance state) - can be synthesized using tri-state buffers but not directly
![Page 56: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/56.jpg)
If they cannot be synthesizd why do we need them?
![Page 57: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/57.jpg)
Remember verilog is for1) Simulation2) FPGA based design3) ASIC based design
![Page 58: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/58.jpg)
Simulationunsynthesizable constructs are needed for simulation
![Page 59: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/59.jpg)
FPGA vs ASIC
Some constructs are synthesizable on FPGA but not ASIClike initial block requires explicit hardware implementation on ASIC
Timing failures In case of FPGA, compiler ensures proper floorplan to minimize such failuresIn ASIC, floorplan is manual, timing faliures are more probable
![Page 60: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/60.jpg)
Preprocessors
`define DELAY 2 //macro definition just like in C`include mylib.v //include just like in C`ifdef ENABLE_MY_CODE//my code goes here`endif
b <= `DELAY a;
![Page 61: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/61.jpg)
Misc
Open Drain Configall inputs low => output is highotherwise output is lowwor is use to model not of open drain config similarly wand models not of open collector config
![Page 62: Introduction to Digital Design using VerilogIntroduction to Digital Design using Verilog EE370 Ashish Bhatia. What is Verilog? models digital hardware to what extent? ... highest level](https://reader030.vdocuments.net/reader030/viewer/2022040302/5e7df7dd7cb53f26ff7b8d43/html5/thumbnails/62.jpg)
Good Reference Book: Verilog HDL by Palnitkar