Introduction To FPGA and Verilog
Introduction To FPGA and Verilog
VHDL Verilog
Strongly typed Weakly typed
Easier to understand Less code to write
More natural in use More of a hardware modeling language
Wordy Succinct
Syntax
1. `timescale <time_unit>/<time_precision>
Character Unit
ns nanoseconds
ps picoseconds
fs Femtoseconds
Modelling styles in Verilog HDL.
A module can be designed in several ways using Verilog
HDL. There are
four types of abstraction levels, as per the designer
specifications;
▪ Switch level
▪ Gate level (Structural)
▪ Data flow
▪ Behavioral
Ex:-
module xyz(A,B,Y);
input A,B;
output Y;
nor N1(Y,A,B);
endmodule
Ex:-
module xyz(P, Q,R);
input P,Q;
output R;
reg R;
always @(P or Q)
begin
Y=~(P|Q);
end
endmodule
Behavioural Modelling …..cont.
module half_adder_structural (
input a, // Input 'a'
input b, // Input 'b'
output s, // Output 's' (Sum)
output c // Output 'c' (Carry)
);
xor gate_xor (s, a, b); // XOR gate for sum
and gate_and (c, a, b); // AND gate for carry
endmodule
Half Adder Using Verilog: Dataflow Method
module half_adder_dataflow (
input a, // Input 'a'
input b, // Input 'b'
output s, // Output 's' (Sum)
output c // Output 'c' (Carry)
);