Skip to content

Commit

Permalink
Merge pull request #1 from steveicarus/master
Browse files Browse the repository at this point in the history
Code changes from steveicarus/iverilog
  • Loading branch information
jbhateja authored Sep 2, 2017
2 parents 8a5cbd4 + ac87138 commit 4417e37
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 24 deletions.
4 changes: 2 additions & 2 deletions driver/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -1046,8 +1046,8 @@ int main(int argc, char **argv)
break;

case 'i':
ignore_missing_modules = 1;
break;
ignore_missing_modules = 1;
break;

case 'l':
process_file_name(optarg, 1);
Expand Down
18 changes: 9 additions & 9 deletions net_scope.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2000-2016 Stephen Williams ([email protected])
* Copyright (c) 2000-2017 Stephen Williams ([email protected])
* Copyright (c) 2016 CERN Michele Castellana ([email protected])
*
* This source code is free software; you can redistribute it
Expand Down Expand Up @@ -304,16 +304,16 @@ bool NetScope::auto_name(const char*prefix, char pad, const char* suffix)
*/
bool NetScope::replace_parameter(perm_string key, PExpr*val, NetScope*scope)
{
bool flag = false;
if (parameters.find(key) == parameters.end())
return false;

if (parameters.find(key) != parameters.end()) {
param_expr_t&ref = parameters[key];
ref.val_expr = val;
ref.val_scope = scope;
flag = true;
}
param_expr_t&ref = parameters[key];
if (ref.local_flag)
return false;

return flag;
ref.val_expr = val;
ref.val_scope = scope;
return true;
}

bool NetScope::make_parameter_unannotatable(perm_string key)
Expand Down
36 changes: 29 additions & 7 deletions vvp/vpi_callback.cc
Original file line number Diff line number Diff line change
Expand Up @@ -636,24 +636,37 @@ void callback_execute(struct __vpiCallback*cur)
vpi_mode_flag = save_mode;
}

/*
* Usually there is at most one array word associated with a vvp signal, but
* due to port collapsing, there may be more. Using a linked list to record
* the array words minimises memory use for the most common case (no array
* words) or next most common case (one array word).
*/
struct __vpi_array_word {
struct __vpi_array_word* next;
struct __vpiArray* array;
unsigned long word;
};

vvp_vpi_callback::vvp_vpi_callback()
{
vpi_callbacks_ = 0;
array_ = 0;
array_word_ = 0;
array_words_ = 0;
}

vvp_vpi_callback::~vvp_vpi_callback()
{
assert(vpi_callbacks_ == 0);
assert(array_ == 0);
assert(array_words_ == 0);
}

void vvp_vpi_callback::attach_as_word(vvp_array_t arr, unsigned long addr)
{
assert(array_ == 0);
array_ = arr;
array_word_ = addr;
struct __vpi_array_word*tmp = new __vpi_array_word;
tmp->array = arr;
tmp->word = addr;
tmp->next = array_words_;
array_words_ = tmp;
}

void vvp_vpi_callback::add_vpi_callback(value_callback*cb)
Expand All @@ -671,6 +684,11 @@ void vvp_vpi_callback::clear_all_callbacks()
delete vpi_callbacks_;
vpi_callbacks_ = tmp;
}
while (array_words_) {
struct __vpi_array_word*tmp = array_words_->next;
delete array_words_;
array_words_ = tmp;
}
}
#endif

Expand All @@ -682,7 +700,11 @@ void vvp_vpi_callback::clear_all_callbacks()
*/
void vvp_vpi_callback::run_vpi_callbacks()
{
if (array_) array_->word_change(array_word_);
struct __vpi_array_word*array_word = array_words_;
while (array_word) {
array_word->array->word_change(array_word->word);
array_word = array_word->next;
}

value_callback *next = vpi_callbacks_;
value_callback *prev = 0;
Expand Down
12 changes: 11 additions & 1 deletion vvp/vpi_event.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2012 Stephen Williams ([email protected])
* Copyright (c) 2002-2017 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -63,6 +63,16 @@ char* __vpiNamedEvent::vpi_get_str(int code)
return generic_get_str(code, scope_, name_, NULL);
}

vpiHandle __vpiNamedEvent::vpi_put_value(p_vpi_value, int)
{
// p_vpi_value may be NULL, and an event doesn't care
// what the value is
vvp_vector4_t val;
vvp_net_ptr_t dest(funct, 0);
vvp_send_vec4(dest, val, vthread_get_wt_context());

return this;
}

vpiHandle __vpiNamedEvent::vpi_handle(int code)
{
Expand Down
16 changes: 14 additions & 2 deletions vvp/vpi_priv.cc
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2008-2016 Stephen Williams ([email protected])
* Copyright (c) 2008-2017 Stephen Williams ([email protected])
*
* This source code is free software; you can redistribute it
* and/or modify it in source code form under the terms of the GNU
Expand Down Expand Up @@ -464,6 +464,7 @@ int vpip_time_units_from_handle(vpiHandle obj)
struct __vpiSysTaskCall*task;
__vpiScope*scope;
struct __vpiSignal*signal;
__vpiNamedEvent*event;

if (obj == 0)
return vpip_get_time_precision();
Expand All @@ -483,6 +484,11 @@ int vpip_time_units_from_handle(vpiHandle obj)
scope = vpip_scope(signal);
return scope->time_units;

case vpiNamedEvent:
event = dynamic_cast<__vpiNamedEvent*>(obj);
scope = event->get_scope();
return scope->time_units;

default:
fprintf(stderr, "ERROR: vpip_time_units_from_handle called with "
"object handle type=%u\n", obj->get_type_code());
Expand Down Expand Up @@ -1104,7 +1110,13 @@ vpiHandle vpi_put_value(vpiHandle obj, s_vpi_value*vp,

vpip_put_value_event*put = new vpip_put_value_event;
put->handle = obj;
put->value = *vp;
if (dynamic_cast<__vpiNamedEvent*>(obj)) {
put->value.format = vpiIntVal;
put->value.value.integer = 0;
} else {
assert(vp);
put->value = *vp;
}
/* Since this is a scheduled put event we must copy any pointer
* data to keep it available until the event is actually run. */
switch (put->value.format) {
Expand Down
4 changes: 3 additions & 1 deletion vvp/vpi_priv.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef IVL_vpi_priv_H
#define IVL_vpi_priv_H
/*
* Copyright (c) 2001-2015 Stephen Williams ([email protected])
* Copyright (c) 2001-2017 Stephen Williams ([email protected])
* Copyright (c) 2016 CERN Michele Castellana ([email protected])
*
* This source code is free software; you can redistribute it
Expand Down Expand Up @@ -479,8 +479,10 @@ class __vpiNamedEvent : public __vpiHandle {
__vpiNamedEvent(__vpiScope*scope, const char*name);
~__vpiNamedEvent();
int get_type_code(void) const;
__vpiScope*get_scope(void) const { return scope_; }
int vpi_get(int code);
char* vpi_get_str(int code);
vpiHandle vpi_put_value(p_vpi_value val, int flags);
vpiHandle vpi_handle(int code);

inline void add_vpi_callback(__vpiCallback*cb)
Expand Down
3 changes: 1 addition & 2 deletions vvp/vvp_vpi_callback.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ class vvp_vpi_callback {

private:
value_callback*vpi_callbacks_;
struct __vpiArray* array_;
unsigned long array_word_;
struct __vpi_array_word*array_words_;
};


Expand Down

0 comments on commit 4417e37

Please sign in to comment.