I am a Verification Engineer at Intel. I started the Verification blog to store solutions to small (and big) problems I've faced in my day to day work. I want to share them with the community in the hope that they may be useful to someone else.
Showing posts with label VHDL. Show all posts
Showing posts with label VHDL. Show all posts
Saturday, 23 January 2016
What is the difference between ‘0’ and “0” in VHDL?
In VHDL, the '0' (single quote) is a
single bit when the signal type is std_logic or bit. If you declare:
signal foo : std_logic_vector(7 downto 0);
and attempt the assignment:
foo <= '0';
you'll get a compile-time error
indicating a size mismatch. That's because you're trying to assign a one-bit
value to an 8-bit vector. (NB: Verilog will happily sign-extend, or is it
zero-extend? that single-bit into the full vector.)
For std_logic_vector, it represents a vector of only one bit. For example, the vector may be declared as std_logic_vector(0 downto 0).
Difference between rising_edge(clk) and (clk'event and clk='1') in VHDL
In VHDL there are two ways to find an
edge transition of any signal (generally clock).
- rising_edge(clk)
- clk'event and clk = '1'
So in this article I will explain the
difference between rising_edge or falling_edge function and clk'event based
edge detection.
Example 1:
Result of Example 1:
Example 2:
Result of Example 2:
To get a clear view look at the rising_edge function
as implemented in std_logic_1164 library:
As you can see the function returns a value
"TRUE" only when the present value is '1' and the last value is
'0'.If the past value is something like 'Z','U' etc. then it will return a
"FALSE" value.This makes the code, bug free, beacuse the function
returns only valid clock transitions,that means '0' to '1'.All the rules and
examples said above equally apply to falling_edge() function
also.
But the statement (clk'event and clk='1') results
TRUE when the present value is '1' and there is an edge transition in the
clk.It doesnt see whether the previous value is '0' or not.
Monday, 28 December 2015
Difference between Variable and Signal in VHDL
Scope wise:
SIGNAL has scope to whole architecture. It can be access from any place in architecture of enitity.
VARIABLE is local t procedure defined in the architecture.
Behavior wise:
Variable assignment is evaluated and assigned in a single step:
1) Execution flow within the procedure is blocked until the Execution flow within the procedure is blocked until the
assignment is completed.
Variable assignment is same as Blocking assignment in Verilog.
Signal assignment is Evaluated and assigned in two steps:
1) The right The right-hand side is evaluated immediately.
2) The assignment to the left-hand side is postponed until other evaluations in the current time step are completed other evaluations in the current time step are completed.
Execution flow within the procedure continues until a timing control is encountered (flow is not blocked)
Signal assignment is same as Non-Blocking assignment in Verilog.
If several values are assigned to a given signal in one process, only the last assignment is effective.
Synthesis wise:
SIGNAL inter a FLOP during synthesis.
VARIABLE infer just a WIRE during synthesis.
SIGNAL has scope to whole architecture. It can be access from any place in architecture of enitity.
VARIABLE is local t procedure defined in the architecture.
Behavior wise:
Variable assignment is evaluated and assigned in a single step:
1) Execution flow within the procedure is blocked until the Execution flow within the procedure is blocked until the
assignment is completed.
Variable assignment is same as Blocking assignment in Verilog.
Signal assignment is Evaluated and assigned in two steps:
1) The right The right-hand side is evaluated immediately.
2) The assignment to the left-hand side is postponed until other evaluations in the current time step are completed other evaluations in the current time step are completed.
Execution flow within the procedure continues until a timing control is encountered (flow is not blocked)
Signal assignment is same as Non-Blocking assignment in Verilog.
If several values are assigned to a given signal in one process, only the last assignment is effective.
Synthesis wise:
SIGNAL inter a FLOP during synthesis.
VARIABLE infer just a WIRE during synthesis.
Example:
Signal assignment:
Variable assignment:
Variable assignment:
Subscribe to:
Posts (Atom)
