if (count == 8) begin //for 8 clocks we continue to stay in S_ADDR state only
next_state = S_ADDR_ACK;
count = 0;
end
end
S_ADDR_ACK : begin
master_driving_sda_f = 0; //slave will be drivign SDA pin at this point, master will be in sampling mode
scl_gated_f = 0; //Clock is running now
if (sda == 0) begin
$display(“Slave has acknowledged the address phase”);
end
if (sda == 1) begin
$display(“ERROR : Slave has not acknowledged the address phase”);
end
next_state = S_IDLE_BW_ADDR_DATA;
end
S_IDLE_BW_ADDR_DATA : begin
master_driving_sda_f = 1;
scl_gated_f = 1; //Clock is running now
count = count + 1;
if (count == 4) begin //for 8 clocks we continue to stay in S_ADDR state only
next_state = S_DATA;
count = 0;
end
End
End
Fork join
What time below display will happen?
Sequential execution
Statements run one after other.
Ex: task run();
#5 $display(“ENTRY 1”); //what time print will happen?
#2 $display(“ENTRY 2”); //
#5 $display(“ENTRY 3”); //
endtask
Concurrent execution
Statements run concurrently.
task run();
fork //all the statement inside will run concurrently
#5 $display(“ENTRY 1”); //
#2 $display(“ENTRY 2”); //
#5 $display(“ENTRY 3”); //
join
endtask
Continuous assignment
Write two example codes of any continuous assignments.
Write two example codes of any procedural statements.
What is wrong with below code?
initial begin
assign a = b+c; //Wrong: continuous assignments can’t be written inside initial
end
What is wrong with below code?
initial begin
initial begin
a = 10;
end
end
What is wrong with below code?
initial begin
always @(b) begin
a = b;
end
end
What is wrong with below code?
initial begin
task add();
endtask
end
However calling add inside initial is allowed
What is wrong with below code?
initial begin
and g1(a, b, c);
end
Write a simple continuous assignment-based example to prove that order in which we write continuous assignment statements does not impact the output of the design.
Implement 4×1 Mux using gate level.
Truth table, Kmaps, Boolean expression
List down various procedural blocks in Verilog
What time below initial statements will complete.
module sample;
initial begin//this will start at 0 simulation time
$display(“%t : ENTRY-1”, $time); //
end
initial begin //this will start at 0 simulation time, end at 60 units.
#50;
$display(“%t: ENTRY-2”, $time); //Executes at 50 time
#10;
end
initial begin
fork
#5 $display(“ENTRY 1”); //5
#2 $display(“ENTRY 2”); //2
#5 $display(“ENTRY 3”); //5
join
end
endmodule
Synthesis examples : what circuit below codes will infer and draw the circuit.
Q1
always @(posedge clk) begin //this will infer sequential logic => Flip flops
{co, s} = a + b + cin;
end
Q2
always @(a or b or cin) begin
{co, s} = a + b + cin;
End
Q3 : How many FF does below circuit synthesize to?
always @(posedge clk) begin
a = b+c; //a : 4 bit vector, b, c : 6 bit vector
end
Is above logic combinational or sequential?
How many FFs?
What is the significance of below sensitivity list.
Q1
always @(signal1 or signal2) begin
..
end
Q2
always @(posedge signal1 or posedge signal2) begin
..
end
What does Q1 would infer, Q2 would infer?
Combinational or sequential?
Below code what all times, ENTRY-1 and ENTRY-2 displays will happen?
module tb;
reg clk;
initial begin
clk = 0;
forever #5 clk = ~clk; //TP=10 tu
end
always @(posedge clk) begin
$display(“%t: ENTRY :: 1”, $time);
end
//multi cycle path: Path which takes more than one clock cycle.
//If we are already inside the always block, we will not enter again even if sensitivity list changes
Provide an always block example which results in multi cycle path.
Explain below statements with an example.
initial is suitable for testbench coding.
Always is suitable for design coding.
Write a logic to generate clock using always block, no forever
Clock of #10 TP
What is issue with below code?
What is issue with below code?
always begin //sensitivity list is empty, it will always enter
clk = ~clk;
end
Implement half adder using always block
Write Verilog code for below circuit.
Using always and assign, write the Verilog code
Assume it is synchronous reset
Reset takes effect only at the positive edge of clock
How to approach
How many FFs are there?
Do they use same clock?
Yes, single always is sufficient
Is there is reset?
Yes,
At reset, make Y & W as 0
If reset not there
Y will be and of a & b
W will be inverse of c
Write Verilog code for below circuit
Res and rst both are same
Both flops have same clk
Hint: any unnamed should be named
Write Verilog for below circuit
All FF on same clock and same reset
Write Verilog for below circuit
FF1 and FF3 are on same clock (clk1)
FF2 on different clock (clk2)
Though diagram is different.
As you get time, check all behavior by running Verilog simulation.
In below code, what time b, c, and d will take the values?
initial begin
#5 c = 1;
#5 b = 0;
#5 d = c;
end
How many processes are in below code? at what time c, b, and d assignment will happen?
How many processes are there in below code?
initial begin
fork
#5 c = 1;
#5 b = 0;
#5 d = c;
join
end
How many processes are in below code? at what time c, b, and d assignment will happen?
initial begin
fork
#5; c = 1;
#5; b = 0;
#5; d = c;
join
End
How many processes are there in below code? at what time c, b, and d assignment will happen?
initial begin
fork
begin //since we used begin, end, it becomes one process.
#5 c = 1;
#5 b = 0;
#5 d = c;
end
join
end
How many process in below code?
initial begin
fork
begin
#5 c = 1;
#5 b = 0;
end
#5 d = c;
join
end
Teacher is an important part of anybody's education.
I completed my post graduation in 2005. During my school and College, I always had difficulty coping up with things in classroom. But my Telugu teacher Mr. Hussain Budde during my 7th class , I used to enjoy his way of teaching, way he used to engage students by teaching lessons as stories. After that, I never found any teacher who kept sessions so much engaging. I don't want to blame my teachers, I always felt they could make sessions more engaging. I always had to spend time outside class hours to cope up with every minute of classroom session.
I as a teacher, I adopt a style of teaching which keeps session engaging and ensures that students give 100% focus on the session. I always wanted to be that one teacher, whom my students will remember for lifetime. I am making sure that, rest of trainer's also follow same.
I want your 6 months of education at VLSIGuru to be among your best learning experiences. We at VLSIGuru will do our best to make this a memorable time.