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

Subversion Repositories or1k

[/] [or1k/] [branches/] [branch_qmem/] [or1200/] [rtl/] [verilog/] [or1200_mult_mac.v] - Diff between revs 1035 and 1159

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 1035 Rev 1159
Line 43... Line 43...
//////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////
//
//
// CVS Revision History
// CVS Revision History
//
//
// $Log: not supported by cvs2svn $
// $Log: not supported by cvs2svn $
 
// Revision 1.2  2002/09/08 05:52:16  lampret
 
// Added optional l.div/l.divu insns. By default they are disabled.
 
//
// Revision 1.1  2002/01/03 08:16:15  lampret
// Revision 1.1  2002/01/03 08:16:15  lampret
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
// New prefixes for RTL files, prefixed module names. Updated cache controllers and MMUs.
//
//
// Revision 1.3  2001/10/21 17:57:16  lampret
// Revision 1.3  2001/10/21 17:57:16  lampret
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
// Removed params from generic_XX.v. Added translate_off/on in sprs.v and id.v. Removed spr_addr from dc.v and ic.v. Fixed CR+LF.
Line 110... Line 113...
output  [31:0]                   spr_dat_o;
output  [31:0]                   spr_dat_o;
 
 
//
//
// Internal wires and regs
// Internal wires and regs
//
//
 
`ifdef OR1200_MULT_IMPLEMENTED
reg     [width-1:0]              result;
reg     [width-1:0]              result;
reg     [2*width-1:0]            mul_prod_r;
reg     [2*width-1:0]            mul_prod_r;
reg     [2*width-1:0]            mac_r;
`else
 
wire    [width-1:0]              result;
 
wire    [2*width-1:0]            mul_prod_r;
 
`endif
wire    [2*width-1:0]            mul_prod;
wire    [2*width-1:0]            mul_prod;
wire    [`OR1200_MACOP_WIDTH-1:0]        mac_op;
wire    [`OR1200_MACOP_WIDTH-1:0]        mac_op;
 
`ifdef OR1200_MAC_IMPLEMENTED
reg     [`OR1200_MACOP_WIDTH-1:0]        mac_op_r1;
reg     [`OR1200_MACOP_WIDTH-1:0]        mac_op_r1;
reg     [`OR1200_MACOP_WIDTH-1:0]        mac_op_r2;
reg     [`OR1200_MACOP_WIDTH-1:0]        mac_op_r2;
reg     [`OR1200_MACOP_WIDTH-1:0]        mac_op_r3;
reg     [`OR1200_MACOP_WIDTH-1:0]        mac_op_r3;
reg                             mac_stall_r;
reg                             mac_stall_r;
 
reg     [2*width-1:0]            mac_r;
 
`else
 
wire    [`OR1200_MACOP_WIDTH-1:0]        mac_op_r1;
 
wire    [`OR1200_MACOP_WIDTH-1:0]        mac_op_r2;
 
wire    [`OR1200_MACOP_WIDTH-1:0]        mac_op_r3;
 
wire                            mac_stall_r;
 
wire    [2*width-1:0]            mac_r;
 
`endif
wire    [width-1:0]              x;
wire    [width-1:0]              x;
wire    [width-1:0]              y;
wire    [width-1:0]              y;
wire                            spr_maclo_we;
wire                            spr_maclo_we;
wire                            spr_machi_we;
wire                            spr_machi_we;
wire                            alu_op_div_divu;
wire                            alu_op_div_divu;
Line 134... Line 150...
`endif
`endif
 
 
//
//
// Combinatorial logic
// Combinatorial logic
//
//
 
`ifdef OR1200_MAC_IMPLEMENTED
assign spr_maclo_we = spr_cs & spr_write & spr_addr[`OR1200_MAC_ADDR];
assign spr_maclo_we = spr_cs & spr_write & spr_addr[`OR1200_MAC_ADDR];
assign spr_machi_we = spr_cs & spr_write & !spr_addr[`OR1200_MAC_ADDR];
assign spr_machi_we = spr_cs & spr_write & !spr_addr[`OR1200_MAC_ADDR];
assign spr_dat_o = spr_addr[`OR1200_MAC_ADDR] ? mac_r[31:0] : mac_r[63:32];
assign spr_dat_o = spr_addr[`OR1200_MAC_ADDR] ? mac_r[31:0] : mac_r[63:32];
 
`else
 
assign spr_maclo_we = 1'b0;
 
assign spr_machi_we = 1'b0;
 
assign spr_dat_o = 32'h0000_0000;
 
`endif
`ifdef OR1200_LOWPWR_MULT
`ifdef OR1200_LOWPWR_MULT
assign x = (alu_op_div & a[31]) ? ~a + 1'b1 : alu_op_div_divu | (alu_op == `OR1200_ALUOP_MUL) | (|mac_op) ? a : 32'h0000_0000;
assign x = (alu_op_div & a[31]) ? ~a + 1'b1 : alu_op_div_divu | (alu_op == `OR1200_ALUOP_MUL) | (|mac_op) ? a : 32'h0000_0000;
assign y = (alu_op_div & b[31]) ? ~b + 1'b1 : alu_op_div_divu | (alu_op == `OR1200_ALUOP_MUL) | (|mac_op) ? b : 32'h0000_0000;
assign y = (alu_op_div & b[31]) ? ~b + 1'b1 : alu_op_div_divu | (alu_op == `OR1200_ALUOP_MUL) | (|mac_op) ? b : 32'h0000_0000;
`else
`else
assign x = alu_op_div & a[31] ? ~a + 1'b1 : a;
assign x = alu_op_div & a[31] ? ~a + 1'b1 : a;
Line 153... Line 175...
`else
`else
assign alu_op_div = 1'b0;
assign alu_op_div = 1'b0;
assign alu_op_div_divu = 1'b0;
assign alu_op_div_divu = 1'b0;
`endif
`endif
 
 
 
`ifdef OR1200_MULT_IMPLEMENTED
 
 
//
//
// Select result of current ALU operation to be forwarded
// Select result of current ALU operation to be forwarded
// to next instruction and to WB stage
// to next instruction and to WB stage
//
//
always @(alu_op or mul_prod_r or mac_r or a or b)
always @(alu_op or mul_prod_r or mac_r or a or b)
Line 182... Line 206...
        .Y(y),
        .Y(y),
        .RST(rst),
        .RST(rst),
        .CLK(clk),
        .CLK(clk),
        .P(mul_prod)
        .P(mul_prod)
);
);
`else
`else // OR1200_ASIC_MULTP2_32X32
or1200_gmultp2_32x32 or1200_gmultp2_32x32(
or1200_gmultp2_32x32 or1200_gmultp2_32x32(
        .X(x),
        .X(x),
        .Y(y),
        .Y(y),
        .RST(rst),
        .RST(rst),
        .CLK(clk),
        .CLK(clk),
        .P(mul_prod)
        .P(mul_prod)
);
);
`endif
`endif // OR1200_ASIC_MULTP2_32X32
 
 
//
//
// Registered output from the multiplier and
// Registered output from the multiplier and
// an optional divider
// an optional divider
//
//
Line 217... Line 241...
        else if (alu_op_div_divu && div_free) begin
        else if (alu_op_div_divu && div_free) begin
                mul_prod_r <= #1 {31'b0, x[31:0], 1'b0};
                mul_prod_r <= #1 {31'b0, x[31:0], 1'b0};
                div_cntr <= #1 6'b10_0000;
                div_cntr <= #1 6'b10_0000;
                div_free <= #1 1'b0;
                div_free <= #1 1'b0;
        end
        end
`endif
`endif // OR1200_IMPL_DIV
        else if (div_free | !ex_freeze) begin
        else if (div_free | !ex_freeze) begin
                mul_prod_r <= #1 mul_prod[63:0];
                mul_prod_r <= #1 mul_prod[63:0];
                div_free <= #1 1'b1;
                div_free <= #1 1'b1;
        end
        end
 
 
 
`else // OR1200_MULT_IMPLEMENTED
 
assign result = {width{1'b0}};
 
assign mul_prod = {2*width{1'b0}};
 
assign mul_prod_r = {2*width{1'b0}};
 
`endif // OR1200_MULT_IMPLEMENTED
 
 
 
`ifdef OR1200_MAC_IMPLEMENTED
 
 
//
//
 // Propagation of l.mac opcode
 // Propagation of l.mac opcode
//
//
always @(posedge clk or posedge rst)
always @(posedge clk or posedge rst)
        if (rst)
        if (rst)
Line 283... Line 315...
                mac_stall_r <= #1 (|mac_op | (|mac_op_r1) | (|mac_op_r2)) & id_macrc_op
                mac_stall_r <= #1 (|mac_op | (|mac_op_r1) | (|mac_op_r2)) & id_macrc_op
`ifdef OR1200_IMPL_DIV
`ifdef OR1200_IMPL_DIV
                                | (|div_cntr)
                                | (|div_cntr)
`endif
`endif
                                ;
                                ;
 
`else // OR1200_MAC_IMPLEMENTED
 
assign mac_stall_r = 1'b0;
 
assign mac_r = {2*width{1'b0}};
 
assign mac_op_r1 = `OR1200_MACOP_WIDTH'b0;
 
assign mac_op_r2 = `OR1200_MACOP_WIDTH'b0;
 
assign mac_op_r3 = `OR1200_MACOP_WIDTH'b0;
 
`endif // OR1200_MAC_IMPLEMENTED
 
 
endmodule
endmodule
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

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