Skip to content

Instantly share code, notes, and snippets.

View dvtalk's full-sized avatar
🎯
Focusing

dvtalk dvtalk

🎯
Focusing
View GitHub Profile
@dvtalk
dvtalk / openssl_bn_multmod.c
Last active October 23, 2025 08:50
Big Number operation using OpenSSL library
// https://dvtalk.me
//
#include <openssl/conf.h>
#include <openssl/err.h>
#include <openssl/bn.h>
#include <stdio.h>
#include <string.h>
unsigned int mul_mod() ;
@dvtalk
dvtalk / aes_sv_c_dpi.c
Last active October 23, 2025 08:49
Example of SystemVerilog DPI-C for AES operation
// https://dvtalk.me/2021/08/29/systemverilog-dpi-example-with-aes-openssl-cmodel/
#include "svdpi.h"
#include "aes.c"
#include <stdint.h>
uint32_t cAesEncrypt(enum AES_OP_MODE svaes_mode,
svOpenArrayHandle svplaintext,
int svplaintext_len,
svOpenArrayHandle svkey,
int svkey_len,
@dvtalk
dvtalk / aes.c
Last active October 23, 2025 08:49
AES encryption/decryption using OpenSSL Library
// https://dvtalk.me/2021/08/29/systemverilog-dpi-example-with-aes-openssl-cmodel/
#ifndef __AES_C__
#define __AES_C__
#include "aes.h"
#include <openssl/conf.h>
#include <openssl/evp.h>
#include <openssl/err.h>
#include <stdio.h>
#include <stdlib.h>
@dvtalk
dvtalk / ring_buffer.md
Last active October 16, 2025 07:11
Ring buffer basic (circular buffer, circular queue, cyclic buffer or ring buffer)

DEPEND on the IMPLEMENTATION

but most likely

  • ring buffer length minimum is 2.

  • ring buffer maximum number of occupied entry slots is ring buffer length - 1

  • tail (Write pointer): points to next available entry slot

  • head (Read pointer): points to next occupied entry slot

  • tail (write pointer) is maintained by producer

@dvtalk
dvtalk / objection_debug.md
Created April 2, 2025 08:09
Objection debug
  1. Wait for an objection drop in other uvm component. phase.phase_done.wait_for(UVM_ALL_DROPPED, smthing_manager_component );
  2. Check current objector that has not drop objection yet
phase.phase_done.get_objectors(tmp_q);
		$display(" check objection %d", tmp_q.size());
		$display(" check objection %d", tmp_q.size() - phase.get_objection_count(this));
		$display(" check objection %p", tmp_q);
@dvtalk
dvtalk / uvm_pack_unpack_note.md
Last active November 19, 2024 06:46
uvm pack/unpack example
  • pack
class data_obj extends uvm_object
   virtual function void do_pack(uvm_packer packer);
      packer.pack_field_int(32'habcd_1234, 32); //DW0
      packer.pack_field_int(32'h0, 32);         //DW1
      packer.pack_field_int(32'h0, 32);         //DW2
      packer.pack_field_int(32'h0, 32);         //DW3
   endfunction: do_pack
   ...
@dvtalk
dvtalk / uvm_regular_expression.md
Last active October 10, 2024 04:11
uvm regular expression

Sometimes an expression syntax that is easy to read and easy to write is useful, even ifthe syntax is not as expressive as the full power of posix regular expressions. A popularsubstitute for regular expressions is globs. A glob is a simplified regular expression. Itonly has three metacharacters -- *, +, and ?. Character ranges are not allowed anddots are not a metacharacter in globs as they are in regular expressions. The followingtable shows glob metacharacters.

UVM 1.1 Class Reference 142 UVM html 1.2 https://verificationacademy.com/verification-methodology-reference/uvm/docs_1.2/html/index.html Check "uvm_resource" page

UVM cookbook 2018 page 30

@dvtalk
dvtalk / debug_object_handle.md
Last active July 29, 2024 07:51
Debug object handles if the variables point to the same object.
  • $display("Object handle var1 %p\n var2 %p", m_obj1, m_obj2);
  • Not all simulators EDA support this.
@dvtalk
dvtalk / uvm_config_db_note.md
Last active July 29, 2024 01:58
uvm_config_db note

Why using

  • Avoid dependent between object.
  • Avoid OOP restriction when use factory override.
    • For example: if we assign object directly top_env.module_a_agent.m_obj = m_obj; However, the m_obj only exist in the overriden type of module a agent --> issue.
  • In sequence to get data, comp handle.

Why not using

  • From uvm cookbook, intensive use of uvm_config_db slows simulation
  • Only use with class type, not primitive type variable.
@dvtalk
dvtalk / loop_vcs_cmd.md
Last active June 24, 2024 13:22
inifite loop debug in design

For testbench loop:

  • Not found any solution,
  • check forever and while(1) in all the code

For the design: using vcs with this

  • compile: vcs +vcs+loopreport+20000
  • run sim: simv +vcs+loopreport+1000000 (the simuation option will override the compile option)
  • later VCS version will support start_time: simv +vcs+loopreport+1000000+start_time=1
  • Use start_time to avoid loop at 0 simulation time (could have many loop caused by X value)
  • If +start_time is not supported, incrase the number of loop value.