使用Verilog和VHDL分别实现一个带有FIFO缓冲区的生产者-消费者模型。

FPGA开发岗位面试题

使用Verilog实现带有FIFO缓冲区的生产者-消费者模型示例:

module fifo#(parameter WIDTH = 8, DEPTH = 8) (
    input wire clk, reset, enq, deq,
    input wire [WIDTH-1:0] data_in,
    output wire [WIDTH-1:0] data_out,
    output reg   full, empty
);

... // 这里是FIFO缓冲区的Verilog实现

endmodule

使用VHDL实现带有FIFO缓冲区的生产者-消费者模型示例:

entity fifo is
    generic (
        WIDTH  : integer := 8;
        DEPTH  : integer := 8
    );
    port (
        clk    : in  std_logic;
        reset  : in  std_logic;
        enq    : in  std_logic;
        deq    : in  std_logic;
        data_in: in  std_logic_vector(WIDTH-1 downto 0);
        data_out: out std_logic_vector(WIDTH-1 downto 0);
        full   : out std_logic;
        empty  : out std_logic
    );
end entity fifo;

... -- 这里是FIFO缓冲区的VHDL实现