BlinkenArea - GitList
Repositories
Blog
Wiki
mips_sys
Code
Commits
Branches
Tags
Search
Tree:
902aa40
Branches
Tags
master
mips_sys
mips
regs.vhd
replace email address in headers with blinkenarea address
Stefan Schuermans
commited
902aa40
at 2012-05-21 17:42:50
regs.vhd
Blame
History
Raw
-- MIPS I system -- Copyright 2011-2012 Stefan Schuermans <stefan@blinkenarea.org> -- Copyleft GNU public license V2 or later -- http://www.gnu.org/copyleft/gpl.html LIBRARY ieee; USE ieee.std_logic_1164.all; USE ieee.numeric_std.all; USE work.mips_types.all; ENTITY e_mips_regs IS PORT ( clk: IN std_logic; i_rd_a_no: IN std_logic_vector( 4 DOWNTO 0); o_rd_a_data: OUT std_logic_vector(31 DOWNTO 0); i_rd_b_no: IN std_logic_vector( 4 DOWNTO 0); o_rd_b_data: OUT std_logic_vector(31 DOWNTO 0); i_wr_no: IN std_logic_vector( 4 DOWNTO 0); i_wr_data: IN std_logic_vector(31 DOWNTO 0); i_wr_en: IN std_logic ); END ENTITY e_mips_regs; ARCHITECTURE a_mips_regs OF e_mips_regs IS SUBTYPE t_idx IS natural RANGE 31 DOWNTO 0; TYPE t_regs IS ARRAY(t_idx) OF std_logic_vector(31 DOWNTO 0); SIGNAL r_regs: t_regs := (OTHERS => (OTHERS => '0')); FUNCTION no2idx(no: std_logic_vector(4 DOWNTO 0)) RETURN natural IS BEGIN RETURN to_integer(unsigned(no)); END FUNCTION no2idx; BEGIN p_read_a: PROCESS(i_rd_a_no, r_regs) BEGIN IF i_rd_a_no = "00000" THEN o_rd_a_data <= X"00000000"; ELSE o_rd_a_data <= r_regs(no2idx(i_rd_a_no)); END IF; END PROCESS p_read_a; p_read_b: PROCESS(i_rd_b_no, r_regs) BEGIN IF i_rd_b_no = "00000" THEN o_rd_b_data <= X"00000000"; ELSE o_rd_b_data <= r_regs(no2idx(i_rd_b_no)); END IF; END PROCESS p_read_b; p_write: PROCESS(clk) BEGIN IF rising_edge(clk) THEN IF i_wr_en = '1' THEN r_regs(no2idx(i_wr_no)) <= i_wr_data; END IF; END IF; END PROCESS p_write; END ARCHITECTURE a_mips_regs;