I am unable to update reg_1 and reg_2 vectors by splitting reg_mem?
This is my code in VHDL which i had written in MODELSIM:
In other program i tried to split another vector into two parts and store them into two different Vectors.It worked fine.But same syntax is not working in this code
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity Register_unit is
port (
reg_read : in std_logic;
reg_write : in std_logic;
reg_mem : inout std_logic_vector(3 downto 0);
reg_start : inout std_logic_vector(3 downto 0);
reg_end : inout std_logic_vector(3 downto 0);
reg_write_comp : out std_logic;
reg_read_comp : out std_logic;
reg_1 : inout std_logic_vector(1 downto 0);
reg_2 : inout std_logic_vector(1 downto 0));
end Register_unit;
architecture Register_unit_arch of Register_unit is
begin
process (reg_read,reg_write)
begin
if (reg_read = '1' and reg_write = '0') then
reg_end <= reg_mem;
reg_read_comp <= '1';
elsif (reg_write = '1' and reg_read = '0') then
reg_mem <= reg_start;
reg_write_comp <= '1';
end if;
reg_1 <= reg_mem(1 downto 0); --reg_1 is not getting updated
reg_2 <= reg_mem(3 downto 2); --reg2 is not getting updated
end process;
end Register_unit_arch;
reg_1 and reg_2 is updated but they are updated to previous value of the reg_mem. This line;
reg_mem <= reg_start;
is not in effect until the end of process. You are making the reg_1 and reg_2 assignment before reg_mem has it's new value!
VHDL doesn't work top down like a programming language even if you are in a process.
In your case you should either use a variable (*) or directly assign from reg_start like this;
reg_1 <= reg_start(1 downto 0);
reg_2 <= reg_start(3 downto 2);
(*) variables are immediately assigned in a process, you can use them similar to programming language variables
Related
Can someone help me to create a TestBench Program for the below Program, please?
library ieee;
use ieee.std_logic_1164.all;
entity bitwise is
port( a,b : in std_logic_vector(4 downto 0);
result1, result2, result3, result4, result5, result6 : out std_logic_vector(4 downto 0));
end bitwise;
architecture arch of bitwise is
begin
result1 <= a and b;
result2 <= a or b;
result3 <= a xor b;
result4 <= not a;
result5 <= to_stdlogicvector(to_bitvector(a) sll 1);
result6 <= to_stdlogicvector(to_bitvector(a) srl 1);
end arch;
My Test Bench Program is below: I am stuck to in the Stimulus process where we have to test each and every possibility. It could be either a loop version or just testing possible numbers for each operator.
LIBRARY ieee;
USE ieee.std_logic_1164.all;
entity test_bitwise is
end test_bitwise;
architecture behavior of test_bitwise is
component bitwise;
port( a,b : in std_logic_vector(4 downto 0);
result1, result2, result3, result4 : out std_logic_vector(4 downto 0));
end component;
--INPUTS
signal tb_a : std_logic_vector(4 downto 0) := (others => '0');
`signal tb_b : std_logic_vector(4 downto 0) := (others => '0');
--OUTPUTS
signal tb_result1 : std_logic_vector(7 downto 0);
signal tb_result2 : std_logic_vector(7 downto 0);
signal tb_result3 : std_logic_vector(7 downto 0);
signal tb_result4 : std_logic_vector(7 downto 0);
begin
-- INSTANTIATE THE UNIT UNDER TEST (UUT)
U1_Test : entity work.test_bitwise(behavioral)
port map (a => tb_a,
b => tb_b,
result1 <= tb_result1,
result2 <= tb_result2,
result3 <= tb_result3,
result4 <= tb_result4);
--STIMULUS PROCESS
stim_proc : process
begin
-- CODE HERE
end process;
end behavior;
As others have stated in the comments, you should provide some input yourself. What have you tried and why didn't it succeed? If you have hard time to find out what to try and how to start, you could begin by doing the following. And if you don't succeed, you can then edit your question or post a new one so the other members can help you.
Use a for loop to iterate over each and every possibility. Writing all the possible values to test by hand would be exhausting.
Because you have two inputs, use two nested for loops inside your process. One iterates the values for input a and the other one for b. Check here how a for loop is written.
Inside the loops, assign values to your signals tb_a and tb_b. The loop indices are integers, so you have to convert them to std_logic_vector type before assigning. Check here for a short tutorial about VHDL conversions.
Add some delay after each iteration with wait.
Print the output values for example to simulator console with report, or you can even use assert statement.
Hello I want to build a clock on my ALTERA DE2 that I can adjust the length of by pressing keys.
Now the problem is that when I convert from STD_LOGIC_VECTOR to UNSIGNED the code does not work:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
--use ieee.std_logic_unsigned.all; Do not use with numeric_std
entity Adjust_Clock_4_buttens is
port(
clk,clk1 : in STD_LOGIC;
minutes_plus, minutes_minus,houres_plus,houres_minus : in STD_LOGIC;
minutes : IN STD_LOGIC_VECTOR(5 downto 0);
houres : IN STD_LOGIC_VECTOR(4 downto 0);
output_minutes : out STD_LOGIC_VECTOR(5 downto 0);
output_houres : out STD_LOGIC_VECTOR(4 downto 0);
LED_0 : OUT STD_LOGIC;
LED_1 : OUT STD_LOGIC;
LED_2 : OUT STD_LOGIC;
LED_3 : OUT STD_LOGIC
);
end entity Adjust_Clock_4_buttens ;
architecture behavioral of Adjust_Clock_4_buttens is
signal button1_r : std_logic_vector(2 downto 0);
signal button2_r : std_logic_vector(2 downto 0);
signal button3_r : std_logic_vector(2 downto 0);
signal button4_r : std_logic_vector(2 downto 0);
-- signal minutes_total : unsigned(5 downto 0) := (others => '0');
-- signal houres_total : unsigned(4 downto 0) := (others => '0');
signal minutes_total : unsigned(5 downto 0);
signal houres_total : unsigned(4 downto 0);
begin
process(clk)
begin
if (rising_edge(clk) )then
minutes_total<=unsigned(minutes);
houres_total<=unsigned(houres);
-- Shift the value of button in button_r
-- The LSB is unused and is there solely for metastability
button1_r <= button1_r(button1_r'left-1 downto 0) & minutes_plus;
button2_r <= button2_r(button2_r'left-1 downto 0) & minutes_minus;
button3_r <= button3_r(button3_r'left-1 downto 0) & houres_plus;
button4_r <= button4_r(button4_r'left-1 downto 0) & houres_minus;
if button1_r(button1_r'left downto button1_r'left-1) = "01" then -- Button1 rising --button1_r[2:1]
minutes_total <= (minutes_total + 1);
LED_0<='1';LED_1<='0';LED_2<='0';LED_3<='0';
elsif button2_r(button2_r'left downto button2_r'left-1) = "01" then -- Button2 rising --button1_r[2:1]
minutes_total <= (minutes_total-1 );
LED_0<='0';LED_1<='1';LED_2<='0';LED_3<='0';
end if;
if button3_r(button3_r'left downto button3_r'left-1) = "01" then -- Button1 rising --button1_r[2:1]
houres_total <= (houres_total + 1);
LED_0<='0';LED_1<='0';LED_2<='1';LED_3<='0';
elsif button4_r(button4_r'left downto button4_r'left-1) = "01" then -- Button2 rising --button1_r[2:1]
houres_total<= (houres_total-1 );
LED_0<='0';LED_1<='0';LED_2<='0';LED_3<='1';
end if;
end if;
end process;
output_minutes <= std_logic_vector(minutes_total);
output_houres <= std_logic_vector(houres_total);
end architecture behavioral ;
So in this code I get the time from another block the problem start when I try to add minutes and hours and for some reason it does not react to pressing of the keys. Could anyone explain maybe why is that?
The problem might be that you only have the clock in the sensitivity list of your process. Try adding the buttons in the sensitivity list, since they drive your if conditions. (Not sure if that's the problem but I guess it's worth a try)
minutes_total<=unsigned(minutes);
is on 2 lines, inside and outside of the process, which generates multiple line drivers, and will not work, ever!
(didn't read the rest of the code, there may be other problems, like hours not taking an e)
Now that it's inside the process, you need to rename minutes_total as minute_source, else you're incrementing the value only for the one clock cycle when you have a button edge!
I'm implementing a register file where I wanna read asynchronously and write on the rising edge.
I made concurrent checks on the addresses and the writing occurs inside a process.
However, it always cause me a fatal error and I don't know why!
Here's my code if anyone could help and tell me how can I read asynchronously and write on rising edge
Thank you!
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity RegFile is
port(
outData1 : out std_logic_vector(15 downto 0);
outData2 : out std_logic_vector(15 downto 0);
inData : in std_logic_vector(15 downto 0);
writeEn : in std_logic;
reg1Sel : in std_logic_vector(2 downto 0);
reg2Sel : in std_logic_vector(2 downto 0);
writeRegSel : in std_logic_vector(2 downto 0);
clk : in std_logic
);
end RegFile;
architecture Register_File of RegFile is
type registerFile is array(0 to 5) of std_logic_vector(15 downto 0);
signal registers : registerFile;
signal reg1Address,reg2Address : integer;
signal reg1FinalAddressing,reg2FinalAddressing : std_logic_vector(2 downto 0);
begin
--Conversion of logic vector to unsigned integer
reg1Address <= to_integer(unsigned(reg1Sel));
reg2Address <= to_integer(unsigned(reg2Sel));
reg1FinalAddressing <= reg1Sel when (reg1Address<6 ) else
(others => '0');
reg2FinalAddressing <= reg2Sel when (reg2Address<6 ) else
(others => '0');
outData1 <= registers(to_integer(unsigned(reg1FinalAddressing)));
outData2 <= registers(to_integer(unsigned(reg2FinalAddressing)));
process (clk) is
begin
-- Reading from Registers 1 and 2
if rising_edge(clk) then
-- Writing to Register file Case Enabled
if writeEn = '1' then
registers(to_integer(unsigned(writeRegSel))) <= inData;
-- Case a value being written to register file, it will be out simultaneously if
-- the register was already selected. (The updated values are being released instantly).
if reg1Sel = writeRegSel then
outData1 <= inData;
end if;
if reg2Sel = writeRegSel then
outData2 <= inData;
end if;
end if;
end if;
end process;
end Register_File;
I'm working on a MIPS-like CPU in VHDL with Xilinx Vivado. I have a component for my BranchControl module, which goes like this:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity BranchControl is
Port ( PL : in STD_LOGIC;
BC : in STD_LOGIC_VECTOR(3 downto 0);
PC : in STD_LOGIC_VECTOR (31 downto 0);
AD : in STD_LOGIC_VECTOR (31 downto 0);
Flags : in STD_LOGIC_VECTOR(3 downto 0);
PCLoad : out STD_LOGIC;
PCValue : out STD_LOGIC_VECTOR (31 downto 0));
end BranchControl;
architecture Behavioral of branchcontrol is
signal Z,N,P,C,V, T: std_logic;
begin
Z <= Flags(3); -- zero flag
N <= Flags(2); -- negative flag
P <= not N and not Z; -- positive flag
C <= FLags(1); -- carry flag
V <= Flags(0); -- overflow flag
T <=
'1' when (PL = '1') and (BC = "0000") and (Flags = "XXXX") else -- B
'1' when (PL = '1') and (BC = "0010") and (Flags = "1XXX") else -- BEQ
'1' when (PL = '1') and (BC = "0011") and (Flags = "0XXX") else -- BNE
'1' when (PL = '1') and (BC = "0100") and (Flags = "00XX") else -- BGT
'1' when (PL = '1') and (BC = "0101") and (Flags = "11XX") else -- BGE
'1' when (PL = '1') and (BC = "0110") and (Flags = "01XX") else -- BLT
'1' when (PL = '1') and (BC = "0111") and (Flags = "11XX") else -- BLE
'0';
with T select
PCValue <= PC+AD when '1',
PC when others;
PCLoad <= T;
end Behavioral;
I am writing a simulation to test the BranchControl component, and ensure it is working as I intend. Here's my simulation:
library IEEE;
use IEEE.STD_LOGIC_1164.ALL;
use IEEE.STD_LOGIC_UNSIGNED.ALL;
entity SimulBranchControl is
end SimulBranchControl;
architecture Behavioral of SimulBranchControl is
component BranchControl is
Port ( PL : in STD_LOGIC;
BC : in STD_LOGIC_VECTOR( 3 downto 0);
PC : in STD_LOGIC_VECTOR (31 downto 0);
AD : in STD_LOGIC_VECTOR (31 downto 0);
Flags : in STD_LOGIC_VECTOR(3 downto 0);
PCLoad : out STD_LOGIC;
PCValue : out STD_LOGIC_VECTOR (31 downto 0));
end component;
signal iPL : STD_LOGIC;
signal iBC : STD_LOGIC_VECTOR(3 downto 0);
signal iPC : STD_LOGIC_VECTOR(31 downto 0);
signal iAD : STD_LOGIC_VECTOR(31 downto 0);
signal iFlags : STD_LOGIC_VECTOR(3 downto 0);
signal clock : std_logic := '0';
begin
process
begin
wait for 50 ns;
clock <= not clock;
end process;
process
begin
wait until clock'event and clock='0';
iPL<='1'; iBC<="0010"; iPC<=x"00000000"; iAD<=x"00000001"; iFlags<="0000";
end process;
BC0: BranchControl port map(iPL=>PL, iBC=>BC, iPC=>PC, iAD=>AD, iFlags=>Flags);
end Behavioral;
For some reason, when I try and run the simulation in Vivado, I get a set of errors on the elaboration step:
INFO: [VRFC 10-163] Analyzing VHDL file "/home/meurer/src/acomp/L02/Project2/Project2.srcs/sim_1/new/BranchControl.vhd" into library xil_defaultlib
INFO: [VRFC 10-307] analyzing entity BranchControl
INFO: [VRFC 10-163] Analyzing VHDL file "/home/meurer/src/acomp/L02/Project2/Project2.srcs/sim_1/new/SimulBranchControl.vhd" into library xil_defaultlib
INFO: [VRFC 10-307] analyzing entity SimulBranchControl
ERROR: [VRFC 10-719] formal port/generic <ipl> is not declared in <branchcontrol> [/home/meurer/src/acomp/L02/Project2/Project2.srcs/sim_1/new/SimulBranchControl.vhd:43]
ERROR: [VRFC 10-704] formal pl has no actual or default value [/home/meurer/src/acomp/L02/Project2/Project2.srcs/sim_1/new/SimulBranchControl.vhd:43]
ERROR: [VRFC 10-1504] unit behavioral ignored due to previous errors [/home/meurer/src/acomp/L02/Project2/Project2.srcs/sim_1/new/SimulBranchControl.vhd:8]
INFO: [VRFC 10-240] VHDL file /home/meurer/src/acomp/L02/Project2/Project2.srcs/sim_1/new/SimulBranchControl.vhd ignored due to errors
Now, from what I understand this means that my entity BranchControl, and my my component of it on the Simulation have incompatible declarations, but I don't see how this is true, they seem exactly the same to me. Here's a screenshot of Vivado giving me the error.
Why is this happening? What am I doing wrong?
Your component mapping in the instantiation is the wrong way around; it should be:
bc0: BranchControl port map (pl => ipl, bc => ibc, pc => ipc, ad => iad, flags => iflags);
I wrote code in VHDL and am using Active HDL Student edition to compile and simulate the code using a testbench. As I simulate for 500ns, the signals change but the signals on the waveform is stuck on U without anything displaying. I can't seem find what is causing this problem.
This is my code for the entity:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
entity idexreg is
port(
rst_bar : in std_logic;
clk : in std_logic;
immediate_in : in std_logic_vector(63 downto 0);
reg0_in : in std_logic_vector(63 downto 0);
reg1_in : in std_logic_vector(63 downto 0);
instruction_in : in std_logic_vector(3 downto 0);
pc_in : in std_logic_vector(3 downto 0);
immediate_out : out std_logic_vector(63 downto 0);
reg0_out : out std_logic_vector(63 downto 0);
reg1_out : out std_logic_vector(63 downto 0);
instruction_out : out std_logic_vector(3 downto 0);
pc_out : out std_logic_vector(3 downto 0)
);
end idexreg;
architecture idexreg_arch of idexreg is
begin
arch: process(clk, rst_bar)
begin
if rst_bar = '0' then
immediate_out <= std_logic_vector(x"0000000000000000");
reg0_out <= std_logic_vector(x"0000000000000000");
reg1_out <= std_logic_vector(x"0000000000000000");
instruction_out <= std_logic_vector(x"0");
pc_out <= std_logic_vector(x"0");
elsif falling_edge(clk) then
immediate_out <= immediate_in;
reg0_out <= reg0_in;
reg1_out <= reg1_in;
instruction_out <= instruction_in;
pc_out <= pc_in;
end if;
end process;
end idexreg_arch;
This is the code for the testbench:
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
use ieee.std_logic_arith.all;
entity idexreg_tb is
end idexreg_tb;
architecture test of idexreg_tb is
--input signals
signal rst_bar : std_logic;
signal clk: std_logic;
signal immediate_in : std_logic_vector(63 downto 0);
signal reg0_in : std_logic_vector(63 downto 0);
signal reg1_in : std_logic_vector(63 downto 0);
signal instruction_in : std_logic_vector(3 downto 0);
signal pc_in : std_logic_vector(3 downto 0);
--output signals
signal immediate_out : std_logic_vector(63 downto 0);
signal reg0_out : std_logic_vector(63 downto 0);
signal reg1_out : std_logic_vector(63 downto 0);
signal instruction_out : std_logic_vector(3 downto 0);
signal pc_out : std_logic_vector(3 downto 0);
-- boolean to signify end of simulation
signal end_sim : boolean := false;
constant period : time := 50ns;
begin
UUT: entity idexreg
port map(
rst_bar => rst_bar,
clk => clk,
immediate_in => immediate_in,
reg0_in => reg0_in,
reg1_in => reg1_in,
instruction_in => instruction_in,
pc_in => pc_in,
immediate_out => immediate_out,
reg0_out => reg0_out,
reg1_out => reg1_out,
instruction_out => instruction_out,
pc_out => pc_out);
-- Generate the Clock signal
clk_gen: process
begin
clk <= '0';
loop
wait for period/2;
clk <= not clk;
exit when end_sim = true;
end loop;
wait;
end process;
stim: process
begin
-- reset the register file first
rst_bar <= '0';
wait for 100ns;
rst_bar <= '1';
--Test 1
immediate_in <= std_logic_vector(x"AAAAAAAAAAAAAAAA");
reg0_in <= std_logic_vector(x"AAAAAAAAAAAAAAAA");
reg1_in <= std_logic_vector(x"AAAAAAAAAAAAAAAA");
instruction_in <= std_logic_vector(x"A");
pc_in <= std_logic_vector(x"1");
wait for 10ns;
--Test 2
immediate_in <= std_logic_vector(x"BBBBBBBBBBBBBBBB");
reg0_in <= std_logic_vector(x"BBBBBBBBBBBBBBBB");
reg1_in <= std_logic_vector(x"BBBBBBBBBBBBBBBB");
instruction_in <= std_logic_vector(x"B");
pc_in <= std_logic_vector(x"2");
wait for 30ns;
--Test 3
immediate_in <= std_logic_vector(x"CCCCCCCCCCCCCCCC");
reg0_in <= std_logic_vector(x"CCCCCCCCCCCCCCCC");
reg1_in <= std_logic_vector(x"CCCCCCCCCCCCCCCC");
instruction_in <= std_logic_vector(x"C");
pc_in <= std_logic_vector(x"3");
end_sim <= true;
wait;
end process;
end test;
Any help would be greatly appreciated!
With two other standard compliant simulators three classes of errors were found.
Semantic error:
UUT: entity idexreg
should be
UUT: entity work.idexreg
Without a use clause use.work.all; the declaration for previously analyzed entity idexreg won't be visible (unbound, this would account for 'U's). A selected named can be used when the name is not directly visible.
IEEE Std 1076-2008 12.3 Visibility
The meaning of the occurrence of an identifier at a given place in the text is defined by the visibility rules and also, in the case of overloaded declarations, by the overloading rules. The identifiers considered in this subclause include any identifier other than a reserved word or an attribute designator that denotes a predefined attribute. The places considered in this subclause are those where a lexical element (such as an identifier) occurs. The overloaded declarations considered in this subclause are those for subprograms and enumeration literals.
12.4 Use clauses
A use clause achieves direct visibility of declarations that are visible by selection.
(the fix shown above)
13.2 Design libraries
Every design unit except a context declaration and package STANDARD is assumed to contain the following implicit context items as part of its context clause:
library STD, WORK; use STD.STANDARD.all;
Note the library name WORK is made directly visible by the library clause but the design units analyzed into the library work are not made directly visible without a use clause.
back to 12.4 Use clauses:
Each selected name in a use clause identifies one or more declarations that will potentially become directly visible. If the suffix of the selected name is a simple name other than a type mark, or is a character literal or operator symbol, then the selected name identifies only the declaration(s) of that simple name, character literal, or operator symbol contained within the package or library denoted by the prefix of the selected name.
...
If the suffix is the reserved word all, then the selected name identifies all declarations that are contained within the package or library denoted by the prefix of the selected name.
There are also two additional error classes, the first your simulator does not require adherence by a design description.
The first, a syntax rule:
15.3 Lexical elements, separators, and delimiters
At least one separator is required between an identifier or an abstract literal and an adjacent identifier or abstract literal.
There's at least one successful commercial simulator out there that ignores this rule. It's harder to ignore it for -2008.
The second, another semantic rule:
9.3.6 Type conversions
— Array types—Two array types are closely related if and only if the types have the same dimensionality and the element types are closely related
Character string and std_logic_vector are not closely related for type conversion. You can drop the unneeded type conversions - bit string's type is from context:
9.3.6:
The type of the operand of a type conversion shall be determined by applying the rules of 12.5 to the operand considered as a complete context.
Which means all you see is the expanded bit string (15.8), e.g.:
std_logic_vector(x"0000000000000000")
as a string, an array type with a character element type, while std_logic_vector has a std_ulogic or std_logic element type (depending on the VHDL revision). That means the operand and type mark of the type conversion are not closely related.
This rule shouldn't be ignored.
9.3.2 Literals
String and bit string literals are representations of one-dimensional arrays of characters. The type of a string or bit string literal shall be determinable solely from the context in which the literal appears, excluding the literal itself but using the fact that the type of the literal shall be a one-dimensional array of a character type. The lexical structure of string and bit string literals is defined in Clause 15.
You could likewise use qualified expressions.
9.3.5 Qualified expressions
A qualified expression is a basic operation (see 5.1) that is used to explicitly state the type, and possibly the subtype, of an operand that is an expression or an aggregate.
Both methods are shown below, the amount of effort required dictated most were changed to qualified expression, requiring only an additional ' character.
Your code then will analyze successfully on any standard compliant VHDL tool:
library ieee;
use ieee.std_logic_1164.all;
-- use ieee.numeric_std.all;
entity idexreg is
port(
rst_bar : in std_logic;
clk : in std_logic;
immediate_in : in std_logic_vector(63 downto 0);
reg0_in : in std_logic_vector(63 downto 0);
reg1_in : in std_logic_vector(63 downto 0);
instruction_in : in std_logic_vector(3 downto 0);
pc_in : in std_logic_vector(3 downto 0);
immediate_out : out std_logic_vector(63 downto 0);
reg0_out : out std_logic_vector(63 downto 0);
reg1_out : out std_logic_vector(63 downto 0);
instruction_out : out std_logic_vector(3 downto 0);
pc_out : out std_logic_vector(3 downto 0)
);
end idexreg;
architecture idexreg_arch of idexreg is
begin
arch: process(clk, rst_bar)
begin
if rst_bar = '0' then
immediate_out <= std_logic_vector'(x"0000000000000000");
reg0_out <= std_logic_vector'(x"0000000000000000");
reg1_out <= std_logic_vector'(x"0000000000000000");
instruction_out <= std_logic_vector'(x"0");
pc_out <= std_logic_vector'(x"0");
elsif falling_edge(clk) then
immediate_out <= immediate_in;
reg0_out <= reg0_in;
reg1_out <= reg1_in;
instruction_out <= instruction_in;
pc_out <= pc_in;
end if;
end process;
end idexreg_arch;
library ieee;
use ieee.std_logic_1164.all;
-- use ieee.numeric_std.all;
-- use ieee.std_logic_arith.all;
entity idexreg_tb is
end idexreg_tb;
architecture test of idexreg_tb is
--input signals
signal rst_bar : std_logic;
signal clk: std_logic;
signal immediate_in : std_logic_vector(63 downto 0);
signal reg0_in : std_logic_vector(63 downto 0);
signal reg1_in : std_logic_vector(63 downto 0);
signal instruction_in : std_logic_vector(3 downto 0);
signal pc_in : std_logic_vector(3 downto 0);
--output signals
signal immediate_out : std_logic_vector(63 downto 0);
signal reg0_out : std_logic_vector(63 downto 0);
signal reg1_out : std_logic_vector(63 downto 0);
signal instruction_out : std_logic_vector(3 downto 0);
signal pc_out : std_logic_vector(3 downto 0);
-- boolean to signify end of simulation
signal end_sim : boolean := false;
constant period : time := 50 ns;
begin
UUT: entity work.idexreg -- ERROR HERE was entity idexreg
port map (
rst_bar => rst_bar,
clk => clk,
immediate_in => immediate_in,
reg0_in => reg0_in,
reg1_in => reg1_in,
instruction_in => instruction_in,
pc_in => pc_in,
immediate_out => immediate_out,
reg0_out => reg0_out,
reg1_out => reg1_out,
instruction_out => instruction_out,
pc_out => pc_out);
-- Generate the Clock signal
clk_gen: process
begin
clk <= '0';
loop
wait for period/2;
clk <= not clk;
exit when end_sim = true;
end loop;
wait;
end process;
stim: process
begin
-- reset the register file first
rst_bar <= '0';
wait for 100 ns;
rst_bar <= '1';
--Test 1
immediate_in <= x"AAAAAAAAAAAAAAAA"; -- std_logic_vector'(x"AAAAAAAAAAAAAAAA");
reg0_in <= std_logic_vector'(x"AAAAAAAAAAAAAAAA");
reg1_in <= std_logic_vector'(x"AAAAAAAAAAAAAAAA");
instruction_in <= std_logic_vector'(x"A");
pc_in <= std_logic_vector'(x"1");
wait for 10 ns;
--Test 2
immediate_in <= std_logic_vector'(x"BBBBBBBBBBBBBBBB");
reg0_in <= std_logic_vector'(x"BBBBBBBBBBBBBBBB");
reg1_in <= std_logic_vector'(x"BBBBBBBBBBBBBBBB");
instruction_in <= std_logic_vector'(x"B");
pc_in <= std_logic_vector'(x"2");
wait for 30 ns;
--Test 3
immediate_in <= std_logic_vector'(x"CCCCCCCCCCCCCCCC");
reg0_in <= std_logic_vector'(x"CCCCCCCCCCCCCCCC");
reg1_in <= std_logic_vector'(x"CCCCCCCCCCCCCCCC");
instruction_in <= std_logic_vector'(x"C");
pc_in <= std_logic_vector'(x"3");
end_sim <= true;
wait;
end process;
end test;
And fixing the above mentioned errors gives you something besides 'U's:
.
immediate_in is the signal assignment in Test 1 not using a qualified expression relying instead on 9.3.2's rule for determining the type of a bit string literal. The innermost complete context (12.5) used to determine the bit string literal type is the assignment statement itself.
The method of assigning immediate_in would normally be widely used as the preferred method. The type is taken from the target of the assignment.