multi-bit input confusion

OP (Company: Education) #4062901
Rate this post
• ▲ 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
Guest #4063564
Rate this post
• ▲ 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?
1
module mux_81(
2
    input [7:0] d,
3
   input [2:0] s,
4
   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:
1
   mux81 b0(
2
    .s(s),
3
    .d( { r7[0]),
4
          r6[0]),
5
          r5[0]),
6
          r4[0]),
7
          r3[0]),
8
          r2[0]),
9
          r1[0]),
10
          r0[0] } ) ,
11
    .q(q[0])
12
     );


This is of course only waht my crystalball tells me.

Reply

Note: the original post is older than 6 months. Please don't ask any new questions in this thread, but start a new one.

Formatting
  • [c]C-Code[/c]
  • [vhdl]VHDL-Code[/vhdl]
  • [code]code in other languages, ASCII drawings[/code]
  • [math]formula (LaTeX syntax)[/math]
  • [[Title]] – link to an article
  • Link to another post: right-click its post ID (#8078628), copy the address, paste it into the text

More about formatting

Post long source code as an attachment, not in the text.

Already registered? Log in

Not shown to anyone. We send you a link; your post appears once you confirm it there.

By submitting you create a free account and accept the terms of use.