aboutsummaryrefslogtreecommitdiff
path: root/works/life/computer-organization-experiment/register_file.vhdl
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2021-12-24 19:35:16 +0800
committercrupest <crupest@outlook.com>2021-12-24 19:35:16 +0800
commit496f67d0c03a1b61153b565f67ffbfcc9f6ed3a6 (patch)
tree211679b30c1d2dd393ba4e7a549dc997cc814bfc /works/life/computer-organization-experiment/register_file.vhdl
parent246028dd6c23b5fc1efb3dc53c2fddd79ba865de (diff)
downloadcrupest-496f67d0c03a1b61153b565f67ffbfcc9f6ed3a6.tar.gz
crupest-496f67d0c03a1b61153b565f67ffbfcc9f6ed3a6.tar.bz2
crupest-496f67d0c03a1b61153b565f67ffbfcc9f6ed3a6.zip
import(life): ...
Diffstat (limited to 'works/life/computer-organization-experiment/register_file.vhdl')
-rw-r--r--works/life/computer-organization-experiment/register_file.vhdl28
1 files changed, 28 insertions, 0 deletions
diff --git a/works/life/computer-organization-experiment/register_file.vhdl b/works/life/computer-organization-experiment/register_file.vhdl
new file mode 100644
index 0000000..ab1056f
--- /dev/null
+++ b/works/life/computer-organization-experiment/register_file.vhdl
@@ -0,0 +1,28 @@
+library ieee;
+
+entity register_file is
+ port (
+ CLK: in std_logic;
+ WRITE: in std_logic;
+ R1, R2, W: in std_logic_vector(4 downto 0);
+ WD: in std_logic_vector(31 downto 0);
+ RD1, RD2: out std_logic_vector(31 downto 0);
+ )
+end entity;
+
+architecture Behavioral of register_file is
+ type reg_file_type is array (0 to 31) of std_logic_vector(31 downto 0);
+ signal reg_file: reg_file_type := (others => '0');
+begin
+ process (CLK)
+ begin
+ if rising_edge(CLK) then
+ begin
+ if WRITE then
+ reg_file(W) <= WD;
+ end;
+ RD1 <= reg_file(R1);
+ RD2 <= reg_file(R2);
+ end;
+ end;
+end architecture;