$monitor("%d %d %d",x,y,a,$time);
x=1'bx; #10 x=1'b0; #10 x=1'b1; #10 x=1'b0; #10 x=1'b1; #10 x=1'b0; #10 x=1'b1; #10 x=1'b0; #20 x=1'b1; #10 x =1'b0; #10 x=1'b1; #10 x=1'b0; #10 $finish; end
Initial begin $recordfile("always_block.trn"); $recordvars("depth = 0"); end
endmodule
understand the delay in
$monitor("%d %d %d",x,y,a,$time);
$recordfile("always_testee.trn");
$recordvars("depth = 0");
$monitor("%d %d %d",x,y,a,$time);
x=1'bx; #10 x=1'b0; #10 x=1'b1; #10 x=1'b0; #10 x=1'b1; #30 x=1'b0; #10 x=1'b1; #10 x=1'b0; #20 x=1'b1; #10 x =1'b0; #10 x=1'b1; #10 x=1'b0;
$recordfile("always_testee.trn");
$recordvars("depth = 0");
Check the following code with different inertial delay
module assign_delay_test;
initial $monitor(clk, " ", clk1 ," " ,clk2 ,$time);
Check the following code with different intra assignment delay
module assign_delay_test;
initial $monitor(clk, clk1 ,clk2 ,$time);
Check the output with mixed case assignment
module block_nonblock_test;
$monitor ("a=%b b=%b c=%b d=%b ",a,b,c,d,);
muticase with single assignment
localparam MON=0,TUE=1,WED=2,THU=3,FRI=4,SAT=5,SUN=6;
MON,WED : pocket_money=2;
FRI,SAT,SUN: pocket_money=0;
default : pocket_money=1;
$recordfile("case_test.trn");
$recordvars("depth = 0");
$display("today pocket_money time");
$monitor(today,pocket_money,$time);
Check the triggering of the always with changing value of sensitivity list
$display ("clk, OP1 OP2");
$monitor("%d %d %d",clk,OP1,OP2,$time);
$recordfile("clk_test.trn");
$recordvars("depth = 0");
fork Join Delay check all statement inside fork join run parallel and begin end sequentialy
#1 x=1'b0; //delay specefied in terms of x and z does not take ERROR
#delay $finish; // the delay is specefied in terms of negative is not taking
$recordfile("delay_test.trn");
$recordvars("depth = 0");
Check the code for Logical operator in regular statement
initial //$monitor("%b",D," %b ",A);
$monitor("A = %b B = %b C = %b D = %b E = %b F = %b ",A,B,C,D,E,F);
initial $monitor("clk = ", clk," a=",a,$time);
function integer fun(input integer y); begin
task task_test(input integer y,output integer z);
initial $monitor("x = %2d Y = %2d Z = %2d", x,y,z);
$recordfile("fun_task.trn");
initial begin val=funct(16);
function integer funct(input integer depth);
for(i=0;2**i < depth;i=i+1)
function integer fun(input integer y); begin
task task_test(input integer y,output integer z);
$recordfile("fun_task.trn");
initial begin val=funct(16);
function integer funct(input integer depth);
for(i=0;2**i < depth;i=i+1)
endmodule
if_else Conditions
$monitor("rst En = %b %b x = %b time ",rst,En,x,$time);
$monitor(" y = %2d ",y,$time);
#400 y= 3 + 3 - 6 / 3 * 2 ;
//power operator & function test
for(i=0;2**i < depth;i=i+1)
Create the log file using log system task
#10 x=1'b0; #10 x=1'b1; #10 x=1'b0; #10 $finish;
initial begin $monitor(x);
$log("log_test.v");// to store the output into log file
$monitor(a," " ,$realtime);
//initial begin $monitor("%t " ,$realtime); // if you are using %t for time it will display as
//multiply by the time unit as for the time precision value
module negative_number_test();
initial begin $monitor(" %b %d %d",a,b,$time);
initial begin y= 3 + 3 - 6 / 3 * 2 ;
defparam one.MEM_SIZE=300;// overwriting parameter
one #(400)one();// instantiation time overwriting
initial $display("MEM_SIZE=%3d",MEM_SIZE);
// defparam has higher priority
endmodule`timescale 1ns/1ns
#10; //data[0:3] = 4'b1110; //Reversed part-select index expression ordering
data[3:0] = 4'b1110; //right part selection
random value generation & shift operator
$monitor("%d %b %b",$time,a,b);
$readmemb("mem_data.v",data);
for (i=0; i < 3; i= i+1)
$displayo("data=%b",data[i]);
Check the triggering of the always with changing value of sensitivity list
reg signed [3:0] data=-11 ;
$monitor ("%b,%b",data,d,$time);
// data <= #2 data >> 2;
#4 data= data >>> 3;
integer x,y,z; wire [2:0]a;
initial begin x=10; y=z=x; // this is an ERROR in verilog
initial $monitor(x,y,z,$time);
check the format specification
$monitor($time," %b ",m," %b ", n);
initial #10 n = n + 1'b1;
module test_assign_deassign_test();
reg clk; reg clear; wire q; reg d;
assign_deassign_test as(q,q1,sd,clk,clear);
$monitor("force release o/p = ",q," assign_deassign o/p = ",q1," clk = ", clk);
clk=1'b0; d=1'b0; #50 clear = 1'b1; d=1'b1; #30 clear =1'b1; #50 clear =1'b0; #20 finish; end
$recordfile("assign_dassign_test.trn");
$recordvars("depth = 0");
freq_div_5 freq(clk_out,clk_in,rst);
$recordfile("cl_div.trn");
reg [3:0] A=4'b101Z; // 4 bit value of A
reg [3:0] B=4'b1X10; // 4 bit value of B
reg [3:0] C, D; // 4 bit value of C & D
integer E,F,G; // 32 bit value of e, f & g
C=A+B; // mathematical operation if oprands are X or Z
D=A^B; // bitwise operation
E= 3 + 3 - 6 / 3 * 2 % 3; // operator precedence => / * % + -
F = 3 + 3 - 6 / 3 * (2 % 3 ); // effect of paranthesis
G = 3 + 3 - 6 / ((3 * 2) % 3 ) ; // divide be Zero infinte => X
$display( "input data A=%b B=%b ",A,B);
$display("mathematical result = ",C[3],C[2],C[1],C[0]);
$display("bit wise result = " ,D[3],D[2],D[1],D[0]);
$display("operator precedence result E =%2d F =%3d G =%3d",E,F,G);
$monitor(c[0],c[1],c[2],c[3]," " ,d[0],d[1],d[2],d[3]," ",e);
check the timescale & different system $time task
$display(a,"time=%3d",$time);
$display(a,"stime=%3d",$stime);
$display(a,"realtime=%d",$realtime);
$display(b,"%t" ,$stime);
$display(b,"%t" ,$realtime);
$monitor("%t " ,$time); // without specifying the %t it will display the totel time taken by the
$monitor(a,$time,x,y," ",m," ", n);
initial #10 n = n + 1'b1;
initial name ="aeepak"; // a string is always declare as reg and start from 1 to 8*no of character in that word
$recordfile("case_test.trn");
always @(a) // nested always block dont dare to delate it if u do it will make blast connected to system f ile
$display("the output is %b",a);
$recordfile("register.trn");
module register_test(a,d,clk);
always @(posedge clk) begin
$display("the output is %b",a);
$recordfile("register.trn");
$monitor("sum is %b",mn,$time,data,$printtimescale);
//mn=({1'b0,m} + {1'b0,n}) >> 1;
$display("the output is %b",a);
/*initial // data generation between 45 to 55;
mult_bi_if_cond good(x,y,sig,name,my_name);
$monitor("%b, %b %b",x,y,z,$time); // what is the output if i shift any no with negative no;
x =8'b1101_1010; // handling with negative no
//x =8'b_1101_1010; //this is error the first bit cant declare as underscore
#20 x={1'b01,2'd2,4'h4,1'b0};
y <= x >>> 3;
z <= x <<< 3;
/*always @(sig)@(ctrl) // always block one condition with multiple snnstivity list saperatly
/*always // one always without condition
or #10 (clk,clk,(not (clk,clk));
$monitor("%d %t",x,$time);
#20 x={1'b1,2'd2,4'h4,1'b0};// concatenation of multiple data type in single variable
#10 x={1'b0,2'd2,4'h3,1'b0};
$strobe("%b %t",x,$realtime);
$timeformat(-10,6,"time_unit",2);
$timeformat(-6,4,"ns",4);
// test the follwing code the always block need some delays
$recordfile("wait_test.trn");
$recordvars("depth = 0");
freq_div_5 freq(clk_in,clk_out,rst);
initial forever clk_in = #10 ~clk_in;
$recordfile("cl_div5.trn");
Synthesize the following code & find the hardware
module block_hardware_test_comb(temp1,temp2,temp3,a,b);
output temp1,temp2,temp3;
module block_hardware_test_clk(clk,temp1,temp2,temp3,a,b);
output temp1,temp2,temp3;
module block_hardware_test(clk,temp,a,b);
module counter_hardware(count,count_en,clk,rst);
always @(posedge clk, negedge rst)
module count_hardare(count,clk,reset);
always @(posedge clk ,negedge reset)
module ff_no_else_hardware(q,d,y,x);
module ff_test_asyn_hardware_new(q,d,clk,rst);
always @(posedge clk,posedge rst)
module freq_div_3(clk_out,clk_in,rst);
always @(posedge clk_in,negedge rst)
FF1<=(~FF1)&(~FF2);
always @(posedge temp_clk_in,negedge rst)
assign temp_clk_in=~clk_in;
module freq_div_5(clk_in,clk_out,rst);
always @(posedge clk_in,negedge rst)
always @(negedge clk_in,negedge rst)
assign clk_out=clk_A|clk_B;
module funct_hardware_test(dout,din);
assign dout = funct(din);
function integer funct(input integer din);
for(i=din;i < 5;i=i+1)
module hardware_contineous_assignment(a,b,c);
module hardware_test(a,b,c);
module hardware_without_full_trigger_2(a,b,c,d,e);
module integer_test_hardware(input clk,rst,input [3:0]a,output dout);
always @(posedge clk,negedge rst)
module logical_test_hardware(input [3:0] A,B,output reg [3:0] C,D,E,F);
module nonbloc_test_hardware(clk,temp,a,b);
module nonblock_hardware_test_var(clk,temp1,temp2,temp3,a,b);
output temp1,temp2,temp3;
module test_cond_hardware2(ain,bin,dout,out1);
module string_hardware_test(clk,dout,din);
module test_case_hardware(din,dout,insr);
Synthesize the following code & find the hardware
module test_hardware_block(a,clk,temp1,temp2,temp3);
output temp1,temp2,temp3;
module test_hardware_comb_block(din,enable,dout);
module test_hardware_math_block_without_paran(add_result,int_a,int_b,int_c,int_d,int_e);
input [2:0] int_a,int_b,int_c,int_d,int_e;
output integer add_result;
add_result=int_a + int_b + int_c + int_d;
module test_hardware__multbit_cond(din,data,dout);
module test_hardware_star(temp1,temp2,temp3);
output temp1,temp2,temp3;
module test_hardware_block1(a,temp1,temp2,temp3);
output temp1,temp2,temp3;
always @(posedge clk) begin
module test_cond_hardware2(ain,bin,enable,dout);