kkoloth
91dbf4503c
Implementation of the DMA logic up to 2/12/24. [Note: Testbench creation and full_DMA signal mapping is pending]
88 lines
4.5 KiB
VHDL
88 lines
4.5 KiB
VHDL
-- Execute custom RISC-V instructions structure:
|
|
----------------------------------------------------------------------------------------
|
|
--| 7bits | 5bits | 6bits | 1bit | 1bit | 1bit | 5bit | 7bit |
|
|
--| Funct | rs2 | rs1 | xd | xs1 | xs2 | rd | opcode |
|
|
--|31 25|24 20|19 15| 14 | 13 | 12 |11 7|6 0|
|
|
----------------------------------------------------------------------------------------
|
|
--ROCC_INSTRUCTION_RS1_RS2(x, rs1, rs2, funct) variables avaliable for baremetalC is rs1,rs2-register address and funct-function
|
|
library ieee;
|
|
use ieee.std_logic_1164.all;
|
|
use ieee.numeric_std.all;
|
|
|
|
----------------------RoCC Interface Entity---------------------------
|
|
entity RoCC_Interface is
|
|
port(
|
|
clk : in std_logic;
|
|
rst : in std_logic;
|
|
cmd_valid : in std_logic; --From Core
|
|
Cmd_inst_funct : in std_logic_vector(6 downto 0); --From Core
|
|
Cmd_inst_opcode : in std_logic_vector(6 downto 0); --From Core
|
|
Cmd_inst_rd : in std_logic_vector(4 downto 0); --From Core
|
|
Cmd_inst_rs1 : in std_logic_vector(4 downto 0); --From Core
|
|
Cmd_inst_rs2 : in std_logic_vector(4 downto 0); --From Core
|
|
Cmd_inst_xd : in std_logic; --From Core
|
|
Cmd_inst_xs1 : in std_logic; --From Core
|
|
Cmd_inst_xs2 : in std_logic; --From Core
|
|
Cmd_rs1 : in std_logic_vector(63 downto 0); --From Core
|
|
Cmd_rs2 : in std_logic_vector(63 downto 0); --From Core
|
|
Data_trans_from_DMA : in std_logic_vector(4 downto 0); --From DMA
|
|
Cmd_busy : out std_logic; --To Core
|
|
Cmd_ready : out std_logic; --To Core --always one
|
|
Funct_to_DMA : out std_logic_vector(6 downto 0); --To DMA
|
|
Address_to_DMA : out std_logic_vector(6 downto 0); --To DMA
|
|
Size_to_DMA : out std_logic_vector(4 downto 0) --To DMA
|
|
);
|
|
end entity;
|
|
|
|
----------------------Rocc Interface Behaviour------------------------
|
|
|
|
architecture Noc_Interface_Arch of Noc_Interface is
|
|
Signal Cmd_rs1_sig : std_logic_vector(63 downto 0);
|
|
signal Cmd_rs1_sig : std_logic_vector(63 downto 0);
|
|
Signal Cmd_inst_funct_sig : std_logic_vector(6 downto 0);
|
|
Signal cmd_valid_sig : std_logic;
|
|
--signal Sent_packet : std_logic_vector(4 downto 0);
|
|
--signal packet_length : std_logic_vector(4 downto 0);
|
|
|
|
begin
|
|
process(clk, rst)
|
|
begin
|
|
if rst = '0' then
|
|
Cmd_busy <= '0';
|
|
Cmd_ready <= '1'; --To Core --always one
|
|
cmd_valid_sig <= '0';
|
|
Funct_to_DMA <= (others => '0');
|
|
Address_to_DMA <= (others => '0');
|
|
Size_to_DMA <= (others => '0');
|
|
Cmd_rs1_sig <= (others => '0');
|
|
Cmd_rs1_sig <= (others => '0');
|
|
Cmd_inst_funct_sig <= (others => '0');
|
|
|
|
elsif rising_edge(clk) then
|
|
|
|
--------------------Reading from RoCC--------------------------------
|
|
|
|
if (cmd_valid = '1') then
|
|
Cmd_rs1_sig <= Cmd_rs1;
|
|
Cmd_rs2_sig <= Cmd_rs2; --size 4 downto 0 [5bits]
|
|
Cmd_inst_funct_sig <= Cmd_inst_funct;
|
|
cmd_valid_sig <= '1';
|
|
end if;
|
|
--------------------Send to the DMA--------------------------------
|
|
|
|
if(cmd_valid_sig = '1' and Cmd_rs2_sig(4 downto 0) > Data_trans_from_DMA) then
|
|
Funct_to_DMA <= Cmd_inst_funct_sig;
|
|
Address_to_DMA <= Cmd_rs1_sig(6 downto 0);
|
|
Size_to_DMA <= Cmd_rs2_sig(4 downto 0);
|
|
else
|
|
cmd_valid_sig <= '0';
|
|
Cmd_rs1_sig <= (others => '0');
|
|
Cmd_rs1_sig <= (others => '0');
|
|
Cmd_inst_funct_sig <= (others => '0');
|
|
|
|
end if;
|
|
end if;
|
|
end process;
|
|
end architecture;
|
|
|
|
|