Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Protection against multiple includes
Check that set_id_info was called
Any vendor specific defines go here.
The +define+UVM_CB_TRACE_ON setting will instrument the uvm library to emit messages with message id UVMCB_TRC and UVM_NONE verbosity notifing add,delete and execution of uvm callbacks. The instrumentation is off by default.
Import DPI functions used by the interface to generate the lists.
Deprecation Control Macros
Top-level file for DPI subroutines used by UVM. Tool-specific distribution overlays may be required. To use UVM without any tool-specific overlay, use +defin+UVM_NO_DPI
If `included directly in a program block, can't use a non-blocking assign, but it isn't needed since program blocks are in a seperate region.
`ifndef UVM_USE_FILE_LINE `define UVM_REPORT_DISABLE_FILE_LINE `endif
Period of the master clock
Period of the slave clock
Period of the master clock
Number of registers
Period of the slave clock
Maximum address width unchanged by protocol
Maximum data width unchanged by protocol
Maximum master ID width unchanged by protocol
Minimum address width unchanged by protocol
M_UVM_FIELD_DATA_AA_int_int
TLM imp implementations
These imps are used in uvm_*_port, uvm_*_export and uvm_*_imp, using suffixes
The default timeout for simulation, if not overridden by <uvm_root::set_timeout> or <+UVM_TIMEOUT>
Version numbers to be used in creating version strings for printing or programmatic tesing against version numbers
When specicializing resources the get_by_name and get_by_type functions must be redefined. The reason is that the version of these functions in the base class (uvm_resource#(T)) returns an object of type uvm_resource#(T). In the specializations we must return an object of the type of the specialization. So, we call the base_class implementation of these functions and then downcast to the subtype. This macro is invokved once in each where a resource specialization is a class defined as:class <resource_specialization> extends uvm_resource#(T)where <resource_specialization> is the name of the derived class. The argument to this macro is T, the type of the uvm_resource#(T) specialization. The class in which the macro is defined must supply a typedef of the specialized class of the form:typedef <resource_specialization> this_subtype;where <resource_specialization> is the same as above. The macro generates the get_by_name() and get_by_type() functions for the specialized resource (i.e. resource subtype).
imp definitions
Primitive interfaces
Define blocking mask onehot assignment = 'b100
The macro wraps the function b_transport() Execute a blocking transaction. Once this method returns, the transaction is assumed to have been executed. Whether that execution is succesful or not must be indicated by the transaction itself. The callee may modify or update the transaction object, subject to any constraints imposed by the transaction class. The initiator may re-use a transaction object from one call to the next and across calls to b_transport(). The call to b_transport shall mark the first timing point of the transaction. The return from b_transport() shall mark the final timing point of the transaction. The timing annotation argument allows the timing points to be offset from the simulation times at which the task call and return are executed.
Copyright 2007-2011 Mentor Graphics Corporation
Copyright 2007-2011 Cadence Design Systems, Inc.
Copyright 2010 Synopsys, Inc.
All Rights Reserved Worldwide
Licensed under the Apache License, Version 2.0 (the
"License"); you may not use this file except in
compliance with the License. You may obtain a copy of
the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in
writing, software distributed under the License is
distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied. See
the License for the specific language governing
permissions and limitations under the License.
Defines Not-Yet-Implemented TLM functions
Define Non blocking backward mask onehot assignment = 'b010
Define Non blocking Forward mask onehot assignment = 'b001
Implementation of the backward path. The macro wraps the function called nb_transport_bw(). This function MUST be implemented in the INITIATOR component class. Every call to this method may mark a timing point, including the final timing point, in the execution of the transaction. The timing annotation argument allows the timing point to be offset from the simulation times at which the backward path is used. The final timing point of a transaction may be marked by a call to nb_transport_fw() within`UVM_TLM_NB_TRANSPORT_FW_IMP
or a return from this or subsequent call to nb_transport_bw(). See <TLM2 Interfaces, Ports, Exports and Transport Interfaces Subset> for more details on the semantics and rules of the nonblocking transport interface. Exampleclass master extends uvm_component; uvm_tlm_nb_initiator_socket #(trans, uvm_tlm_phase_e, this_t) initiator_socket; function void build_phase(uvm_phase phase); initiator_socket = new("initiator_socket", this, this); endfunction function uvm_tlm_sync_e nb_transport_bw(trans t, ref uvm_tlm_phase_e p, input uvm_tlm_time delay); transaction = t; state = p; return UVM_TLM_ACCEPTED; endfunction ... endclass
The macro wraps the forward path call function nb_transport_fw()
The first call to this method for a transaction marks the initial timing point.
Every call to this method may mark a timing point in the execution of the
transaction. The timing annotation argument allows the timing points
to be offset from the simulation times at which the forward path is used.
The final timing point of a transaction may be marked by a call
to nb_transport_bw() within `UVM_TLM_NB_TRANSPORT_BW_IMP
or a return from this
or subsequent call to nb_transport_fw().
See <TLM2 Interfaces, Ports, Exports and Transport Interfaces Subset>
for more details on the semantics and rules of the nonblocking
transport interface.
Combination interfaces
Defines Not-Yet-Implemented TLM tasks
Whole version identifiers that can be used in `ifdefs and `ifndefs to do conditional compilation
When there is a FIX_REV, print as "M.mf" When there is NO FIX_REV, print as "M.m". Fix rev kind of string:
This is needed due to an issue in of passing down strings created by args to lower level macros.
This is needed due to an issue in of passing down strings created by args to lower level macros.
Purpose provide print functionality for a specific integral field. This macro is available for user access. If used externally, a record_options object must be avaialble and must have the name opt. Postcondition ARG is printed using the format set by the FLAGS.
DEPRECATED * Group- Sequence Registration Macros The sequence-specific macros perform the same function as the set of `uvm_object_*_utils macros, except they also set the default sequencer type the sequence will run on.
`uvm_analysis_imp_decl(SFX)Define the class uvm_analysis_impSFX for providing an analysis implementation. SFX is the suffix for the new class type. The analysis implemenation is the write function. The `uvm_analysis_imp_decl allows for a scoreboard (or other analysis component) to support input from many places. For example:`uvm_analysis_imp_decl(_ingress) `uvm_analysis_imp_decl(_egress) class myscoreboard extends uvm_component; uvm_analysis_imp_ingress#(mydata, myscoreboard) ingress; uvm_analysis_imp_egress#(mydata, myscoreboard) egress; mydata ingress_list[$]; ... function new(string name, uvm_component parent); super.new(name,parent); ingress = new("ingress", this); egress = new("egress", this); endfunction function void write_ingress(mydata t); ingress_list.push_back(t); endfunction function void write_egress(mydata t); find_match_in_ingress_list(t); endfunction function void find_match_in_ingress_list(mydata t); implement scoreboarding for this particular DUT ... endfunction endclass
`uvm_blocking_get_imp_decl(SFX)Define the class uvm_blocking_get_impSFX for providing blocking get implementations. SFX is the suffix for the new class type.
`uvm_blocking_get_peek_imp_decl(SFX)Define the class uvm_blocking_get_peek_impSFX for providing the blocking get_peek implemenation.
`uvm_blocking_master_imp_decl(SFX)Define the class uvm_blocking_master_impSFX for providing the blocking master implemenation.
`uvm_blocking_peek_imp_decl(SFX)Define the class uvm_blocking_peek_impSFX for providing blocking peek implementations. SFX is the suffix for the new class type.
`uvm_blocking_put_imp_decl(SFX)Define the class uvm_blocking_put_impSFX for providing blocking put implementations. SFX is the suffix for the new class type.
`uvm_blocking_slave_imp_decl(SFX)Define the class uvm_blocking_slave_impSFX for providing the blocking slave implemenation.
`uvm_blocking_transport_imp_decl(SFX)Define the class uvm_blocking_transport_impSFX for providing the blocking transport implemenation.
Registers a uvm_component-based class with the factory`uvm_component_registry(T,S)Registers a uvm_component-based class T and lookup string S with the factory. S typically is the name of the class in quotes. The`uvm_object_utils
family of macros uses this macro.
MACRO `uvm_component_end uvm_component-based class declarations may contain one of the above forms of utility macros. For simple components with no field macros, use`uvm_component_utils(TYPE)For simple components with field macros, use`uvm_component_utils_begin(TYPE) `uvm_field_* macro invocations here `uvm_component_utils_endFor parameterized components with no field macros, use`uvm_component_param_utils(TYPE)For parameterized components with field macros, use`uvm_component_param_utils_begin(TYPE) `uvm_field_* macro invocations here `uvm_component_utils_endSimple (non-parameterized) components must use the uvm_components_utils* versions, which do the following:
`uvm_create(SEQ_OR_ITEM)This action creates the item or sequence using the factory. It intentionally does zero processing. After this action completes, the user can manually set values, manipulate rand_mode and constraint_mode, etc.
`uvm_create_on(SEQ_OR_ITEM, SEQR)This is the same as`uvm_create
except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified SEQR argument.
This macro is used to declare a variable p_sequencer whose type is specified by SEQUENCER.`uvm_declare_p_sequencer(SEQUENCER)The example below shows using the the `uvm_declare_p_sequencer macro along with the uvm_object_utils macros to set up the sequence but not register the sequence in the sequencer's library.class mysequence extends uvm_sequence#(mydata); `uvm_object_utils(mysequence) `uvm_declare_p_sequencer(some_seqr_type) task body; Access some variable in the user's custom sequencer if(p_sequencer.some_variable) begin ... end endtask endclass
DEPRECATED * Group- Sequencer Registration Macros The sequencer-specific macros perform the same function as the set of `uvm_componenent_*utils macros except that they also declare the plumbing necessary for creating the sequencer's sequence library.
`uvm_do(SEQ_OR_ITEM)This macro takes as an argument a uvm_sequence_item variable or object. The argument is created using`uvm_create
if necessary, then randomized. In the case of an item, it is randomized after the call to <uvm_sequence_base::start_item()> returns. This is called late-randomization. In the case of a sequence, the sub-sequence is started using <uvm_sequence_base::start()> with call_pre_post set to 0. In the case of an item, the item is sent to the driver through the associated sequencer. For a sequence item, the following are called, in order`uvm_create(item) sequencer.wait_for_grant(prior) (task) this.pre_do(1) (task) item.randomize() this.mid_do(item) (func) sequencer.send_request(item) (func) sequencer.wait_for_item_done() (task) this.post_do(item) (func)For a sequence, the following are called, in order`uvm_create(sub_seq) sub_seq.randomize() sub_seq.pre_start() (task) this.pre_do(0) (task) this.mid_do(sub_seq) (func) sub_seq.body() (task) this.post_do(sub_seq) (func) sub_seq.post_start() (task)
`uvm_do_obj_callbacks(T,CB,OBJ,METHOD)Calls the given METHOD of all callbacks based on type CB registered with the given object, OBJ, which is or is based on type T. This macro is identical to`uvm_do_callbacks
macro, but it has an additional OBJ argument to allow the specification of an external object to associate the callback with. For example, if the callbacks are being applied in a sequence, OBJ could be specified as the associated sequencer or parent sequence.... `uvm_do_callbacks(mycb, mycomp, seqr, my_function(seqr, curr_addr, curr_data)) ...
`uvm_do_obj_callbacks_exit_on(T,CB,OBJ,METHOD,VAL)Calls the given METHOD of all callbacks of type CB registered with the given object OBJ, which must be or be based on type T, and returns upon the first callback that returns the bit value given by VAL. It is exactly the same as the`uvm_do_callbacks_exit_on
but has a specific object instance (instead of the implicit this instance) as the third argument.... Exit if a callback returns a 1 `uvm_do_callbacks_exit_on(mycomp, mycb, seqr, drop_trans(seqr,trans), 1) ...Because this macro calls return, its use is restricted to implementations of functions that return a bit value, as in the above example.
`uvm_do_on(SEQ_OR_ITEM, SEQR)This is the same as`uvm_do
except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified SEQR argument.
`uvm_do_on_pri(SEQ_OR_ITEM, SEQR, PRIORITY)This is the same as`uvm_do_pri
except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified SEQR argument.
`uvm_do_on_pri_with(SEQ_OR_ITEM, SEQR, PRIORITY, CONSTRAINTS)This is the same as `uvm_do_pri_with except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified SEQR argument.
`uvm_do_on_with(SEQ_OR_ITEM, SEQR, CONSTRAINTS)This is the same as`uvm_do_with
except that it also sets the parent sequence to the sequence in which the macro is invoked, and it sets the sequencer to the specified SEQR argument. The user must supply brackets around the constraints.
`uvm_do_pri(SEQ_OR_ITEM, PRIORITY)This is the same as `uvm_do except that the sequene item or sequence is executed with the priority specified in the argument
`uvm_do_pri_with(SEQ_OR_ITEM, PRIORITY, CONSTRAINTS)This is the same as `uvm_do_pri except that the given constraint block is applied to the item or sequence in a randomize with statement before execution.
`uvm_do_with(SEQ_OR_ITEM, CONSTRAINTS)This is the same as `uvm_do except that the constraint block in the 2nd argument is applied to the item or sequence in a randomize with statement before execution.
`uvm_error(ID,MSG)Calls uvm_report_error with a verbosity of UVM_NONE. The message can not be turned off using the reporter's verbosity setting, but can be turned off by setting the action for the message. ID is given as the message tag and MSG is given as the message text. The file and line are also sent to the uvm_report_error call.
`uvm_error_context(ID,MSG,CNTXT)Operates identically to `uvm_error but requires that the context, or <uvm_report_object> in which the message is printed be explicitly supplied as a macro argument.
`uvm_fatal(ID,MSG)Calls uvm_report_fatal with a verbosity of UVM_NONE. The message can not be turned off using the reporter's verbosity setting, but can be turned off by setting the action for the message. ID is given as the message tag and MSG is given as the message text. The file and line are also sent to the uvm_report_fatal call.
`uvm_fatal_context(ID,MSG,CNTXT)Operates identically to `uvm_fatal but requires that the context, or <uvm_report_object>, in which the message is printed be explicitly supplied as a macro argument.
Implements the data operations for an associative array of integral types indexed by the byte data type.`uvm_field_aa_int_byte(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with byte key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by the byte unsigned data type.`uvm_field_aa_int_byte_unsigned(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with byte unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by any enumeration key data type.`uvm_field_aa_int_longint_unsigned(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with longint unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by the int data type.`uvm_field_aa_int_int(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with int key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by the int unsigned data type.`uvm_field_aa_int_int_unsigned(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with int unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by the integer data type.`uvm_field_aa_int_integer(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with integer key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by the integer unsigned data type.`uvm_field_aa_int_integer_unsigned(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with integer unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by any integral key data type.`uvm_field_aa_int_key(long unsigned,ARG,FLAG)KEY is the data type of the integral key, ARG is the name of a property that is an associative array of integrals, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by the longint data type.`uvm_field_aa_int_longint(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with longint key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by the longint unsigned data type.`uvm_field_aa_int_longint_unsigned(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with longint unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by the shortint data type.`uvm_field_aa_int_shortint(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with shortint key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integral types indexed by the shortint unsigned data type.`uvm_field_aa_int_shortint_unsigned(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with shortint unsigned key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of integrals indexed by string.`uvm_field_aa_int_string(ARG,FLAG)ARG is the name of a property that is an associative array of integrals with string key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of <uvm_object>-based objects indexed by the int data type.`uvm_field_aa_object_int(ARG,FLAG)ARG is the name of a property that is an associative array of objects with int key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of <uvm_object>-based objects indexed by string.`uvm_field_aa_object_string(ARG,FLAG)ARG is the name of a property that is an associative array of objects with string key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an associative array of strings indexed by string.`uvm_field_aa_string_string(ARG,FLAG)ARG is the name of a property that is an associative array of strings with string key, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a one-dimensional dynamic array of enums.`uvm_field_array_enum(T,ARG,FLAG)T is a one-dimensional dynamic array of enums type ARG is an instance of that type, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a one-dimensional dynamic array of integrals.`uvm_field_array_int(ARG,FLAG)ARG is a one-dimensional dynamic array of integrals, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a one-dimensional dynamic array of <uvm_object>-based objects.`uvm_field_array_object(ARG,FLAG)ARG is a one-dimensional dynamic array of <uvm_object>-based objects, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a one-dimensional dynamic array of strings.`uvm_field_array_string(ARG,FLAG)ARG is a one-dimensional dynamic array of strings, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an enumerated property.`uvm_field_enum(T,ARG,FLAG)T is an enumerated _type_, ARG is an instance of that type, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an event property.`uvm_field_event(ARG,FLAG)ARG is an event property of the class, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for any packed integral property.`uvm_field_int(ARG,FLAG)ARG is an integral property of the class, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for an <uvm_object>-based property.`uvm_field_object(ARG,FLAG)ARG is an object property of the class, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a one-dimensional queue of enums.`uvm_field_queue_enum(T,ARG,FLAG)T is a queue of enums _type_, ARG is an instance of that type, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a queue of integrals.`uvm_field_queue_int(ARG,FLAG)ARG is a one-dimensional queue of integrals, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a queue of <uvm_object>-based objects.`uvm_field_queue_object(ARG,FLAG)ARG is a one-dimensional queue of <uvm_object>-based objects, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a queue of strings.`uvm_field_queue_string(ARG,FLAG)ARG is a one-dimensional queue of strings, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for any real property.`uvm_field_real(ARG,FLAG)ARG is an real property of the class, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a one-dimensional static array of enums.`uvm_field_sarray_enum(T,ARG,FLAG)T is a one-dimensional dynamic array of enums _type_, ARG is an instance of that type, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a one-dimensional static array of integrals.`uvm_field_sarray_int(ARG,FLAG)ARG is a one-dimensional static array of integrals, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a one-dimensional static array of <uvm_object>-based objects.`uvm_field_sarray_object(ARG,FLAG)ARG is a one-dimensional static array of <uvm_object>-based objects, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a one-dimensional static array of strings.`uvm_field_sarray_string(ARG,FLAG)ARG is a one-dimensional static array of strings, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
Implements the data operations for a string property.`uvm_field_string(ARG,FLAG)ARG is a string property of the class, and FLAG is a bitwise OR of one or more flag settings as described in <Field Macros> above.
MACRO `uvm_field_utils_end These macros form a block in which `uvm_field_* macros can be placed. Used as`uvm_field_utils_begin(TYPE) `uvm_field_* macros here `uvm_field_utils_endThese macros do not perform factory registration nor implement the get_type_name and create methods. Use this form when you need custom implementations of these two methods, or when you are setting up field macros for an abstract class (i.e. virtual class).
`uvm_get_imp_decl(SFX)Define the class uvm_get_impSFX for providing both blocking and non-blocking get implementations. SFX is the suffix for the new class type.
`uvm_get_peek_imp_decl(SFX)Define the class uvm_get_peek_impSFX for providing both blocking and non-blocking get_peek implementations. SFX is the suffix for the new class type.
`uvm_info(ID,MSG,VERBOSITY)Calls uvm_report_info if VERBOSITY is lower than the configured verbosity of the associated reporter. ID is given as the message tag and MSG is given as the message text. The file and line are also sent to the uvm_report_info call.
`uvm_info_context(ID,MSG,VERBOSITY,CNTXT)Operates identically to `uvm_info but requires that the context, or <uvm_report_object>, in which the message is printed be explicitly supplied as a macro argument.
`uvm_master_imp_decl(SFX)Define the class uvm_master_impSFX for providing both blocking and non-blocking master implementations. SFX is the suffix for the new class type.
`uvm_nonblocking_get_imp_decl(SFX)Define the class uvm_nonblocking_get_impSFX for providing non-blocking get implementations. SFX is the suffix for the new class type.
`uvm_nonblocking_get_peek_imp_decl(SFX)Define the class uvm_nonblocking_get_peek_impSFX for providing non-blocking get_peek implemenation.
`uvm_nonblocking_master_imp_decl(SFX)Define the class uvm_nonblocking_master_impSFX for providing the non-blocking master implemenation.
`uvm_nonblocking_peek_imp_decl(SFX)Define the class uvm_nonblocking_peek_impSFX for providing non-blocking peek implementations. SFX is the suffix for the new class type.
`uvm_nonblocking_put_imp_decl(SFX)Define the class uvm_nonblocking_put_impSFX for providing non-blocking put implementations. SFX is the suffix for the new class type.
`uvm_nonblocking_slave_imp_decl(SFX)Define the class uvm_nonblocking_slave_impSFX for providing the non-blocking slave implemenation.
`uvm_nonblocking_transport_imp_decl(SFX)Define the class uvm_nonblocking_transport_impSFX for providing the non-blocking transport implemenation.
Register a uvm_object-based class with the factory`uvm_object_registry(T,S)Registers a uvm_object-based class T and lookup string S with the factory. S typically is the name of the class in quotes. The`uvm_object_utils
family of macros uses this macro.
<uvm_object>-based class declarations may contain one of the above forms of utility macros. For simple objects with no field macros, use`uvm_object_utils(TYPE)For simple objects with field macros, use`uvm_object_utils_begin(TYPE) `uvm_field_* macro invocations here `uvm_object_utils_endFor parameterized objects with no field macros, use`uvm_object_param_utils(TYPE)For parameterized objects, with field macros, use`uvm_object_param_utils_begin(TYPE) `uvm_field_* macro invocations here `uvm_object_utils_endSimple (non-parameterized) objects use the uvm_object_utils* versions, which do the following:
`uvm_object_utils
only in that they do not supply a type name
when registering the object with the factory. As such, name-based lookup with
the factory for parameterized classes is not possible.
The macros with _begin suffixes are the same as the non-suffixed versions
except that they also start a block in which `uvm_field_* macros can be
placed. The block must be terminated by `uvm_object_utils_end.
Objects deriving from uvm_sequence must use the `uvm_sequence_* macros
instead of these macros. See `uvm_sequence_utils
for details.
Pack a dynamic array without having to also specify the bit size of its elements. Array size must be non-zero.`uvm_pack_array(VAR)
Pack a dynamic array of integrals.`uvm_pack_arrayN(VAR,SIZE)
Pack an enumeration value. Packing does not require its type be specified.`uvm_pack_enum(VAR)
Pack an integral variable.`uvm_pack_enumN(VAR,SIZE)
Pack an integral variable without having to also specify the bit size.`uvm_pack_int(VAR)
Pack an integral variable.`uvm_pack_intN(VAR,SIZE)
Pack a queue without having to also specify the bit size of its elements. Queue must not be empty.`uvm_pack_queue(VAR)
Pack a queue of integrals.`uvm_pack_queueN(VAR,SIZE)
Pack a variable of type real.`uvm_pack_real(VAR)
Pack a static array without having to also specify the bit size of its elements.`uvm_pack_sarray(VAR)
Pack a static array of integrals.`uvm_pack_sarray(VAR,SIZE)
Pack a string variable.`uvm_pack_string(VAR)
Use `uvm_package to define the SV package and to create a bogus type to help automate triggering the static initializers of the package. Use uvm_end_package to endpackage.
`uvm_peek_imp_decl(SFX)Define the class uvm_peek_impSFX for providing both blocking and non-blocking peek implementations. SFX is the suffix for the new class type.
Associative array printing methods
Uvm_print_array*
Uvm_print_int*
Uvm_print_object*
Uvm_print_sarray*
Uvm_print_string*
`uvm_put_imp_decl(SFX)Define the class uvm_put_impSFX for providing both blocking and non-blocking put implementations. SFX is the suffix for the new class type.
`uvm_rand_send(SEQ_OR_ITEM)This macro processes the item or sequence that has been already been allocated (possibly with `uvm_create). The processing is done with randomization. Essentially, an `uvm_do without the create.
`uvm_rand_send_pri(SEQ_OR_ITEM, PRIORITY)This is the same as `uvm_rand_send except that the sequene item or sequence is executed with the priority specified in the argument.
`uvm_rand_send_pri_with(SEQ_OR_ITEM, PRIORITY, CONSTRAINTS)This is the same as `uvm_rand_send_pri except that the given constraint block is applied to the item or sequence in a randomize with statement before execution.
`uvm_rand_send_with(SEQ_OR_ITEM, CONSTRAINTS)This is the same as `uvm_rand_send except that the given constraint block is applied to the item or sequence in a randomize with statement before execution.
Macro for recording name-value pairs into a transaction recording database. Requires a valid transaction handle, as provided by the <uvm_transaction::begin_tr> and <uvm_component::begin_tr> methods.
Use the following if the simulator's recording API can not distinguish types.
`uvm_register_cb(T,CB)Registers the given CB callback type with the given T object type. If a type-callback pair is not registered then a warning is issued if an attempt is made to use the pair (add, delete, etc.). The registration will typically occur in the component that executes the given type of callback. For instance:virtual class mycb extends uvm_callback; virtual function void doit(); endclass class my_comp extends uvm_component; `uvm_register_cb(my_comp,mycb) ... task run_phase(uvm_phase phase); ... `uvm_do_callbacks(my_comp, mycb, doit()) endtask endclass
`uvm_send(SEQ_OR_ITEM)This macro processes the item or sequence that has been created using `uvm_create. The processing is done without randomization. Essentially, an `uvm_do without the create or randomization.
`uvm_send_pri(SEQ_OR_ITEM, PRIORITY)This is the same as `uvm_send except that the sequene item or sequence is executed with the priority specified in the argument.
This macro is used to trigger static initializers in packages. `uvm_package creates a bogus type which gets referred to by uvm_sequence_library_package to make a package-based variable of the bogus type.
`uvm_sequence_library_utils(TYPE)Declares the infrastructure needed to define extensions to the <uvm_sequence_library> class. You define new sequence library subtypes to statically specify sequence membership from within sequence definitions. See also <`uvm_add_to_sequence_library> for more information.typedef simple_seq_lib uvm_sequence_library #(simple_item); class simple_seq_lib_RST extends simple_seq_lib; `uvm_object_utils(simple_seq_lib_RST) `uvm_sequence_library_utils(simple_seq_lib_RST) function new(string name=""); super.new(name); endfunction endclassEach library, itself a sequence, can then be started independently on different sequencers or in different phases of the same sequencer. See <uvm_sequencer_base::start_phase_sequence> for information on starting default sequences.
The sequence macros can be used in non-parameterized <uvm_sequence #(REQ,RSP)> extensions to pre-register the sequence with a given <uvm_sequencer #(REQ,RSP)> type. For sequences that do not use any `uvm_field macros`uvm_sequence_utils(TYPE_NAME,SQR_TYPE_NAME)For sequences employing with field macros`uvm_sequence_utils_begin(TYPE_NAME,SQR_TYPE_NAME) `uvm_field_* macro invocations here `uvm_sequence_utils_endThe sequence-specific macros perform the same function as the set of `uvm_object_*_utils macros except that they also register the sequence's type, TYPE_NAME, with the given sequencer type, SQR_TYPE_NAME, and define the p_sequencer variable and m_set_p_sequencer method. Use `uvm_sequence_utils[_begin] for non-parameterized classes and `uvm_sequence_param_utils[_begin] for parameterized classes.
The sequencer macros are used in uvm_sequencer-based class declarations in one of four ways. For simple sequencers, no field macros `uvm_sequencer_utils(SQR_TYPE_NAME) For simple sequencers, with field macros `uvm_sequencer_utils_begin(SQR_TYPE_NAME) `uvm_field_* macros here `uvm_sequencer_utils_end For parameterized sequencers, no field macros `uvm_sequencer_param_utils(SQR_TYPE_NAME) For parameterized sequencers, with field macros `uvm_sequencer_param_utils_begin(SQR_TYPE_NAME) `uvm_field_* macros here `uvm_sequencer_utils_end The sequencer-specific macros perform the same function as the set of `uvm_componenent_*utils macros except that they also declare the plumbing necessary for creating the sequencer's sequence library. This includes: 1. Declaring the type-based static queue of strings registered on the sequencer type. 2. Declaring the static function to add strings to item #1 above. 3. Declaring the static function to remove strings to item #1 above. 4. Declaring the function to populate the instance specific sequence library for a sequencer. Use `uvm_sequencer_utils[_begin] for non-parameterized classes and `uvm_sequencer_param_utils[_begin] for parameterized classes.
`uvm_set_super_type(T,ST)Defines the super type of T to be ST. This allows for derived class objects to inherit typewide callbacks that are registered with the base class. The registration will typically occur in the component that executes the given type of callback. For instance:virtual class mycb extend uvm_callback; virtual function void doit(); endclass class my_comp extends uvm_component; `uvm_register_cb(my_comp,mycb) ... task run_phase(uvm_phase phase); ... `uvm_do_callbacks(my_comp, mycb, doit()) endtask endclass class my_derived_comp extends my_comp; `uvm_set_super_type(my_derived_comp,my_comp) ... task run_phase(uvm_phase phase); ... `uvm_do_callbacks(my_comp, mycb, doit()) endtask endclass
`uvm_slave_imp_decl(SFX)Define the class uvm_slave_impSFX for providing both blocking and non-blocking slave implementations. SFX is the suffix for the new class type.
`uvm_transport_imp_decl(SFX)Define the class uvm_transport_impSFX for providing both blocking and non-blocking transport implementations. SFX is the suffix for the new class type.
Unpack a dynamic array without having to also specify the bit size of its elements. Array size must be non-zero.`uvm_unpack_array(VAR)
Unpack into a dynamic array of integrals.`uvm_unpack_arrayN(VAR,SIZE)
Unpack an enumeration value, which requires its type be specified.`uvm_unpack_enum(VAR,TYPE)
Unpack enum of type TYPE into VAR. `uvm_unpack_enumN(VAR,SIZE,TYPE)
Unpack an integral variable without having to also specify the bit size.`uvm_unpack_int(VAR)
Unpack into an integral variable.`uvm_unpack_intN(VAR,SIZE)
Unpack a queue without having to also specify the bit size of its elements. Queue must not be empty.`uvm_unpack_queue(VAR)
Unpack into a queue of integrals.`uvm_unpack_queue(VAR,SIZE)
Unpack a variable of type real.`uvm_unpack_real(VAR)
Unpack a static array without having to also specify the bit size of its elements.`uvm_unpack_sarray(VAR)
Unpack a static (fixed) array of integrals.`uvm_unpack_sarrayN(VAR,SIZE)
Pack a string variable.`uvm_unpack_string(VAR)
This macro populates the instance-specific sequence library for a sequencer. It should be invoked inside the sequencer¿s constructor.
This macro populates the instance specific sequence library for a sequencer, and it registers the given USER_ITEM as an instance override for the simple sequence's item variable. The macro should be invoked inside the sequencer's constructor.
`uvm_warning(ID,MSG)Calls uvm_report_warning with a verbosity of UVM_NONE. The message can not be turned off using the reporter's verbosity setting, but can be turned off by setting the action for the message. ID is given as the message tag and MSG is given as the message text. The file and line are also sent to the uvm_report_warning call.
`uvm_warning_context(ID,MSG,CNTXT)Operates identically to `uvm_warning but requires that the context, or <uvm_report_object>, in which the message is printed be explicitly supplied as a macro argument.


Speed swith mode
1 = 3-positional switch; speeds 1, 2 and 3 are used.
2 = one button; pressing will cycle three speeds:
1 -> 2 -> 3 -> 1 -> 2 -> 3 ...
3 = ?
4 = one button; pressing will cycle four speeds:
1 -> 2 -> 3 -> 4 -> 1 -> 2 -> ...
If no button/switch installed - speed 2 is used.


Welcome to the todo app. The create a new todo item simply type it into the box below and hit "Enter". To mark an item as completed just click the red square next to it. You can re-arrange items in the list using your mouse.
Just ToDo it!


Plan for Axis Objects¶
- class pyspecdata.axis_class.nddata_axis(*args)¶
The axis that gives the list of coordinates along a particular dimension.
Todo
There is no actual code here – this is a proposal for the new axis class
Internally uses the minimum number of variables to store information about the axis.
Also includes information about the chosen location (alias) in infinitely periodic domains. This is analogous to the concept of using fftshift in matlab or traditional numpy, but more general.
The nddata_axis has overloading routines to deal with the following operations like a standard numpy array (example_axis below is an instance of nddata_axis)
- indexing
>>> retval = example_axis[1]
returns the second value along the axis
- slicing
>>> retval = example_axis[0:20:5]
returns every fifth value from zero up to, but not including, 20
- nddata-like slicing
>>> retval = example_axis[(0,5.5)]
returns everything where the values of the axis coordinates are between 0 and 5.5 (inclusive)
>>> retval = example_axis[(0,None)]
returns everything where the values of the axis coordinates are 0 (inclusive) or above
- multiplication
>>> retval = example_axis * b
or
>>> retval = b * example_axis
- if
b
is a numpy array will return another numpy array
- if
b
is an nddata will return another nddata – note that this replaces the previous use of
fromaxis
.
- if
- addition + subtraction + division
same rules as multiplication
- argument of a function
>>> retval = exp(example_axis)
(or
sin
,cos
, etc.) returns another axis object. Note that this just amounts to setting the transf_func attribute, below.If
self.multiplier
is set to a complex number, specialized routines are always used (e.g.exp
can be calculated more efficiently, etc.)- interpolation (
@
) >>> retval = b @ example_axis
Here,
b
must be an nddata, andexample_axis
must have aname
matching one of the dimension labels ofb
.retval
will consist ofb
interpolated onto the new axis.Note that while
@
is typically used for matrix multiplication, it is NOT here.
- size¶
the length of the axis
- Type:
long
- dx¶
Step size multiplying the base array. For a non-uniform array, if possible, divide by the smallest step size, then multiply by a number that will convert the resulting floats to integers.
- Type:
float
- start¶
determines the starting value of the axis: >>> self.start+self.dx*r_[0:self.size]
- Type:
float
- names¶
Names for this dimension that this axis is used to label, in order of preference. The first name is the “preferred” name, and all subsequent names are “aliases”. For example, you might want to have a nicely named \(B_0\) (stored as
$B_0$
or a sympy variable) to describe your axis- Type:
list of strings or sympy variables
- domains¶
The keys correspond to a list of allowed transformations. Currently these are (future plans for
(I)LT
,(I)NUS
,(I)Wavelet
)'FT'
'IFT'
These are the names of transformations that have previously been applied (or can be applied, though the list doesn’t need to be comprehensive in that case) to the
nddata
object that thenddata_axis
is being used to label.I...
must always stand for “inverse”; on application of a transformation, the newaxis
object that is generated must have a domains attribute with the opposite (I
removed or added) transformation listed.The values are axis objects that label the data in the conjugate domains (after the transformation has been applied).
For example, on application of the nddata
nddata.ft()
method, the data will be labeled with an axis that has a domains attribute with a key containing IFT. The value of that key will point to the axis object of the data before transformation, and will be used in the even of a call tonddata.ift()
.This makes the get_ft_props and set_ft_props of older versions of nddata obsolete.
- Type:
OrderedDict
- multiplier¶
this is only used in the event that the axis is subjected to arithmetic involving a complex number it changes the way that the axis acts as an argument to various functions (especially exp)
- Type:
complex, default None
- transf_func¶
this and following attributes pertain only to non-uniform (non-linear) axes a function that is applied to a uniformly spaced axis to achieve non-uniform spacing (for example, an axis with log10 spacing). If this is set, the axis is constructed as
>>> self.transf_func(self.start+self.dx*r_[0:self.size])
- Type:
function or (default) None
- uneven_steps¶
if this attribute exists, it must be an array of length self.size and determines the axis values as follows: self.offset+self.dx*cumsum(self.uneven_steps)
- Type:
int or float (default non-existent)
- uneven_step_coords¶
if self.uneven_steps exists, this stores the value of cumsum(self.uneven_steps)
- property references¶
returns OrderedDict of all names and aliases such that keys all point to the current instance (self)
the idea is that this should be placed in a ChainMap object to be used by the
axis_collection
class that contains the axis.
- to_array()¶
returns the axis as a standard numpy array
- class pyspecdata.axis_class.axis_collection(dimlabels)¶
A collection of
axis
objects.Designed so that an instance of axis_collection is an attribute of nddata called axes, which behaves like a dictionary whose keys are the dimlabels of the nddata object, and whose values are
axis
objects.Used to make sure that no axis names or aliases are duplicated.
You can add axes to the collection in any of the following ways, where example_nddata is an nddata instance. (Remember that all nddata instances have an attribute axes of type axis_collection).
- building a new axis
example_nddata.axes[‘t2’] = ax_[0:1.2:100j] or example_nddata.axes[‘t2’] = ax_[0:1.2:0.01] (uses the same notation as numpy r_[…])
this takes the place of labels or setaxis in old versions of pyspecdata.
- associating an existing axis
example_nddata.axes += existing_axis existing_axis must have a name or alias that matches one of example_nddata.dimlabels.
- dimlabels¶
This is the same dimlabels attribute as the instance of the parent class.
- Type:
list
- names_used¶
Stores a list of all the names and aliases used by the axis objects that are contained in the collection, as well as the axes for any conjugate domains. since these need to be unique.
This is simply ChainMap(ax1.references,ax2.references,…,etc.)
- Type:
ChainMap
- rename(oldname, newname)¶
Rename an axis. If oldname is the preferred name of the axis, also go into dimlabels, and change the name (since dimlabels is the same list used by the nddata that contains the collection, it will update the dimlabel there as well)


Owner:
Last seen:
Volunteers:
Ownership Transfer
User login:
Transfer board
Board Deletion
Yes, I wish to delete this board
Delete board
Special Settings
Safe for work board
Locked
Save special settings


{% include '/header.html' %}
Read and Re-read the Question
Read the question carefully. What, specifically, is the question asking for? Make sure your answer provides that – or a viable alternative. The answer can be “don’t do that”, but it should also include “try this instead”. Any answer that gets the asker going in the right direction is helpful, but do try to mention any limitations, assumptions or simplifications in your answer. Brevity is acceptable, but fuller explanations are better.
Provide context for links
Links to external resources are encouraged, but please add context around the link so your fellow users will have some idea what it is and why it’s there. Always quote the most relevant part of an important link, in case the target site is unreachable or goes permanently offline.
Write to the best of your ability
We don't expect every answer to be perfect, but answers with correct spelling, punctuation, and grammar are easier to read. They also tend to get upvoted more frequently.
Answer well-asked questions
Not all questions can or should be answered here. Save yourself some frustration and avoid trying to answer questions which...
Always be polite and have fun
It’s fine to disagree and express concern, but please be civil. There’s a real human being on the other end of that network connection, however misguided they may appear to be. We’re here to learn from our peers, not yell at each other.


{% from "macros" import img, blogimg, snippet %}
{% extends "templates/post.html" %} {% block post %} {% filter markdown %}
These notes are based on the content of [Introduction to the Design and
Analysis of Algorithms (3rd Edition)][0].
[0]: http://www.amazon.com/Introduction-Design-Analysis-Algorithms-Edition/dp/0132316811/
The ideas behind Warshall's algorithm, which was discussed in the [previous
notes][1] on dynamic programming, can be applied to the more general problem of
finding lengths of shortest paths in weighted graphs.
[1]: /code/notes-on-dynamic-programming-part-1/
def: weighted graph
> A graph which associates a label (called a weight) with every edge in the graph.
Example:
{{blogimg(g,post,"img1.jpg")|safe}}
def: all-pairs shortest-path problem
> Given a weighted connected graph, find the distances from each vertex to all
other vertices.
Shortest-path algorithms play important parts in
* communications
* transportation networks
* operations research
* motion planning in video games
def: length of a path
> The length of a path of a weighted graph is the accumulation of the weights
of all the edges in the path.
def: weight matrix
> The distance matrix is an n x n matrix W. The element wij in the
i-th row and j-th column of the matrix indicates the weight of the edge
from the i-th vertex to the j-th vertex.
def: distance matrix
> The distance matrix is an n x n matrix D. The element dij in the
i-th row and j-th column of the matrix indicates the length of the shortest
path from the i-th vertex to the j-th vertex.
{{blogimg(g,post,"img2.jpg")|safe}}
def: shortest path
> The shortest path from vi to vj is the path from
vi to vj with the smallest length. In other words, it
is the path with the lowest sum of all the edges in the path.
Note that the distance from a vertex to itself is 0. For the weight matrix
`W`, the distance from a vertex `A` to a vertex `B` is infinity if there is
no edge from vertex `A` to vertex `B`. For directed graphs, remember that an
edge from `A` to `B` does not mean there is also an edge from `B` to `A`.
That is why wab is infinity while wba is 2. That is not
the case with undirected graphs, where the edge from `A` to `B` is by
definition equal to the edge from `B` to `A`.
For the distance matrix `D`, the value of dij is the length of the
path from the vertex `i` to the vertex `j`. Here are some examples to
demonstrate how we filled out the distance matrix table.
{{blogimg(g,post,"img3.jpg")|safe}}
The distance matrix can be generated with an algorithm that is similar to
Warshall's algorithm. It's called Floyd's algorithm.
Floyd's algorithm
-----------------
Floyd's algorithm computes the distance matrix of a weighted graph with `n`
vertices through a series of `n`x`n` matrices (with the assumption that the
graph's vertices are numbered from 1 to `n`.)
> D(0),...D(k-1),D(k),...D(n)
The algorithm works for digraphs and undirected graphs, but the graphs must
not contain a negative cycle. Note how familiar the series above is to that
of Warshall's algorithm.
def: negative cycle
> A cycle whose edges sum to a negative value
The element dij(k) is located at the i-th row and j-th
column of the matrix D(k) in the series, with `i,j=1,2,...,n` and
`k=0,1,...,n` . This element is equal to the length of the shortest possible
path from the i-th vertex to the j-th vertex, with all intermediate vertices
less than or equal to k.
Since the vertices are numbered 1 to `n`, elements of D(0), which
are of the form dij(0), are equal to the length of the
shortest path from the i-th vertex to j-th vertex, with no intermediates
allowed. This is exactly the **same thing** as the weight matrix.
Elements of D(1), which are of the form
dij(1), are equal to the length of the shortest path
from the i-th vertex to the j-th vertex with the vertex `1` allowed as an
intermediate.
Elements of D(2), which are of the form
dij(2), are equal to the length of the shortest path
from the i-th vertex to the j-th vertex with the vertices `1,2` allowed as
intermediates.
And so on.
Eventually we arrive at D(n), which is the distance matrix.
In order to avoid confusion between vertex numbers and weights, our vertices
are "numbered" with letters. `a=1`, `b=2`, and so on. So, for example,
D(2) would allow for the vertices `a,b` as intermediates.
Example:
{{blogimg(g,post,"img4.jpg")|safe}}
### Relating the matrices in the series
Just like with Warshall's algorithm, we can relate D(k) to
D(k-1). Here's how we do that.
Let dij(k) be the element in the i-th row and j-th
column of matrix D(k). Then by definition,
dij(k) is equal to the length of the shortest path from
the i-th vertex vi to the j-th vertex vj, with all
intermediate vertices <= `k`. Let `L` be this list of intermediate vertices.
We can thus describe the path from vi to vj as
** vi, L, vj **
Just like with Warshall's algorithm, there are two possible scenarios at this
point:
#### First scenario
In the first scenario, the k-th vertex, vk, is not in the list of
intermediate vertices `L`. Since all vertices in `L` are less than or equal to
`k` but `k` is not in `L`, we can conclude all vertices in `L` are less than
or equal to `k-1`. So we have a set of paths, each of the form
**vi, L, vj** with all vertices in `L` <= `k-1`. By how
we've defined the matrices in the series, the shortest of these paths is equal
to dij(k-1)
#### Second scenario
In the second scenario, the k-th vertex, vk, is in the list of
intermediate vertices `L`. Since we've explicitly stated that the graph
contains no negative cycles, we can conclude that vk occurs in `L`
only once for the shortest path. Otherwise, the second occurrence of
vk would imply an unnecessary cycle -- the path could not possibly
be the shortest possible path. Consequently, we can split `L` into three
groups: `L1`, a list of vertices <= `k-1` (since vk only appears
once in `L`), vk, and `L2`, another list of vertices <= `k-1`.
Finally, we conclude that candidates for the shortest path from vi
to vj are of the form **vi, L1, vk, L2,
vj**.
With this information, we can conclude a couple of things. First, note that
above we've shown that there exist paths from vi to vk
with all intermediate vertices <= `k-1`. The shortest of these paths by
definition is equal to dik(k-1). Similarly, we've also
shown there exist paths from vk to vj with all
intermediate vertices <= `k-1`. The shortest of these paths by definition is
equal to dkj(k-1). Since the shortest path from
vi to vk is dik(k-1) and the
shortest path from vk to vj is
dkj(k-1), we can conclude the shortest path from
vi to vj is (dik(k-1) +
dkj(k-1))
{{blogimg(g,post,"img5.jpg")|safe}}
#### What we've shown
We've just shown for both cases (vk in `L` and not in `L`) that we
can express dkj(k) in terms of
dkj(k-1). The first scenario tells us that as we
increase the `k` in D(k), the shortest path from vi to
vj is guaranteed to remain the same despite this bigger `k` **if**
the new vk is not an intermediate vertex in a path from
vi to vj. This makes sense because by definition, the
only paths dij(k) has that dij(k-1)
does not are paths that involve vk as an intermediate vertex.
For example:
{{blogimg(g,post,"img6.jpg")|safe}}
If the introduction of vk as an allowed intermediate creates new
paths from vi to vj, then it seems like we would have to
calculate the length of all such paths and compare them with eachother to
determine the shortest of these new paths, which we'll call `p`. We would then
need to compare `p` to dij(k-1) to see if this new path
is actually shorter than what already existed before the introduction of
vk as an allowed intermediate. However, we already proved that the
length of the shortest path that has vk as an intermediate is
exactly (dik(k-1) + dkj(k-1)),
thus `p` = (dik(k-1) + dkj(k-1)).
This reduces our work load to simply comparing `p` with
dij(k-1), and choosing the smaller of the two as the
shortest path from vi to vj.
This gives us the information we need to finally construct an algorithm.
### Algorithm
> dij(k) = min{(dik(k-1) +
dkj(k-1)), dij(k-1)} for k>=1.
dij(0) is just the weight matrix.
### Pseudocode
This pseduocode overwrites the matrix D each iteration, unlike the Warshall
algorithm from part 1. This is more space efficient than keeping track of
multiple multiple matrices since we only intend on returning the last matrix
D(n).
# W is the nxn weight matrix, indexed at 1
def Floyd(W[1..n, 1..n]):
D = W
for k = 1 to n do
for i = 1 to n do
for j = 1 to n do
D[i,j] = min{D[i,j], D[i,k]+D[k,j]}
return D
### Python implementation
The example weight matrix in the implementation represents the following
graph, shown earlier in the notes:
{{blogimg(g,post,"img2.jpg")|safe}}
{{snippet(post, "floyd.py")|safe}}
### Analysis
Similar to Warshall's algorithm, the time efficiency of Floyd's algorithm is
O(n3).
Next time
---------
Next time, we'll apply dynamic programming concepts to searching and optimal
binary search trees.
{% endfilter %} {% endblock post %}


Demo: Get Started Debugging JavaScript with Chrome DevTools
Number 1
Number 2
Add Number 1 and Number 2


--- title: "SOCI832 Lesson 4.1 An introduction to linear regression" lastmod: 2018-12-28T00:00:00.000Z draft: true type: docs maths: true output: blogdown::html_page: toc: true linktitle: "4.1 Regression: Linear" menu: docs: parent: SOCI832 weight: 410 ---
ReadingField, A., Miles, J., and Field, Z. (2012). Discovering statistics using R. Sage publications.
|
ConceptsLevel 1Level 2 Level 3 |
SummaryThis is a 300 word summary of clase |
setwd("C:/G/2018, SOCI832/Datasets/AES 2013/")
https://mqsociology.github.io/learn-r/soci832/elect_2013.csv
https://mqsociology.github.io/learn-r/soci832/codebook%20aes%202013.html
elect_2013 <- read.csv("elect_2013.csv") # loads dataset
FYI the command works by saying “copy all columns except the first”.

So far we have looked at the relationship between two variables - correlations and comparisons of means. However, often we want to look at the relationship between three or more variables.
A linear regression is one model - and probably the most popular model - for exploring the relationship between three or more variables.
A linear regression has a number of fundamental characteristics, including:
Let’s use a silly example - because it is memorable. Say we are interested in knowing how many time a patron of a bar visits the rest room in an evening. And supposing we have some ethical way to measure this and collect the data on 100 people who are in this busy bar on a saturday night.
In this case, our dependent variable is ‘visits to the rest room’, and it might vary between 0 and 10.
And the question we ask ourselves is - what cause or predicts the number of visits?
Well we might think that there are two important variables (1) the number of hours the person has been in the bar; and (2) the number of drinks the person has had at the bar.
To express this as a line we could say that, on average:
Rest room visits = B1*hours_at_bar + B2*drinks + C
And we have three ‘coefficients’ which we need to try to estimate. These are * B1 - which is the slope of the relations between hours_at_bar and rest_room_visits. * B2 - the slope of the relationship between drinks and vists * C - the constant or y-intercept, which is the number of rest_room_visits (on average) for someone with zero for the other two variables - i.e. who just arrive at the bar (hours_at_bar = 0) and has not had a drink yet (drinks = 0).
Now if we want to try to work out what B1, B2, and C are we would first need to get a whole lot of data. Well we are lucky, because we have collected data from 100 people on a Saturday night at a local Irish Pub.
The data looks like this, with four columns
| Patron | Visits | Hours | Drinks |
|---|---|---|---|
| 01 | 3 | 1 | 4 |
| 02 | 1 | 0.5 | 1 |
| 03 | 1 | 2 | 1 |
| 04 | 6 | 4 | 4 |
| 05 | 9 | 5 | 6 |
| 06 | 2 | 3 | 2 |
| 07 | 1 | 0 | 1 |
| 08 | 0 | 2 | 0 |
| 09 | 15 | 9 | 13 |
| 10 | 4 | 2 | 3 |
… AND SO ON FOR 100 people …
We can ignore the first colum (patron) which is just an identifing column.
Now we could, if we wanted to, plot each person on a chart, where the y axis is visits, and the x axis is one of the predictor/independent variables (e.g. hours).
If we did this we would have a very messy graph but there would be a general tendency for visits to go up, and number of hours at the pub went up.
In a linear regression, the statistical software calculates the ‘line of best fit’ - meaning the line that is as close as possible to all persons - all the dots on our graph.
This line of best fit can then be described with the three coefficients discussed earlier: B1, B2, and C.
B1 and B2 are ‘slopes’ - which you would have learnt about in year 8 mathematics. Remember the equation y = bx + c Well b is the slope, and c is the intercept, and it is the same in linear regression models.
Exactly how the statistical packages calcuate the line of best fit is not our concern, and it involves some complex maths. What matters to us as social scientists is that - so long as basic assumptions about the nature of the data are true, and the statistical package is sound - these models can estimate the relationship between various causes - independent variables - and a dependent variable we care about.
So let’s say we did analyse our data, and we got a value for B1 (of 0.5), B2 (of 0.8), and C (of 0.2). What does this mean? It means that - on average - for each one hour a person spends at the bar the will visit the rest room 0.5 times.
Let’s run a model in R ourselves now, and see how it is done with a real dataset - the dataset from McAllister 2016.
Let’s start with a very simple model of political knowledge, looking at the impact of being 18-24 years of age (or not) on political knowledge.
Now remember, our political knowledge scale goes from 0 to 10, and each one point represents one quiz question the person go right (out of a total of 10 questions)
The independent variable we are using to use is a binary variable (also called a dummy variable) which is equal to 1 if the person in aged 18-24 years of age or zero otherwise.
To run a linear regression model, we need to run two lines of code. The first run’s the model, with the command ‘lm()’. Inside the brackets we put the dependent variable and then a tilde ( ~ ) and then the independent variable/s (if we have multiple independent variables, we separate them with plus (+) sign).
We send this model to a variable to hold it, and then in the second line we call the summary command to give us a very useful summary of the model. when you are ready, run the following commands:
model1 <- lm(elect_2013$pol_knowledge ~ elect_2013$age_18_24)
summary(model1)
##
## Call:
## lm(formula = elect_2013$pol_knowledge ~ elect_2013$age_18_24)
##
## Residuals:
## Min 1Q Median 3Q Max
## -4.8545 -2.5405 0.1455 2.1455 6.4595
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.85451 0.04792 101.312 < 2e-16 ***
## elect_2013$age_18_24 -1.31396 0.19957 -6.584 5.2e-11 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.887 on 3849 degrees of freedom
## (104 observations deleted due to missingness)
## Multiple R-squared: 0.01114, Adjusted R-squared: 0.01088
## F-statistic: 43.35 on 1 and 3849 DF, p-value: 5.198e-11
Now this code might look confusing, but it will become easy - with some practice reading it.
Remember the rule “First look at the p-value”.
However, for models (e.g. regression models like this), we aren’t that interested in the p-value for the model overall. What you should look at is the p-value for the coefficients. and for some reason in R these p-values are listed under the heading “Pr(>|t|)”. Why? I don’t know.
Anyway, so we look at the two numbers under “Pr” and they are both very small numbers (with 11 and 16 zeros after the decimal point), which means that p < 0.05, and so they are significant and we can interpret the coefficients.
What do the coefficients say? Well lets start with the first that is just called “(Intercept)”. This is the C which we discussed in the earlier section, as in the value of y, when all the x’s are equal to zero.
In this case, the intercept has a value of 4.85, which means that people who have a zero for the variable 18-24 year old (i.e. everyone else) have a mean score on the political knowledge quiz of 4.85.
And now let’s look at the second coefficient - the first variable - which is -1.31. So this means persons who are 18-24 years of age, get, on average, 1.31 less questions correct in the quiz than persons who are older.
So, in essence, this model says that 25+ year olds get on average 4.85 quiz questions right, and 18-24 year olds get 3.54 question right.
What else can this model tell us? Well towards the bottom of the model you can see that it gives a value for the R-squared and the Adjusted R-squared.
We were introduced to the notion of an R-squared in the last set of notes (Week 2, Part 2 - correlation), because R-squared is literally the square of Pearson’s R.
We learnt in that that R-squared is an measure of effect size, and that it can it represents the proportion (percentage) of variation in the dependent variable that MIGHT be able to be explained by the independent variable/s.
We also said that roughly speaking we can look at R-squared and say that:
So given this, what does the output for our regression model say? It says that the multiple R-squared is 0.01. So basically the difference between 18-24 year olds and the rest of the population explains about 1% of the variation in political knowledge - at best!
So let’s now make a more complex model of political engagement. I will just write the model out below. You should understand it’s meaning:
model2 <- lm(elect_2013$pol_knowledge ~
elect_2013$age_18_24
+ elect_2013$internet_skills
+ elect_2013$female
+ elect_2013$tertiary_ed
+ elect_2013$income_quintiles
+ elect_2013$aust_born
+ elect_2013$interest_pol)
summary(model2)
##
## Call:
## lm(formula = elect_2013$pol_knowledge ~ elect_2013$age_18_24 +
## elect_2013$internet_skills + elect_2013$female + elect_2013$tertiary_ed +
## elect_2013$income_quintiles + elect_2013$aust_born + elect_2013$interest_pol)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.0520 -1.8193 0.0145 1.7488 8.0475
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 7.25724 0.16747 43.335 < 2e-16 ***
## elect_2013$age_18_24 -0.72437 0.18756 -3.862 0.000115 ***
## elect_2013$internet_skills 0.11722 0.03581 3.273 0.001073 **
## elect_2013$female -0.74846 0.08348 -8.965 < 2e-16 ***
## elect_2013$tertiary_ed 0.87490 0.09883 8.852 < 2e-16 ***
## elect_2013$income_quintiles 0.13042 0.03345 3.899 9.84e-05 ***
## elect_2013$aust_born 0.04310 0.09517 0.453 0.650638
## elect_2013$interest_pol -1.56222 0.05367 -29.108 < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.416 on 3423 degrees of freedom
## (524 observations deleted due to missingness)
## Multiple R-squared: 0.2926, Adjusted R-squared: 0.2912
## F-statistic: 202.3 on 7 and 3423 DF, p-value: < 2.2e-16
If you run this model and look at the output you will see that it is a much better model, with nearly 1/3 of all political knowledge explainable by the model itself. One question you might have is: “Which of these varibles is most important?”
This is essentially an effect size question. There are two ways of answering this question: the first uses R-square; and the second Standardised regression coefficients.
We can measure the effect size of a particular variable by looking at the change in the R-squared when we run the model with and without the variable.
For example, let’s run exactly the same model as model 2 but we will drop out interest in politics:
model3 <- lm(elect_2013$pol_knowledge ~
elect_2013$age_18_24
+ elect_2013$internet_skills
+ elect_2013$female
+ elect_2013$tertiary_ed
+ elect_2013$income_quintiles
+ elect_2013$aust_born)
summary(model3)
##
## Call:
## lm(formula = elect_2013$pol_knowledge ~ elect_2013$age_18_24 +
## elect_2013$internet_skills + elect_2013$female + elect_2013$tertiary_ed +
## elect_2013$income_quintiles + elect_2013$aust_born)
##
## Residuals:
## Min 1Q Median 3Q Max
## -6.8976 -2.1343 0.0906 2.1452 6.6690
##
## Coefficients:
## Estimate Std. Error t value Pr(>|t|)
## (Intercept) 4.25792 0.14715 28.936 < 2e-16 ***
## elect_2013$age_18_24 -1.52965 0.20706 -7.387 1.87e-13 ***
## elect_2013$internet_skills 0.16802 0.03986 4.215 2.56e-05 ***
## elect_2013$female -1.08989 0.09213 -11.830 < 2e-16 ***
## elect_2013$tertiary_ed 1.15270 0.10969 10.509 < 2e-16 ***
## elect_2013$income_quintiles 0.16298 0.03722 4.379 1.23e-05 ***
## elect_2013$aust_born 0.10165 0.10592 0.960 0.337
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.697 on 3435 degrees of freedom
## (513 observations deleted due to missingness)
## Multiple R-squared: 0.1179, Adjusted R-squared: 0.1163
## F-statistic: 76.48 on 6 and 3435 DF, p-value: < 2.2e-16
What is the R-squared (or actually Adjusted R-squared - this is a better measure)? It is around 0.11, meaning that the explanatory power of the model has dropped from explaining around 30% of variation in political knowledge, to only explaining approximately 10%.
We can also use a second method to measure effect size: standardized regression coefficients.
The other method that is commonly used to measure effect size and to compare effect size across independent variables in a regression model is ‘standardised regression coefficients’.
At some level these are quite simple to understand. To estimate standardised coefficients, all of the variables are standardised (also called normalised) so that their mean is zero and their standard deviation is 1. And then they are put in the regression model.
The effect of this is to make the coefficients all measured in the same units: Each coefficient is a number that represents “The number of standard deviations change in y (the dependent variables) are predicted/caused by a one standard deviation change in each X (each independent variable).”
Let’s estimate the standardised regression coefficients - which are also called ‘standardized betas’ or just ‘betas’ - for model 2.
To do this we need to install and then load the package “lm.beta”.
install.packages("lm.beta", repos = 'http://cran.rstudio.com')
## Installing package into 'C:/Users/nickh/Documents/R/win-library/3.5'
## (as 'lib' is unspecified)
## package 'lm.beta' successfully unpacked and MD5 sums checked
##
## The downloaded binary packages are in
## C:\Users\nickh\AppData\Local\Temp\Rtmpi8zEgj\downloaded_packages
library(lm.beta)
and then the command is simple: we just run lm.beta() before we run summary (and after we have run lm())
model2b <- lm.beta(model2)
summary(model2b)
##
## Call:
## lm(formula = elect_2013$pol_knowledge ~ elect_2013$age_18_24 +
## elect_2013$internet_skills + elect_2013$female + elect_2013$tertiary_ed +
## elect_2013$income_quintiles + elect_2013$aust_born + elect_2013$interest_pol)
##
## Residuals:
## Min 1Q Median 3Q Max
## -7.0520 -1.8193 0.0145 1.7488 8.0475
##
## Coefficients:
## Estimate Standardized Std. Error t value
## (Intercept) 7.257238 0.000000 0.167467 43.335
## elect_2013$age_18_24 -0.724365 -0.058174 0.187560 -3.862
## elect_2013$internet_skills 0.117223 0.054972 0.035811 3.273
## elect_2013$female -0.748458 -0.130416 0.083484 -8.965
## elect_2013$tertiary_ed 0.874900 0.140944 0.098833 8.852
## elect_2013$income_quintiles 0.130415 0.062661 0.033448 3.899
## elect_2013$aust_born 0.043104 0.006551 0.095170 0.453
## elect_2013$interest_pol -1.562223 -0.431747 0.053669 -29.108
## Pr(>|t|)
## (Intercept) < 2e-16 ***
## elect_2013$age_18_24 0.000115 ***
## elect_2013$internet_skills 0.001073 **
## elect_2013$female < 2e-16 ***
## elect_2013$tertiary_ed < 2e-16 ***
## elect_2013$income_quintiles 9.84e-05 ***
## elect_2013$aust_born 0.650638
## elect_2013$interest_pol < 2e-16 ***
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Residual standard error: 2.416 on 3423 degrees of freedom
## (524 observations deleted due to missingness)
## Multiple R-squared: 0.2926, Adjusted R-squared: 0.2912
## F-statistic: 202.3 on 7 and 3423 DF, p-value: < 2.2e-16
sd(elect_2013$age, na.rm = TRUE)
## [1] 16.97413
sd(elect_2013$pol_knowledge, na.rm = TRUE)
## [1] 2.939528
This information is identity to the output from a summary of a normally linear regression model, except that it has added the standardised beta coefficients, as the second set of numbers (under the heading ‘Standardized’).
If we look at these, we can see that the highest beta is for interest in politics, which is -0.43. When assessing effect size, we can ignore the sign (+/-), and a beta of 0.4 is very large.
When thinking about effect size, and beta, a rough rule of thumb is
Reading the beta’s we can see that the three variables in our model with the largest impact on political knowledge are, in rank order:
This is the end of the Linear Regression R code/ R-script file. The class continues next week (Week 3), where we learn about logistic regression and also regression diagnostics.


DD-WRT is a third-party firmware project that is designed to replace the original firmware for commercial wireless routers and wireless access points. It is a Linux-based firmware and is a solid alternative to the original firmware in your router.
The TP-Link TL-WDR3600 N600 is a pretty good budget Gigabit router for homes. I’ve been using it for a few years now and I like almost everything about this except the fact that there’s no inherent VPN or QoS functionality. Not a deal breaker, but it would be great to extend the capabilities of the device for no additonal cost. There’s also the fact that I’m a networking enthusiast and this is a good opportunity to learn.
Head to the DD-WRT website and search for your router. Mine is TP-Link TL-WDR3600, hence I pick that one from the search results.

In this case, we see 3 firmwares.
factory-to-ddwrt.bin
wdr3600v1_webrevert.rar
tl-wdr3600-webflash.bin
Once the factory-to-ddwrt.bin
file is downloaded, head to your router’s web interface and log in.
Open up your browser and type your router’s IP address. By default, it should be <IP_ADDRESS>
or <IP_ADDRESS>
. If your network uses a different private IP range, then enter the appropriate router address.
[video width=”842” height=”444” webm=”https://wiseindy.com/wp-content/uploads/2015/07/installing-dd-wrt-on-tp-link-tl-wdr3600-n600-05.webm” loop=”true” autoplay=”true” preload=”auto”][/video]
From the left sidebar, navigate to System Tools > Firmware Upgrade
Select Browse… and pick the factory-to-ddwrt.bin
file downloaded in the previous steps. Then click Upgrade.
The firmware upgrade process will take about 2-3 minutes. Hang tight.
Once the upgrade is done, you should see another progress bar like this informing you that the router is restarting.
If all goes well, which it should and will, you should see the new DD-WRT router page.
One thing to note here. If your router was configured to use a different IP range, for example10.15.15.x
, then you'll need to manually go to<IP_ADDRESS>
to see this page. This is the new firmware's default IP range. You'll need to reconfigure it if you want to work on a different range.
On this page, enter a username and password and click Change Password.
Now you will be inside the router configuration page.
Your router just gained a whole lot of features that are available only in high end ones. For free. And in less than 10 minutes. That isn’t so bad, is it? Have fun configuring!
Now that you’ve got DD-WRT powered up, see how you can configure DD-WRT to access computers using hostnames on your home network
(header image source: freeimageslive.co.uk)


Routing determines how your Kitura server will respond to requests from a client on a given endpoint. An endpoint is the URI (the path) and the specific HTTP request method.
HTTP methods indicate a desired action to be performed on the given URI, and there’s many methods out there for this. The main ones are:
You can find a more exhaustive list with descriptions here
An example of registering an endpoint:
router.get(“/hello”) { … }
Where router is an instance of a Kitura router, get is the HTTP method to be used on the URI and “/hello” is the URI.
You can also register multiple endpoints on a Kitura server:
router.get(“/hello”) { … }
router.post(“/hello”) { … }
router.put(“/hello”) { … }
router.get(“/world”) { … }
router.post(“/world) { … }
Kitura offers two options for routing, Raw routing and Codable routing. Both of these options are provided with Kitura out of the box.


Players
Teams
Season
Name
Team
Role
Lives
Fame
Level
Abilities
Edit
Name
Gold
Food
Fame
Edit
Last season statistics
Deaths
Name
Gold
Name
Gold Picked
Fame
Food
Name
Food Picked
Fame
Shield Cards
Name
Shield Cards Picked
Fame
New Season


{sweep-section.png width=520}
A "{_sweep sweep}" generator is what many other synthesizers call a "low frequency oscillator", or simply "LFO". Each of the two sweeps outputs repetitive low frequency patterns, most commonly sine waves, for producing effects such as vibrato, but also for triggering {_envelope envelopes} or running the {_arpeggiation} keyboard algorithms. The sweep parameters fall into two categories, so each sweep has two parameter clusters: