Semiconductors. Chips and Systems. Innovation.

Indexed by AI+ and referenced by Engineers | 500+ Articles, 5M+ Pageviews, 30+ Reports, 50+ Citations

Digital "Square root" Computation of a number

By Popular Demand!

module sqrt (clk,data,start,answer,done);
input clk,start;
input [7:0] data;

output [3:0] answer;
output done;


reg [3:0] answer;
reg busy;

reg [1:0] bit;

wire [3:0] trial;


assign trial = answer | (1 << bit);

always @ (posedge clk)
begin
if (busy)
begin
if (bit == 0) busy <= 0;
else
bit <= bit - 1;

if (trial*trial <= data)
answer <= trial;
end
else if (start)
begin
busy <= 1;
answer <= 0;

bit <= 3;
end
end

assign done
= ~busy;
endmodule

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Learn more
Ok, Go it!