V
Verilog_Maan
Guest
Hello All
I am designing packet header and I am stuck with very
simple problem and I an beginer of Verilog so I need your help.
packet is made up 80 bit and this 80 bit is devided into 20 bit phit
and this each phit is made up of various sub filed.I want to comapre
each sub filed with each 32 AND(bit wise AND) combination of 6
variable each is 32 bit long.how i will do?[Note:this filed varies
between 2 bits to 15 bits. In short i am doing mask and match].here is
my code and i am not getting the ouput so please help me with this.I
know i have to use byte comparator but how?
i also want to store this all 32 combination in 32 bit regesiter and
then want to comapre.
even i donot know like in VHDL how to defined internal signal in
Verilog?do i need to define internal signal in module?do i need to
define data type to internal signal?if yes then what data type i ahve
to use?wire or reg?
when I am suing assign out= a & b as an internal signal and that i
ahve to use further to comapre my input how i will do this?
Kindly go through my code(I ahve developed for one 20 bit phit) and
let me know where i am doing mistake
Module
test_packet1(a,b,c,d,e,f,packet_out,sub_file1,sub_field2,sub_filed_3,
sub_filed4,sub_file5,sub_file6,sub_filed7,sub_filed8,clk);
input [31:0] a,b,c,d,e,f;
input sub_file1,sub_field2;
input [2:0] sub_field3;
input [1:0] sub_field4;
input [3:0] sub_field5;
input [3:0] sub_field6;
input [1:0] sub_field7;
input [2:0] sub_field8;
ouput [19:0] packet_out;
wire [31:0] a,b,c,d,e,f;
wire sub_file1,sub_field2;
wire [2:0] sub_field3;
wire [1:0] sub_field4;
wire [3:0] sub_field5;
wire [3:0] sub_field6;
wire [1:0] sub_field7;
wire [2:0] sub_field8;
reg [19:0] packet_out;
//Internal signal and 35 bit wise AND combination store in this
reg(here i have question do i need to define this internal signal as
eg or wire?)
wire [31:0] out
0,out1,out2,out3,out4,out5,out6........................out35(I am not
writing the whole code)
//35 AND combination of 6 variable
assign out0 = a & b;
assign out0 = a & b;
assign out1 = a & c;
assign out2 = a & d;
assign out3 = a & e;
assign out4 = a & f;
assign out5 = a & b & c;
assign out6 = a & b & d;
assign out7 = a & b & e;
assign out8 = a & b & f;
assign out9 = a & b & c & d;
..
..
..
..
..
assign out 35 = e & f;
//here the actual code start
always @ (posedge clk)
begin
if (sub_field1 == out 0 || sub_field1 == out1 || sub_field1 ==
out2.................|| sub_filed1 == out 35 ) begin
packet_out[0]<= sub_field1;
else
begin
packet_out[0]<= packet_out[0];
sub_field1<= sub_field1;
end
end
if(sub_field2 == out0 || sub_filed2 == out1................sub_filed2
== out 35)begin
packet_out[1]<= sub_field2;
else
begin
packet_out[1]<=packet_out[1];
sub_field2<= sub_filed2;
end
end
..
..
..
..
..
if(sub_field8 == out0 || sub_filed8 == out1................sub_filed8
== out 35)begin
packet_out[19:17]<= sub_field2;
else
begin
packet_out[19:17]<=packet_out[19:17];
sub_field8<=sub_field8;
end
end
end module
kindly let me know where i am doing mistake?as I want to comapre each
filed with each 35 combination and sub_field matched with any
combination it will gives the output to the define packet bits.
kindly help me as i am stuck with this.
verilog_maan
I am designing packet header and I am stuck with very
simple problem and I an beginer of Verilog so I need your help.
packet is made up 80 bit and this 80 bit is devided into 20 bit phit
and this each phit is made up of various sub filed.I want to comapre
each sub filed with each 32 AND(bit wise AND) combination of 6
variable each is 32 bit long.how i will do?[Note:this filed varies
between 2 bits to 15 bits. In short i am doing mask and match].here is
my code and i am not getting the ouput so please help me with this.I
know i have to use byte comparator but how?
i also want to store this all 32 combination in 32 bit regesiter and
then want to comapre.
even i donot know like in VHDL how to defined internal signal in
Verilog?do i need to define internal signal in module?do i need to
define data type to internal signal?if yes then what data type i ahve
to use?wire or reg?
when I am suing assign out= a & b as an internal signal and that i
ahve to use further to comapre my input how i will do this?
Kindly go through my code(I ahve developed for one 20 bit phit) and
let me know where i am doing mistake
Module
test_packet1(a,b,c,d,e,f,packet_out,sub_file1,sub_field2,sub_filed_3,
sub_filed4,sub_file5,sub_file6,sub_filed7,sub_filed8,clk);
input [31:0] a,b,c,d,e,f;
input sub_file1,sub_field2;
input [2:0] sub_field3;
input [1:0] sub_field4;
input [3:0] sub_field5;
input [3:0] sub_field6;
input [1:0] sub_field7;
input [2:0] sub_field8;
ouput [19:0] packet_out;
wire [31:0] a,b,c,d,e,f;
wire sub_file1,sub_field2;
wire [2:0] sub_field3;
wire [1:0] sub_field4;
wire [3:0] sub_field5;
wire [3:0] sub_field6;
wire [1:0] sub_field7;
wire [2:0] sub_field8;
reg [19:0] packet_out;
//Internal signal and 35 bit wise AND combination store in this
reg(here i have question do i need to define this internal signal as
eg or wire?)
wire [31:0] out
0,out1,out2,out3,out4,out5,out6........................out35(I am not
writing the whole code)
//35 AND combination of 6 variable
assign out0 = a & b;
assign out0 = a & b;
assign out1 = a & c;
assign out2 = a & d;
assign out3 = a & e;
assign out4 = a & f;
assign out5 = a & b & c;
assign out6 = a & b & d;
assign out7 = a & b & e;
assign out8 = a & b & f;
assign out9 = a & b & c & d;
..
..
..
..
..
assign out 35 = e & f;
//here the actual code start
always @ (posedge clk)
begin
if (sub_field1 == out 0 || sub_field1 == out1 || sub_field1 ==
out2.................|| sub_filed1 == out 35 ) begin
packet_out[0]<= sub_field1;
else
begin
packet_out[0]<= packet_out[0];
sub_field1<= sub_field1;
end
end
if(sub_field2 == out0 || sub_filed2 == out1................sub_filed2
== out 35)begin
packet_out[1]<= sub_field2;
else
begin
packet_out[1]<=packet_out[1];
sub_field2<= sub_filed2;
end
end
..
..
..
..
..
if(sub_field8 == out0 || sub_filed8 == out1................sub_filed8
== out 35)begin
packet_out[19:17]<= sub_field2;
else
begin
packet_out[19:17]<=packet_out[19:17];
sub_field8<=sub_field8;
end
end
end module
kindly let me know where i am doing mistake?as I want to comapre each
filed with each 35 combination and sub_field matched with any
combination it will gives the output to the define packet bits.
kindly help me as i am stuck with this.
verilog_maan