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 segment and led I also need a testbench for the top modules.
module calculatorfsm
input clk
input btnmode
input btnmode
input : btnsel,
output reg : opcode,
output reg mode,
output reg aluenable
;
localparam MODEb; Arithmetic operations
localparam MODEb; Bitwise operations
reg currentmode;
reg btnmodelast, btnmodelast;
reg : btnselinternal;
Detect mode switch and reset btnsel
always @posedge clk begin
if btnmode && btnmodelast begin
currentmode MODE;
btnselinternal b; Reset to default operation
end else if btnmode && btnmodelast begin
currentmode MODE;
btnselinternal b; Reset to default operation
end else begin
btnselinternal btnsel; Retain btnsel
end
btnmodelast btnmode;
btnmodelast btnmode;
end
always @ begin
aluenable ; Default disable ALU
case currentmode
MODE: begin
mode ; Arithmetic Mode
case btnsel
b: opcode b; Addition
b: opcode b; Subtraction
b: opcode b; Multiplication
b: opcode b; Division
default: opcode b; Default to Addition
endcase
aluenable ;
end
MODE: begin
mode ; Bitwise Mode
case btnsel
b: opcode b; AND
b: opcode b; OR
b: opcode b; Shift Left
b: opcode b; Shift Right
default: opcode b; Default to AND
endcase
aluenable ;
end
default: begin
mode ;
opcode b;
aluenable ;
end
endcase
end
endmodule
module SevenSegmentCombinational
input x
input x
input xl
input x
output a
output b
output c
output d
output e
output f
output g
;
assign a x x x & x ~x &~x ;
assign b ~x x & x ~x &~x ;
assign c x x ~x x ;
assign d x x & ~x x & ~x ~x &~x x& x &~x;
assign e ~x& ~x& ~x ~x& x& ~x ~x &~x& ~x;
assign f ~x& ~x& ~x~x& x& ~x ~x& x& ~x x& textrmx&textrmx;
assign g x &~x x &~xl x ~x & x ;
endmodule
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
