Init leds with a definitive state

This commit is contained in:
Yannick Reiß 2025-03-16 17:28:17 +01:00
parent b5dad1b5e6
commit f357cd51bf
1 changed files with 134 additions and 133 deletions

View File

@ -14,19 +14,19 @@ entity bfpu is
debug : out std_logic_vector(7 downto 0); -- Value of currently selected logic cell.
led : out std_logic_vector(7 downto 0) -- Output for instruction .
);
end bfpu;
end entity bfpu;
-- Architecture arch of bfpu: setup and connect components
architecture arch of bfpu is
component instructionMemory
component instructionMemory is
port (
instructionAddr : in std_logic_vector(7 downto 0);
instruction : out std_logic_vector(2 downto 0)
);
end component;
end component instructionMemory;
component alu
component alu is
port (
instruction : in std_logic_vector(2 downto 0);
old_cell : in std_logic_vector(7 downto 0);
@ -39,18 +39,18 @@ architecture arch of bfpu is
enable_ptr : out std_logic;
extern_out : out std_logic_vector(7 downto 0)
);
end component;
end component alu;
component ptr
component ptr is
port (
clk : in std_logic;
enable_ptr : in std_logic;
new_ptr : in std_logic_vector(15 downto 0);
old_ptr : out std_logic_vector(15 downto 0)
);
end component;
end component ptr;
component cellblock
component cellblock is
port (
clk : in std_logic;
enable : in std_logic;
@ -58,9 +58,9 @@ architecture arch of bfpu is
new_cell : in std_logic_vector(7 downto 0);
old_cell : out std_logic_vector(7 downto 0)
);
end component;
end component cellblock;
component program_counter
component program_counter is
port (
clk : in std_logic;
enable : in std_logic;
@ -68,9 +68,9 @@ architecture arch of bfpu is
pc_in : in std_logic_vector(7 downto 0);
pc_out : out std_logic_vector(7 downto 0)
);
end component;
end component program_counter;
component branch
component branch is
port (
clk : in std_logic;
state : in std_logic;
@ -83,11 +83,12 @@ architecture arch of bfpu is
pc_enable : out std_logic;
pc_out : out std_logic_vector(7 downto 0)
);
end component;
end component branch;
signal s_clk : std_logic;
signal s_in : std_logic_vector(7 downto 0) := (others => '0');
signal s_out : std_logic_vector(7 downto 0) := (others => '0');
signal s_led : std_logic_vector(7 downto 0) := (others => '0');
signal s_instrAddr : std_logic_vector(7 downto 0) := "00000000";
signal s_instruction : std_logic_vector(2 downto 0) := "000";
@ -115,34 +116,33 @@ begin
-- clock and state logic
s_clk <= clk;
-- Process state change state between execute and write back
state : process (s_clk) -- runs only, when s_clk changed
state: process (s_clk) is -- runs only, when s_clk changed
begin
if rising_edge(s_clk) then
processor_state <= not processor_state;
end if;
end process;
end process state;
-- Process in_out set in- and output on clk high and exec/write back
in_out : process (s_clk) -- runs only, when s_clk changed
in_out: process (s_clk) is -- runs only, when s_clk changed
begin
if rising_edge(s_clk) then
if processor_state = '1' then
led <= s_out;
s_led <= s_out;
else
s_in <= sw;
end if;
end if;
end process;
end process in_out;
instrMemory : instructionMemory
instrMemory: component instructionMemory
port map (
instructionAddr => s_instrAddr,
instruction => s_instruction
);
alu_entity : alu
alu_entity: component alu
port map (
instruction => s_instruction,
old_cell => s_cell_out,
@ -156,7 +156,7 @@ begin
extern_out => s_out
);
ptr_bf : ptr
ptr_bf: component ptr
port map (
clk => s_clk,
enable_ptr => s_enable_ptr,
@ -164,7 +164,7 @@ begin
old_ptr => s_ptr_out
);
cellblock_bf : cellblock
cellblock_bf: component cellblock
port map (
clk => s_clk,
enable => s_enable_cells,
@ -173,7 +173,7 @@ begin
old_cell => s_cell_out
);
pc : program_counter
pc: component program_counter
port map (
clk => s_clk,
enable => s_enable_pc and processor_state,
@ -182,7 +182,7 @@ begin
pc_out => s_instrAddr
);
branch_bf : branch
branch_bf: component branch
port map (
clk => s_clk,
state => processor_state,
@ -198,5 +198,6 @@ begin
s_enable_ptr <= not s_skip and s_enable_ptr_o and processor_state;
s_enable_cells <= not s_skip and s_enable_cells_o and processor_state;
debug <= s_cell_out;
led <= s_led;
end arch;
end architecture arch;