Question: I need a top modules and the number should go into a four segment display for decimal and a led display for binary. it from

I need a top modules and the number should go into a four segment display for decimal and a led display for binary. it from the ALU to the 4 segment and led I also need a testbench for the top modules.
module calculator_fsm (
input clk,
input btn_mode1,
input btn_mode2,
input [1:0] btn_sel,
output reg [2:0] opcode,
output reg mode,
output reg alu_enable
);
localparam MODE_1=1'b0; // Arithmetic operations
localparam MODE_2=1'b1; // Bitwise operations
reg current_mode;
reg btn_mode1_last, btn_mode2_last;
reg [1:0] btn_sel_internal;
// Detect mode switch and reset btn_sel
always @(posedge clk) begin
if (btn_mode1 && !btn_mode1_last) begin
current_mode = MODE_1;
btn_sel_internal =2'b00; // Reset to default operation
end else if (btn_mode2 && !btn_mode2_last) begin
current_mode = MODE_2;
btn_sel_internal =2'b00; // Reset to default operation
end else begin
btn_sel_internal = btn_sel; // Retain btn_sel
end
btn_mode1_last = btn_mode1;
btn_mode2_last = btn_mode2;
end
always @(*) begin
alu_enable =0; // Default disable ALU
case (current_mode)
MODE_1: begin
mode =0; // 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
mode =1; // 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
mode =0;
opcode =3'b000;
alu_enable =0;
end
endcase
end
endmodule
module SevenSegmentCombinational(
input x3,
input x2,
input xl,
input x0,
output a,
output b,
output c,
output d,
output e,
output f,
output g
);
assign a = x3| x1| x2 & x0| ~x2 &~x0 ;
assign b = ~x2| x1 & x0| ~x1 &~x0 ;
assign c = x3| x2| ~x1| x0 ;
assign d = x3| x1 & ~x2| x1 & ~x0| ~x0 &~x2| x0& x2 &~x1;
assign e = ~x3& ~x2& ~x0| ~x3& x1& ~x0| ~x2 &~x1& ~x0;
assign f = ~x3& ~x0& ~x1|~x3& x2& ~x0| ~x3& x2& ~x1| x3& \textrm{x}2&\textrm{x}1;
assign g = x1 &~x0| x2 &~xl | x3| ~x2 & x1 ;
endmodule
I need a top modules and the number should go

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 Electrical Engineering Questions!