SlideShare a Scribd company logo
1 of 1
Practical RISC-V Random Test Generation using Constraint
Programming
Edmond A. Cote – http://www.edmondcote.com
ABSTRACT
A proof-of-concept random test generator for RISC-V ISA is
presented. The test generator uses constraint programming for
specification of relationships between instructions and operands.
Example scenarios to cover basic instruction randomization, data
hazards, and non-sharing are presented. The tool integrates the
RISC-V instruction set simulator to enable the generation of self-
checking tests. The tool is implemented in Python using a freely-
available constraint solver library. A summary of problems
encountered is provided and next steps are discussed.
BACKGROUND
Constrained random verification is an important and effective tool
for functional verification of microprocessors. Simple random
stimulus is not sufficient to verify a processor fully [1]. The use of
constraint programming for functional verification has
traditionally been limited to domain-specific languages such as e,
OpenVera, and SystemVerilog. In the context of a lean
semiconductor development model, the cost to acquire licenses of
such tools may be prohibitive. The freely-available SystemC
Verification Library offers limited supports for constraints. Python
verification frameworks exist such as cocotb [2] and Migen [3] but
do not offer support for constraint programming. This project
aims to explore the possibility of extending Python-based
hardware verification frameworks with support for constrained
random verification.
OBJECTIVES
• Learn about RISC-V architecture ahead of workshop
• Learn about low-level constraint programming
• Demonstrate proof-of-concept random test generator
• Complete interesting technical project outside of work
METHODS CONCLUSIONS AND NEXT STEPS
REFERENCES
• [1] Applying Constrained-Random Verification to
Microprocessors - Jason C. Chen, Synopsys Inc.
• [2] cocoTB documentation -
https://media.readthedocs.org/pdf/cocotb/latest/cocotb.pdf
• [3] Migen manual http://m-labs.hk/migen.pdf
• [4] Constraint Satisfaction Problem Wiki -
http://en.wikipedia.org/wiki/Constraint_satisfaction_problem
Constraint Programming
• Used Python language and python-constraint CSP solver library
• CSPs defined by triple {X,D,C} [4]:
X = {X1,…, Xn} is a set of variables
D = {D1,…,Dn} is a set of respective domain values
C = {C1,…,Cm} is a set of constraints
• Problem is input to tool using this paradigm
• MinConflictSolver in library provides a single valid random
solution
Examples
• Define 10 variables (instructions) and their domain
(set of all instructions)
i_var = ["i[{}]".format(x) for _ in range(10)]
i_dom = ['sw','lw','add','sub', …] # RISC-V instrs
csp.addVariables(i_var, i_dom)
• Constrain instruction 0 and 2 to be either load or store
csp.addConstraint(InSetConstraint(['sw','lw']),
['i[0]','i[2]'])
• Constrain for probable WAW hazard
rd_var = ["rd[{}]".format(x) for _ in range(10)]
rd_dom = ['ra','s0','s1', …] # RISC-V registers
csp.addVariables(rd_vars, rd_dom)
# At least 5 values of rd are in set
csp.addConstraint(SomeInSetConstraint(['s1'], 5), rd_var)
• Use of anonymous functions non shared addresses
csp.addVariable('addr', range(256)) # fixed domain issue
csp.addConstraint(lambda addr: # non sharing
addr > cpu*256/ncpu and addr <= (cpu+1)*256/ncpu))
Test Generation
• Generate random initial values for all registers
• Solve CSP; use csp.getSolution()
• Generate instruction sequence based on instruction type, save to
temporary file, and compile.
Self Checking
• Test generator instructs ISS to execute ELF
p = Popen('spike -d /path/to/elf'.split(' '),
stdin=subprocess.PIPE, stderr=subprocess.PIPE)
• ISS runs until magic number reached
until reg 0 gp DEADBEEF
• Test generator inserts reg commands to ISS and captures values of
registers
• Self checking code appended to test
• Generated self checking tests pass on RISC-V ISS
• Random stability checked by varying random seed
• Low level constraint programming is difficult, but
interesting exercise
• Fixed domains are problematic for integer space
• Access to alternative solvers can provide the entire
solution space. This presents interesting opportunities
for functional verification (e.g. analysis of state space,
creation of exhaustive tests, etc.).
• Use of Python subprocess module to communicate with
ISS was effective, but required patch for tool to accept
commands from stdin
• Explore Google or-tools and SystemC Verification Library
• Find a project to apply such a methodology to
Example test case :
RVTEST_CODE_BEGIN
// Randomly generated initial values (subset shown)
li s0, 0x8e73c
li s1, 0xa46d6
// Random instructions
or s0 , s0, s1
// Magic number register write
li gp, 0xDEADBEEF
// Generated self checking code, values from ISS
li gp, 0xAE7FE
bne s0, gp, fail
li gp, 0xa46d6
bne s1, gp, fail
TEST_PASSFAIL
RVTEST_CODE_END

More Related Content

What's hot

How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveAmiq Consulting
 
Return oriented programming
Return oriented programmingReturn oriented programming
Return oriented programminghybr1s
 
Clang compiler `
Clang compiler `Clang compiler `
Clang compiler `Rabin BK
 
Efficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode DetectionEfficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode DetectionGeorg Wicherski
 
Linux binary analysis and exploitation
Linux binary analysis and exploitationLinux binary analysis and exploitation
Linux binary analysis and exploitationDharmalingam Ganesan
 
Mixing d ps building architecture on the cross cutting example
Mixing d ps building architecture on the cross cutting exampleMixing d ps building architecture on the cross cutting example
Mixing d ps building architecture on the cross cutting examplecorehard_by
 
HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...
HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...
HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...AdaCore
 
Pinpointing Vulnerabilities (Ravel)
Pinpointing Vulnerabilities (Ravel)Pinpointing Vulnerabilities (Ravel)
Pinpointing Vulnerabilities (Ravel)Yue Chen
 
GPCE16 Poster: Automatic Non-functional Testing of Code Generators Families
GPCE16 Poster: Automatic Non-functional Testing of Code Generators Families GPCE16 Poster: Automatic Non-functional Testing of Code Generators Families
GPCE16 Poster: Automatic Non-functional Testing of Code Generators Families Mohamed BOUSSAA
 
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017OpenEBS
 
Deterministic Galois: On-demand, Portable and Parameterless
Deterministic Galois: On-demand, Portable and ParameterlessDeterministic Galois: On-demand, Portable and Parameterless
Deterministic Galois: On-demand, Portable and ParameterlessDonald Nguyen
 
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation GuideBKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation GuideLinaro
 
Introduction to llvm
Introduction to llvmIntroduction to llvm
Introduction to llvmTao He
 
Survey of Program Transformation Technologies
Survey of Program Transformation TechnologiesSurvey of Program Transformation Technologies
Survey of Program Transformation TechnologiesChunhua Liao
 
TMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Vellvm - Verifying the LLVMTMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Vellvm - Verifying the LLVMIosif Itkin
 
TMPA-2017: Stemming Architectural Decay in Software Systems
TMPA-2017:  Stemming Architectural Decay in Software SystemsTMPA-2017:  Stemming Architectural Decay in Software Systems
TMPA-2017: Stemming Architectural Decay in Software SystemsIosif Itkin
 

What's hot (20)

How to Connect SystemVerilog with Octave
How to Connect SystemVerilog with OctaveHow to Connect SystemVerilog with Octave
How to Connect SystemVerilog with Octave
 
Return oriented programming
Return oriented programmingReturn oriented programming
Return oriented programming
 
Clang compiler `
Clang compiler `Clang compiler `
Clang compiler `
 
Efficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode DetectionEfficient Bytecode Analysis: Linespeed Shellcode Detection
Efficient Bytecode Analysis: Linespeed Shellcode Detection
 
Linux binary analysis and exploitation
Linux binary analysis and exploitationLinux binary analysis and exploitation
Linux binary analysis and exploitation
 
Mixing d ps building architecture on the cross cutting example
Mixing d ps building architecture on the cross cutting exampleMixing d ps building architecture on the cross cutting example
Mixing d ps building architecture on the cross cutting example
 
HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...
HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...
HIS 2015: Alastair F. Donaldson - Fighting for Software Correctness in a Mass...
 
Pinpointing Vulnerabilities (Ravel)
Pinpointing Vulnerabilities (Ravel)Pinpointing Vulnerabilities (Ravel)
Pinpointing Vulnerabilities (Ravel)
 
Design for Testability
Design for TestabilityDesign for Testability
Design for Testability
 
system verilog
system verilogsystem verilog
system verilog
 
GPCE16 Poster: Automatic Non-functional Testing of Code Generators Families
GPCE16 Poster: Automatic Non-functional Testing of Code Generators Families GPCE16 Poster: Automatic Non-functional Testing of Code Generators Families
GPCE16 Poster: Automatic Non-functional Testing of Code Generators Families
 
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
Dynamic Instrumentation- OpenEBS Golang Meetup July 2017
 
Deterministic Galois: On-demand, Portable and Parameterless
Deterministic Galois: On-demand, Portable and ParameterlessDeterministic Galois: On-demand, Portable and Parameterless
Deterministic Galois: On-demand, Portable and Parameterless
 
Scan insertion
Scan insertionScan insertion
Scan insertion
 
LLVM Compiler
LLVM CompilerLLVM Compiler
LLVM Compiler
 
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation GuideBKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
BKK16-302: Android Optimizing Compiler: New Member Assimilation Guide
 
Introduction to llvm
Introduction to llvmIntroduction to llvm
Introduction to llvm
 
Survey of Program Transformation Technologies
Survey of Program Transformation TechnologiesSurvey of Program Transformation Technologies
Survey of Program Transformation Technologies
 
TMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Vellvm - Verifying the LLVMTMPA-2017: Vellvm - Verifying the LLVM
TMPA-2017: Vellvm - Verifying the LLVM
 
TMPA-2017: Stemming Architectural Decay in Software Systems
TMPA-2017:  Stemming Architectural Decay in Software SystemsTMPA-2017:  Stemming Architectural Decay in Software Systems
TMPA-2017: Stemming Architectural Decay in Software Systems
 

Viewers also liked

Программно-аппаратная разработка с использованием FPGA на примере поддержки п...
Программно-аппаратная разработка с использованием FPGA на примере поддержки п...Программно-аппаратная разработка с использованием FPGA на примере поддержки п...
Программно-аппаратная разработка с использованием FPGA на примере поддержки п...CEE-SEC(R)
 
Instruction: dev environment
Instruction: dev environmentInstruction: dev environment
Instruction: dev environmentSoshi Nemoto
 
Scaling python to_hpc_big_data-maidanov
Scaling python to_hpc_big_data-maidanovScaling python to_hpc_big_data-maidanov
Scaling python to_hpc_big_data-maidanovDenis Nagorny
 
Sour Pickles
Sour PicklesSour Pickles
Sour PicklesSensePost
 
Common technique in Bypassing Stuff in Python.
Common technique in Bypassing Stuff in Python.Common technique in Bypassing Stuff in Python.
Common technique in Bypassing Stuff in Python.Shahriman .
 

Viewers also liked (7)

Программно-аппаратная разработка с использованием FPGA на примере поддержки п...
Программно-аппаратная разработка с использованием FPGA на примере поддержки п...Программно-аппаратная разработка с использованием FPGA на примере поддержки п...
Программно-аппаратная разработка с использованием FPGA на примере поддержки п...
 
Instruction: dev environment
Instruction: dev environmentInstruction: dev environment
Instruction: dev environment
 
Scaling python to_hpc_big_data-maidanov
Scaling python to_hpc_big_data-maidanovScaling python to_hpc_big_data-maidanov
Scaling python to_hpc_big_data-maidanov
 
Sql Injection 0wning Enterprise
Sql Injection 0wning EnterpriseSql Injection 0wning Enterprise
Sql Injection 0wning Enterprise
 
Sour Pickles
Sour PicklesSour Pickles
Sour Pickles
 
Common technique in Bypassing Stuff in Python.
Common technique in Bypassing Stuff in Python.Common technique in Bypassing Stuff in Python.
Common technique in Bypassing Stuff in Python.
 
Guru01 13 15
Guru01 13 15Guru01 13 15
Guru01 13 15
 

Similar to Practical RISC-V Random Test Generation using Constraint Programming

Continuous Integration for BSP
Continuous Integration for BSPContinuous Integration for BSP
Continuous Integration for BSPWitekio
 
GPCE16: Automatic Non-functional Testing of Code Generators Families
GPCE16: Automatic Non-functional Testing of Code Generators FamiliesGPCE16: Automatic Non-functional Testing of Code Generators Families
GPCE16: Automatic Non-functional Testing of Code Generators FamiliesMohamed BOUSSAA
 
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMPInria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMPStéphanie Roger
 
Introduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaIntroduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaopenseesdays
 
PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)Andrey Karpov
 
VLSI lab manual Part A, VTU 7the sem KIT-tiptur
VLSI lab manual Part A, VTU 7the sem KIT-tipturVLSI lab manual Part A, VTU 7the sem KIT-tiptur
VLSI lab manual Part A, VTU 7the sem KIT-tipturPramod Kumar S
 
Getting started with RISC-V verification what's next after compliance testing
Getting started with RISC-V verification what's next after compliance testingGetting started with RISC-V verification what's next after compliance testing
Getting started with RISC-V verification what's next after compliance testingRISC-V International
 
OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Foundation
 
Bounded Model Checking for C Programs in an Enterprise Environment
Bounded Model Checking for C Programs in an Enterprise EnvironmentBounded Model Checking for C Programs in an Enterprise Environment
Bounded Model Checking for C Programs in an Enterprise EnvironmentAdaCore
 
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...inside-BigData.com
 
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test SuiteProcessor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test SuiteDVClub
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9Ivan Krylov
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone CivettaCocoaHeads France
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio
 

Similar to Practical RISC-V Random Test Generation using Constraint Programming (20)

Continuous Integration for BSP
Continuous Integration for BSPContinuous Integration for BSP
Continuous Integration for BSP
 
GPCE16: Automatic Non-functional Testing of Code Generators Families
GPCE16: Automatic Non-functional Testing of Code Generators FamiliesGPCE16: Automatic Non-functional Testing of Code Generators Families
GPCE16: Automatic Non-functional Testing of Code Generators Families
 
Basavanthrao_resume_vlsi
Basavanthrao_resume_vlsiBasavanthrao_resume_vlsi
Basavanthrao_resume_vlsi
 
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMPInria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
Inria Tech Talk : Comment améliorer la qualité de vos logiciels avec STAMP
 
Introduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKennaIntroduction to OpenSees by Frank McKenna
Introduction to OpenSees by Frank McKenna
 
PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)
 
ASIC design verification
ASIC design verificationASIC design verification
ASIC design verification
 
VLSI lab manual Part A, VTU 7the sem KIT-tiptur
VLSI lab manual Part A, VTU 7the sem KIT-tipturVLSI lab manual Part A, VTU 7the sem KIT-tiptur
VLSI lab manual Part A, VTU 7the sem KIT-tiptur
 
Typesafe spark- Zalando meetup
Typesafe spark- Zalando meetupTypesafe spark- Zalando meetup
Typesafe spark- Zalando meetup
 
Getting started with RISC-V verification what's next after compliance testing
Getting started with RISC-V verification what's next after compliance testingGetting started with RISC-V verification what's next after compliance testing
Getting started with RISC-V verification what's next after compliance testing
 
OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11OpenSAF Symposium_Python Bindings_9.21.11
OpenSAF Symposium_Python Bindings_9.21.11
 
Bounded Model Checking for C Programs in an Enterprise Environment
Bounded Model Checking for C Programs in an Enterprise EnvironmentBounded Model Checking for C Programs in an Enterprise Environment
Bounded Model Checking for C Programs in an Enterprise Environment
 
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
Abstractions and Directives for Adapting Wavefront Algorithms to Future Archi...
 
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test SuiteProcessor Verification Using Open Source Tools and the GCC Regression Test Suite
Processor Verification Using Open Source Tools and the GCC Regression Test Suite
 
Hemanth_Krishnan_resume
Hemanth_Krishnan_resumeHemanth_Krishnan_resume
Hemanth_Krishnan_resume
 
Værktøjer udviklet på AAU til analyse af SCJ programmer
Værktøjer udviklet på AAU til analyse af SCJ programmerVærktøjer udviklet på AAU til analyse af SCJ programmer
Værktøjer udviklet på AAU til analyse af SCJ programmer
 
What to expect from Java 9
What to expect from Java 9What to expect from Java 9
What to expect from Java 9
 
Code quality par Simone Civetta
Code quality par Simone CivettaCode quality par Simone Civetta
Code quality par Simone Civetta
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code Testing
 
NET Code Testing
NET Code TestingNET Code Testing
NET Code Testing
 

Recently uploaded

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxupamatechverse
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Dr.Costas Sachpazis
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSKurinjimalarL3
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxwendy cai
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxpranjaldaimarysona
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024hassan khalil
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...Call Girls in Nagpur High Profile
 

Recently uploaded (20)

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Introduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptxIntroduction to Multiple Access Protocol.pptx
Introduction to Multiple Access Protocol.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCRCall Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
Call Us -/9953056974- Call Girls In Vikaspuri-/- Delhi NCR
 
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANJALI) Dange Chowk Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur EscortsCall Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
Call Girls Service Nagpur Tanvi Call 7001035870 Meet With Nagpur Escorts
 
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
Sheet Pile Wall Design and Construction: A Practical Guide for Civil Engineer...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICSAPPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
APPLICATIONS-AC/DC DRIVES-OPERATING CHARACTERISTICS
 
What are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptxWhat are the advantages and disadvantages of membrane structures.pptx
What are the advantages and disadvantages of membrane structures.pptx
 
Processing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptxProcessing & Properties of Floor and Wall Tiles.pptx
Processing & Properties of Floor and Wall Tiles.pptx
 
Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024Architect Hassan Khalil Portfolio for 2024
Architect Hassan Khalil Portfolio for 2024
 
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
High Profile Call Girls Nashik Megha 7001305949 Independent Escort Service Na...
 

Practical RISC-V Random Test Generation using Constraint Programming

  • 1. Practical RISC-V Random Test Generation using Constraint Programming Edmond A. Cote – http://www.edmondcote.com ABSTRACT A proof-of-concept random test generator for RISC-V ISA is presented. The test generator uses constraint programming for specification of relationships between instructions and operands. Example scenarios to cover basic instruction randomization, data hazards, and non-sharing are presented. The tool integrates the RISC-V instruction set simulator to enable the generation of self- checking tests. The tool is implemented in Python using a freely- available constraint solver library. A summary of problems encountered is provided and next steps are discussed. BACKGROUND Constrained random verification is an important and effective tool for functional verification of microprocessors. Simple random stimulus is not sufficient to verify a processor fully [1]. The use of constraint programming for functional verification has traditionally been limited to domain-specific languages such as e, OpenVera, and SystemVerilog. In the context of a lean semiconductor development model, the cost to acquire licenses of such tools may be prohibitive. The freely-available SystemC Verification Library offers limited supports for constraints. Python verification frameworks exist such as cocotb [2] and Migen [3] but do not offer support for constraint programming. This project aims to explore the possibility of extending Python-based hardware verification frameworks with support for constrained random verification. OBJECTIVES • Learn about RISC-V architecture ahead of workshop • Learn about low-level constraint programming • Demonstrate proof-of-concept random test generator • Complete interesting technical project outside of work METHODS CONCLUSIONS AND NEXT STEPS REFERENCES • [1] Applying Constrained-Random Verification to Microprocessors - Jason C. Chen, Synopsys Inc. • [2] cocoTB documentation - https://media.readthedocs.org/pdf/cocotb/latest/cocotb.pdf • [3] Migen manual http://m-labs.hk/migen.pdf • [4] Constraint Satisfaction Problem Wiki - http://en.wikipedia.org/wiki/Constraint_satisfaction_problem Constraint Programming • Used Python language and python-constraint CSP solver library • CSPs defined by triple {X,D,C} [4]: X = {X1,…, Xn} is a set of variables D = {D1,…,Dn} is a set of respective domain values C = {C1,…,Cm} is a set of constraints • Problem is input to tool using this paradigm • MinConflictSolver in library provides a single valid random solution Examples • Define 10 variables (instructions) and their domain (set of all instructions) i_var = ["i[{}]".format(x) for _ in range(10)] i_dom = ['sw','lw','add','sub', …] # RISC-V instrs csp.addVariables(i_var, i_dom) • Constrain instruction 0 and 2 to be either load or store csp.addConstraint(InSetConstraint(['sw','lw']), ['i[0]','i[2]']) • Constrain for probable WAW hazard rd_var = ["rd[{}]".format(x) for _ in range(10)] rd_dom = ['ra','s0','s1', …] # RISC-V registers csp.addVariables(rd_vars, rd_dom) # At least 5 values of rd are in set csp.addConstraint(SomeInSetConstraint(['s1'], 5), rd_var) • Use of anonymous functions non shared addresses csp.addVariable('addr', range(256)) # fixed domain issue csp.addConstraint(lambda addr: # non sharing addr > cpu*256/ncpu and addr <= (cpu+1)*256/ncpu)) Test Generation • Generate random initial values for all registers • Solve CSP; use csp.getSolution() • Generate instruction sequence based on instruction type, save to temporary file, and compile. Self Checking • Test generator instructs ISS to execute ELF p = Popen('spike -d /path/to/elf'.split(' '), stdin=subprocess.PIPE, stderr=subprocess.PIPE) • ISS runs until magic number reached until reg 0 gp DEADBEEF • Test generator inserts reg commands to ISS and captures values of registers • Self checking code appended to test • Generated self checking tests pass on RISC-V ISS • Random stability checked by varying random seed • Low level constraint programming is difficult, but interesting exercise • Fixed domains are problematic for integer space • Access to alternative solvers can provide the entire solution space. This presents interesting opportunities for functional verification (e.g. analysis of state space, creation of exhaustive tests, etc.). • Use of Python subprocess module to communicate with ISS was effective, but required patch for tool to accept commands from stdin • Explore Google or-tools and SystemC Verification Library • Find a project to apply such a methodology to Example test case : RVTEST_CODE_BEGIN // Randomly generated initial values (subset shown) li s0, 0x8e73c li s1, 0xa46d6 // Random instructions or s0 , s0, s1 // Magic number register write li gp, 0xDEADBEEF // Generated self checking code, values from ISS li gp, 0xAE7FE bne s0, gp, fail li gp, 0xa46d6 bne s1, gp, fail TEST_PASSFAIL RVTEST_CODE_END