Combinational logic based ALU

Guest #2664737
Rate this post
• ▲ useful
▼ not useful
Hi, I'm running into a problem that probably has a (really) easy fix but 
I can't seem to find it:
1
module MemAndALU(input wire [2:0]f, input wire [31:0]A,B, output [31:0]Y, output Z,N);
2

3
wire Cout;
4
wire [31:0]sum;
5

6
if(f==3'b000) begin
7
  ripple_carry_adder RCA(Cout, sum, A, B, 1'b0);
8
  assign Y=sum;
9

10
  if(sum==32'b0)
11
    assign Z=1;
12
  else
13
    assign Z=0;
14
  
15
  if(sum[31]==1)
16
    assign N=1;
17
  else
18
    assign N=0;
19
end
20
endmodule

One of the errors I'm getting is
Error (10149): Verilog HDL Declaration error at MemAndALU.v(7): 
identifier "sum" is already declared in the present scope

and

Error (10759): Verilog HDL error at MemAndALU.v(7): object A declared in 
a list of port declarations cannot be redeclared within the module body

I can't use registers for this assignment (which is frustrating) The 
header for ripple_carry_adder is here
module ripple_carry_adder
(
  output Cout,
  output [31:0]Sum,
  input [31:0]A,
  input [31:0]B,
  input Cin
);
and I know that it works

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.