Question: INFO: [ VRFC 1 0 - 2 2 6 3 ] Analyzing Verilog file C: / Users / rha 3 1 / Downloads /

INFO: [VRFC 10-2263] Analyzing Verilog file "C:/Users/rha31/Downloads/Final Project/Final Project/Final Project.srcs/sources_1/new/FSM.v" into library xil_defaultlib
INFO: [VRFC 10-311] analyzing module calculator_fsm
WARNING: [VRFC 10-9336] redeclaration of ANSI port 'mode' is not allowed [C:/Users/rha31/Downloads/Final Project/Final Project/Final Project.srcs/sources_1/new/FSM.v:33]
ERROR: [VRFC 10-2989] 'debounce_cnt' is not declared [C:/Users/rha31/Downloads/Final Project/Final Project/Final Project.srcs/sources_1/new/FSM.v:41]
ERROR: [VRFC 10-2989] 'debounce_cnt' is not declared [C:/Users/rha31/Downloads/Final Project/Final Project/Final Project.srcs/sources_1/new/FSM.v:42]
ERROR: [VRFC 10-2989] 'debounce_cnt' is not declared [C:/Users/rha31/Downloads/Final Project/Final Project/Final Project.srcs/sources_1/new/FSM.v:43]
ERROR: [VRFC 10-2989] 'debounce_cnt' is not declared [C:/Users/rha31/Downloads/Final Project/Final Project/Final Project.srcs/sources_1/new/FSM.v:45]
ERROR: [VRFC 10-8530] module 'calculator_fsm' is ignored due to previous errors [C:/Users/rha31/Downloads/Final Project/Final Project/Final Project.srcs/sources_1/new/FSM.v:21]
module calculator_fsm (
input clk,
input btn_mode, // Single button for toggling modes
input [1:0] btn_sel, // Operation selection input
output reg [2:0] opcode,
output reg mode, //0= Arithmetic, 1= Bitwise
output reg alu_enable
);
localparam MODE_1=1'b0; // Arithmetic operations
localparam MODE_2=1'b1; // Bitwise operations
reg mode = MODE_1; // Initialize mode
reg btn_mode_sync; // Synchronized button signal
reg btn_mode_debounced; // Debounced button signal
// Synchronize and debounce btn_mode
always @(posedge clk) begin
btn_mode_sync <= btn_mode; // Synchronize input to clock domain
if (btn_mode_sync != btn_mode_debounced) begin
debounce_cnt <=0; // Reset counter
end else if (debounce_cnt <4'd15) begin
debounce_cnt <= debounce_cnt +1; // Increment counter
end
if (debounce_cnt ==4'd15) begin
btn_mode_debounced <= btn_mode_sync; // Update debounced signal
end
end
// Toggle mode on falling edge of debounced button
always @(posedge clk) begin
if (btn_mode_debounced && !btn_mode_sync) begin
mode <= ~mode; // Toggle mode
end
end
// Determine opcode based on mode and button inputs
always @(*) begin
alu_enable =0; // Default disable ALU
case (mode)
MODE_1: begin
// Arithmetic Mode
case (btn_sel)
2'b00: opcode =3'b000; // Addition
2'b01: opcode =3'b001; // Subtraction
2'b10: opcode =3'b010; // Multiplication
2'b11: opcode =3'b011; // Division
default: opcode =3'b000; // Default to Addition
endcase
alu_enable =1;
end
MODE_2: begin
// Bitwise Mode
case (btn_sel)
2'b00: opcode =3'b100; // AND
2'b01: opcode =3'b101; // OR
2'b10: opcode =3'b110; // Shift Left
2'b11: opcode =3'b111; // Shift Right
default: opcode =3'b100; // Default to AND
endcase
alu_enable =1;
end
default: begin
opcode =3'b000;
alu_enable =0;
end
endcase
end
endmodule

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!