Jump to content
    

Нужно нарисовать схему по коду verilog, помогите пожалуйста

////////////////////////////////////////////////////////////////////
//
// main_fft_twiddle_roms.v
//
//
// This file is part of the "bel_fft" project
//
// Author(s):
//     - Frank Storm ([email protected])
//
////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2010-2012 Authors
//
// This source file may be used and distributed without
// restriction provided that this copyright statement is not
// removed from the file and that any derivative work contains
// the original copyright notice and the associated disclaimer.
//
// This source file is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser General
// Public License as published by the Free Software Foundation;
// either version 2.1 of the License, or (at your option) any
// later version.
//
// This source is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
// PURPOSE.  See the GNU Lesser General Public License for more
// details.
//
// You should have received a copy of the GNU Lesser General
// Public License along with this source; if not, download it
// from http://www.gnu.org/licenses/lgpl.html
//
////////////////////////////////////////////////////////////////////
//
// CVS Revision History
//
// $Log$
//
////////////////////////////////////////////////////////////////////


`include "bel_core/bel_fft_def.v"


module main_fft_twiddle_roms (clk_i, rst_i, adr_i, rd_i, dat_o, cfg_sel_i);

    parameter word_width = 16;
    parameter config_num = 1;
    parameter max_awidth = 6;

    parameter size = 256;
    parameter awidth = 6;
    parameter file_name = "bel_rom_twiddles.dat";

    parameter size2 = 256;
    parameter awidth2 = 6;
    parameter file_name2 = "bel_rom_twiddles2.dat";

    parameter size3 = 256;
    parameter awidth3 = 6;
    parameter file_name3 = "bel_rom_twiddles3.dat";

    parameter size4 = 256;
    parameter awidth4 = 6;
    parameter file_name4 = "bel_rom_twiddles4.dat";

    input clk_i;
    input rst_i;
    input [max_awidth - 1:0] adr_i;
    input rd_i;
    output [word_width * 2 - 1:0] dat_o;
    input [config_num - 1:0] cfg_sel_i;

    reg [word_width * 2 - 1:0] rom [0:size - 1];
    reg [awidth - 1:0] adr;
    reg [word_width * 2 - 1:0] dat_o;


    initial begin
        $readmemh (file_name, rom);
    end


    always @ (posedge rst_i or posedge clk_i) begin
        if (rst_i) begin
            adr <= 0;
        end else begin
            if (rd_i) begin
                adr <= adr_i;
            end
        end
    end


generate

    if (config_num > 1) begin
    
        reg [word_width * 2 - 1:0] rom2 [0:size2 - 1];

        initial begin
            $readmemh (file_name2, rom2);
        end


        if (config_num > 2) begin

            reg [word_width * 2 - 1:0] rom3 [0:size3 - 1];

            initial begin
                $readmemh (file_name3, rom3);
            end


            if (config_num > 3) begin

                reg [word_width * 2 - 1:0] rom4 [0:size4 - 1];

                initial begin
                    $readmemh (file_name4, rom4);
                end

                always @ (cfg_sel_i or adr) begin
                    case (cfg_sel_i)
                        4'b1000: begin
                            dat_o = rom4[adr[awidth4 - 1: 0]];
                        end
                        4'b0100: begin
                            dat_o = rom3[adr[awidth3 - 1: 0]];
                        end
                        4'b0010: begin
                            dat_o = rom2[adr[awidth2 - 1: 0]];
                        end
                        default: begin
                            dat_o = rom[adr];
                        end
                    endcase
                end

            end else begin

                always @ (cfg_sel_i or adr) begin
                    case (cfg_sel_i)
                        3'b100: begin
                            dat_o = rom3[adr[awidth3 - 1:0]];
                        end
                        3'b010: begin
                            dat_o = rom2[adr[awidth2 - 1:0]];
                        end
                        default: begin
                            dat_o = rom[adr[awidth - 1:0]];
                        end
                    endcase
                end

            end

        end else begin

            always @ (cfg_sel_i or adr) begin
                case (cfg_sel_i)
                    2'b10: begin
                        dat_o = rom2[adr[awidth2 - 1:0]];
                    end
                    default: begin
                        dat_o = rom[adr[awidth - 1:0]];
                    end
                endcase
            end

        end

    end else begin

        always @ (adr)
            dat_o = rom[adr[awidth - 1:0]];

    end

endgenerate

    
endmodule

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...