Verilog Modeling for Digital Logic Gates
In This post will walk you through the Verilog code for modeling various digital logic gates, covering level, data flow, and behavioral styles. Each gate will also include its CMOS representation and a truth table for better understanding.
1. NOT Gate
Gate Level Modeling:
module not_gate_level_modelling(y, a);
output y;
input a;
not x1(y, a);
endmodule
Data Flow Modeling:
module not_data_flow_modelling(y, a);
output y;
input a;
assign y = ~a;
endmodule
Behavioral Modeling:
module not_behavioural_modelling(y, a);
output y;
input a;
reg y;
always @(a)
y = ~a;
endmodule
CMOS Representation:
2. AND Gate
Truth Table:
Gate Level Modeling:
module and_gate_level_modelling(y, a, b);
output y;
input a, b;
and x1(y, a, b);
endmodule
Data Flow Modeling:
module and_data_flow_modelling(y, a, b);
output y;
input a, b;
assign y = a & b;
endmodule
Behavioral Modeling:
module and_behavioural_modelling(y, a, b);
output y;
input a, b;
reg y;
always @(a or b)
y = a & b;
endmodule
CMOS Representation:
3. OR Gate
Truth Table:
Gate Level Modeling:
module or_gate_level_modelling(y, a, b);
output y;
input a, b;
or x1(y, a, b);
endmodule
Data Flow Modeling:
module or_data_flow_modelling(y, a, b);
output y;
input a, b;
assign y = a | b;
endmodule
Behavioral Modeling:
module or_behavioural_modelling(y, a, b);
output y;
input a, b;
reg y;
always @(a or b)
y = a | b;
endmodule
CMOS Representation:
4. NAND Gate
Truth Table:
Gate Level Modeling:
module nand_gate_level_modelling(y, a, b);
output y;
input a, b;
nand x1(y, a, b);
endmodule
Data Flow Modeling:
module nand_data_flow_modelling(y, a, b);
output y;
input a, b;
assign y = ~(a & b);
endmodule
Behavioral Modeling:
module nand_behavioural_modelling(y, a, b);
output y;
input a, b;
reg y;
always @(a or b)
y = ~(a & b);
endmodule
CMOS Representation:
5. NOR Gate
Truth Table:
Gate Level Modeling:
module nor_gate_level_modelling(y, a, b);
output y;
input a, b;
nor x1(y, a, b);
endmodule
Data Flow Modeling:
module nor_data_flow_modelling(y, a, b);
output y;
input a, b;
assign y = ~(a | b);
endmodule
Behavioral Modeling:
module nor_behavioural_modelling(y, a, b);
output y;
input a, b;
reg y;
always @(a or b)
y = ~(a | b);
endmodule
CMOS Representation:
6. XOR Gate
Truth Table:
Gate Level Modeling:
module xor_gate_level_modelling(y, a, b);
output y;
input a, b;
xor x1(y, a, b);
endmodule
Data Flow Modeling:
module xor_data_flow_modelling(y, a, b);
output y;
input a, b;
assign y = a ^ b;
endmodule
Behavioral Modeling:
module xor_behavioural_modelling(y, a, b);
output y;
input a, b;
reg y;
always @(a or b)
y = a ^ b;
endmodule
CMOS Representation: [CMOS XOR Image]
7. XNOR Gate
Truth Table:
Gate Level Modeling:
module xnor_gate_level_modelling(y, a, b);
output y;
input a, b;
xnor x1(y, a, b);
endmodule
Data Flow Modeling:
module xnor_data_flow_modelling(y, a, b);
output y;
input a, b;
assign y = ~(a ^ b);
endmodule
Behavioral Modeling:
module xnor_behavioural_modelling(y, a, b);
output y;
input a, b;
reg y;
always @(a or b)
y = ~(a ^ b);
endmodule
CMOS Representation: [CMOS XNOR Image]
Follow for More Updates:
-
YouTube: T Maharshi Sanand Yadav
-
GitHub: T-Maharshi-Sanand-Yadav/scripts