Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions melange/core/src/veriloga/osdi_0_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub const DOMAIN_CONTINUOUS: u32 = 2;
pub const NOISE_TYPE_WHITE: u32 = 0;
pub const NOISE_TYPE_FLICKER: u32 = 1;
pub const NOISE_TYPE_TABLE: u32 = 2;
pub const MODULEFLAG_ABSTIME: u32 = 1;

#[repr(C)]
pub struct OsdiLimFunction {
Expand Down Expand Up @@ -195,6 +196,7 @@ pub struct OsdiDescriptor {
pub residual_nature: *mut OsdiNatureRef,
pub noise_source_type: *mut u32,
pub load_noise_params: fn(*mut c_void, *mut c_void, *mut f64, *mut f64),
pub module_flags: u32,
}
impl OsdiDescriptor {
pub fn access(
Expand Down
2 changes: 2 additions & 0 deletions openvaf/openvaf/tests/load/osdi_0_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ pub const DOMAIN_CONTINUOUS: u32 = 2;
pub const NOISE_TYPE_WHITE: u32 = 0;
pub const NOISE_TYPE_FLICKER: u32 = 1;
pub const NOISE_TYPE_TABLE: u32 = 2;
pub const MODULEFLAG_ABSTIME: u32 = 1;

#[repr(C)]
pub struct OsdiLimFunction {
Expand Down Expand Up @@ -195,6 +196,7 @@ pub struct OsdiDescriptor {
pub residual_nature: *mut OsdiNatureRef,
pub noise_source_type: *mut u32,
pub load_noise_params: fn(*mut c_void, *mut c_void, *mut f64, *mut f64),
pub module_flags: u32,
}
impl OsdiDescriptor {
pub fn access(
Expand Down
3 changes: 3 additions & 0 deletions openvaf/osdi/header/osdi_0_4.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
#define NOISE_TYPE_FLICKER 1
#define NOISE_TYPE_TABLE 2

#define MODULEFLAG_ABSTIME 1

typedef struct OsdiLimFunction {
char *name;
uint32_t num_args;
Expand Down Expand Up @@ -226,6 +228,7 @@ typedef struct OsdiDescriptor {
OsdiNatureRef* residual_nature;
uint32_t *noise_source_type;
void (*load_noise_params)(void *inst, void *model, double *power, double *exponent);
uint32_t module_flags;
}OsdiDescriptor;

typedef struct OsdiNature {
Expand Down
13 changes: 11 additions & 2 deletions openvaf/osdi/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::iter::once;
use hir::{CompilationDB, ParamSysFun, Type};
use hir_def::db::HirDefDB;
use hir_def::ndatable::NDATable;
use hir_lower::CurrentKind;
use hir_lower::{CurrentKind, ParamKind};
use lasso::{Rodeo, Spur};
use llvm_sys::core::{
LLVMConstArray2, LLVMConstInt, LLVMConstPtrToInt, LLVMGetArrayLength2, LLVMGetDataLayoutStr,
Expand Down Expand Up @@ -34,7 +34,7 @@ use crate::metadata::osdi_0_4::{
JACOBIAN_ENTRY_RESIST, JACOBIAN_ENTRY_RESIST_CONST, NATREF_DISCIPLINE_FLOW,
NATREF_DISCIPLINE_POTENTIAL, NATREF_NONE, NOISE_TYPE_FLICKER, NOISE_TYPE_TABLE,
NOISE_TYPE_WHITE, PARA_KIND_INST, PARA_KIND_MODEL, PARA_KIND_OPVAR, PARA_TY_INT, PARA_TY_REAL,
PARA_TY_STR,
PARA_TY_STR,MODULEFLAG_ABSTIME,
};
use crate::ty_len;

Expand Down Expand Up @@ -401,6 +401,14 @@ impl<'ll> OsdiCompilationUnit<'_, '_, 'll> {
.collect();

let (uvec, rvec) = self.unknown_residual_natures(db);

let mut module_flags = 0u32;
module.intern.params.iter().for_each(|(p, _)| {
if let ParamKind::Abstime = p {
module_flags |= MODULEFLAG_ABSTIME;
}
});

OsdiDescriptor {
name: module.info.module.name(db),
num_nodes: module.dae_system.unknowns.len() as u32,
Expand Down Expand Up @@ -457,6 +465,7 @@ impl<'ll> OsdiCompilationUnit<'_, '_, 'll> {
residual_nature: rvec,
noise_source_type,
load_noise_params: self.load_noise_params(),
module_flags: module_flags,
}
}
}
Expand Down
4 changes: 4 additions & 0 deletions openvaf/osdi/src/metadata/osdi_0_4.rs
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ pub const DOMAIN_CONTINUOUS: u32 = 2;
pub const NOISE_TYPE_WHITE: u32 = 0;
pub const NOISE_TYPE_FLICKER: u32 = 1;
pub const NOISE_TYPE_TABLE: u32 = 2;
pub const MODULEFLAG_ABSTIME: u32 = 1;

pub struct OsdiLimFunction<'ll> {
pub name: String,
Expand Down Expand Up @@ -415,6 +416,7 @@ pub struct OsdiDescriptor<'ll> {
pub residual_nature: Vec<OsdiNatureRef>,
pub noise_source_type: Vec<u32>,
pub load_noise_params: &'ll llvm_sys::LLVMValue,
pub module_flags: u32,
}
impl<'ll> OsdiDescriptor<'ll> {
pub fn to_ll_val(
Expand Down Expand Up @@ -483,6 +485,7 @@ impl<'ll> OsdiDescriptor<'ll> {
ctx.const_arr_ptr(tys.osdi_nature_ref, &arr_47),
ctx.const_arr_ptr(ctx.ty_int(), &arr_48),
self.load_noise_params,
ctx.const_unsigned_int(self.module_flags),
];
let ty = tys.osdi_descriptor;
ctx.const_struct(ty, &fields)
Expand Down Expand Up @@ -542,6 +545,7 @@ impl OsdiTyBuilder<'_, '_, '_> {
ctx.ty_ptr(),
ctx.ty_ptr(),
ctx.ty_ptr(),
ctx.ty_int(),
];
let ty = ctx.ty_struct("OsdiDescriptor", &fields);
self.osdi_descriptor = Some(ty);
Expand Down
Loading