V
Ved
Guest
Hi
I need a faster sort algorithm, which I got at
http://www.engr.sjsu.edu/crabill/ in lecture module5.
I am an ardent VHDL user. So I need to convert the verilog code to
VHDL.
I am attaching the code for convenience.
Is there any VERILOG to VHDL converter available?
I could find VHDL to verilog converter in abundance but no verilog to
vhdl.
--------------------------------------------------------------------------------------------
`timescale 1 ns / 1 ps
module oetsort(clk, in1, in2, in3, in4, in5,
out1, out2, out3, out4, out5);
input clk;
input [15:0] in1, in2, in3, in4, in5;
output [15:0] out1, out2, out3, out4, out5;
reg [15:0] dat1s0, dat2s0, dat3s0, dat4s0, dat5s0;
reg [15:0] dat1s1, dat2s1, dat3s1, dat4s1, dat5s1;
reg [15:0] dat1s2, dat2s2, dat3s2, dat4s2, dat5s2;
reg [15:0] dat1s3, dat2s3, dat3s3, dat4s3, dat5s3;
reg [15:0] dat1s4, dat2s4, dat3s4, dat4s4, dat5s4;
reg [15:0] dat1s5, dat2s5, dat3s5, dat4s5, dat5s5;
always @(posedge clk)
begin
// This implements the input registers.
dat1s0 <= in1;
dat2s0 <= in2;
dat3s0 <= in3;
dat4s0 <= in4;
dat5s0 <= in5;
// This implements the first pipeline stage.
dat1s1 <= (dat1s0 < dat2s0) ? dat2s0 : dat1s0;
dat2s1 <= (dat1s0 < dat2s0) ? dat1s0 : dat2s0;
dat3s1 <= (dat3s0 < dat4s0) ? dat4s0 : dat3s0;
dat4s1 <= (dat3s0 < dat4s0) ? dat3s0 : dat4s0;
dat5s1 <= dat5s0;
// This implements the second pipeline stage.
dat1s2 <= dat1s1;
dat2s2 <= (dat2s1 < dat3s1) ? dat3s1 : dat2s1;
dat3s2 <= (dat2s1 < dat3s1) ? dat2s1 : dat3s1;
dat4s2 <= (dat4s1 < dat5s1) ? dat5s1 : dat4s1;
dat5s2 <= (dat4s1 < dat5s1) ? dat4s1 : dat5s1;
// This implements the third pipeline stage.
dat1s3 <= (dat1s2 < dat2s2) ? dat2s2 : dat1s2;
dat2s3 <= (dat1s2 < dat2s2) ? dat1s2 : dat2s2;
dat3s3 <= (dat3s2 < dat4s2) ? dat4s2 : dat3s2;
dat4s3 <= (dat3s2 < dat4s2) ? dat3s2 : dat4s2;
dat5s3 <= dat5s2;
// This implements the fourth pipeline stage.
dat1s4 <= dat1s3;
dat2s4 <= (dat2s3 < dat3s3) ? dat3s3 : dat2s3;
dat3s4 <= (dat2s3 < dat3s3) ? dat2s3 : dat3s3;
dat4s4 <= (dat4s3 < dat5s3) ? dat5s3 : dat4s3;
dat5s4 <= (dat4s3 < dat5s3) ? dat4s3 : dat5s3;
// This implements the fifth pipeline stage.
dat1s5 <= (dat1s4 < dat2s4) ? dat2s4 : dat1s4;
dat2s5 <= (dat1s4 < dat2s4) ? dat1s4 : dat2s4;
dat3s5 <= (dat3s4 < dat4s4) ? dat4s4 : dat3s4;
dat4s5 <= (dat3s4 < dat4s4) ? dat3s4 : dat4s4;
dat5s5 <= dat5s4;
end
// The output data is already registered, so all
// I have to do is drive it out of the module.
assign out1 = dat1s5;
assign out2 = dat2s5;
assign out3 = dat3s5;
assign out4 = dat4s5;
assign out5 = dat5s5;
endmodule
I need a faster sort algorithm, which I got at
http://www.engr.sjsu.edu/crabill/ in lecture module5.
I am an ardent VHDL user. So I need to convert the verilog code to
VHDL.
I am attaching the code for convenience.
Is there any VERILOG to VHDL converter available?
I could find VHDL to verilog converter in abundance but no verilog to
vhdl.
--------------------------------------------------------------------------------------------
`timescale 1 ns / 1 ps
module oetsort(clk, in1, in2, in3, in4, in5,
out1, out2, out3, out4, out5);
input clk;
input [15:0] in1, in2, in3, in4, in5;
output [15:0] out1, out2, out3, out4, out5;
reg [15:0] dat1s0, dat2s0, dat3s0, dat4s0, dat5s0;
reg [15:0] dat1s1, dat2s1, dat3s1, dat4s1, dat5s1;
reg [15:0] dat1s2, dat2s2, dat3s2, dat4s2, dat5s2;
reg [15:0] dat1s3, dat2s3, dat3s3, dat4s3, dat5s3;
reg [15:0] dat1s4, dat2s4, dat3s4, dat4s4, dat5s4;
reg [15:0] dat1s5, dat2s5, dat3s5, dat4s5, dat5s5;
always @(posedge clk)
begin
// This implements the input registers.
dat1s0 <= in1;
dat2s0 <= in2;
dat3s0 <= in3;
dat4s0 <= in4;
dat5s0 <= in5;
// This implements the first pipeline stage.
dat1s1 <= (dat1s0 < dat2s0) ? dat2s0 : dat1s0;
dat2s1 <= (dat1s0 < dat2s0) ? dat1s0 : dat2s0;
dat3s1 <= (dat3s0 < dat4s0) ? dat4s0 : dat3s0;
dat4s1 <= (dat3s0 < dat4s0) ? dat3s0 : dat4s0;
dat5s1 <= dat5s0;
// This implements the second pipeline stage.
dat1s2 <= dat1s1;
dat2s2 <= (dat2s1 < dat3s1) ? dat3s1 : dat2s1;
dat3s2 <= (dat2s1 < dat3s1) ? dat2s1 : dat3s1;
dat4s2 <= (dat4s1 < dat5s1) ? dat5s1 : dat4s1;
dat5s2 <= (dat4s1 < dat5s1) ? dat4s1 : dat5s1;
// This implements the third pipeline stage.
dat1s3 <= (dat1s2 < dat2s2) ? dat2s2 : dat1s2;
dat2s3 <= (dat1s2 < dat2s2) ? dat1s2 : dat2s2;
dat3s3 <= (dat3s2 < dat4s2) ? dat4s2 : dat3s2;
dat4s3 <= (dat3s2 < dat4s2) ? dat3s2 : dat4s2;
dat5s3 <= dat5s2;
// This implements the fourth pipeline stage.
dat1s4 <= dat1s3;
dat2s4 <= (dat2s3 < dat3s3) ? dat3s3 : dat2s3;
dat3s4 <= (dat2s3 < dat3s3) ? dat2s3 : dat3s3;
dat4s4 <= (dat4s3 < dat5s3) ? dat5s3 : dat4s3;
dat5s4 <= (dat4s3 < dat5s3) ? dat4s3 : dat5s3;
// This implements the fifth pipeline stage.
dat1s5 <= (dat1s4 < dat2s4) ? dat2s4 : dat1s4;
dat2s5 <= (dat1s4 < dat2s4) ? dat1s4 : dat2s4;
dat3s5 <= (dat3s4 < dat4s4) ? dat4s4 : dat3s4;
dat4s5 <= (dat3s4 < dat4s4) ? dat3s4 : dat4s4;
dat5s5 <= dat5s4;
end
// The output data is already registered, so all
// I have to do is drive it out of the module.
assign out1 = dat1s5;
assign out2 = dat2s5;
assign out3 = dat3s5;
assign out4 = dat4s5;
assign out5 = dat5s5;
endmodule