Implement cell memory

This commit is contained in:
Yannick Reiß 2023-09-26 12:03:53 +02:00
parent 51fe976188
commit d27378e58f
No known key found for this signature in database
GPG Key ID: 5A3AF456F0A0338C
2 changed files with 61 additions and 0 deletions

View File

@ -50,6 +50,16 @@ architecture arch of bfpu is
);
end component;
component cellblock
port(
clk : in std_logic;
enable : in std_logic;
address : in std_logic_vector(15 downto 0);
new_cell : in std_logic_vector(7 downto 0);
old_cell : out std_logic_vector(7 downto 0)
);
end component;
signal s_clk : std_logic;
signal s_instrAddr : std_logic_vector(7 downto 0);
signal s_instruction : std_logic_vector(2 downto 0);
@ -95,4 +105,13 @@ begin
old_ptr => s_ptr_out
);
cellblock_bf : cellblock
port map(
clk => s_clk,
enable => s_enable_cells,
address => s_ptr_out,
new_cell => s_cell_in,
old_cell => s_cell_out
);
end arch;

View File

@ -0,0 +1,42 @@
-- cellMemory.vhd
-- Created on: Di 26. Sep 11:39:10 CEST 2023
-- Author(s): Yannick Reiß
-- Content: Cell memory as part of brainfuck logic
library ieee;
use ieee.std_logic_1164.all;
use ieee.numeric_std.all;
-- Entity cellblock
entity cellblock is
port(
clk : in std_logic; -- clock with speed of board clock
enable : in std_logic;
address : in std_logic_vector(15 downto 0);
new_cell : in std_logic_vector(7 downto 0);
old_cell : out std_logic_vector(7 downto 0)
);
end cellblock;
-- Architecture arch of cellblock: read on every clock cycle to cell.
architecture arch of cellblock is
type empty is array(0 to 65536) of std_logic_vector(7 downto 0);
signal memory : empty := (others => (others => '0'));
begin
-- Process clk_read
clk_read : process (clk) -- runs only, when clk changed
begin
if rising_edge(clk) and enable = '1' then
memory(to_integer(unsigned(address))) <= new_cell;
end if;
end process;
old_cell <= memory(to_integer(unsigned(address)));
end arch;