Verilog Simulation Tools & Verification Overview

undefined
Verilog Simulation
 Tools
 
&
Verification
池翊忞
(Yi-Min Chih)
Outline
One
 
wire/ Two wire
Verilog Procedural Interface/ nicotb
2
One wire/ Two wire
3
One Wire
4
Slave receive data when data ready.
Lost 
the
 data if salve is busy.
Master
Slave
ready
data
Two Wire
5
Master will hold the data when slave is not ack.
Master
Slave
ready
data
ack
Nicotb
6
UVM (Universal Verfication Methodology).
(
W
e
 
u
s
u
a
l
l
y
 
c
a
l
l
 
t
h
i
s
 
o
v
e
r
a
l
l
 
p
l
a
t
f
o
r
m
 
a
s
 
t
e
s
t
b
e
n
c
h
.
)
What Forms Verification?
7
https://verificationacademy.com
Generate Golden Data
Your RTL
Drive data to
input ports
Monitor output ports
and collect data
The non-RTL parts can be implemented without Verilog!
This is usuallyed called co-simulation (co-sim).
The Non-RTL Parts
8
Instantiate (make a copy of) your module.
D
r
i
v
e
r
 
t
o
 
s
e
n
d
 
d
a
t
a
.
M
o
n
i
t
o
r
 
t
o
 
r
e
c
e
i
v
e
 
a
n
d
 
c
o
l
l
e
c
t
 
t
h
e
m
.
D
r
i
v
e
r
 
a
n
d
 
M
o
n
i
t
o
r
 
m
i
g
h
t
 
f
o
l
l
o
w
 
s
p
e
c
i
f
i
c
 
p
r
o
t
o
c
o
l
s
.
T
h
e
 
c
o
l
l
e
c
t
e
d
 
d
a
t
a
 
a
r
e
 
c
o
m
p
a
r
e
d
 
b
y
 
S
c
o
r
e
b
o
a
r
d
.
Golden (Mostly text file in Verilog, or programmatically when co-simed.)
G
e
n
e
r
a
t
e
d
 
b
y
 
y
o
u
r
 
R
T
L
 
m
o
d
u
l
e
 
a
n
d
 
c
o
l
l
e
c
t
e
d
 
b
y
 
M
o
n
i
t
o
r
.
Brief Conclusions - A Testbench Must
9
Verilog provide external C accesses through VPI.
https://en.wikipedia.org/wiki/Verilog_Procedural_Interface
Based on C, people develops Java, Python... versions.
AFAIK, there are quite a lot Python based frameworks.
myhdl: 
https://github.com/myhdl/myhdl
cocotb: 
https://github.com/potentialventures/cocotb
nicotb: 
https://github.com/johnjohnlin/nicotb
No Need for Verify RTL with Verilog
10
We focus on this today.
Bridging Python and Verilog (Events)
Add these lines in Python
rst_out_ev, ck_ev = CreateEvents(["
rst_out
", "
ck_ev
",])
Add this lines in Verilog
`Pos(
rst_out
, rst)
`PosIf(
ck_ev
, 
clk
, rst)
This means, whenever a 
clk
 posedge in Python, 
ck_ev
 is triggered
Mostly your submodules use 1 reset and clock and you just copy it.
That is,
P
y
t
h
o
n
 
y
i
e
l
d
 
c
k
_
e
v
 
=
 
V
e
r
i
l
o
g
 
@
p
o
s
e
d
g
e
 
c
l
k
11
Bridging Python and Verilog (Wires)
API to connect Verilog wires
my_data_bus = CreateBus
es
((
 
("", "a_signal", (4,2)),
 
("dut", "sig"),
))
The Verilog to be connected
logic [7:0] a_signal [4][2];
DUT my_dut(
 
.clk(clk),
 
.sig(sig)
)
12
hierarchy: toplevel → ""
name: a_signal
shape: (4,2)
Bridging Python and Verilog (Wires)
API to connect Verilog wires
my_data_bus = CreateBus
es
((
 
("", "a_signal", (4,2)),
 
("dut", "sig"),
))
The Verilog to be connected
logic [7:0] a_signal [4][2];
DUT dut(
 
.clk(clk),
 
.sig(sig)
)
13
hierarchy: "dut" (nested: "dut.a.b")
name: sig
shape: not a array
First, you need to create the buses
(
irdy
, 
iack
, 
iint
)
 = CreateBus
es
(
[
 
(("dut", "irdy")
,
)
,
 
(("dut", "iack")
,
)
,
 
(("dut", "iint ")
,
)
,])
Then, construct the classes in Python
master = TwoWire.Master(irdy, iack, iint, ck_ev, A=1, B=5)
master_data = master.values
Convert Bus into Protocol
(Master)
14
Convert Bus into Protocol
(Master)
Create transfer function.
def iter():
  
for i in range(pattern_len):
   
np.copyto(master_data.iint, pattern[i])
   
yield master_data
Thread = JoinableFork(master.SendIter(iter()))
yield from Thread.Join()
15
create the buses
(
o
rdy
, 
oack
, 
oint
)
 = CreateBus
es
(
[
 
(("dut", 
o
rdy")
,
)
,
 
(("dut", 
o
ack")
,
)
,
 
(("dut", 
o
int ")
,
)
,])
Then, construct the classes in Python
 
scb = Scoreboard("ISE")
 
test = scb.GetTest(f"output")
 
st = Stacker(1, callbacks=[test.Get])
 
bg = BusGetter(callbacks=[st.Get])
 
slave = TwoWire.Slave(
  
ordy, oack, oint, ck_ev, callbacks=[
bg
.Get]
 
)
Convert Bus into Protocol
(Slave)
16
for i in range(golden_len):
 
test.Expect((golden[i].reshape(1, 1, 1)
Expect(Slave)
17
Check data every time
dimension of data 
Constant value
(x, ) = CreateBuses([((“dut”, “x”),),])
x.values[0][0] = x_data
x.Write()
18
Simulation finish
for i in range(100):
 
yield ck_ev
assert st.is_clean
FinishSim()
19
I
n
t
r
o
d
u
c
e
 
t
h
e
 
i
d
e
a
 
b
e
h
i
n
d
 
S
y
s
t
e
m
V
e
r
i
l
o
g
 
U
V
M
.
With Python, you can do the same thing much easily.
We introduce Nicotb today.
Document: 
https://johnjohnlin.github.io/nicotb/
And there are many choices.
myhdl: 
https://github.com/myhdl/myhdl
cocotb: 
https://github.com/potentialventures/cocotb
Conclusions
20
undefined
The End
 
Slide Note
Embed
Share

Learn about Verilog simulation tools, verification methodologies, procedural interfaces, and co-simulation techniques. Understand the role of testbenches, driving data, monitoring output, and comparing results for effective verification in Verilog. Explore bridging Python with Verilog for event handling.

  • Verilog
  • Simulation Tools
  • Verification
  • Testbenches
  • Co-Simulation

Uploaded on Feb 16, 2025 | 1 Views


Download Presentation

Please find below an Image/Link to download the presentation.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.If you encounter any issues during the download, it is possible that the publisher has removed the file from their server.

You are allowed to download the files provided on this website for personal or commercial use, subject to the condition that they are used lawfully. All files are the property of their respective owners.

The content on the website is provided AS IS for your information and personal use only. It may not be sold, licensed, or shared on other websites without obtaining consent from the author.

E N D

Presentation Transcript


  1. Verilog Simulation Tools &Verification (Yi-Min Chih)

  2. Outline One wire/ Two wire Verilog Procedural Interface/ nicotb 2

  3. One wire/ Two wire 3

  4. One Wire Slave receive data when data ready. Lost the data if salve is busy. ready Master Slave data 4

  5. Two Wire Master will hold the data when slave is not ack. ready ack Master Slave data 5

  6. Nicotb 6

  7. What Forms Verification? UVM (Universal Verfication Methodology). (We usually call this overall platform as testbench.) Your RTL https://verificationacademy.com Generate Golden Data Monitor output ports and collect data Drive data to input ports 7

  8. The Non-RTL Parts The non-RTL parts can be implemented without Verilog! This is usuallyed called co-simulation (co-sim). 8

  9. Brief Conclusions - A Testbench Must Instantiate (make a copy of) your module. Driver to send data. Monitor to receive and collect them. Driver and Monitor might follow specific protocols. The collected data are compared by Scoreboard. Golden (Mostly text file in Verilog, or programmatically when co-simed.) Generated by your RTL module and collected by Monitor. 9

  10. No Need for Verify RTL with Verilog Verilog provide external C accesses through VPI. https://en.wikipedia.org/wiki/Verilog_Procedural_Interface Based on C, people develops Java, Python... versions. AFAIK, there are quite a lot Python based frameworks. myhdl: https://github.com/myhdl/myhdl cocotb: https://github.com/potentialventures/cocotb nicotb: https://github.com/johnjohnlin/nicotb We focus on this today. 10

  11. Bridging Python and Verilog (Events) Add these lines in Python rst_out_ev, ck_ev = CreateEvents(["rst_out", "ck_ev",]) Add this lines in Verilog `Pos(rst_out, rst) `PosIf(ck_ev, clk, rst) This means, whenever a clk posedge in Python, ck_ev is triggered Mostly your submodules use 1 reset and clock and you just copy it. That is, Python yield ck_ev = Verilog @posedge clk 11

  12. Bridging Python and Verilog (Wires) API to connect Verilog wires my_data_bus = CreateBuses(( ("", "a_signal", (4,2)), ("dut", "sig"), )) hierarchy: toplevel "" name: a_signal shape: (4,2) The Verilog to be connected logic [7:0] a_signal [4][2]; DUT my_dut( .clk(clk), .sig(sig) ) 12

  13. Bridging Python and Verilog (Wires) API to connect Verilog wires my_data_bus = CreateBuses(( ("", "a_signal", (4,2)), ("dut", "sig"), )) The Verilog to be connected hierarchy: "dut" (nested: "dut.a.b") name: sig shape: not a array logic [7:0] a_signal [4][2]; DUT dut( .clk(clk), .sig(sig) ) 13

  14. Convert Bus into Protocol(Master) First, you need to create the buses (irdy, iack, iint) = CreateBuses([ (("dut", "irdy"),), (("dut", "iack"),), (("dut", "iint "),),]) Then, construct the classes in Python master = TwoWire.Master(irdy, iack, iint, ck_ev, A=1, B=5) master_data = master.values 14

  15. Convert Bus into Protocol(Master) Create transfer function. def iter(): for i in range(pattern_len): np.copyto(master_data.iint, pattern[i]) yield master_data Thread = JoinableFork(master.SendIter(iter())) yield from Thread.Join() 15

  16. Convert Bus into Protocol(Slave) create the buses (ordy, oack, oint) = CreateBuses([ (("dut", ordy"),), (("dut", oack"),), (("dut", oint "),),]) Then, construct the classes in Python scb = Scoreboard("ISE") test = scb.GetTest(f"output") st = Stacker(1, callbacks=[test.Get]) bg = BusGetter(callbacks=[st.Get]) slave = TwoWire.Slave( ordy, oack, oint, ck_ev, callbacks=[bg.Get] ) 16

  17. Expect(Slave) for i in range(golden_len): test.Expect((golden[i].reshape(1, 1, 1) dimension of data Check data every time 17

  18. Constant value (x, ) = CreateBuses([(( dut , x ),),]) x.values[0][0] = x_data x.Write() 18

  19. Simulation finish for i in range(100): yield ck_ev assert st.is_clean FinishSim() 19

  20. Conclusions Introduce the idea behind SystemVerilog UVM. With Python, you can do the same thing much easily. We introduce Nicotb today. Document: https://johnjohnlin.github.io/nicotb/ And there are many choices. myhdl: https://github.com/myhdl/myhdl cocotb: https://github.com/potentialventures/cocotb 20

  21. The End

More Related Content

giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#giItT1WQy@!-/#