EmbDev.net

Forum: FPGA, VHDL & Verilog multi-bit input confusion


Author: Chris Phillips (Company: Education) (code_capitalist)
Posted on:

Rate this post
0 useful
not useful
Im using verilog for a school assignment, and as a computer science 
major, I probably wont be using it again for any more classes, since 
this is the only electrical engineering class I need to take, so I find 
that doing everything at the gate level makes sense. i've seen more 
abstract methods to accomplish what I'm trying to do, but I'd like to 
keep my coding style consistent throughout the project.

What im doing in this module is making a 9-bit 8-to-1 multiplexer by 
putting 9 1-bit 8-to-1 multiplexers in parallel. I've tested my 1-bit 
multiplexer, and it works as intended. my issue is with the 9bit, where 
im moving bits from the input into the nested multiplexers. here is a 
snippit of code

module mux_9b_81(
    input [8:0] r0, r1, r2, r3, r4, r5, r6, r7,
   input [2:0] s,
   output [8:0] q);

   mux81 b0(
    .s(s),
    .d[0](r0[0]),   <-error
    .d[1](r1[0]),
    .d[2](r2[0]),
    .d[3](r3[0]),
    .d[4](r4[0]),
    .d[5](r5[0]),
    .d[6](r6[0]),
    .d[7](r7[0]),
    .q(q[0])
     );
     mux81 bn(
     ...
end module

to explain - mux0 selects the first bit from the selected(s) input, r0
             mux1 selects the second bit from the selected(s) input, r1
             ...
all these bits are combined into q and returned.
I noted where xilinx shows that my error is,
and this error occurs in the same place in each mux81.

is this just a syntax error?
thanks,

-chris

Author: Klakx (Guest)
Posted on:

Rate this post
0 useful
not useful
Whats the text of error exactly?

Author: RtfNetiquette (Guest)
Posted on:

Rate this post
0 useful
not useful
error message?

Author: Lattice User (Guest)
Posted on:

Rate this post
0 useful
not useful
Chris Phillips wrote:
>
> ...  here is a
> snippit of code

Which is incomplete, as it doesn't include the port definition of your 
1-bit multiplexer.

>
> module mux_9b_81(
>     input [8:0] r0, r1, r2, r3, r4, r5, r6, r7,
>    input [2:0] s,
>    output [8:0] q);
>
>    mux81 b0(
>     .s(s),
>     .d[0](r0[0]),   <-error

Is your 1-bit mux defined like this?
module mux_81(
    input [7:0] d,
   input [2:0] s,
   output q);

You can't pass single wires to a vector port definition, as the port is 
a single entity.
You have tp pass a vector:
   mux81 b0(
    .s(s),
    .d( { r7[0]),
          r6[0]),
          r5[0]),
          r4[0]),
          r3[0]),
          r2[0]),
          r1[0]),
          r0[0] } ) ,
    .q(q[0])
     );


This is of course only waht my crystalball tells me.

Reply

Entering an e-mail address is optional. If you want to receive reply notifications by e-mail, please log in.

Rules — please read before posting

  • Post long source code as attachment, not in the text
  • Posting advertisements is forbidden.

Formatting options

  • [c]C code[/c]
  • [avrasm]AVR assembler code[/avrasm]
  • [vhdl]VHDL code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]




Bild automatisch verkleinern, falls nötig
Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.