INTEL VERILOG COURSE
INTEL VERILOG COURSE
-----------------------------MODULE 1: VERILOG
OVERVIEW-----------------------------
Verilog is a IEEE standard Hardware Description Language, a text based language
used to describe circuits (or model hardware) to be implemented in hardware.
- Used for simulation & synthesis
2. Structural modeling:
- A component is described by its interconnecting lower- level
components/primitives
- Both functionality & structure of circuit are described
- Particular hardware element are called out and wired together
> Register Transfer Level (RTL): A type of behavioral modeling that defines input &
output relationships in terms of dataflow operations inside hardware model.
RTL constructs are synthesizable
> Synthesis: the translation and optimization of HDL code into circuit.
> RTL Synthesis: translation of RTL model of hardware into an omptimized technology
specific gate level implementation
RTL SYNTHESIS:-
The synthesis engine translates code into hardware using architectural elements
of your target device. Then it is optimized to ensure you have the optimal
implementation of your circuit description. E.g.
//
always @(a, b, c, d, sel)
case (sel)
2'b00: mux_out = a;
2'b01: mux_out = b;
2'b10: mux_out = c;
2'b11: mux_out = d;
endcase
//
2. Simulation Flow: Using siumlators e.g. ModelSim, the simulation compiler will
simulate your Verilog model with stimulus provided by either a Verilog testbench
or through test vectors to output text or waveforms
> Most synthesis tools can also write out a post-synthesis Verilog file to check
the
synthesis results before place/routing. The output Verilog file from the synthesis
tool can replace the og Verilog files in the simulator. The same testbench and
test vectors can be used for verification.
> Additional simulation model files may be required depending on synthesis tool.
Can
be provided by synthesis vendor or generated by synthesis tool along with the
post-synthesis model.
-----------------------------MODULE 2: MODULE
STRUCTURE-----------------------------
-
endmodule
MODULE DECLARATION:
- provides module name
- includes port list, which contains all inputs, outputs and bi-directional
connections
to a module.
PORT DECLARATIONS:
- associates each port with a port type. There are 3 types:
1. input
2. output
3. inout (bi-directional ports)
- structure: port_type port_name;
- buses have a square brackets following port type with bus size:
port_type [bus:size] port_name; {where [MSB:LSB]}
- For example,
input [7:0] ina, inb; > are 8 bit inputs
input clk, aclr; > 1 bit inputs
output [15:0] out; > 16 bit output bus
DATA TYPES:
After port declaration, we declare data types.
There are 2 fundamental types of data in Verilog HDL:
1. Net data types: Nets represnt physical interconnects between processes or
functional
blocks. They need to be driven continuously and do not store value.
2. Variable data types: Used to temporarily store data. Similar to variables in
other
languages. They may be synthesized into hardware flip flops or registers or
combinatorial nodes depending on usage
EXAMPLE:
data_type [MSB:LSB] signal_type
- wire [7:0] out;
- tri enable
-- Variable data types can only be assigned within a procedure, task or function.
-- Cannot be driven using the continuous assignment statement: assign
-- Bus declarations can be made the same way as wires using reg, e.g.
reg [MSB:LSB] signal-name;
reg [LSB:MSB] signal-name;
reg [7:0] out;
integer count;
> INSTANTIATION:
-- instantiation is when a computer system creates a new context based on a pre-
existing
model or scheme, the model is said to have been instantiated.
-- the enscapulated context that results from this is an instance of the model
-- once a module is declared, it may be instantiated at a higher level module by
using:
<component_name> #<delay> <instance_name> (port_list);
1. By Ordered List:
- port connections defined by order of port list in lower-level module declaration
module half_adder (co, sum, a, b);
- order of port connection DOES matter (use for modules w/ few ports),
co -> c1, sum -> s1, a -> a, b -> b
2. By Name:
- port connections defined by name
- recommended method
- order of port connection DOES NOT matter
a -> s1, b -> cin, sum -> fsum, co -> c2
> PARAMETERS:-
-- Parameters can be used to have a value assigned to a symbolic name.
-- Using the keyword: parameter
-- You can base construct information like size and settings on the symbolic name
to
make code readable and meaningful.
-- Parameters must resolve to a constant at compile time, they cannot be changed
during module execution
-- Parameters can be floating point ("real parameter")
-- Parameters can be overwritten during compilation from a module intantiating the
module containing the parameters.
-- Exception to this: by defining a parameter as a local parameter using:
localparam - local parameter cannot be overwritten at compile time.
//
parameter size = 8; // size is parameter equal to 8
localparam outsize = 16; // local parametr having value 16
reg [size-1:0] dataa, datab;
reg [outsize-1:0] out
//
+For Verilog-2001 plus, you can declare variable along module declaration:
//
module mult_acc
#(parameter size = 8)
(....);
//
FORMAT OF NUMBER:
= size, tick, letter/letters for format, actual number
> NUMBERS:
-- For a negative number: specify a minus sign before the size or else error. E.g.,
-8'd3 = legal 8-bit negative number stored as 2's complement of 3
> EQUALITY
Also used to compare values, returning one-bit True (1) or False (0) value
- ==: equality
- !=: inequality
- ===: case equality
- !==: case inequality
Examples:
Here, ain = 3'b101; bin = 3'b110; c = 3'b01x;
- ain != bin gives 1'b1
- cin == cin gives 1'bx
- ain === bin gives 1'b0
- cin === 1'b1
EXAMPLE:
Here, ain = 3'b101; bin = 3'b000; c = 3'b01x;
- !ain gives 1'b10, !cin gives 1'bx and !bin gives 1'b1
- ain && bin gives 1'b0, bin && cin gives 1'bx
- ain || bin gives 1'b1, ain || cin gives 1'bx
- {{}} Replicate: takes one vector and replicates it a specified no. of times
EXAMPLE: {3{3'b101}} gives 9'b101101101
- Properties:
1. Left hand side must be a net data type (wire and tri)
2. Always active. When one RHS operands changes, expression is evaluated and
LHS net is updated immediately.
3. Continuous assignmetns can be made implicitly when net is declared. E.g.,
wire[15:0] adder_out = mult_out + out;
4. RHS can be net, register or function calls.
5. In simlation, delat values can be assigned to model gate delays. E.g.,
assign #5 adder_out = mlt_out + out
endmodule
//////////
2. Nonblocking:
//////////
initial
begin
a <= #5 b;
c <= #10 a;
end
//////////
Here, compiler schedules assignment of 'a' at timestep 5 then moves on to next,
which schedules assignment of 'c' at timestep 10. at timestep 5, 'a' gets the
value of 'b' and at timestep 10, 'c' gets evaluated to 'a'
EXAMPLE:
//////////
always a( posedge clk )
begin
x <= next_x;
y <= x;
end
//////////
Here, y gets the value of x first then x gets next_x. Thus it takes two clock
cycles
for next_x to get to y. Here two registers are inferred.
If it was a blocking statement, the transfer would occur in the same clock edge
so only one ff (1-bit flip-flop register) is inferred.
- Always block will only execute after change in any signal in the list.
- Sensitivity list can be further controlled by two keywords;
1. posedge - only positive edged transitions will trigger always block
2. negedge - only negative edged transitions will trigger always block
- Sensitivity list can be used to infer the two types of RTL processes:
1. Combinatorial Process: Sensitive to all inputs used in the logic. E.g.,
always @(a, b, sel)
always @* // * indicates all inputs
2. Clocked Process: Sensitive to clock or/and asynchronous control signals.
Does not include the d or ena inputs.
always @(posedge clk, negedge clr_n)