- Joined
- May 2, 2006
- Messages
- 1
- Reaction score
- 0
I'm building a simple processor for one of my classes. I am just using the behavior view to handle all the details going on inside of the register file. I've got an array of four registers and I give them default values inside of the register file. Everything seems to be working but a few nanoseconds after the register was written with the new value it goes back to what the default value was. I'm not sure if I should be giving them the default values somewhere or if I'm doing something else wrong.
I think all the relevant code is pasted below, intval() just takes a bit_vector and returns a integer value.
I think all the relevant code is pasted below, intval() just takes a bit_vector and returns a integer value.
Code:
process
--define register file
type register_unit is array(0 to 3) of bit_vector(7 downto 0);
variable registers: register_unit;
begin
-- initial the registers values
registers(0) := "00000000";
registers(1) := "00000001";
registers(2) := "00000010";
registers(3) := "00000011";
-- write data to register
if ((W = '1') and (CLOCK='1') ) then
registers(intval(Write_Reg)) := Write_Data;
end if;