diff --git a/cpu_project/cpu_project.xpr b/cpu_project/cpu_project.xpr index f4fd161..c0e6921 100644 --- a/cpu_project/cpu_project.xpr +++ b/cpu_project/cpu_project.xpr @@ -91,18 +91,6 @@ - - - - - - - - - - - - @@ -127,6 +115,20 @@ + + + + + + + + + + + + + + + + + + + + + + @@ -184,7 +194,7 @@ - + Vivado Synthesis Defaults diff --git a/src/cpu.vhd b/src/cpu.vhd index 3385674..0a694cb 100644 --- a/src/cpu.vhd +++ b/src/cpu.vhd @@ -4,10 +4,14 @@ use IEEE.STD_LOGIC_ARITH.ALL; use IEEE.STD_LOGIC_UNSIGNED.ALL; entity cpu is + Port ( + clk : in STD_LOGIC; + instruction_pointer : in STD_LOGIC_VECTOR(7 downto 0) + ); end cpu; ARCHITECTURE cpu_arch OF cpu IS - COMPONENT instruction IS + COMPONENT instruction IS PORT ( instruction : IN STD_LOGIC_VECTOR(7 DOWNTO 0); code : OUT STD_LOGIC_VECTOR(31 DOWNTO 0); @@ -52,11 +56,11 @@ ARCHITECTURE cpu_arch OF cpu IS COMPONENT pipeline_step IS PORT ( - A_in: in STD_LOGIC_VECTOR(7 downto 0); - B_in: in STD_LOGIC_VECTOR(7 downto 0); - C_in: in STD_LOGIC_VECTOR(7 downto 0); - OP_in: in STD_LOGIC_VECTOR(3 downto 0); - clk : in STD_LOGIC; + A_in: in STD_LOGIC_VECTOR(7 downto 0); + B_in: in STD_LOGIC_VECTOR(7 downto 0); + C_in: in STD_LOGIC_VECTOR(7 downto 0); + OP_in: in STD_LOGIC_VECTOR(3 downto 0); + clk: in STD_LOGIC; A_out: out STD_LOGIC_VECTOR(7 downto 0); B_out: out STD_LOGIC_VECTOR(7 downto 0); C_out: out STD_LOGIC_VECTOR(7 downto 0); @@ -64,16 +68,25 @@ ARCHITECTURE cpu_arch OF cpu IS ); END COMPONENT; - ---FOR ALL : instruction USE ENTITY work.instruction; -begin - step1_lidi : pipeline_step PORT MAP(); - step2_diex : pipeline_step PORT MAP(); - step3_exmem : pipeline_step PORT MAP(); - step4_memre : pipeline_step PORT MAP(); + signal li_A, di_A, ex_A, mem_A, re_A : STD_LOGIC_VECTOR(7 downto 0); + signal li_B, di_B, ex_B, mem_B, re_B : STD_LOGIC_VECTOR(7 downto 0); + signal li_C, di_C, ex_C, mem_C, re_C : STD_LOGIC_VECTOR(7 downto 0); + signal di_OP, ex_OP, mem_OP, re_OP : STD_LOGIC_VECTOR(3 downto 0); + signal li_OP : STD_LOGIC_VECTOR(31 downto 0); + ---signal main_clk : STD_LOGIC; - instruction_memory_inst : instruction PORT MAP(); - memory_register_inst : reg PORT MAP(); - alu_inst : alu PORT_MAP(); - data_memory_inst : data_memory PORT MAP(); + signal empty_8 : STD_LOGIC_VECTOR(7 downto 0); + signal empty_4 : STD_LOGIC_VECTOR(3 downto 0); + +begin + step1_lidi : pipeline_step PORT MAP(li_A, li_B, li_C, li_OP(7 downto 4), clk, di_A, di_B, di_C, di_OP); + step2_diex : pipeline_step PORT MAP(di_A, di_B, di_C, di_OP, clk, ex_A, ex_B, ex_C, ex_OP); + step3_exmem : pipeline_step PORT MAP(ex_A, ex_B, ex_C, ex_OP, clk, mem_A, mem_B, mem_C, mem_OP); + step4_memre : pipeline_step PORT MAP(mem_A, mem_B, mem_C, mem_OP, clk, re_A, re_B, re_C, re_OP); + + instruction_memory_inst : instruction PORT MAP(instruction_pointer, li_OP , clk); + memory_register_inst : reg PORT MAP(empty_4, empty_4, re_A(3 downto 0), re_OP(0), re_B, '0', clk, empty_8, empty_8); + -- alu_inst : alu PORT MAP(); + -- data_memory_inst : data_memory PORT MAP(); END cpu_arch; \ No newline at end of file diff --git a/src/pipeline_step.vhd b/src/pipeline_step.vhd index 6eb62cd..fe8e3d6 100644 --- a/src/pipeline_step.vhd +++ b/src/pipeline_step.vhd @@ -23,9 +23,9 @@ begin begin if clk'event and clk='1' then A_out <= A_in; - A_out <= B_in; - A_out <= C_in; - A_out <= OP_in; + B_out <= B_in; + C_out <= C_in; + OP_out <= OP_in; end if; end process; end behavior_pipeline_step; \ No newline at end of file