OpenCores
URL https://opencores.org/ocsvn/integer_square_root/integer_square_root/trunk

Subversion Repositories integer_square_root

[/] [integer_square_root/] [trunk/] [src/] [mult_stage.sv] - Blame information for rev 2

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 2 ayka
`timescale 1ns / 100ps
2
//////////////////////////////////////////////////////////////////////////////////
3
// Company:
4
// Engineer: Yihua Liu
5
//
6
// Create Date: 2022/06/06 12:58:15
7
// Design Name:
8
// Module Name: mult_stage
9
// Project Name: lab_3_a
10
// Target Devices: xczu7eg-ffvf1517-2-i
11
// Tool Versions:
12
// Description:
13
//
14
// Dependencies:
15
//
16
// Revision:
17
// Revision 0.01 - File Created
18
// Additional Comments:
19
//
20
//////////////////////////////////////////////////////////////////////////////////
21
 
22
 
23
// This is one stage of an 8 stage (9 depending on how you look at it)
24
// pipelined multiplier that multiplies 2 64-bit integers and returns
25
// the low 64 bits of the result.  This is not an ideal multiplier but
26
// is sufficient to allow a faster clock period than straight *
27
module mult_stage(
28
        input clock, reset, start,
29
        input [63:0] product_in, mplier_in, mcand_in,
30
 
31
        output logic done,
32
        output logic [63:0] product_out, mplier_out, mcand_out
33
);
34
 
35
        // This parameter is used to change the number of stages.
36
        // For example, if N_STAGE = 8, we are using an 8-stage pipelined multiplier.
37
    parameter N_STAGE = 8;
38
 
39
        logic [63:0] prod_in_reg, partial_prod_reg;
40
        logic [63:0] partial_product, next_mplier, next_mcand;
41
 
42
        assign product_out = prod_in_reg + partial_prod_reg;
43
 
44
        assign partial_product = mplier_in[64/N_STAGE-1:0] * mcand_in;
45
 
46
        // assign next_mplier = {{(64/N_STAGE){1'b0}},mplier_in[63:64/N_STAGE]};
47
        // assign next_mcand = {mcand_in[64-64/N_STAGE-1:0],{(64/N_STAGE){1'b0}}};
48
        assign next_mplier = mplier_in >> 64/N_STAGE;
49
        assign next_mcand = mcand_in << 64/N_STAGE;
50
 
51
        //synopsys sync_set_reset "reset"
52
        always_ff @(posedge clock) begin
53
                prod_in_reg      <= #1 product_in;
54
                partial_prod_reg <= #1 partial_product;
55
                mplier_out       <= #1 next_mplier;
56
                mcand_out        <= #1 next_mcand;
57
        end
58
 
59
        // synopsys sync_set_reset "reset"
60
        always_ff @(posedge clock) begin
61
                if(reset)
62
                        done <= #1 1'b0;
63
                else
64
                        done <= #1 start;
65
        end
66
 
67
endmodule
68
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.