"std_logic_vector" Related Questions

Status
Not open for further replies.

dzafar

Member level 4
Joined
Jan 17, 2017
Messages
76
Helped
1
Reputation
2
Reaction score
1
Trophy points
8
Activity points
690
I have three question!

Q1. Say:

signal X, Y: std_logic_vector (7 downto 0);
variable change_bit: std_logic;

change_bit = '0';

X <= "11100110";
Y <= X;

Y(6) <= change_bit; -- Is this valid? i.e. does Y now equal "10100110"?

Q2. Can we initialize an array using pre-defined attributes?

Say:

signal X: std_logic_vector (7 downto 0);
signal Y: X' range; -- is this valid? i.e. does this initialize Y to be (7 downto 0)?

Q3. What happens when:

signal X: std_logic_vector (7 downto 0);
signal X: std_logic_vector (3 downto 0);?
 

Q1. Say:

signal X, Y: std_logic_vector (7 downto 0);
variable change_bit: std_logic;

change_bit = '0';

X <= "11100110";
Y <= X;

Y(6) <= change_bit; -- Is this valid? i.e. does Y now equal "10100110"?
Variables can only exist in a process, so I will assume it was defined in a process.
Wrong assignment to the variable, it should be like this:
change_bit := '0';
Answer Q1: Yes it is valid.

Q2. Can we initialize an array using pre-defined attributes?

signal X: std_logic_vector (7 downto 0);
signal Y: X' range; -- is this valid? i.e. does this initialize Y to be (7 downto 0)? <<<<---------- WRONG
Where I have wrote WRONG, it should be like this:
signal Y: std_logic_vector(X'range); <<<---- THIS IS VALID

Q3. What happens when:

signal X: std_logic_vector (7 downto 0);
signal X: std_logic_vector (3 downto 0);?
ERROR, signal "X" has 2 definitions.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…