RTL Final
RTL Final
AIM:
To design and implement a parameterized First-In-First-Out (FIFO) queue
using System Verilog. This FIFO queue will handle data storage and retrieval in the
sequence it is received, essential for sequential data processing in digital systems.
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
3. cd cadence_db
4. csh
5. source cshrc1
6. NCO/rclabs/rtl
10
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
7. gedit filename.sv
8. Press enter. A window appears type the program and save it.
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press enter. The program is
compiled.
11. Type the command as gedit filename_tb.sv. A
window appears type the test bench program and save it.
12. Compile it by typing the command nco filename_tb.sv
–mess and press enter.
13. To run the program type the command as
i. ncelab filename(without extension) –access +rwc –mess
14. Similarly run the test bench program.
11
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
//Design_code
module fifo #(
parameter DATA_WIDTH = 8, // Width of the data
parameter FIFO_DEPTH = 16 // Depth of the FIFO
)(
input logic clk,
input logic rst_n,
input logic [DATA_WIDTH-1:0] data_in,
input logic w_fifo, // Write enable
input logic r_fifo, // Read enable
output logic empty, // FIFO empty flag
output logic full, // FIFO full flag
output logic [DATA_WIDTH-1:0] data_out //
Data output );
12
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
if (!rst_n) begin
wr_ptr <= 0;
rd_ptr <= 0;
count <= 0;
end else begin
// Write operation
if (w_fifo && !full) begin
fifo_mem[wr_ptr] <= data_in; // Write data to FIFO wr_ptr <=
(wr_ptr + 1) % FIFO_DEPTH; // Increment write pointer count
<= count + 1; // Increment count
end
// Read operation
if (r_fifo && !empty) begin
data_out <= fifo_mem[rd_ptr]; // Read data from FIFO
rd_ptr <= (rd_ptr + 1) % FIFO_DEPTH; // Increment read
pointer count <= count - 1; // Decrement count
end
end
end
endmodule
// Testbench
module tb_fifo;
parameter DATA_WIDTH = 8;
parameter FIFO_DEPTH = 4;
logic clk;
logic rst_n;
logic [DATA_WIDTH-1:0] data_in;
logic w_fifo;
logic r_fifo;
logic empty;
logic full;
logic [DATA_WIDTH-1:0] data_out;
fifo #(
.DATA_WIDTH(DATA_WIDTH),
.FIFO_DEPTH(FIFO_DEPTH)
) uut (
13
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
.clk(clk),
.rst_n(rst_n),
.data_in(data_in),
.w_fifo(w_fifo),
.r_fifo(r_fifo),
.empty(empty),
.full(full),
.data_out(data_out)
);
// Clock generation
initial begin
clk = 0;
forever #5 clk = ~clk; // 10 time units
clock period end
// Test sequence
initial begin
rst_n = 0; // Assert reset
#10;
rst_n = 1; // Deassert reset
14
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
end
r_fifo = 0; // Disable reading
OUTPUT:
Writing 0 to FIFO
Writing 1 to FIFO
Writing 2 to FIFO
FIFO is full, cannot write 3
FIFO is full, cannot write 4
FIFO is full, cannot write 5
Reading 0 from FIFO
Reading 1 from FIFO
Reading 2 from FIFO
FIFO is empty, cannot read
FIFO is empty, cannot read
FIFO is empty, cannot read
Aim & Execution (5) Viva Voce Output (5) Total Relevance to
Algorithm/ (5) (20) POs/PSOs
Apparatus
Required (5)
PO1,2,3,4,5,9,11,PSO1
RESULT:
Thus the system verilog code for logic gates using parameterized
simple FIFO using input was verified.
15
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
EXP. NO: 02 Design a content addressable memory using
associative array and show their output in System
DATE: Verilog
AIM:
To write the system Verilog code to design a content addressable memory
using associate array and show their output in system Verilog.
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
3. cd cadence_db
4. csh
5. source csh rc1
6. NCO/rclabs/rtl
7. gedit filename.sv
8. Press enter. A window appears type the program and save it.
16
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press enter. The program is
compiled.
17
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
module CAM;
byte last_index;
byte found_index;
bit found = 0;
initial begin
mem[8'h00] = 3'b001;
mem[8'h01] = 3'b010;
mem[8'h02] = 3'b011;
mem[8'h03] = 3'b100;
18
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
//4)Checking the index presence
if (mem.exists(8'h05))
last_index = i;
mem[last_index]);
//6)Check specific value is present or not in the mem, if present print the
index of that value
foreach(mem[i]) begin
found_index = i;
found = 1;
found_index); break;
end
end
if (!found)
end
endmodule
19
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
OUTPUT:
Aim & Execution (5) Viva Voce Output (5) Total Relevance to
Algorithm/ (5) (20) POs/PSOs
Apparatus
Required (5)
PO1,2,3,4,5,9,11,PSO1
RESULT:
Thus the system verilog code to design a content addressable memory
Using associate array and show their output was verified.
20
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
EXP NO: 03
AIM:
To write the system verilog code to declare a register to perform write
read operation using Pre and post randomization methods using test bench.
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
3. cd cadence_db
4. csh
5. source csh rc1
6. NCO/rclabs/rtl
7. gedit filename.sv
8. Press enter. A window appears type the program and save it.
21
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press enter. The program is compiled.
22
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
class Register;
// Register properties
rand bit [7:0] data; // 8-bit register
bit [7:0] initial_value;
// Pre-randomization method
function void pre_randomize();
// Perform any necessary operations before randomization //
For example, logging or adjusting data based on initial_value
$display("Pre-randomization: Initial value is %0d",
this.initial_value); endfunction
// Post-randomization method
function void post_randomize();
// Perform any necessary operations after randomization //
For example, constraints checking or logging the randomized
value $display("Post-randomization: Randomized value is
%0d", this.data); endfunction
// Call post-randomization
this.post_randomize();
endfunction
endclass
23
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
// Testbench to demonstrate usage
module tb_register;
initial begin
Register reg1 = new(8'hAA); // Initialize with some value
reg1.randomize_register(); // Perform the randomization operation
end
endmodule
OUTPUT:
Aim & Execution (5) Viva Voce Output (5) Total Relevance to
Algorithm/ (5) (20) POs/PSOs
Apparatus
Required (5)
PO1,2,3,4,5,9,11,PSO1
RESULT:
Thus, the System Verilog code for code to declare a register to perform
write read operation using Pre and post randomization methods using Verilog
test bench was verified.
24
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
EXP NO: 04
Design an Inter Process Synchronization- Mailbox between
DATE: Generator and Driver component to receive the
transaction using System Verilog
AIM:
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
25
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
3. cd cadence_db
4. csh
5. source csh rc1
6. NCO/rclabs/rtl
7. gedit filename.sv
8. Press enter. A window appears type the program and save it.
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press enter. The program is
compiled.
11. Type the command as gedit filename_tb.sv. A window appears
type the test bench program and save it.
12. Compile it by typing the command nco filename_tb.sv
–mess and press enter. 13. To run the program type the
command as
i. ncelab filename(without extension) –access +rwc –mess
14. Similarly run the test bench program.
15. To simulate the test bench program, type the
command ncsim testbench file name(without
extension) –gui. A window appears.
16. Select the nco_output and select all the inputs and outputs.
17. Right click and select send to waveform window.
18. Click run/continue netlist button and after some
timeperiod stop it. 19. The digital domain output is
displayed.
20. In nco_output right click and select trace-> analog
sample and hold.
21. The analog doma in output is displayed.
26
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
// Transaction type
class transaction;
Constructor
function new();
data = 8'b0;
endfunction
27
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
// Method to display the
transaction function
void display();
$display("Transaction Data:
endclass
module tb;
#(transaction) mail;
end
endmodule
// Generator process
transaction trans;
28
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
// Generate transactions
end
endtask
// Driver process
transaction trans;
// Receive transactions
end
endtask
29
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
OUTPUT:
30
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
Aim & Execution (5) Viva Voce Output (5) Total Relevance to
Algorithm/ (5) (20) POs/PSOs
Apparatus
Required (5)
PO1,2,3,4,5,9,11,PSO1
RESULT:
31
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
EXP NO: 05
Design an interface with Modport and Clocking
Block using System Verilog
DATE:
AIM:
To design an interface with modport and clocking block using system Verilog.
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
3. cd cadence_db
4. csh
5. source csh rc1
6. NCO/rclabs/rtl
7. gedit filename.sv
8. Press enter. A window appears type the program and save it.
32
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press enter.
The program is compiled.
33
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
34
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
if (intf.reset)
intf.data_out <= 8'h00;
else if (intf.valid)
intf.data_out <= intf.data_in;
end
endmodule
`timescale 1ns / 1ps
module top_tb;
bit clk;
// Clock generation
initial begin
clk = 0;
forever #5 clk = ~clk; // 100 MHz clock
end
// Test sequence
initial begin
// Initialize signals
intf.reset = 1;
intf.valid = 0;
intf.ready = 0;
35
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
$display("Starting test...");
$display("Time=%0t : Reset applied.", $time);
36
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
OUTPUT:
Starting test...
Time=0 : Reset applied.
Time=10000 : Reset deasserted, ready signal is high.
Time=20000 : Valid signal set high, data transfer begins.
Time=25000 : Data_in = 1, Data_out = 0, Valid = 1, Ready = 1
Time=35000 : Data_in = 2, Data_out = 1, Valid = 1, Ready = 1
Time=45000 : Data_in = 3, Data_out = 2, Valid = 1, Ready = 1
Time=55000 : Data_in = 4, Data_out = 3, Valid = 1, Ready = 1
Time=65000 : Data_in = 5, Data_out = 4, Valid = 1, Ready = 1
Time=75000 : Data_in = 6, Data_out = 5, Valid = 1, Ready = 1
Time=85000 : Data_in = 7, Data_out = 6, Valid = 1, Ready = 1
Time=95000 : Data_in = 8, Data_out = 7, Valid = 1, Ready = 1
Time=105000 : Data_in = 9, Data_out = 8, Valid = 1, Ready = 1
Time=105000 : Ending test.
PO1,2,3,4,5,9,11,PS
O1
RESULT:
Thus, the System Verilog code to design an interface with modport and
clocking block was written and executed and hence the output was
verified.
37
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
EXP NO: 06
Implement and test a stack data structure using
parameterized classes, allowing for various data
DATE:
types and depths
AIM:
To implement and test a stack data structure using parameterized classes,
allowing for various data types and depths using system Verilog.
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
3. cd cadence_db
4. csh
5. source csh rc1
6. NCO/rclabs/rtl
7. gedit filename.sv
38
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
8. Press enter. A window appears type the program and save it.
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press enter.
The program is compiled.
39
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
function T pop();
T item;
if (queue_data.size() > 0) begin
item = queue_data.pop_front();
$display("Popped: %0d", item);
end else begin
$display("Stack underflow: No data to pop.");
end
return item;
endfunction
endclass
module top;
stack #(.T(byte), .DEPTH(20)) data = new();
byte data_array[20];
stack_ext1 data_ext1 = new();
stack_ext2#(.S(string)) data_ext2 = new();
initial begin
40
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
foreach (data_array[i]) begin
data_array[i] = $urandom_range(0, 255);
data.push(data_array[i]);
end
data_ext2.push("Hello");
data_ext2.push("World");
data_ext2.show_string();
end
endmodule
OUTPUT:
Stack underflow: No data to pop.
Stack underflow: No data to pop.
Pushed: 54
Pushed: 60
Pushed: 125
Pushed: -30
Pushed: 11
Pushed: -33
Pushed: 64
41
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
Pushed: -9
Pushed: -90
Pushed: 27
Pushed: -75
Pushed: -6
Pushed: 78
Pushed: 21
Pushed: 125
Pushed: 114
Pushed: -106
Pushed: 49
Pushed: -60
Pushed: -86
Error: Mismatch at index 0. Popped = 0, Expected = 54
Error: Mismatch at index 1. Popped = 0, Expected = 60
Error: Mismatch at index 2. Popped = 0, Expected = 125
Error: Mismatch at index 3. Popped = 0, Expected = -30
Error: Mismatch at index 4. Popped = 0, Expected = 11
Error: Mismatch at index 5. Popped = 0, Expected = -33
Error: Mismatch at index 6. Popped = 0, Expected = 64
Error: Mismatch at index 7. Popped = 0, Expected = -9
Error: Mismatch at index 8. Popped = 0, Expected = -90
Error: Mismatch at index 9. Popped = 0, Expected = 27
Error: Mismatch at index 10. Popped = 0, Expected = -75
Error: Mismatch at index 11. Popped = 0, Expected = -6
Error: Mismatch at index 12. Popped = 0, Expected = 78
Error: Mismatch at index 13. Popped = 0, Expected = 21
Error: Mismatch at index 14. Popped = 0, Expected = 125
Error: Mismatch at index 15. Popped = 0, Expected = 114
Error: Mismatch at index 16. Popped = 0, Expected = -106
Error: Mismatch at index 17. Popped = 0, Expected = 49
Error: Mismatch at index 18. Popped = 0, Expected = -60
Error: Mismatch at index 19. Popped = 0, Expected = -86
Pushed: 54
42
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
Pushed: 60
Pushed: 125
Pushed: -30
Pushed: 11
Pushed: -33
Pushed: 64
Pushed: -9
Pushed: -90
Pushed: 27
Pushed: 1701604463
Pushed: 1869769828
String element: ello
String element: orld
Aim & Execution (5) Viva Voce Output (5) Total Relevance to
Algorithm/ (5) (20) POs/PSOs
Apparatus
Required (5)
PO1,2,3,4,5,9,11,PSO1
RESULT:
Thus, the System Verilog code to implement and test stack data
structure was written and executed and hence the output was verified.
43
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
EXP NO: 07
Demonstrate the creation, randomization,
DATE: and copying of objects between classes,
AIM:
To implement and to demonstrate the creation, randomization, and copying of
objects between classes, using system Verilog.
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
3. cd cadence_db
4. csh
5. source csh rc1
6. NCO/rclabs/rtl
7. gedit filename.sv
8. Press enter. A window appears type the program and save it.
44
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press
enter. The program is compiled.
45
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
class my_pkt;
int m_count;
function new();
m_count = 0;
endfunction
endclass
class eth_pkt;
rand bit [7:0] sof;
rand bit [15:0] len;
int count;
my_pkt m_pkt;
function new();
m_pkt = new();
endfunction
constraint len_c {
len < 40;
len > 20;
}
46
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
module top;
eth_pkt pkt1;
eth_pkt pkt2;
initial begin
pkt1 = new();
pkt1.randomize();
pkt1.m_pkt.m_count = 'h5;
pkt1.print();
pkt2 = new();
pkt2.print();
pkt1.copy(pkt2);
pkt2.print();
pkt1.m_pkt.m_count = 'h4;
pkt1.sof = 'h1;
pkt1.len = 'h5;
pkt1.print();
pkt2.print();
end
endmodule
OUTPUT:
47
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
Aim & Execution (5) Viva Voce Output (5) Total Relevance to
Algorithm/ (5) (20) POs/PSOs
Apparatus
Required (5)
PO1,2,3,4,5,9,11,PSO1
RESULT:
Thus, the System Verilog code to demonstrate the creation, randomization, and
copying of objects between classes, was written and executed and hence the output
was verified.
48
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
EXP NO: 08
Explore inheritance, constraints, and method
DATE: overriding in object-oriented programming
AIM:
To implement and to explore inheritance, constraints, and method overriding in
object-oriented programming using system Verilog.
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
3. cd cadence_db
4. csh
5. source csh rc1
6. NCO/rclabs/rtl
7. gedit filename.sv
49
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
8. Press enter. A window appears type the program and save it.
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press
enter. The program is compiled.
50
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
class eth_pkt;
rand bit [7:0] sof;
rand bit [15:0] len;
string count;
function new();
sof = 0;
len = 0;
count = "0";
endfunction
constraint len_c {
len < 40;
len > 20;
}
function new();
super.new();
good_count = 0;
endfunction
constraint len_c {
len > 60;
len < 80;
}
51
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
$display("good_pkt: good_count = %0d", good_count);
endfunction
module top;
eth_pkt pkt;
good_pkt g_pkt;
initial begin
pkt = new();
if (!pkt.randomize()) begin
$display("Randomization of pkt failed.");
end
pkt.print();
g_pkt = new();
if (!g_pkt.randomize()) begin
$display("Randomization of g_pkt failed.");
end
g_pkt.print();
g_pkt.set();
g_pkt.set();
end
endmodule
OUTPUT:
eth_pkt: sof = b9, len = 24, count = 0
eth_pkt: sof = 7, len = 62, count = 0
good_pkt: good_count = 0
Set method in good_pkt: sof = 14
Set method in good_pkt: sof = 14
52
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
Aim & Execution (5) Viva Voce Output (5) Total Relevance to
Algorithm/ (5) (20) POs/PSOs
Apparatus
Required (5)
PO1,2,3,4,5,9,11,PSO1
RESULT:
53
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
EXP NO: 09
Declare, initialize, and display elements of
multidimensional arrays.
DATE:
AIM:
To implement and declare the elements of multidimensional arrays using
system Verilog.
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
3. cd cadence_db
4. csh
5. source csh rc1
6. NCO/rclabs/rtl
7. gedit filename.sv
54
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
8. Press enter. A window appears type the program and save it.
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press
enter. The program is compiled.
55
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
module tb;
bit [15:0] mem1 [63:0]; //Declaration sir
reg[7:0][9:0]mem2[8][6:0]; //Declared sir
initial begin
foreach(mem2[i, j, k])
mem2[i][j][k] = $urandom_range(1, 100);//Randomizing the elements sir
OUTPUT:
56
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
90996690773096766905362, 20117434365877584730167,
63841884475916007029807, 36677971788065512946752},
'{85045307813536876040202, 56730718689699145238624,
2376216328462517983319, 116920110548984950487118,
30717305724381768461408, 10636919141108775180340,
57885931419316703543332}, '{63840754104352258484268,
47294095599725620271180, 50811627552050088251433,
113406078994206819382316, 40210551492767043894277,
26060641139335554456622, 13000443172509766981713},
'{36644555103018549302310, 27199783844664036103242,
22457841355513734950961, 66156984589043015682061,
10648462957742284382249, 17718116881374905409551,
103974004530974998682678}, '{64949887077797543827465,
68526242855045024479290, 13063823375616569328668,
75643285820090292926469, 23641854616776454787085,
88628551801298987593813, 81520790652776241776668},
'{14174110437311488475234, 68583921532980204416088,
103997003356579315060745, 76816890103725633404945,
9466654340289366426685, 1193369474191999454307,
14259404152401294278744}}
# KERNEL: mem2[0][0][0] = 43
# KERNEL: mem2[0][0][1] = 50
# KERNEL: mem2[0][0][2] = 18
# KERNEL: mem2[0][0][3] = 79
# KERNEL: mem2[0][0][4] = 44
# KERNEL: mem2[0][0][5] = 83
# KERNEL: mem2[0][0][6] = 56
# KERNEL: mem2[0][0][7] = 73
57
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
# KERNEL: mem2[0][0][8] = x
# KERNEL: mem2[0][0][9] = x
# KERNEL: mem2[0][1][0] = 81
.# KERNEL: mem2[7][6][0] = 98
# KERNEL: mem2[7][6][1] = 16
# KERNEL: mem2[7][6][2] = 63
# KERNEL: mem2[7][6][3] = 81
# KERNEL: mem2[7][6][4] = 9
# KERNEL: mem2[7][6][5] = 83
# KERNEL: mem2[7][6][6] = 6
# KERNEL: mem2[7][6][7] = 12
# KERNEL: mem2[7][6][8] = x
# KERNEL: mem2[7][6][9] = x
# KERNEL:
mem2[6][2]=00000101000000011010000010100100010010100000101101000
101011100010101000000001101
58
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
# KERNEL: mem2[6][2][1]=0001010100
# KERNEL: mem2[6][2][1][4]=1
PO1,2,3,4,5,9,11,PS
O1
RESULT:
Thus the System Verilog code to declare the elements of multidimensional arrays
was written and executed and hence the output was verified.
59
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
EXP NO: 10
D Flip Flop complete implementation and
DATE: verification using system Verilog
AIM:
To implement and declare the elements of multidimensional arrays using
system Verilog.
APPARATUS REQUIRED:
1 Cadence software 1
2 Personal computer 1
PRECAUTIONS:
PROCEDURE:
3. cd cadence_db
4. csh
5. source csh rc1
6. NCO/rclabs/rtl
7. gedit filename.sv
60
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
8. Press enter. A window appears type the program and save it.
9. Open the terminal window and press ctrl+C.
10. Type the command as ncvlog –mess and press
enter. The program is compiled.
61
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
PROGRAM:
`include "d_ff.v"
`include "dff_cfg.sv"
`include "dff_tx.sv"
`include "dff_ckr.sv"
`include "dff_cov.sv"
`include "dff_mon.sv"
`include "dff_bfm.sv"
`include "dff_gen.sv"
`include "dff_env.sv"
`include "dff_int.sv"
`include "dff_tb.sv"
module top;
logic clk,rst;
d_ff dut(.clk(inf.clk),.rst(inf.rst),.d(inf.d),.q(inf.q));
dff_int inf(clk,rst);
dff_tb tb();
initial
begin
clk=0;
forever #5 clk=~clk;
end
initial
begin
rst=1;
repeat(2)@(posedge clk);
rst=0;
#100 $finish;
end
initial
begin
dff_cfg::vif=inf;
end
initial begin
$dumpfile("dump.vcd");
$dumpvars(1);
end
endmodule
//dff _int.sv
62
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
logic d;
logic q;
clocking cb @(posedge clk);
//default input #0 output #9;
output d;
input q;
endclocking
endinterface
//dff_cfg.sv
class dff_cfg;
static virtual dff_int vif;
static mailbox gen2bfm=new();
static mailbox mon2ckr=new();
static mailbox mon2cov=new();
endclass
//dff_tb.sv
program dff_tb;
dff_env env=new();
initial
begin
env.run();
end
endprogram
//dff_env.sv
class dff_env;
dff_gen gen=new();
dff_bfm bfm=new();
dff_mon mon=new();
dff_ckr ckr=new();
dff_cov cov=new();
task run();
fork
gen.run();
bfm.run();
mon.run();
ckr.run();
cov.run();
join
endtask
endclass
63
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
//dff_tx.sv
class dff_tx;
rand bit d;
bit q;
endclass
//dff_gen.sv
class dff_gen;
dff_tx tx;
virtual dff_int vif;
task run();
begin
$display("GEN");
vif=dff_cfg::vif;
wait(vif.rst==0);
for(int i=0;i<10;i++)
begin
tx=new();
tx.randomize() with {d dist {1:=5,0:=5};};
dff_cfg::gen2bfm.put(tx);
end
end
endtask
endclass
//dff_bfm.sv
class dff_bfm;
virtual dff_int vif;
dff_tx tx;
task run();
begin
$display("BFM");
vif=dff_cfg::vif;
forever
begin
dff_cfg::gen2bfm.get(tx);
drive();
end
end
endtask
task drive();
begin
// @(posedge vif.clk)
@(vif.cb)
64
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
vif.d<=tx.d;
end
endtask
endclass
//dff_mon.sv
class dff_mon;
virtual dff_int vif;
dff_tx tx;//=new();
task run();
begin
$display("MON");
vif=dff_cfg::vif;
forever
begin
tx=new();
// @(posedge vif.clk)
@(vif.cb);
tx.d=vif.d;
tx.q=vif.q;
dff_cfg::mon2ckr.put(tx);
dff_cfg::mon2cov.put(tx);
end
end
endtask
endclass
//dff_ckr.sv
class dff_ckr;
dff_tx tx;
task run();
$display("CKR");
forever
begin
dff_cfg::mon2ckr.get(tx);
if(tx.d==tx.q)
$display("at %0tns data received correct d=%b, q=%b",$time,tx.d,tx.q);
else
$display("at %0tns ERROR:data received Wrongly d=%b,
q=%b",$time,tx.d,tx.q);
end
endtask
endclass
65
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
//dff_cov.sv
class dff_cov;
dff_tx tx;
covergroup dff_cg;
out: coverpoint tx.q{
bins one={1};
bins zero={0};
}
option.per_instance=1;
endgroup
function new();
dff_cg=new();
endfunction
task run();
$display("COV");
forever
begin
dff_cfg::mon2cov.get(tx);
dff_cg.sample();
end
endtask
endclass
//dff_run.do
vsim -c +access +r;
run -all;
acdb save;
acdb report -db fcover.acdb -txt -o cov.txt;
exec cat cov.txt;
exit
//use aldec riviera pro 2017.02 simulator
66
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
OUTPUT:
GEN
BFM
MON
CKR
COV
67
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies
Aim & Execution (5) Viva Voce Output (5) Total Relevance to
Algorithm/ (5) (20) POs/PSOs
Apparatus
Required (5)
PO1,2,3,4,5,9,11,PSO1
RESULT:
Thus, the implementation and verification of the D Flip Flop using
System Verilog was done successfully and hence verified.
68
PSVPEC/ECE/22EC592 RTL Design Verification Methodologies