-- Package (and subprograms) instantiations -- When a package is instantiated, we need to 'duplicate' its declaration. -- This looks useless for analysis but it isn't: a type from a package -- instantiated twice declares two different types. Without duplication, we -- need to attach to each declaration its instance, which looks more expansive -- that duplicating the declaration. -- -- Furthermore, for generic type interface, it looks a good idea to duplicate -- the body (macro expansion). -- -- Duplicating is not trivial: internal links must be kept and external -- links preserved. A table is used to map nodes from the uninstantiated -- package to its duplicated node. Links from instantiated declaration to -- the original declaration are also stored in that table. with Tables; with Vhdl.Nodes_Priv; with Vhdl.Nodes_Meta; with Types; use Types; with Files_Map; with Vhdl.Utils; use Vhdl.Utils; with Vhdl.Errors; use Vhdl.Errors; with Vhdl.Sem_Utils; package body Vhdl.Sem_Inst is -- Table of origin. This is an extension of vhdl nodes to track the -- origin of a node. If a node has a non-null origin, then the node was -- instantiated for the origin node. -- -- Furthermore, during instantiation, we need to keep track of instantiated -- nodes (ie nodes created by instantiation) used by references. As an -- instance cannot be uninstantiated, there is no collisions, as soon as -- such entries are cleaned after instantiation. -- -- As an example, here are declarations of an uninstantiated package: -- type Nat is range 0 to 1023; -- constant N : Nat := 5; -- A node Nat1 will be created from node Nat (an integer type definition). -- The origin of Nat1 is Nat and this is true forever. During -- instantiation, the instance of Nat is Nat1, so that the type of N will -- be set to Nat1. package Origin_Table is new Tables (Table_Component_Type => Iir, Table_Index_Type => Iir, Table_Low_Bound => 2, Table_Initial => 1024); procedure Expand_Origin_Table is use Vhdl.Nodes_Priv; Last : constant Iir := Nodes.Get_Last_Node; El : constant Iir := Origin_Table.Last; begin if El < Last then Origin_Table.Set_Last (Last); Origin_Table.Table (El + 1 .. Last) := (others => Null_Iir); end if; end Expand_Origin_Table; -- This is the public function; the table may not have been extended. function Get_Origin (N : Iir) return Iir is -- Make the '<=' operator visible. use Vhdl.Nodes_Priv; begin if N <= Origin_Table.Last then return Origin_Table.Table (N); else return Null_Iir; end if; end Get_Origin; -- This is the private function: the table *must* have been extended. function Get_Instance (N : Iir) return Iir is -- Make '<=' operator visible for the assert. use Vhdl.Nodes_Priv; begin pragma Assert (N <= Origin_Table.Last); return Origin_Table.Table (N); end Get_Instance; procedure Set_Origin (N : Iir; Orig : Iir) is begin -- As nodes are created, we need to expand origin table. Expand_Origin_Table; pragma Assert (Orig = Null_Iir or else Origin_Table.Table (N) = Null_Iir); Origin_Table.Table (N) := Orig; end Set_Origin; type Instance_Entry_Type is record -- Node N : Iir; -- Old value in Origin_Table. Old_Origin : Iir; end record; type Instance_Index_Type is new Natural; -- Table of previous values in Origin_Table. The first purpose of this -- table is to be able to revert the calls to Set_Instance, so that a unit -- can be instantiated several times. Keeping the nodes that have been -- instantiated is cheaper than walking the tree a second time. -- The second purpose of this table is to be able to have uninstantiated -- packages in instantiated packages. In that case, the slot in -- Origin_Table cannot be the origin and the instance at the same time and -- has to be saved. package Prev_Instance_Table is new Tables (Table_Component_Type => Instance_Entry_Type, Table_Index_Type => Instance_Index_Type, Table_Low_Bound => 1, Table_Initial => 256); -- The instance of ORIG is now N. So during instantiation, a reference -- to ORIG will be replaced by a reference to N. The previous instance -- of ORIG is saved. procedure Set_Instance (Orig : Iir
/*
The MIT License (MIT)
Copyright (c) 2016 Fred Sundvik
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
#ifndef TMK_VISUALIZER_LED_TEST_H_
#define TMK_VISUALIZER_LED_TEST_H_
#include "visualizer.h"
bool keyframe_fade_in_all_leds(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_fade_out_all_leds(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_led_left_to_right_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_led_top_to_bottom_gradient(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_led_crossfade(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_mirror_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
bool keyframe_normal_led_orientation(keyframe_animation_t* animation, visualizer_state_t* state);
extern keyframe_animation_t led_test_animation;
#endif /* TMK_VISUALIZER_LED_TEST_H_ */