who can help me?how to design one bidirection 1/8 multiplexr

Status
Not open for further replies.

ZFDok

Junior Member level 2
Joined
Aug 30, 2005
Messages
22
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,512
i will design one bidirection 1-8 multiplexer, i did not sucessful,i used the method
module (Dir, Sel, Row, Col);
input Dir;
input [2 : 0] Sel;
inout Row;
inout [7 : 0] Col;
...
endmodule

who can help me ? how to design the bidirection module?
 

Re: who can help me?how to design one bidirection 1/8 multip

Here is what you are looking for along with testbench!
Hope this helps!


Code:
module bi_mux_8_1(/*AUTOARG*/
   // Inouts
   Row, Col, 
   // Inputs
   Dir, Sel
   );
   input Dir;
   input [2 : 0] Sel;
   inout         Row;
   inout [7 : 0] Col;
   reg [7:0]   decoded;
   
   // input from row to col
   assign      Col[0] = decoded[0] & Dir ? Row : 1'bz;
   assign      Col[1] = decoded[1] & Dir ? Row : 1'bz;
   assign      Col[2] = decoded[2] & Dir ? Row : 1'bz;
   assign      Col[3] = decoded[3] & Dir ? Row : 1'bz;
   assign      Col[4] = decoded[4] & Dir ? Row : 1'bz;
   assign      Col[5] = decoded[5] & Dir ? Row : 1'bz;
   assign      Col[6] = decoded[6] & Dir ? Row : 1'bz;
   assign      Col[7] = decoded[7] & Dir ? Row : 1'bz;
   // input from col to row
   assign Row = decoded[0] & ~Dir ? Col[0] : 1'bz;
   assign Row = decoded[1] & ~Dir ? Col[1] : 1'bz;
   assign Row = decoded[2] & ~Dir ? Col[2] : 1'bz;
   assign Row = decoded[3] & ~Dir ? Col[3] : 1'bz;
   assign Row = decoded[4] & ~Dir ? Col[4] : 1'bz;
   assign Row = decoded[5] & ~Dir ? Col[5] : 1'bz;
   assign Row = decoded[6] & ~Dir ? Col[6] : 1'bz;
   assign Row = decoded[7] & ~Dir ? Col[7] : 1'bz;
   
   always @(/*AS*/Dir or Sel) begin
      decoded = 8'b00000000;
      decoded[Sel] = 1'b1;
   end
   
endmodule // bi_mux_8_1

   
module test();
   reg                  Dir;                    // To bi_mux_8_1 of bi_mux_8_1.v
   reg [2:0]            Sel;                    // To bi_mux_8_1 of bi_mux_8_1.v

   wire [7:0]           Col;                    // To/From bi_mux_8_1 of bi_mux_8_1.v
   wire                 Row;                    // To/From bi_mux_8_1 of bi_mux_8_1.v

   reg [7:0]           Col_reg;                    // To/From bi_mux_8_1 of bi_mux_8_1.v
   reg                 Row_reg;                    // To/From bi_mux_8_1 of bi_mux_8_1.v

   assign      Col = Col_reg;
   assign      Row = Row_reg;
   
   bi_mux_8_1 bi_mux_8_1(/*AUTOINST*/
                         // Inouts
                         .Row           (Row),
                         .Col           (Col[7:0]),
                         // Inputs
                         .Dir           (Dir),
                         .Sel           (Sel[2:0]));
   initial begin
      $monitor ($time,,"Dir = %b Sel = %b Col = %b Row = %b ", Dir, Sel, Col, Row);
      Dir = 1;
      Col_reg = 8'bzzzzzzzz; 
      Row_reg = 1'b1; 
      Sel = 0;
      #10 Sel = 1;
      #10 Sel = 2;
      #10 Sel = 3;
      #10 Sel = 4;
      #10 Sel = 5;
      #10 Sel = 6;
      #10 Sel = 7;
      #10;
      
      Dir = 0;
      Col_reg = 8'b10101010; 
      Row_reg = 1'bz; 
      Sel = 0;
      #10 Sel = 1;
      #10 Sel = 2;
      #10 Sel = 3;
      #10 Sel = 4;
      #10 Sel = 5;
      #10 Sel = 6;
      #10 Sel = 7;
      #10 $finish;
   end
   
endmodule // test
 

Re: who can help me?how to design one bidirection 1/8 multip

very thanks for you ! but i meet a problem when i call two module of them ,the synthesiser report error is @E: FX173 :"e:\zfd\fpga\xilinx\xcr3032xl\test.v":11:66:11:70|Bidir pin MobRi feeds another bidir pin. You must add a register or buffer between them. the MobRi is one signal of my input ,the top module :
`define MAXBITS 26
module Test(
UsbDcd, UsbRxd, UsbTxd, UsbDtr, UsbDsr, UsbRts, UsbCts, UsbRi,

MobDcd, MobRxd, MobTxd, MobDtr, MobDsr, MobRts, MobCts, MobRi);

inout UsbTxd, UsbDtr, UsbRts;
inout UsbDcd, UsbRxd, UsbDsr, UsbRi, UsbCts;

inout MobDcd, MobRxd, MobTxd, MobDtr, MobDsr, MobRts, MobCts, MobRi;
wire MobDcd, MobRxd, MobTxd, MobDtr, MobDsr, MobRts, MobCts, MobRi;
wire [7 : 0] wDirection;
wire [2 : 0] wSelRxd, wSelTxd, wSelDtr, wSelDsr, wSelRts, wSelCts, wSelDcd, wSelRi;
wire [`MAXBITS : 1] wCtrlData;


assign wDirection = 8'b00110100;
assign wSelRxd = wCtrlData[21 : 19];
assign wSelTxd = wCtrlData[18 : 16];


bi_mux_8_1 MatrixRxd(.Dir(wDirection[6]), .Sel(wSelRxd), .Row(UsbRxd), .Col({MobDcd, MobRxd, MobTxd, MobDtr, MobDsr, MobRts, MobCts, MobRi}));
bi_mux_8_1 MatrixTxd(.Dir(wDirection[5]), .Sel(wSelTxd), .Row(UsbTxd), .Col({MobDcd, MobRxd, MobTxd, MobDtr, MobDsr, MobRts, MobCts, MobRi}));

endmodule
why it is able to appear this error? i use the xilinx CPLD XCR3032XL chip.
 

what kind of usage for the bidirection mux?
 

Re: who can help me?how to design one bidirection 1/8 multip

i will use the cpld to config RS_232 signal input random and output random , that mean a 8 x 8 matrix, the select through a microcontroller.
 

Re: who can help me?how to design one bidirection 1/8 multip

How about this 1x8 mux?
Code:
module top (Dir, Sel, Row, Col);
  input        Dir;  // Low selects row-to-col. High selects col-to-row.
  input  [2:0] Sel;
  inout        Row;
  inout  [7:0] Col;

  assign Row = Dir ? Col[Sel] : 'bz;
  assign Col = Dir ? 'bz : {7'bz,Row,7'bz} >> (7-Sel);
endmodule
Or this 8x8 mux?
Code:
module top (Dir, Sel, Row, Col);
  input  [7:0] Dir;  // Low selects row-to-col. High selects col-to-row.
  input [23:0] Sel;  // Eight 3-bit selectors
  inout  [7:0] Row;
  inout  [7:0] Col;

  genvar n;
  generate
    for (n=0; n<8; n=n+1) begin : muxs
      assign Row[n] = Dir[n] ? Col[Sel[n*3+2:n*3]] : 'bz;
      assign Col[n] = Dir[n] ? 'bz : Row[Sel[n*3+2:n*3]];
    end
  endgenerate
endmodule
I didn't fully test them, so beware of goofs.
Both seem to route fine in CPLD using ISE 7.1.03.
I selected XCR3064XL-6-VQ100 for the second one because I used a lot of I/O pins.
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…