Init leds with a definitive state
This commit is contained in:
parent
b5dad1b5e6
commit
f357cd51bf
|
@ -8,26 +8,26 @@ use ieee.numeric_std.all;
|
||||||
|
|
||||||
-- Entity bfpu: brainfuck processing unit
|
-- Entity bfpu: brainfuck processing unit
|
||||||
entity bfpu is
|
entity bfpu is
|
||||||
port(
|
port (
|
||||||
clk : in std_logic; -- board clock
|
clk : in std_logic; -- board clock
|
||||||
sw : in std_logic_vector(7 downto 0); -- Input for instruction ,
|
sw : in std_logic_vector(7 downto 0); -- Input for instruction ,
|
||||||
debug : out std_logic_vector(7 downto 0); -- Value of currently selected logic cell.
|
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 .
|
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: setup and connect components
|
||||||
architecture arch of bfpu is
|
architecture arch of bfpu is
|
||||||
|
|
||||||
component instructionMemory
|
component instructionMemory is
|
||||||
port(
|
port (
|
||||||
instructionAddr : in std_logic_vector(7 downto 0);
|
instructionAddr : in std_logic_vector(7 downto 0);
|
||||||
instruction : out std_logic_vector(2 downto 0)
|
instruction : out std_logic_vector(2 downto 0)
|
||||||
);
|
);
|
||||||
end component;
|
end component instructionMemory;
|
||||||
|
|
||||||
component alu
|
component alu is
|
||||||
port(
|
port (
|
||||||
instruction : in std_logic_vector(2 downto 0);
|
instruction : in std_logic_vector(2 downto 0);
|
||||||
old_cell : in std_logic_vector(7 downto 0);
|
old_cell : in std_logic_vector(7 downto 0);
|
||||||
old_pointer : in std_logic_vector(15 downto 0);
|
old_pointer : in std_logic_vector(15 downto 0);
|
||||||
|
@ -39,39 +39,39 @@ architecture arch of bfpu is
|
||||||
enable_ptr : out std_logic;
|
enable_ptr : out std_logic;
|
||||||
extern_out : out std_logic_vector(7 downto 0)
|
extern_out : out std_logic_vector(7 downto 0)
|
||||||
);
|
);
|
||||||
end component;
|
end component alu;
|
||||||
|
|
||||||
component ptr
|
component ptr is
|
||||||
port(
|
port (
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
enable_ptr : in std_logic;
|
enable_ptr : in std_logic;
|
||||||
new_ptr : in std_logic_vector(15 downto 0);
|
new_ptr : in std_logic_vector(15 downto 0);
|
||||||
old_ptr : out 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(
|
port (
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
enable : in std_logic;
|
enable : in std_logic;
|
||||||
address : in std_logic_vector(15 downto 0);
|
address : in std_logic_vector(15 downto 0);
|
||||||
new_cell : in std_logic_vector(7 downto 0);
|
new_cell : in std_logic_vector(7 downto 0);
|
||||||
old_cell : out 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(
|
port (
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
enable : in std_logic;
|
enable : in std_logic;
|
||||||
jmp : in std_logic;
|
jmp : in std_logic;
|
||||||
pc_in : in std_logic_vector(7 downto 0);
|
pc_in : in std_logic_vector(7 downto 0);
|
||||||
pc_out : out 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(
|
port (
|
||||||
clk : in std_logic;
|
clk : in std_logic;
|
||||||
state : in std_logic;
|
state : in std_logic;
|
||||||
instruction : in std_logic_vector(2 downto 0);
|
instruction : in std_logic_vector(2 downto 0);
|
||||||
|
@ -83,11 +83,12 @@ architecture arch of bfpu is
|
||||||
pc_enable : out std_logic;
|
pc_enable : out std_logic;
|
||||||
pc_out : out std_logic_vector(7 downto 0)
|
pc_out : out std_logic_vector(7 downto 0)
|
||||||
);
|
);
|
||||||
end component;
|
end component branch;
|
||||||
|
|
||||||
signal s_clk : std_logic;
|
signal s_clk : std_logic;
|
||||||
signal s_in : std_logic_vector(7 downto 0) := (others => '0');
|
signal s_in : std_logic_vector(7 downto 0) := (others => '0');
|
||||||
signal s_out : 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_instrAddr : std_logic_vector(7 downto 0) := "00000000";
|
||||||
signal s_instruction : std_logic_vector(2 downto 0) := "000";
|
signal s_instruction : std_logic_vector(2 downto 0) := "000";
|
||||||
|
@ -115,35 +116,34 @@ begin
|
||||||
-- clock and state logic
|
-- clock and state logic
|
||||||
s_clk <= clk;
|
s_clk <= clk;
|
||||||
-- Process state change state between execute and write back
|
-- 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
|
begin
|
||||||
if rising_edge(s_clk) then
|
if rising_edge(s_clk) then
|
||||||
processor_state <= not processor_state;
|
processor_state <= not processor_state;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process state;
|
||||||
|
|
||||||
-- Process in_out set in- and output on clk high and exec/write back
|
-- 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
|
begin
|
||||||
if rising_edge(s_clk) then
|
if rising_edge(s_clk) then
|
||||||
if processor_state = '1' then
|
if processor_state = '1' then
|
||||||
led <= s_out;
|
s_led <= s_out;
|
||||||
else
|
else
|
||||||
s_in <= sw;
|
s_in <= sw;
|
||||||
end if;
|
end if;
|
||||||
end if;
|
end if;
|
||||||
end process;
|
end process in_out;
|
||||||
|
|
||||||
|
|
||||||
|
instrMemory: component instructionMemory
|
||||||
instrMemory : instructionMemory
|
port map (
|
||||||
port map(
|
|
||||||
instructionAddr => s_instrAddr,
|
instructionAddr => s_instrAddr,
|
||||||
instruction => s_instruction
|
instruction => s_instruction
|
||||||
);
|
);
|
||||||
|
|
||||||
alu_entity : alu
|
alu_entity: component alu
|
||||||
port map(
|
port map (
|
||||||
instruction => s_instruction,
|
instruction => s_instruction,
|
||||||
old_cell => s_cell_out,
|
old_cell => s_cell_out,
|
||||||
old_pointer => s_ptr_out,
|
old_pointer => s_ptr_out,
|
||||||
|
@ -156,16 +156,16 @@ begin
|
||||||
extern_out => s_out
|
extern_out => s_out
|
||||||
);
|
);
|
||||||
|
|
||||||
ptr_bf : ptr
|
ptr_bf: component ptr
|
||||||
port map(
|
port map (
|
||||||
clk => s_clk,
|
clk => s_clk,
|
||||||
enable_ptr => s_enable_ptr,
|
enable_ptr => s_enable_ptr,
|
||||||
new_ptr => s_ptr_in,
|
new_ptr => s_ptr_in,
|
||||||
old_ptr => s_ptr_out
|
old_ptr => s_ptr_out
|
||||||
);
|
);
|
||||||
|
|
||||||
cellblock_bf : cellblock
|
cellblock_bf: component cellblock
|
||||||
port map(
|
port map (
|
||||||
clk => s_clk,
|
clk => s_clk,
|
||||||
enable => s_enable_cells,
|
enable => s_enable_cells,
|
||||||
address => s_ptr_out,
|
address => s_ptr_out,
|
||||||
|
@ -173,8 +173,8 @@ begin
|
||||||
old_cell => s_cell_out
|
old_cell => s_cell_out
|
||||||
);
|
);
|
||||||
|
|
||||||
pc : program_counter
|
pc: component program_counter
|
||||||
port map(
|
port map (
|
||||||
clk => s_clk,
|
clk => s_clk,
|
||||||
enable => s_enable_pc and processor_state,
|
enable => s_enable_pc and processor_state,
|
||||||
jmp => s_jmp_pc,
|
jmp => s_jmp_pc,
|
||||||
|
@ -182,8 +182,8 @@ begin
|
||||||
pc_out => s_instrAddr
|
pc_out => s_instrAddr
|
||||||
);
|
);
|
||||||
|
|
||||||
branch_bf : branch
|
branch_bf: component branch
|
||||||
port map(
|
port map (
|
||||||
clk => s_clk,
|
clk => s_clk,
|
||||||
state => processor_state,
|
state => processor_state,
|
||||||
instruction => s_instruction,
|
instruction => s_instruction,
|
||||||
|
@ -198,5 +198,6 @@ begin
|
||||||
s_enable_ptr <= not s_skip and s_enable_ptr_o and processor_state;
|
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;
|
s_enable_cells <= not s_skip and s_enable_cells_o and processor_state;
|
||||||
debug <= s_cell_out;
|
debug <= s_cell_out;
|
||||||
|
led <= s_led;
|
||||||
|
|
||||||
end arch;
|
end architecture arch;
|
||||||
|
|
Loading…
Reference in New Issue