Академический Документы
Профессиональный Документы
Культура Документы
Testing (HLDDT)
Course Content
• VHDL Primer
– J Bhasker
• VHDL
– Douglas Perry
• External - 50 Marks
• Note :
No retest will be given.
RTL Description
Functional verification
Logic Synthesis
Logical Verification
Floorplanning Automatic PR
Physical Layout
Layout Verification
Implementation
always @( fetch_done)
begin
casez ( IR [7:6] )
Algorithmic 2’ b00 : LDA (acc, IR[ 5:0 ] );
2’ b01 : STR (acc, IR [ 5:0 ] );
Increasing 2’ b10 : JMP (IR [ 5:0 ] );
level of 2’ b11 : ; / / NOP
abstraction endcase
end
behavioral
Gate (non-structural)
gate/switch
(structural)
Switch
Graphical Specification
Specification Textual
Description of the system design
Tables
Behavioural System Design
VHDL System design
Validation Modeling system behaviour
Variable declarations
Assignments
Lower level module instantiation
Initial and always block
Tasks and functions (Body)
endmodule
In_1 Sum
In_2
1-bit
full-adder
C_In Carry
carry = (in_1 and in2) or (in_2 and c_in) or (in_1 and c_in)
endmodule
endmodule
• Data Types
• Tabs - \t
• Newline - \n
• Comments
– One line comments - //
– Multiple line comments - /* */
• Three types
– Unary operator ( a = ~b )
Example
12’h13x
//12-bit hex number; last 4 bit
Unknown value -X // unknown value
32’bz
//32-bit binary number
// 32 bit “z”
Example
• Identifiers
– Identifiers are names assigned to modules, signals, variables..
– They must begin with an alphabetic character or underscore
– Example:
• addbit, sum, a$b, _multi etc
Example
\a + b +c
\ ** my name **
– system1
– 1reg
– $latch
– exec$
Syntax
reg register_name;
• Gate Types
• Gate Delay
in1 in1
out out
in2 in2
and 0 1 x z nand 0 1 x z
0 0 0 0 0 0 1 1 1 1
1 0 1 x x 1 1 0 x x
x 0 x x x x 1 x x x
z 0 x x x z 1 x x x
in1 in1
out out
in2 in2
or 0 1 x z nor 0 1 x z
0 0 1 x x 0 1 0 x x
1 1 1 1 1 1 0 0 0 0
x x 1 x x x x 0 x x
z x 1 x x z x 0 x x
in1 in1
out out
in2 in2
xor 0 1 x z xnor 0 1 x z
0 0 1 x x 0 1 0 x x
1 1 0 x x 1 0 1 x x
x x x x x x x x x x
z x x x x z x x x x
In 0 1 x z
buffer input output
out 0 1 x x
control
bufif1 0 1 x z
0 z 0 L L
1 z 1 H H bufif1 input output
input x z x x x
z z x x x
control
control
bufif0 0 1 x z
0 0 z L L
input output
1 1 z H H bufif0
input
x x z x x
z x z x x control
In 0 1 x z
not input output
out 1 0 x x
control
notif1 0 1 x z
0 z 1 H H
1 z 0 L L notif1 input output
input x z x X x
z z x x x
control
control
notif0 0 1 x z
0 1 z H H
input output
1 0 z L L notif0
input
x x z x x
z x z x x control
0 0 z L L
data pmos
1 1 z H H
x x z x x control
z z z z z
control
nmos 0 1 x z data out
0 z 0 L L
1 z 1 H H nmos
data
x z x X x control
z z z z z
• Turn-off delay
1, x or z
0, x or z
rise_time fall_time
Turn-off Delay
Gate output transition to the high impedance value from
another value
0, 1 or x z
Example
and #(2:3:4, 3:4:5, 5:6:7) a3 (out, in1, in2)
#10 out = in1 & in2; out = #10 in1 & in2;
• Continuous Assignment
– Implicit Continuous Assignment
• Delays
– Regular Assignment Delay
– Implicit Continuous Assignment Delay
– Net Declaration Delay
in1
in2
out
10 20 30 60 70 80 85
//Net Delays
wire #10 out;
assign out = in1 & in2;
endmodule
always
#10 clock = ~clock;
initial
#1000 $finish;
endmodule
• Syntax
<assignment>
::= <lvalue> = <expression>
• RHS has more bits than the LHS, then MSB is truncated
• RHS has fewer bits than the LHS, then MSB is padded with
Zeros
// same as above
Initial
begin
x = 0; z = 0;
temp_xz = x + z;
#5 y = temp_xz;
end
Initial
begin
#0 x = 0; The
Theorder
orderofofexecution
executionisisnot
notdeterministic
deterministic
#0 z = 0;
end
Event
Eventcontrol
control
@ (clock) q = d;
@ (posedge clock) q = d;
@ (negedge clock) q = d;
q = @(posedege clock) d;
always @(received_data)
always
wait (clock) Level
Levelsensitive
sensitiveevent
event
count = count + 1;
If statement construct
If (<expression>) true_statement1;
else if true_statement2;
else if true_statement3;
else default_statement;
case (<expression>)
Alternative1: statement1;
Alternative2: statement2;
Alternative3: statement3;
-----
-----
default: default_statement;
end case
Casex statement
Treats all “x” & “z” values in the case item as don’t cares
while expression
begin
statement1
statement2
statement3
end
initial
begin
count = 0;
while (count <128)
begin
count = count + 1;
end
end
Note:
In case of variable or signal, it is evaluated only when
the loop starts and not during the loop execution
count = 0;
repeat(128)
begin
count = count + 1;
end
initial initial
begin begin
x = 1’b0; x = 1’b0;
y = 1’b1; #5 y = 1’b1;
z = {x, y}; #10 z = {x, y};
w = {x, y}; #20 w = {x, y};
end end
initial
fork
x = 1’b0;
#5 y = 1’b1;
#10 z = {x, y};
#20 w = {x, y};
join
initial Nesting
Nestingofofsequential
sequential&¶llel
parallelblocks
blocks
begin
x = 1’b0;
fork
#5 y = 1’b1;
#10 z = {x, y};
join
#20 w = {x, y};
end
initial
sequential
sequentialblocks
blocks
begin: block1
Integer
Integerisisstatic
static&&local
localtotoblock
block11
integer i; Can
Canbe
beaccessed
accessedby byhierarchical
hierarchicalname,
name,top.block1.i
top.block1.i
----
----
end
parallel
parallelblocks
blocks
initial
register
registerisisstatic
static&&local
localto
toblock
block22
fork: block2 Can
Canbe
beaccessed
accessedby byhierarchical
hierarchicalname,
name,top.block2.i
top.block2.i
reg i;
-----
-----
join
Example
Flag = 8’b 0010_0000;
i = 0;
begin: block1
while (I<8)
begin
if (flag[I])
begin
$display(“encountered the TRUE condition”)
disable block1;
end
I = I +1;
end
Functions must not contain any Tasks may contain delays, event, or
delays, event, or timing control timing control statements
statements
Functions must have at least one Tasks may have zero or more arguments
input arguments. They can have of type input, output or inout
more than one input
Functions always return a single Tasks do not return with a value but
value. They cannot have output or can pass multiple values through output
input arguments & inout arguments
always @(rst)
begin
if (rst) Assigns
assign q = 1’b0; Assignsthe
thevalue
valueofofqq==00&&qbar
qbar==11
assign qbar =1’b1;
irrespective
irrespectiveofofvalue
valueofofqq&&qbar
qbar
else
deassign q;
deassign qbar;
end
end module
module top;
defparam w1.id_num = 1, w2.id_num = 2;
hello_world w1 ();
hello_world w2 ();
endmodule