100 likes | 323 Views
Something “Simple”. Simple …. A simple mistake in some “simple” electronics Traditional application, nothing new. Just one example of a problem that is becoming a common error, not quite epidemic proportions. Yet. Simple Changes …. Simulation now standard, of course Almost a religion
E N D
Simple … • A simple mistake in some “simple” electronics • Traditional application, nothing new. • Just one example of a problem that is becoming a common error, not quite epidemic proportions. Yet.
Simple Changes … • Simulation now standard, of course • Almost a religion • For our example -- two requirements • Check corner cases (start, end of line, beginning of next line, end) • No off by one errors • 4 megabit detector simulation is lengthy • “Solution:” Comment out or change constants to run on a smaller array to check logic for corner cases and off by one errors.
Comments -- Very Simple • Used to: • Control size and length of simulations • “Try things out” • “Isolate problems when troubleshooting simulations” • The Problem • Commented out “code” does not always get restored • Comments are buried in the “code.” • Been seeing this regularly
Comments -- Some ThoughtsWhen VHDL is in the Comment • Designers: • Write a text description for all comments that contain VHDL • Use a preprocessor for “conditional compilation.” We wrote KPP for this reason. • Use the VHDL generic feature. • Reviewers: • Flag and investigate all comments that contain VHDL
KPP - A VHDL Pre-Processor • A pre-processor, similar to CPP, designed for VHDL applications. • Provides many functions such as: • #def, #undef, #ifdef • #include • define <variable> {number}; #undef <variable> • Loops • other features. • Makes temporary modifications easier to control and see. http://klabs.org/richcontent/software_content/kpp.htm
KPP Example #define variable1 -- define variable1 and make it accessible in the program #define variable2 -- define variable2 and make it accessible in the program #undef variable2 -- undefine variable2 and make it inaccessible in the program #ifdef variable1 Any code written in here should come through because variable1 is defined. #ifndef variable2 Any code written in here should come through because variable2 is not defined. #endif #else This code should not come through. #endif #ifndef variable1 This code should not come through. #else This code should come through. #endif http://klabs.org/richcontent/software_content/kpp.htm
Generics Example: Part 1 Definition: Parameterizable D Flip-flop with Reset, Enable library IEEE; use IEEE.std_logic_1164.all; entity pDFFE is generic (n: integer := 2); port (d: in std_logic_vector(n - 1 downto 0); en: in std_logic; clk: in std_logic; rst: in std_logic q: out std_logic_vector(n - 1 downto 0); ) ; end pDFFE;
Generics Example: Part 2 Instantiation: Parameterizable D Flip-flop with Reset, Enable library IEEE; use IEEE.std_logic_1164.all; use work.primitive.all; architecture parameterize of pararnDFF is ul: pDFFE genericmap(n => size) portmap (d => data, clk =>clock, rst => reset, en => ff_enable, q => reg ); u2: pTRIBUF generic map(n => size) port map (ip => reg,