Question: is this correct code becase in edaplayground i have errors if i have eny mestak plzz fixed it depandent this code and give me finall
is this correct code becase in edaplayground i have errors if i have eny mestak plzz fixed it depandent this code and give me finall right code this is design : Code your design here
Basic Logic Modules
NOT Gate
module INVinput A output Y;
assign Y ~A;
endmodule
NAND Gate
module NANDinput A input B output Y;
assign Y ~A & B;
endmodule
NOR Gate
module NORinput A input B output Y;
assign Y ~A B;
endmodule
AND Gate
module ANDinput A input B output Y;
assign Y A & B;
endmodule
OR Gate
module ORinput A input B output Y;
assign Y A B;
endmodule
XOR Gate
module XORinput A input B output Y;
assign Y A B;
endmodule
XNOR Gate
module XNORinput A input B output Y;
assign Y ~A B;
endmodule
Equal Comparator
module EqualComparator #parameter WIDTH input WIDTH: A input WIDTH: B output Equal;
wire WIDTH: xorout;
wire norout;
XOR each bit and combine using NOR
genvar i;
generate
for i ; i WIDTH; i i begin : genxor
XOR uxor AAiBBiYxorouti;
end
endgenerate
NOR all XOR results
assign norout ~xorout; Reduction NOR
assign Equal norout;
endmodule
Greater Comparator
module GreaterComparator #parameter WIDTH input WIDTH: A input WIDTH: B input S output Greater;
wire WIDTH: gtbits;
wire WIDTH: ltbits;
wire unsignedgt;
wire signedgt;
Compare each bit for unsigned comparison
assign gtbits A & ~B;
assign ltbits ~A & B;
Check for unsigned greater
assign unsignedgt gtbits & ~ltbits;
Handle signed greater
assign signedgt SAWIDTH & ~BWIDTH
~AWIDTH & ~BWIDTH & unsignedgt
: unsignedgt;
assign Greater signedgt;
endmodule
Smaller Comparator
module SmallerComparator #parameter WIDTH input WIDTH: A input WIDTH: B input S output Smaller;
wire WIDTH: gtbits;
wire WIDTH: ltbits;
wire unsignedlt;
wire signedlt;
Compare each bit for unsigned comparison
assign gtbits A & ~B;
assign ltbits ~A & B;
Check for unsigned smaller
assign unsignedlt ltbits & ~gtbits;
Handle signed smaller
assign signedlt S~AWIDTH & BWIDTH
~AWIDTH & ~BWIDTH & unsignedlt
: unsignedlt;
assign Smaller signedlt;
endmodule
TopLevel Comparator Module
module Comparator #parameter WIDTH input clk input WIDTH: A input WIDTH: B input S
output reg Equal, output reg Greater, output reg Smaller;
wire eq gt lt;
Instantiate comparators
EqualComparator #WIDTH eqcomp AABBEqualeq;
GreaterComparator #WIDTH gtcomp AABBSSGreatergt;
SmallerComparator #WIDTH ltcomp AABBSSSmallerlt;
Synchronous outputs
always @posedge clk begin
Equal eq;
Greater gt;
Smaller lt;
end
endmodule
and this testbench:
module tbComparator;
reg clk;
reg : A B;
reg S;
wire Equal, Greater, Smaller;
Instantiate the Comparator module
Comparator # uut clkclkAABBSSEqualEqualGreaterGreaterSmallerSmaller;
Clock generation
initial begin
clk ;
forever # clk ~clk; ns clock
end
Test cases
initial begin
$displayStarting testbench...";
Test Case : A B
A b; B b; S ; #;
$displayAb Bb Sb Equalb Greaterb Smallerb A B S Equal, Greater, Smaller;
Test Case : A B Unsigned
A b; B b; S ; #;
$displayAb Bb Sb Equalb Greaterb Smallerb A B S Equal, Greater, Smaller;
Test Case : A B Unsigned
A b; B b; S ; #;
$displayAb Bb Sb Equalb Greaterb Smallerb A B S Equal, Greater, Smaller;
Test Case : A B Signed
A b; B b; S ; #;
$displayAb Bb Sb Equalb Greaterb Smallerb A B S Equal, Greater, Smaller;
Test Case : A B Signed
A b; B b; S ; #;
$displayAb Bb Sb Equalb Greaterb Smallerb A B S Equal, Greater, Smaller;
$stop; End simulation
end
endmodule an error in your design and to do a verification that will discover the error and write it to the console screen.
Format of the report:
This project should be written as formal report. The report should include sections on the following:
Brief introduction
Brief theoretical overview
Design philosophy
Simulation Results
Conclusion and Future works
The report shouldn't exceed pages excluding the code with
line spacing.
Times new roman.
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
