matrixofdynamism
Advanced Member level 2
String in VHDL is declared as a character array. Thus, in my case I have declared a string that can contain the largest string assigned to it in a select case construct:
So I have: variable instr_str : string (1 to 4); and then assigning value to it in case statement.
case instr(5 downto 0) is
when alu_add =>
instr_str := "add";
when alu_sub =>
instr_str := "sub";
when alu_and =>
instr_str := "and";
when alu_or =>
instr_str := "or";
when alu_xor =>
instr_str := "xor";
when alu_nor =>
instr_str := "nor";
when others =>
end case;
When I compile the file I get a list of warning messages like:
# ** Warning: [14] /Documents/MIPS/cpu_defs.vhdl(75): (vcom-1272) Length of expected is 4; length of actual is 3.
When I run it I get this error:
# ** Fatal: (vsim-3420) Array lengths do not match. Left is 4 (1 to 4). Right is 3 (1 to 3).
Is there really no around this other than assign a string of 4 characters to instr_str everytime? This doesn't look right.
So I have: variable instr_str : string (1 to 4); and then assigning value to it in case statement.
case instr(5 downto 0) is
when alu_add =>
instr_str := "add";
when alu_sub =>
instr_str := "sub";
when alu_and =>
instr_str := "and";
when alu_or =>
instr_str := "or";
when alu_xor =>
instr_str := "xor";
when alu_nor =>
instr_str := "nor";
when others =>
end case;
When I compile the file I get a list of warning messages like:
# ** Warning: [14] /Documents/MIPS/cpu_defs.vhdl(75): (vcom-1272) Length of expected is 4; length of actual is 3.
When I run it I get this error:
# ** Fatal: (vsim-3420) Array lengths do not match. Left is 4 (1 to 4). Right is 3 (1 to 3).
Is there really no around this other than assign a string of 4 characters to instr_str everytime? This doesn't look right.