A
Andy Luotto
Guest
I am looking for the best practice to design a cross connection matrix
which connevts bit i-th of port A to bit j-th of port B, where port A
and port B are bidir vectors.
All of this under the control of a text file which connect the elements
of a matrix which are set to 1.
the first line of the matrix is the size of the vectors (A and B are
same size) in binary format
module xconnect
(
inout [15:0] port_a,
inout [15:0] port_b
);
parameter config_file = "./xcon.pat";
reg [15:0] file_array[-1:15];
integer i,j;
reg [15:0] data_reg;
integer size;
initial begin
for(i=0;i<16;i=i+1)
data_reg <= 1'bz;
$readmemb(config_file, file_array,-1,15);
/* Size is the nr of the higher port to be considered in the
connection */
size = file_array[-1];
$display("***I: xconnect: Port nr=%0d",size);
end
always@(port_b)
begin
for(i=0;i<size;i=i+1)
begin
for(j=0;j<size;j=j+1)
if (file_array[j] == 1)
begin
data_reg <= port_b[j];
end
end
end
assign port_a = data_reg;
endmodule
A sample pattern file
0000000000010000
0000000100000000
0000001000000000
0000010000000000
0000100000000000
0001000000000000
0010000000000000
0100000000000000
1000000000000000
0000000000000001
0000000000000010
0000000000000100
0000000000001000
0000000000010000
0000000000100000
0000000001000000
0000000010000000
shows a 16x16 matrix where port_a is supposed to be connected to
port_b[j+8]
Is this implementation correct? Does anybody see any drawback?
I am scary that this module has a kind of 'preferred direction'
embedded since port_b is in the sensitivty list of the process the
assign port_b to port_a
What is confusing me is probably due to my mis-understanding about how
verilog models bidirectional signals
Any comment on this is very welcome
which connevts bit i-th of port A to bit j-th of port B, where port A
and port B are bidir vectors.
All of this under the control of a text file which connect the elements
of a matrix which are set to 1.
the first line of the matrix is the size of the vectors (A and B are
same size) in binary format
module xconnect
(
inout [15:0] port_a,
inout [15:0] port_b
);
parameter config_file = "./xcon.pat";
reg [15:0] file_array[-1:15];
integer i,j;
reg [15:0] data_reg;
integer size;
initial begin
for(i=0;i<16;i=i+1)
data_reg <= 1'bz;
$readmemb(config_file, file_array,-1,15);
/* Size is the nr of the higher port to be considered in the
connection */
size = file_array[-1];
$display("***I: xconnect: Port nr=%0d",size);
end
always@(port_b)
begin
for(i=0;i<size;i=i+1)
begin
for(j=0;j<size;j=j+1)
if (file_array[j] == 1)
begin
data_reg <= port_b[j];
end
end
end
assign port_a = data_reg;
endmodule
A sample pattern file
0000000000010000
0000000100000000
0000001000000000
0000010000000000
0000100000000000
0001000000000000
0010000000000000
0100000000000000
1000000000000000
0000000000000001
0000000000000010
0000000000000100
0000000000001000
0000000000010000
0000000000100000
0000000001000000
0000000010000000
shows a 16x16 matrix where port_a is supposed to be connected to
port_b[j+8]
Is this implementation correct? Does anybody see any drawback?
I am scary that this module has a kind of 'preferred direction'
embedded since port_b is in the sensitivty list of the process the
assign port_b to port_a
What is confusing me is probably due to my mis-understanding about how
verilog models bidirectional signals
Any comment on this is very welcome