18340 - Generate Blocks

5 views
Skip to first unread message

Ray Cao

unread,
Apr 29, 2013, 2:55:50 PM4/29/13
to 18340...@googlegroups.com
Hello,

When making a gate-level implementation of a design (for example, Part B of Project 4), are we allowed to use 'generate' blocks in order to create large quantities of a similar design block? It would greatly cut down on the amount of cut and pasting in the project.

Thanks for your help,
Ray Cao

Matthew Beckler

unread,
Apr 29, 2013, 3:33:10 PM4/29/13
to Ray Cao, 18340...@googlegroups.com
Can you give an example of your specific situation?

We strongly encourage the use of hierarchical designs (modules composed
of modules composed of modules) to build up a locally structured design.
If you are, for example, trying to build everything in one large module
(with no sub-modules) then we encourage you to split your design into
logical sub-modules to make things easier to manage. Having to do a
large amount of copy-paste-tweak work is probably indicative of a
poorly-structured design.

Thanks,
Matthew Beckler
18340 System Staff
> --
> You received this message because you are subscribed to the Google
> Groups "18340-staff" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to 18340-staff...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.
>
>

Ray Cao

unread,
Apr 29, 2013, 3:53:00 PM4/29/13
to Matthew Beckler, 18340...@googlegroups.com
Hello,

Sure, an example of some code I have without using a generate block would be:

  minMag mm1_0 (min_tmp1[0], SM_inputs[0][2:0], SM_inputs[1][2:0]);
  minMag mm1_1 (min_tmp1[1], SM_inputs[2][2:0], SM_inputs[3][2:0]);
  minMag mm1_2 (min_tmp1[2], SM_inputs[4][2:0], SM_inputs[5][2:0]);
  minMag mm1_3 (min_tmp1[3], SM_inputs[6][2:0], SM_inputs[7][2:0]);
  minMag mm1_4 (min_tmp1[4], SM_inputs[8][2:0], SM_inputs[9][2:0]);
  minMag mm1_5 (min_tmp1[5], SM_inputs[10][2:0], SM_inputs[11][2:0]);
  minMag mm1_6 (min_tmp1[6], SM_inputs[12][2:0], SM_inputs[13][2:0]);
  minMag mm1_7 (min_tmp1[7], SM_inputs[14][2:0], SM_inputs[15][2:0]);

With a generate block this can be shortened to:

  genvar i;
  
  generate
    for (i = 0; i < 8; i=i+1) begin
      minMag mm1 (min_tmp1[i], SM_inputs[2*i][2:0], SM_inputs[2*i+1][2:0]);
    end
  endgenerate

The difference using a generate block would make would be even greater when designing the 32-bit nodes.

Thanks for your help,
Ray Cao

Matthew Beckler

unread,
Apr 29, 2013, 4:02:16 PM4/29/13
to Ray Cao, 18340...@googlegroups.com
So for this example, one way to make it simpler would be to collect four
minMag blocks into a minMag4 block, which could be collected into a
minMag16 block, you know?

That being said, you make a fair point, but I must confer with the rest
of the course staff before making a decision about generate blocks.
We'll get back to you later tonight or tomorrow.

Thanks,
Matthew


On 04/29/2013 03:53 PM, Ray Cao wrote:
> Hello,
>
> an email to 18340-staff+unsubscribe@__googlegroups.com
> <mailto:18340-staff%2Bunsu...@googlegroups.com>.
> For more options, visit
> https://groups.google.com/__groups/opt_out
> <https://groups.google.com/groups/opt_out>.
>
>
>

Matthew Beckler

unread,
Apr 29, 2013, 4:03:23 PM4/29/13
to Shawn Blanton, 18-340 Staff
Any thoughts about this? Should we permit them to use generate
statements? I'm inclined to permit it, since it will only save them time
with the copy-pasting, but I kind of want to encourage them to design
more hierarchically.

-Matthew
an email to 18340-staff...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.




Shawn Blanton

unread,
Apr 29, 2013, 10:14:08 PM4/29/13
to Matthew Beckler, 18-340 Staff
I agree with you, they should learn to design hierarchically...

SB

Kyle Verma

unread,
Apr 29, 2013, 10:25:20 PM4/29/13
to Shawn Blanton, Matthew Beckler, 18-340 Staff
You should consider not allowing generate statements for two reasons: 
1 - it causes students to think flat instead of hierarchically as has already been said
2 - I would say at least 1/3 and up to 1/2 of all problems students have come to office hours or emailed me about with code not compiling or acting oddly is due to generate statements...

~Kyle

Shawn Blanton

unread,
Apr 29, 2013, 10:29:11 PM4/29/13
to Kyle Verma, Matthew Beckler, 18-340 Staff
yes...thanks Kyle...no generate statements...

SB

Matthew Beckler

unread,
Apr 30, 2013, 8:04:18 AM4/30/13
to Shawn Blanton, Kyle Verma, 18-340 Staff
Thanks for the feedback everyone! I just sent out a blackboard
announcement about generate statements.

-Matthew

On 04/29/2013 10:29 PM, Shawn Blanton wrote:
> yes...thanks Kyle...no generate statements...
>
> SB
>
> On Apr 29, 2013, at 7:25 PM, Kyle Verma <kyle...@gmail.com
> <mailto:kyle...@gmail.com>> wrote:
>
>> You should consider not allowing generate statements for two reasons:
>> 1 - it causes students to think flat instead of hierarchically as has
>> already been said
>> 2 - I would say at least 1/3 and up to 1/2 of all problems students
>> have come to office hours or emailed me about with code not compiling
>> or acting oddly is due to generate statements...
>>
>> ~Kyle
>>
>>
>> On Mon, Apr 29, 2013 at 10:14 PM, Shawn Blanton <bla...@ece.cmu.edu
>> <mailto:bla...@ece.cmu.edu>> wrote:
>>
>> I agree with you, they should learn to design hierarchically...
>>
>> SB
>>
>> On Apr 29, 2013, at 1:03 PM, Matthew Beckler <mbec...@cmu.edu
>> <http://googlegroups.com>
>> >> <mailto:18340-staff%2Bunsu...@googlegroups.com
>> <mailto:18340-staff%252Buns...@googlegroups.com>>.
>> >> For more options, visit
>> >> https://groups.google.com/__groups/opt_out
>> >> <https://groups.google.com/groups/opt_out>.
>> >
>> > --
>> > You received this message because you are subscribed to the
>> Google Groups "18340-staff" group.
>> > To unsubscribe from this group and stop receiving emails from
>> it, send an email to 18340-staff...@googlegroups.com
>> <mailto:18340-staff%2Bunsu...@googlegroups.com>.
>> > For more options, visit https://groups.google.com/groups/opt_out.
>> >
>> >
>> >
>> >
>>
>> --
>> You received this message because you are subscribed to the Google
>> Groups "18340-staff" group.
>> To unsubscribe from this group and stop receiving emails from it,
>> send an email to 18340-staff...@googlegroups.com
>> <mailto:18340-staff%2Bunsu...@googlegroups.com>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
Reply all
Reply to author
Forward
0 new messages