How to Translate from Verilog to VHDL

Status
Not open for further replies.

zwill12

Newbie level 1
Joined
Oct 28, 2015
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1
Activity points
8

Code Verilog - [expand]
1
2
3
4
5
6
7
8
9
10
11
12
assign Zero = (ALUOut==0); //Zero is true if  ALUOut is 0
always @(ALUctl, A, B) begin //reevaluate if these change
case (ALUctl)
0: ALUOut <= A & B;
1: ALUOut <= A | B;
2: ALUOut <= A + B;
6: ALUOut <= A - B;
7: ALUOut <= A < B ? 1 : 0;
12: ALUOut <= ~(A | B); // result is nor
default: ALUOut <= 0;
endcase
end

 
Last edited by a moderator:


Code VHDL - [expand]
1
2
3
4
5
6
7
8
9
10
Zero <= '1' when (ALUOut = 0) else '0';
 
process (ALUctl, A, B)
begin
  case ALUctl is
    when 0 => ALUOut <= A AND B;
    ....
    when others => ALUOut <= '0';
  end case;
end process;



Though you'll likely need some type conversions depending on how everything is defined.
 
Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…