Professional Documents
Culture Documents
Observations:
With three inputs and three states for each input (0, 1, and x),
the full table of definition has 27 entries. Such definitions
become cumbersome as the number of inputs increase to even
moderate values say 4 or 5.
Only the entries essential to the definition of the primitive are
included here. Others which lead to x output are left out
intentionally. Thus with the carry primitive if any two inputs
have x values, the output car_o too has x value. Hence such a
row has not been specified.
? and b have been used in the primitive definition to make
the tables more compact
Sequential UDPs
Two examples of sequential UDPs are considered here one being
level-sensitive and the other edge-sensitive.
A UDP for a D Latch
The three rows of the table signify the following:
1. When clk = 1, if din = 0, the next state (qn) is also at 0 whatever
be the value of present state (qp).
2. When clk = 1, if din = 1, the next state (qn) is also at 1 whatever
be the value of present state (qp).
3. When clk = 0, the output (next state) does not change even if
din changes.
Symbol Significance Restrictions of use
B or b 0 and 1 values Only in the input or current state fields
? 0, 1 or ,x value Only in the input or current state fields
No change Only in the output field of sequential UDP(mn)
Change of value from m to n
Only in the input field. m & n can be 0, 1, x, b, or ?
* Same as (??)
r Same as (01)
f Same as (10)
p Rise from 0 or x to x or 1
n Fall from 1 or x to x or 0
Only in the input field
primitive dlatch(q,din,clk);
output q; input din,clk; reg q;
table
// din clk qp qn
0 1 : ? : 0; // If clk is at 1 state, the output
1 1 : ? : 1; //follows the input. If clk is at 0
? 0 : ? : -; // state, the output remains frozen
endtable
endprimitive
module dlatch_tst;
wire q; reg din,clk;
dlatch ll(q,din,clk);
initial
begin
clk=1'b1;din=1'b0;
repeat (2) begin #4 din=1'b1; #4 din=1'b0; end
clk=1'b0;
repeat (2) begin #4 din=1'b1; #4 din=1'b0; end
$stop;
end
initial $monitor($time ,"clk = %b, din = %b, q = %b
",clk,din,q);
endmodule
Result:
# 0clk = 1, din = 0, q = 0 # 16clk = 0, din = 0, q = 0
# 4clk = 1, din = 1, q = 1 # 20clk = 0, din = 1, q = 0
# 8clk = 1, din = 0, q = 0 # 24clk = 0, din = 0, q = 0
# 12clk = 1, din = 1, q = 1 # 28clk = 0, din = 1, q = 0